From eccd9ac0b676aed1cd921cb112397eb4b069f706 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 18 Sep 2026 00:38:13 -0700 Subject: [PATCH] test(session): pin the other side of the presence rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Widening the predicate to "always survives" passed the whole file — the counterweight rides on the host-precedence ordering, not on the predicate, so nothing objected to dropping the rule entirely. An emptied row is evidence the workspace exists; no row on either side is not. --- ...kspace-session-merge-local-survival.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/renderer/src/hooks/remote-workspace-session-merge-local-survival.test.ts b/src/renderer/src/hooks/remote-workspace-session-merge-local-survival.test.ts index 8a3e5f7d071..cbff6640181 100644 --- a/src/renderer/src/hooks/remote-workspace-session-merge-local-survival.test.ts +++ b/src/renderer/src/hooks/remote-workspace-session-merge-local-survival.test.ts @@ -386,6 +386,24 @@ describe('local rows the snapshot carries no answer for', () => { expect(merged.activeWorktreeId).toBe(OTHER_WORKTREE) }) + it('does not stand the user in a workspace that survived in neither side', () => { + // The boundary the presence rule actually draws, and the only case that separates it from + // "always preserve": an emptied row is evidence the workspace exists, but NO row on either + // side is not. Preserving here would leave the user pointed at a workspace the merge has no + // record of, which is the home screen's job to catch. + const current = sessionState() + const remote = sessionState({ + activeWorktreeId: null, + activeWorkspaceKey: null, + activeRepoId: null + }) + + const merged = merge(current, remote) + + expect(merged.activeWorktreeId).toBeNull() + expect(merged.activeWorkspaceKey).toBeNull() + }) + it('invents no row for a worktree neither side has one for', () => { // The counterweight: presence has to come from a real local row, not from membership in the // replace set, or a never-initialized workspace gets a tombstone it never earned.