test(mobile-sync): pin the mirrored-tab guard on the groups-empty projection

The publishable-terminal filter and the order-loop guard are two call sites, but
deleting the order-loop one left all 1150 runtime tests green. With no host
groups the projection returns the legacy nav order, which is built from every
terminal tab rather than the filtered set, so that guard is the only thing
holding a web mirror back on this path.
This commit is contained in:
Brennan Benson
2026-08-29 20:12:23 -07:00
committed by Merge Sim
parent 54adea0627
commit b5b75a311b
@@ -631,4 +631,53 @@ describe('buildMobileSessionTabSnapshots published group references', () => {
expect(danglingGroupRefs(snapshot)).toEqual([])
expect(snapshot?.activeGroupId).toBeNull()
})
// Why the groups-empty arm: with no host groups the projection returns the legacy nav order, which
// is built from every terminal tab rather than the filtered publishable set, so the per-tab guard
// in the order loop is the only thing holding a web mirror back on this path.
it('keeps a web-mirrored terminal out of the legacy nav order projection', () => {
const mirroredLeafId = '33333333-3333-4333-8333-333333333333'
const state = makeState({
groupsByWorktree: { 'wt-1': [] } as unknown as AppState['groupsByWorktree'],
unifiedTabsByWorktree: {
'wt-1': [
{
id: 'web-terminal-term-host',
groupId: null,
contentType: 'terminal',
entityId: 'web-terminal-term-host',
title: 'Mirrored'
}
]
} as unknown as AppState['unifiedTabsByWorktree'],
tabsByWorktree: {
'wt-1': [
{
id: 'web-terminal-term-host',
worktreeId: 'wt-1',
ptyId: 'remote:pty-host',
title: 'Mirrored',
defaultTitle: 'Mirrored',
customTitle: null,
color: null,
sortOrder: 0,
createdAt: 1
}
]
} as unknown as AppState['tabsByWorktree'],
terminalLayoutsByTabId: {
'web-terminal-term-host': {
root: { type: 'leaf', leafId: mirroredLeafId },
activeLeafId: mirroredLeafId,
expandedLeafId: null,
ptyIdsByLeafId: { [mirroredLeafId]: 'remote:pty-host' }
}
} as unknown as AppState['terminalLayoutsByTabId']
})
const snapshot = buildMobileSessionTabSnapshots(state)[0]
// The persisted layout resolves a leaf, so without the guard this publishes a surface row.
expect(snapshot?.tabs).toEqual([])
expect(danglingTabRefs(snapshot)).toEqual([])
})
})