Skip to content

fix(persistence): a paired server's workspaces keep their saved tabs across desktop restarts - #33926

Merged
nwparker merged 4 commits into
mainfrom
fix/runtime-partition-fence-expiry
Oct 26, 2026
Merged

nwparker merged 4 commits into
mainfrom
fix/runtime-partition-fence-expiry

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​131

ELI5

On a desktop paired to a managed SSH server, Orca stopped saving which tabs your server workspaces had. A safety lock that blocks stale saves, meant to last a moment, never unlocked once the desktop removed a workspace or closed a tab on its own. So after every restart Orca forgot your tabs and reopened those workspaces wherever the server last pointed, often on the second tab. The lock now releases after a few seconds.

What Changed

Before:

  • A desktop paired to a managed SSH orcad (or any paired runtime) removes one workspace, or main records a terminal close, in a repo.
  • From then on, every workspace in that repo is saved with empty terminal rows: tabs [], groups [], active tab null.
  • On every restart the desktop has no tab state of its own for those workspaces. It adopts the server's per-device pick, which may not be the tab you were on.

After:

  • Those workspaces save normally, and a restart reopens them on the desktop's own last tab.

Mechanism:

  • setHostWorkspaceSession runs sanitizeWorkspaceSessionTerminalRetirements → rebaseWorkspaceSessionTerminalMembership.
  • Once a partition holds terminalTopologyRevisionByRepoId[repo] > 0, any write that doesn't raise that revision has its terminal rows replaced by the prior rows. That is main's fence against a stale window save undoing main's own change.
  • The window never sends revisions. On local and SSH partitions main keeps membership current itself. On a runtime partition, which mirrors a paired server, only window saves maintain it, so a single main-side change froze the repo for good.
  • New: runtime-partition-topology-fence.ts. On runtime partitions, a repo main changed (a write that raises its revision, or a removal) stays fenced for RUNTIME_PARTITION_TOPOLOGY_FENCE_MS (10s), measured on a monotonic clock. After that, window saves are the membership again. Revisions are still carried forward.
  • Local and SSH partitions are unchanged.

Why

The fence exists for the race between main's change and a window save already in flight. The window's saves debounce at 150ms, and a save held by a closed persistence gate can land a few seconds later. After that, every window save has seen main's change.

Alternatives considered:

  • Pruning against the server's published layout census. Rejected: the census lists only workspaces with server-side tabs and can be partial or stale while subscriptions reconnect, so it deleted live rows in review.
  • Reconstructing main's changes from in-session records. Rejected: it leaked in many edge cases.

Known limit: after the window, a very stale window save, one captured more than 10s before it is delivered, could bring back a row main removed. A listed workspace's rows are replaced by the server's first frame after a restart.

Follow-up (the real fix): the window echoes the topology revision it has seen, and main pushes revision bumps to it, so the fence can tell a stale save from a fresh one exactly with no time bound.

Linked Issue

Fixes #21236

The same freeze kept a mirrored tab the server had closed on disk for days: every window save that dropped it was rebased back onto the prior rows. Thanks to @yulin0629 for the detailed persisted-state evidence in #21236.

It also fixes the second half of a wrong-tab-on-switch-back report from a managed SSH orcad host; #33761 fixed the first half (keyboard tab switches never reached the server).

Visual Proof

N/A. This is a persistence fix with no UI change.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New tests in worktree-removal-session-partition-fencing.test.ts:

  • Existing tests that a stale window save inside the window cannot bring back a removed worktree's rows pass unchanged.

  • The equal-repo-id per-host fence test runs on SSH partitions, where the permanent fence still applies.

  • Evidence from the user's machine, read-only: their runtime:<omarchy> partition had a revision on the repo, and 56 of its ~70 server workspaces saved as empty rows. That included workspaces they were actively using.

  • pnpm typecheck, lint and the PR static checks pass.

AI Disclosure

Review

Codex review is clean on the final head (base pinned at 7b5f50d). An independent review found no P0–P2 issues.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Mixed versions: no wire or schema change. Older builds read the same partition and simply rebase as before.
  • Cross-platform: no platform-specific code.
  • Folder workspaces: same path as worktrees.
  • Mobile: unaffected.

…across desktop restarts

Main's per-repo terminal topology revision fences window saves so a stale save
cannot undo main's own membership change. The window never sends revisions, so
on a runtime partition, which mirrors a paired server, one removal or main-side
close froze every workspace of that repo: from then on each window save had its
terminal rows rebased onto the prior rows, and every restart reopened those
workspaces on the server's per-device tab pick.

On runtime partitions the fence now lasts only through the race it guards: a
repo main changed is fenced for RUNTIME_PARTITION_TOPOLOGY_FENCE_MS, then the
window's saves win again. Local and SSH partitions keep the permanent fence.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4940fa7-4d35-45fa-aef6-0805337bcbb8
Commits

Reviewing files that changed from the base of the PR and between 1a77543 and 5d306e2.

Files selected for processing: 3
  • src/main/persistence/loading-store/runtime-partition-topology-fence.ts
  • src/main/persistence/loading-store/session-host-partitions.ts
  • src/main/worktree-removal-session-partition-fencing.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Paired client keeps a mirrored terminal tab for days after the host closed it (blank pane, "Remote terminal was closed.")

1 participant