The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep minted Browser tab ids across restore; complete test mocks for session-focus
Brooklyn Nicholson9fe0a57533a1
diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsxindex d9fafca0bb9..e18f8d4177c 100644--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx@@ -27,9 +27,25 @@ const $focusedTreePaneId = $focusedTreePaneIdMock as unknown as WritableAtom<nul// The focused pane is derived from the layout tree; a settable atom stands in// so a test can focus a tile without building a pane tree.vi.mock('@/store/session-focus', async () => {- const { atom } = await import('nanostores')-- return { $focusedTreePaneId: atom<null | string>(null) }+ const { atom, computed } = await import('nanostores')+ const { $selectedStoredSessionId } = await import('@/store/session')++ // The focused pane is derived from the layout tree; a settable atom stands+ // in so a test can focus a tile without building a pane tree.+ const $focusedTreePaneId = atom<null | string>(null)++ // The preview store (reached via session-states) derives $visiblePreviewTabs+ // from $focusedStoredSessionId at import time, and the timer tests depend on+ // the REAL derivation (tile focus overrides the primary selection), so the+ // mock mirrors session-focus's shape instead of stubbing a static atom.+ const TILE_PANE_PREFIX = 'session-tile:'++ return {+ $focusedTreePaneId,+ $focusedStoredSessionId: computed([$focusedTreePaneId, $selectedStoredSessionId], (active, selected) =>+ active?.startsWith(TILE_PANE_PREFIX) ? active.slice(TILE_PANE_PREFIX.length) : selected+ )+ }})// $focusedStoredSessionId derives from the LAYOUT TREE ($activeTreeGroup +diff --git a/apps/desktop/src/sdk/open-session-refresh-in-place.test.ts b/apps/desktop/src/sdk/open-session-refresh-in-place.test.tsindex 5d643c556f6..f0a442da50e 100644--- a/apps/desktop/src/sdk/open-session-refresh-in-place.test.ts+++ b/apps/desktop/src/sdk/open-session-refresh-in-place.test.ts@@ -29,7 +29,10 @@ vi.mock('@/app/open-session', () => ({ openSession: vi.fn() }))vi.mock('@/components/pane-shell/tree/store', async () => {const { atom } = await import('nanostores')+ // session-focus.ts (reached via the preview store) and the layout store+ // read these at import time; a mock without them crashes before any test.return {+ $activeTreeGroup: atom(null),$collapsedTreeSides: atom(new Set()),$hiddenTreePanes: atom(new Set()),$layoutTree: atom(null),diff --git a/apps/desktop/src/sdk/profile-routing.test.ts b/apps/desktop/src/sdk/profile-routing.test.tsindex 42ee2c7cc45..c7b6e1c0d42 100644--- a/apps/desktop/src/sdk/profile-routing.test.ts+++ b/apps/desktop/src/sdk/profile-routing.test.ts@@ -11,7 +11,10 @@ vi.mock('@/app/open-session', () => ({ openSession: vi.fn() }))vi.mock('@/components/pane-shell/tree/store', async () => {const { atom } = await import('nanostores')+ // session-focus.ts (reached via the preview store) and the layout store+ // read these at import time; a mock without them crashes before any test.return {+ $activeTreeGroup: atom(null),$collapsedTreeSides: atom(new Set()),$hiddenTreePanes: atom(new Set()),$layoutTree: atom(null),diff --git a/apps/desktop/src/store/preview.ts b/apps/desktop/src/store/preview.tsindex 10c7a4f91f9..2ddacf36f66 100644--- a/apps/desktop/src/store/preview.ts+++ b/apps/desktop/src/store/preview.ts@@ -160,10 +160,14 @@ function parseTabList(parsed: unknown): PreviewTab[] {tab.sessionId !== undefined || tab.pinned !== undefined ? tab : { ...tab, pinned: true })- // One Browser: rekey restored URL tabs onto the singleton id (rows written- // before the id existed carried one id per address). File tabs rekey onto- // their session-scoped canonical id. Keep only the LAST row per id — the- // most recently opened wins.+ // File tab identities are session-scoped: a row written before the scope+ // existed (or by an id-collapsing legacy build) rekeys onto the canonical+ // `file:<session>:<path>` form, deduping the same file persisted under both+ // old and new ids. Browser (URL) rows keep their MINTED id verbatim: ids are+ // never rekeyed (#119850), because the pop-out window hand-off looks tabs up+ // by the persisted id, and reusing a navigated Browser depends on the id+ // surviving restore. Keep only the LAST row per id — the most recently+ // opened wins.const lastUrl = owned.findLast(tab => tab.target.kind === 'url')const deduped = new Map<string, PreviewTab>()@@ -172,12 +176,9 @@ function parseTabList(parsed: unknown): PreviewTab[] {continue}- const id =- tab.target.kind === 'url' || tab.target.kind === 'file'- ? previewTabId(tab.target, tab.sessionId)- : tab.id+ const id = tab.target.kind === 'file' ? previewTabId(tab.target, tab.sessionId) : tab.id- deduped.set(id, { ...tab, id })+ deduped.set(id, tab.target.kind === 'file' ? { ...tab, id } : tab)}return [...deduped.values()]