From b5b75a311b1e6d7bc0befaa9178dea8b3753043b Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 28 Aug 2026 23:39:41 -0700 Subject: [PATCH] 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. --- ...e-graph-published-group-references.test.ts | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/renderer/src/runtime/sync-runtime-graph-published-group-references.test.ts b/src/renderer/src/runtime/sync-runtime-graph-published-group-references.test.ts index 68f34f8da6a..d7fbb0d86a0 100644 --- a/src/renderer/src/runtime/sync-runtime-graph-published-group-references.test.ts +++ b/src/renderer/src/runtime/sync-runtime-graph-published-group-references.test.ts @@ -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([]) + }) })