From 68cd052bd79927c39cfa6caa99ad543dcabe5fed Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 6 Sep 2026 14:22:35 -0700 Subject: [PATCH] test(cmd-j): cover restored browser recency in the ownership regression The same unifiedTabsByWorktree map that establishes host ownership also feeds lastActiveAt, which orders Open Tabs and renders the row's session age. That half of the fix had no coverage, so assert it alongside the execution host. --- ...ktree-jump-palette-browser-ownership.test.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/components/use-worktree-jump-palette-browser-ownership.test.ts b/src/renderer/src/components/use-worktree-jump-palette-browser-ownership.test.ts index 51063a2aa5e..c8aea613f03 100644 --- a/src/renderer/src/components/use-worktree-jump-palette-browser-ownership.test.ts +++ b/src/renderer/src/components/use-worktree-jump-palette-browser-ownership.test.ts @@ -10,7 +10,7 @@ import { useWorktreeJumpPaletteOpenTabs } from './use-worktree-jump-palette-open afterEach(cleanup) -it('keeps same-id browser results on their owner and updates when tab ownership changes', () => { +it('keeps same-id browser results on their owner with recency, and follows ownership changes', () => { const worktrees = [ makeWorktree('same-id', 'Local workspace', { hostId: 'local' }), makeWorktree('same-id', 'Remote workspace', { hostId: 'runtime:paired' }) @@ -37,11 +37,13 @@ it('keeps same-id browser results on their owner and updates when tab ownership const tab: Tab = { ...makeUnifiedTab('tab', 'same-id', 'browser', 'Browser proof'), contentType: 'browser', - executionHostId: 'runtime:paired' + executionHostId: 'runtime:paired', + lastFocusedAt: 5_000 } type PaletteInput = Parameters[0] const input: Partial = { ...useAppStore.getInitialState(), + // The store holds {key, result}; the hook takes the unwrapped result. workspacePortScan: null, paletteStatusInputsActive: true, allWorktrees: worktrees, @@ -60,10 +62,15 @@ it('keeps same-id browser results on their owner and updates when tab ownership (props: Partial) => useWorktreeJumpPaletteOpenTabs(props as PaletteInput), { initialProps: input } ) + // lastActiveAt rides the same map: without it every browser row sorts as never-focused. const owners = () => - result.current.browserItems.map(({ result: entry }) => [entry.pageId, entry.executionHostId]) + result.current.browserItems.map(({ result: entry }) => [ + entry.pageId, + entry.executionHostId, + entry.lastActiveAt + ]) - expect(owners()).toEqual([['page', 'runtime:paired']]) + expect(owners()).toEqual([['page', 'runtime:paired', 5_000]]) rerender({ ...input, @@ -71,5 +78,5 @@ it('keeps same-id browser results on their owner and updates when tab ownership 'same-id': [{ ...tab, executionHostId: 'local' }] } }) - expect(owners()).toEqual([['page', 'local']]) + expect(owners()).toEqual([['page', 'local', 5_000]]) })