Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions apps/desktop/src/store/zustand/tabs/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,18 @@ const openTab = <T extends BasicState & NavigationState>(
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<T>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 State update on existing tab bypasses history tracking

When an existing tab is found and its state is updated (the shouldUpdateState branch at line 287-298), the function returns { tabs: nextTabs, currentTab, history } at line 299 — passing the original history map unchanged. This means navigating to an already-open tab with a new state (e.g., openNew({ type: 'ai', state: { tab: 'templates' } }) when an ai tab is already open with { tab: 'intelligence' }) will silently update the tab's state without creating a history entry. The user cannot "go back" to the previous state of that tab.

This is the same behavior as before this PR (the old code also returned history unchanged for existing tabs), so it's not a regression. However, it's worth noting that the new state-update feature amplifies the impact of this pre-existing design choice — previously, reopening an existing tab was a no-op on state, so skipping history was fine. Now that state actually changes, skipping history means state transitions are not reversible via back/forward navigation.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

}

Expand Down
Loading