test(renderer): restore layout-value coverage and record the workspaceId dependency

Notes why browser page identity reuse is safe: browserPageEqual must keep
comparing workspaceId, since the removed-workspace page-list cleanup gates on
it. Also re-asserts the effective active leaf that the patch-only assertion
stopped covering.

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-08-10 21:11:23 -07:00
co-authored by Orca
parent 6391040c4c
commit 9d095abd20
2 changed files with 30 additions and 21 deletions
@@ -3102,28 +3102,30 @@ describe('applyWebSessionTabsSnapshot', () => {
}
}
const state = makeState({
activeTabId: mirroredTabId,
activeTabIdByWorktree: { [WT]: mirroredTabId },
activeTabType: 'terminal',
activeTabTypeByWorktree: { [WT]: 'terminal' },
tabsByWorktree: {
[WT]: [
{
id: mirroredTabId,
ptyId: 'remote:web-env-1@@terminal-2',
worktreeId: WT,
title: 'right pane',
customTitle: null,
color: null,
sortOrder: 0,
createdAt: NOW
}
]
},
terminalLayoutsByTabId: { [mirroredTabId]: currentLayout }
})
const patch = applyWebSessionTabsSnapshot(
makeState({
activeTabId: mirroredTabId,
activeTabIdByWorktree: { [WT]: mirroredTabId },
activeTabType: 'terminal',
activeTabTypeByWorktree: { [WT]: 'terminal' },
tabsByWorktree: {
[WT]: [
{
id: mirroredTabId,
ptyId: 'remote:web-env-1@@terminal-2',
worktreeId: WT,
title: 'right pane',
customTitle: null,
color: null,
sortOrder: 0,
createdAt: NOW
}
]
},
terminalLayoutsByTabId: { [mirroredTabId]: currentLayout }
}),
state,
makeSnapshot([
{
type: 'terminal',
@@ -3163,7 +3165,11 @@ describe('applyWebSessionTabsSnapshot', () => {
ptyId: 'remote:web-env-1@@terminal-2',
title: 'right pane'
})
// No layout patch at all, and the effective layout keeps the local active leaf.
expect(patch.terminalLayoutsByTabId).toBeUndefined()
expect({ ...state, ...patch }.terminalLayoutsByTabId[mirroredTabId]?.activeLeafId).toBe(
SECOND_LEAF_ID
)
})
it('removes a null-pty pending activation tab when the host publishes the initial terminal', () => {
@@ -3540,6 +3546,7 @@ describe('applyWebSessionTabsSnapshot', () => {
title: 'Example Domain'
}
])
// Absent key, not a missing handle: the seeded { ENV, 'host-browser-page' } handle matched.
expect(patch.remoteBrowserPageHandlesByPageId).toBeUndefined()
expect(patch.unifiedTabsByWorktree?.[WT]?.map((tab) => tab.id)).toEqual([
'local-browser-unified'
@@ -1215,6 +1215,8 @@ function buildMirroredBrowserTabs(
browserRuntimeEnvironmentId: environmentId,
viewportPresetId: existing?.page.viewportPresetId ?? null
}
// Why: reuse hinges on browserPageEqual comparing workspaceId — the removed-workspace
// page-list cleanup gates on page.workspaceId matching this entry's workspace.id.
const page = existing && browserPageEqual(existing.page, nextPage) ? existing.page : nextPage
const workspace: BrowserWorkspace = {
id: workspaceId,