Repository navigation
fix(layout-owner): paired desktops see server-created and server-closed tabs (C3, C4) - #52149
Conversation
…rames and retire bindings of tabs frames drop A paired desktop's frames drew a server workspace only after the desktop held groups for it, while the session.tabs mirror already skipped it, so a tab created on the server (by the CLI on a windowless host) never showed until the user opened the workspace. Frames now draw every workspace the desktop mirrors from that server. A tab a frame drops also takes its window-side PTY binding and local scrollback with it, as a window close does; before, a server-side close left the desktop holding a dead binding. Census rows C3 (L313) and C4 (L307): expected-fail marks removed.
… from its pane tree A frame-drawn row stays unbound until its pane mounts; the server's binding is on the pane tree. The check that activation attaches the original terminal is unchanged.
[Medium impact] The changes reach paired-server workspace display and terminal state across mirrored workspaces. The PR still needs the existing fix for sleeping terminals that retain live bindings before merging. Findings
SummaryServer frames now draw unopened mirrored workspaces and remove records for closed tabs, panes, and workspaces.
|
…y and reconcile window tab state by identity - Unopened server workspaces get terminal rows and pane trees only; the full build runs when one is opened or activated, and saves and view reports skip them. - Frame builds copy each keyed map once (was a copy per key). - One reconcile step retires the window's per-tab state that no longer matches main's frame: a dropped tab's bindings, scrollback, pending startup and focus; a closed or rebound pane's terminal and scrollback; a removed workspace's rows and pane trees. - Server frame rows carry their live terminal before the pane mounts, as the session.tabs mirror did. - Cold-activation oracle reads row bindings again and checks parking across a switch before any tab is force-mounted.
… rebound in place keeps its records
…-workspace save filter
…er-c3-c4-server-frames # Conflicts: # .github/workflows/layout-owner-switch-on.yml
| const panes = live.get(row.id) | ||
| if (!panes) { | ||
| return |
There was a problem hiding this comment.
Sleeping terminals still look live
When a server terminal stops or sleeps while its tab is unmounted on this desktop, the early return leaves its old binding in ptyIdsByTabId. Tabs with no live panes have no entry in live. Row merging preserves the old ptyId, and cleanup only retires panes whose leaf IDs disappeared. A sleeping pane keeps its leaf ID, so the desktop continues to report a live terminal and can treat stale titles as current activity.
Reconcile empty live-pane lists too: clear ptyIdsByTabId when none remain, while keeping any history hint on the row separate from live state.
… keep the O(N) build and the reconcile Owner decision: no lazy listing of unopened server workspaces and no save or view-report skips for now. Kept: one copy per keyed map, the dropped-tab scan over framed workspaces only, the identity reconcile, removed-workspace retirement and the live row bindings.
…bs keep their bindings, scoped removal, cached view report - A tab moved (or a workspace renamed) into a workspace an earlier build of the same flush drew keeps its pane tree and browser pages when its old workspace builds. - Server row bindings skip tabs the window's own split or close holds. - A removed workspace is wiped only if the source owns it; the removed set clears on start, when not live and on hand-back (which also forgets what was shown); a server-removed workspace is not resynced to the mirror. - The view report caches each workspace's view by its inputs and reads active groups per drawn key. - A terminal moved to another pane of its tab stays live; reconcile writes are annotated.
…er-c3-c4-server-frames # Conflicts: # .github/workflows/layout-owner-switch-on.yml
… for workspaces it dropped A replacement stream holds no workspaces until its first snapshot: hand-back before then, or a first snapshot that omits an inherited workspace, returns it to the mirror.
…er-c3-c4-server-frames
ELI5
A paired desktop learns about a server's tabs only from the server's layout frames. Before this PR, some things the server did never reached the desktop, and some left stale state behind:
orca servehost) never showed on the desktop until the user opened that workspace. The desktop drew a server workspace from frames only once it held groups for it, while the session.tabs mirror was already switched off for that workspace.This PR fixes both. It also fixes the cost and the stale-state gaps that review and the new tests found.
Before / after
ptyIdnull, no binding, so it cannot be parked and reports no live terminalThe numbers come from a scratch benchmark on a loaded shared Mac, so they are noisy; ranges are from three runs.
Mechanism
server-layout-frames.ts), opened or not, because they are its only source.keyedDraft). Before, every key copied the whole map, so a build was O(N²).frame-dropped-terminal-tab-records.ts), run on every frame build. It compares the window's per-tab state against the frame by tab id and pane leaf. A tab the frame dropped takes its PTY binding, scrollback, pending startup and the global focused-tab id with it. A pane that left takes its PTY and its scrollback. A workspace main removed is built from no layout, so its records go (workspace-layout-frame-sync.ts). Tab-level checks look only at the framed workspaces, unless a tab actually left. The tab and pane-tree half of a build isbuildLayoutFrameTerminalPatch(frame-terminal-rows.ts).frame-records-shown-outside.ts). A tab or browser tab one build drops, but which another build of the same flush already shows, keeps its pane tree, binding and pages.frame-row-live-bindings.ts), except for tabs the window's own in-flight split or close holds. For server sources, each row gets its active pane's terminal, andptyIdsByTabIdgets its live panes, whether or not the pane is mounted. A pane with a start status counts as unbound. Restore flags stay on the row, because a remote binding with every pane live already settles them for parking.Census rows
headless-serve-cli-terminal-retention-parityand fromheadless-paired-remote-terminal-retention-memory(cold-activates).paired-remote-terminal-serve-restart-binding.How it was tested
Switch on (
ORCA_LAYOUT_OWNER=main,ORCA_SERVER_LAYOUT_OWNER=main,ORCA_E2E_WEB_CLIENT=1, all exported and logged), darwin, hidden windows:headless-serve-cli-terminal-retention-parity,headless-paired-remote-terminal-retention-memory(both tests),paired-remote-terminal-serve-restart-binding, the four new specs from test(layout-owner): switch-on edge-case tests against #52149 (C3, C4) #52196 (paired-server-frames-disconnect-and-restart,-close-and-reopen,-many-workspaces,paired-two-desktops-and-phone-tabs),headless-serve-desktop-activation,terminal-cold-activation-deferral,terminal-pane-close-layout-consistency,terminal-tab-close-restart-persistenceandlocal-cli-terminal-retention.frame-dropped-terminal-tab-records,server-layout-frames-lifecycle).vitest relatedon every changed source file passes with the switch on and off.typecheck:ci, oxlint and the ratchet runner are clean.Layout-writer ratchet
The new frame-applier files have baseline entries:
frame-terminal-rows.ts(2, moved out ofworkspace-layout-frame-store-patch.ts, which drops from 12 to 10),frame-dropped-terminal-tab-records.ts(3) andframe-row-live-bindings.ts(2). Each one applies main's frame to the window's own records; none writes layout of its own. The total goes from 548 to 553.Performance
Every keyed map is copied once per build instead of once per key, so connecting is O(workspaces). Following the owner's call, the desktop still builds, saves and view-reports every server workspace it mirrors. The view report caches each workspace's view by its own inputs, so a store write rebuilds only the workspaces it touched: 3-4 ms per write at 1,900 workspaces, down from 10-12 ms.
Visible changes