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; }