From b95a8c248d79d1204eeb961647649fc2787aa094 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 13:00:09 +0000 Subject: [PATCH] fix: update existing tab state when openNew/openCurrent called with explicit state When openNew or openCurrent is called with an explicit state (e.g., { type: 'ai', state: { tab: 'intelligence' } }), and an existing tab of the same type is found, the existing tab's state is now updated with the requested state instead of being ignored. Previously, the existing tab was simply activated without updating its state, so calling openNew({ type: 'ai', state: { tab: 'intelligence' } }) when the AI tab was already open on the 'templates' sub-tab would keep showing templates instead of switching to intelligence. Co-Authored-By: yujonglee --- apps/desktop/src/store/zustand/tabs/basic.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/store/zustand/tabs/basic.ts b/apps/desktop/src/store/zustand/tabs/basic.ts index b383866089..3eaadd3d48 100644 --- a/apps/desktop/src/store/zustand/tabs/basic.ts +++ b/apps/desktop/src/store/zustand/tabs/basic.ts @@ -284,8 +284,18 @@ const openTab = ( const isNewTab = !existingTab; if (!isNewTab) { - nextTabs = setActiveFlags(tabs, existingTab!); - const currentTab = { ...existingTab!, active: true }; + const shouldUpdateState = + "state" in newTab && newTab.state != null && "state" in existingTab!; + const currentTab = shouldUpdateState + ? ({ + ...existingTab!, + state: (tabWithDefaults as any).state, + active: true, + } as Tab) + : { ...existingTab!, active: true }; + nextTabs = tabs.map((t) => + isSameTab(t, existingTab!) ? currentTab : { ...t, active: false }, + ); return { tabs: nextTabs, currentTab, history } as Partial; }