Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(composer): prevent duplicate trigger registration on re-render

Steven Enamakel767961cbe957
diff --git a/app/src/features/conversations/aui/ComposerTriggers.tsx b/app/src/features/conversations/aui/ComposerTriggers.tsx
new file mode 100644
index 0000000000..6d62aa9626
--- /dev/null
+++ b/app/src/features/conversations/aui/ComposerTriggers.tsx
@@ -0,0 +1,26 @@
+/**
+ * The chat composer's `/` command and `@` mention pickers.
+ *
+ * Mounted by `thread.tsx` through the `ComposerTriggers` slot (inside
+ * `ComposerPrimitive.Unstable_TriggerPopoverRoot`), so both sources run under
+ * the assistant-ui runtime (`useAui`, `useAuiState`) and read the thread the
+ * runtime provider is bound to. Rendering is the vendored assistant-ui
+ * `ComposerTriggerPopover`; this file only spreads the two sources into it.
+ */
+import { ComposerTriggerPopover } from '@/components/assistant-ui/composer-trigger-popover';
+import { useAuiThreadId } from '@/providers/AssistantUiRuntimeProvider';
+
+import { useMentionSource } from './useMentionSource';
+import { useSlashCommandSource } from './useSlashCommandSource';
+
+export function ComposerTriggers() {
+ const threadId = useAuiThreadId();
+ const slash = useSlashCommandSource(threadId);
+ const mention = useMentionSource(threadId);
+ return (
+ <>
+ <ComposerTriggerPopover char="/" data-testid="composer-slash-popover" {...slash} />
+ <ComposerTriggerPopover char="@" data-testid="composer-mention-popover" {...mention} />
+ </>
+ );
+}