From 5a2781f97069bbb7385ca4dee28fafbd36e24d67 Mon Sep 17 00:00:00 2001 From: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Date: Fri, 12 Jun 2026 13:13:36 -0400 Subject: [PATCH] fix: stop tab-complete from also swapping the selected agent (#1544) Skill/snippet/command/file-mention autocomplete branches in ChatInput called preventDefault()+return but not stopPropagation(). The Tab key bubbled to the global window keydown listener in useKeyboardShortcuts, whose cycle_agent shortcut (default 'tab') then ran setAgent(). Add e.stopPropagation() to all four autocomplete branches so the synthetic event no longer reaches the window-level handler when an autocomplete consumes the key. --- packages/ui/src/components/chat/ChatInput.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/ui/src/components/chat/ChatInput.tsx b/packages/ui/src/components/chat/ChatInput.tsx index 0b91c32a..223c9add 100644 --- a/packages/ui/src/components/chat/ChatInput.tsx +++ b/packages/ui/src/components/chat/ChatInput.tsx @@ -2279,6 +2279,7 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo if (showCommandAutocomplete && commandRef.current) { if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); + e.stopPropagation(); commandRef.current.handleKeyDown(e.key); return; } @@ -2287,6 +2288,7 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo if (showSkillAutocomplete && skillRef.current) { if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); + e.stopPropagation(); skillRef.current.handleKeyDown(e.key); return; } @@ -2295,6 +2297,7 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo if (showSnippetAutocomplete && snippetRef.current) { if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); + e.stopPropagation(); snippetRef.current.handleKeyDown(e.key); return; } @@ -2303,6 +2306,7 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo if (showFileMention && mentionRef.current) { if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); + e.stopPropagation(); mentionRef.current.handleKeyDown(e.key); return; }