From a79eb6e7f574251916c907b913734923970df57f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 14 Feb 2026 01:10:33 +0000 Subject: [PATCH 1/2] fix: prevent copilot keyboard shortcuts from triggering when panel is inactive The OptionsSelector component was capturing keyboard events (1-9 number keys and Enter) globally on the document, causing accidental option selections when users were interacting with other parts of the application. This fix adds a check to only handle keyboard shortcuts when the copilot panel is the active tab, preventing the shortcuts from interfering with other workflows. Co-authored-by: Emir Karabeg --- .../copilot/components/tool-call/tool-call.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx index c7f1032094d..83c053e15cd 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx @@ -23,7 +23,7 @@ import { ParallelTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/compo import { getDisplayValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block' import { getBlock } from '@/blocks/registry' import type { CopilotToolCall } from '@/stores/panel' -import { useCopilotStore } from '@/stores/panel' +import { useCopilotStore, usePanelStore } from '@/stores/panel' import type { SubAgentContentBlock } from '@/stores/panel/copilot/types' import { useWorkflowStore } from '@/stores/workflows/workflow/store' @@ -341,16 +341,20 @@ export function OptionsSelector({ const [hoveredIndex, setHoveredIndex] = useState(-1) const [chosenKey, setChosenKey] = useState(selectedOptionKey) const containerRef = useRef(null) + const activeTab = usePanelStore((s) => s.activeTab) const isLocked = chosenKey !== null - // Handle keyboard navigation - only for the active options selector + // Handle keyboard navigation - only for the active options selector when copilot is active useEffect(() => { if (isInteractionDisabled || !enableKeyboardNav || isLocked) return const handleKeyDown = (e: KeyboardEvent) => { if (e.defaultPrevented) return + // Only handle keyboard shortcuts when the copilot panel is active + if (activeTab !== 'copilot') return + const activeElement = document.activeElement const isInputFocused = activeElement?.tagName === 'INPUT' || @@ -387,7 +391,7 @@ export function OptionsSelector({ document.addEventListener('keydown', handleKeyDown) return () => document.removeEventListener('keydown', handleKeyDown) - }, [isInteractionDisabled, enableKeyboardNav, isLocked, sortedOptions, hoveredIndex, onSelect]) + }, [isInteractionDisabled, enableKeyboardNav, isLocked, sortedOptions, hoveredIndex, onSelect, activeTab]) if (sortedOptions.length === 0) return null From 78fdba9dba79d94c024cfd2fca8c62500dcbe933 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 17 Feb 2026 10:08:29 -0800 Subject: [PATCH 2/2] lint --- .../copilot/components/tool-call/tool-call.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx index 83c053e15cd..53af845ef43 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx @@ -391,7 +391,15 @@ export function OptionsSelector({ document.addEventListener('keydown', handleKeyDown) return () => document.removeEventListener('keydown', handleKeyDown) - }, [isInteractionDisabled, enableKeyboardNav, isLocked, sortedOptions, hoveredIndex, onSelect, activeTab]) + }, [ + isInteractionDisabled, + enableKeyboardNav, + isLocked, + sortedOptions, + hoveredIndex, + onSelect, + activeTab, + ]) if (sortedOptions.length === 0) return null