codeant-ai-for-open-source[bot] commented on code in PR #45392:
URL: https://github.com/apache/superset/pull/45392#discussion_r4303935847
##########
superset-frontend/src/core/chat/ChatProvider.ts:
##########
@@ -190,10 +221,52 @@ class ChatProvider {
return this.resizePanelEmitter.subscribe;
}
+ /**
+ * Registers a single client-side tool — mirrors commands.ts's
+ * registerCommand exactly: keyed by the tool's own `name` (fully-qualified,
+ * author-chosen — nothing prefixes or validates it here, same as a
+ * `Command.id`), warns and overwrites on a duplicate name, and the
+ * returned Disposable removes it by name unconditionally on dispose.
+ *
+ * Registering after registerChat() is safe — nothing here depends on call
+ * order. (An earlier version of this method warned about that ordering,
+ * back when ChatPanel snapshotted `chat.getTools()` once at mount via
+ * `useMemo(..., [])`; the actual fix was moving that snapshot to send-time
+ * in ChatPanel itself, which made the order genuinely not matter rather
+ * than just warning about it.)
+ */
+ public registerClientTool(tool: ClientTool): Disposable {
+ const { name } = tool;
+ if (this.clientTools.has(name)) {
+ logging.warn(
+ `[Superset] Client tool "${name}" is already registered. ` +
+ 'Overwriting the existing tool.',
+ );
+ }
+ this.clientTools.set(name, tool);
+ return new Disposable(() => {
+ this.clientTools.delete(name);
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `cf3061c`.
Cleanup now deletes the tool only when the name still maps to that
registration, so disposing an older overwritten registration preserves the
newer one.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]