From c24352fefbb4f048e3b4be0cf926c978853f05cf Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 18:32:05 -0700 Subject: [PATCH] Reset tab entry selection during render (#3311) --- .../src/components/tab-bar/TabBarCreateEntry.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx b/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx index 6a0b439d9..1ecaf5547 100644 --- a/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx +++ b/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx @@ -41,6 +41,7 @@ export default function TabBarCreateEntry({ const [pending, setPending] = useState(false) const [error, setError] = useState(null) const [selectedIndex, setSelectedIndex] = useState(0) + const [selectedIndexQuery, setSelectedIndexQuery] = useState(query) const inputRef = useRef(null) const fileList = useRuntimeFileListForWorktree({ enabled: menuOpen, worktreeId }) @@ -62,9 +63,13 @@ export default function TabBarCreateEntry({ [agentOptions, query] ) - useEffect(() => { - setSelectedIndex(0) - }, [query]) + if (selectedIndexQuery !== query) { + setSelectedIndexQuery(query) + if (selectedIndex !== 0) { + // Why: the first filtered action should be highlighted on the same paint as the new query. + setSelectedIndex(0) + } + } const disabled = !onOpenEntry const hasQuery = query.trim().length > 0