The best way to control Claude Code, Codex and more from any computer or phone
Improve composer menu highlighting and suppress triggers near mentions
Adds visual active-item highlighting to the command menu, suppresses trigger detection when the cursor is adjacent to a mention pill, and resets transient UI state on thread change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Julius Marminge committed
Mar 2, 2026 at 13:54 UTC
5e78386cdc805ee64ccc745454ce476475597f6f
2 files changed
+59
-7
apps/web/src/components/ChatView.tsx
+33
-4
@@ -361,12 +361,16 @@ const VscodeEntryIcon = memo(function VscodeEntryIcon(props: {
361
const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
362
item: ComposerCommandItem;
363
resolvedTheme: "light" | "dark";
364
+ isActive: boolean;
365
onSelect: (item: ComposerCommandItem) => void;
366
}) {
367
return (
368
<CommandItem
369
value={props.item.id}
369
- className="cursor-pointer select-none gap-2"
370
+ className={cn(
371
+ "cursor-pointer select-none gap-2",
372
+ props.isActive && "bg-accent text-accent-foreground",
373
+ )}
374
onMouseDown={(event) => {
375
event.preventDefault();
376
}}
@@ -400,6 +404,7 @@ const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
404
resolvedTheme: "light" | "dark";
405
isLoading: boolean;
406
triggerKind: ComposerTriggerKind | null;
407
+ activeItemId: string | null;
408
onHighlightedItemChange: (itemId: string | null) => void;
409
onSelect: (item: ComposerCommandItem) => void;
410
}) {
@@ -419,6 +424,7 @@ const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
424
key={item.id}
425
item={item}
426
resolvedTheme={props.resolvedTheme}
427
+ isActive={props.activeItemId === item.id}
428
onSelect={props.onSelect}
429
/>
430
))}
@@ -1389,6 +1395,26 @@ export default function ChatView({ threadId }: ChatViewProps) {
1395
scheduleStickToBottom();
1396
}, [phase, scheduleStickToBottom, timelineEntries]);
1397
1398
+ useEffect(() => {
1399
+ setExpandedWorkGroups({});
1400
+ }, [activeThread?.id]);
1401
+
1402
+ useEffect(() => {
1403
+ if (!composerMenuOpen) {
1404
+ setComposerHighlightedItemId(null);
1405
+ return;
1406
+ }
1407
+ setComposerHighlightedItemId((existing) =>
1408
+ existing && composerMenuItems.some((item) => item.id === existing)
1409
+ ? existing
1410
+ : (composerMenuItems[0]?.id ?? null),
1411
+ );
1412
+ }, [composerMenuItems, composerMenuOpen]);
1413
+
1414
+ useEffect(() => {
1415
+ setIsRevertingCheckpoint(false);
1416
+ }, [activeThread?.id]);
1417
+
1418
useEffect(() => {
1419
if (!activeThread?.id || terminalState.terminalOpen) return;
1420
const frame = window.requestAnimationFrame(() => {
@@ -2274,12 +2300,14 @@ export default function ChatView({ threadId }: ChatViewProps) {
2300
workspaceEntriesQuery.isLoading ||
2301
workspaceEntriesQuery.isFetching);
2302
2277
- const onPromptChange = useCallback((nextPrompt: string, nextCursor: number) => {
2303
+ const onPromptChange = useCallback((nextPrompt: string, nextCursor: number, cursorAdjacentToMention: boolean) => {
2304
promptRef.current = nextPrompt;
2305
setPrompt(nextPrompt);
2306
setComposerCursor(nextCursor);
2307
setComposerTrigger(
2282
- detectComposerTrigger(nextPrompt, expandCollapsedComposerCursor(nextPrompt, nextCursor)),
2308
+ cursorAdjacentToMention
2309
+ ? null
2310
+ : detectComposerTrigger(nextPrompt, expandCollapsedComposerCursor(nextPrompt, nextCursor)),
2311
);
2312
}, [setPrompt]);
2313
@@ -2301,8 +2329,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
2329
const selectedItem = activeComposerMenuItemRef.current ?? currentItems[0];
2330
if (selectedItem) {
2331
onSelectComposerItem(selectedItem);
2332
+ return true;
2333
}
2305
- return true;
2334
}
2335
}
2336
@@ -2464,6 +2492,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
2492
resolvedTheme={resolvedTheme}
2493
isLoading={isComposerMenuLoading}
2494
triggerKind={composerTriggerKind}
2495
+ activeItemId={activeComposerMenuItem?.id ?? null}
2496
onHighlightedItemChange={onComposerMenuItemHighlighted}
2497
onSelect={onSelectComposerItem}
2498
/>
apps/web/src/components/ComposerPromptEditor.tsx
+26
-3
@@ -395,7 +395,7 @@ interface ComposerPromptEditorProps {
395
disabled: boolean;
396
placeholder: string;
397
className?: string;
398
- onChange: (nextValue: string, nextCursor: number) => void;
398
+ onChange: (nextValue: string, nextCursor: number, cursorAdjacentToMention: boolean) => void;
399
onCommandKeyDown?: (
400
key: "ArrowDown" | "ArrowUp" | "Enter" | "Tab",
401
event: KeyboardEvent,
@@ -540,6 +540,29 @@ function ComposerMentionSelectionNormalizePlugin() {
540
return null;
541
}
542
543
+function $isCursorAdjacentToMention(): boolean {
544
+ const selection = $getSelection();
545
+ if (!$isRangeSelection(selection) || !selection.isCollapsed()) return false;
546
+ const anchorNode = selection.anchor.getNode();
547
+
548
+ if (anchorNode instanceof ComposerMentionNode) return true;
549
+
550
+ if ($isElementNode(anchorNode)) {
551
+ const childIndex = selection.anchor.offset - 1;
552
+ if (childIndex >= 0) {
553
+ const child = anchorNode.getChildAtIndex(childIndex);
554
+ if (child instanceof ComposerMentionNode) return true;
555
+ }
556
+ }
557
+
558
+ if ($isTextNode(anchorNode) && selection.anchor.offset === 0) {
559
+ const prev = anchorNode.getPreviousSibling();
560
+ if (prev instanceof ComposerMentionNode) return true;
561
+ }
562
+
563
+ return false;
564
+}
565
+
566
function ComposerMentionBackspacePlugin() {
567
const [editor] = useLexicalComposerContext();
568
@@ -662,7 +685,7 @@ function ComposerPromptEditorInner({
685
value: snapshotRef.current.value,
686
cursor: boundedCursor,
687
};
665
- onChangeRef.current(snapshotRef.current.value, boundedCursor);
688
+ onChangeRef.current(snapshotRef.current.value, boundedCursor, false);
689
},
690
[editor],
691
);
@@ -715,7 +738,7 @@ function ComposerPromptEditorInner({
738
value: nextValue,
739
cursor: nextCursor,
740
};
718
- onChangeRef.current(nextValue, nextCursor);
741
+ onChangeRef.current(nextValue, nextCursor, $isCursorAdjacentToMention());
742
});
743
}, []);
744