Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Workspace layout changes can appear applied even when saving them failed, so a restart may restore an older layout. Adopting a workspace under a new key can drop its default-tab and browser-page records. Orphan adoption can report success when nothing was written. These issues should be fixed before merging the stack. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6e8a5ea0-969a-4e4b-ab35-aa72b84a3d47
📒 Files selected for processing (96)
config/main-layout-writer-baseline.txtconfig/scripts/check-layout-writer-ratchets.mjssrc/main/ipc/pty-dead-owner-respawn.test.tssrc/main/ipc/pty-launch-parity.test-fixture.tssrc/main/ipc/pty-launch-parity.test.tssrc/main/ipc/pty-launch-race-parity.test.tssrc/main/ipc/pty-launch-race-test-fixture.tssrc/main/ipc/pty-pane-claim-arbitration.test.tssrc/main/ipc/pty-pane-materialization-race.test.tssrc/main/ipc/pty-pane-reservation-settlement.test.tssrc/main/ipc/pty-persisted-incarnation-repair.test.tssrc/main/ipc/pty-runtime-ssh-binding-persistence.test.tssrc/main/ipc/pty-spawn-placement-threading.test.tssrc/main/ipc/pty/ipc/spawn-commit.tssrc/main/ipc/pty/pane/spawn-registration.tssrc/main/ipc/pty/pane/stable-owner.tssrc/main/ipc/pty/pane/stable-pane-absence-respawn.test.tssrc/main/ipc/pty/runtime/spawn-commit-run-facts.test.tssrc/main/ipc/pty/runtime/spawn-commit.tssrc/main/ipc/pty/runtime/spawn-options.tssrc/main/ipc/pty/runtime/spawn-preflight.tssrc/main/ipc/pty/runtime/spawn-state.tssrc/main/ipc/repos/folder-workspace-attachment-handlers.test.tssrc/main/ipc/repos/folder-workspace-handlers.tssrc/main/ipc/worktrees-canonical-ssh-listing.test.tssrc/main/ipc/worktrees-test-runtime-stub.tssrc/main/ipc/worktrees-windows.test.tssrc/main/ipc/worktrees/listing/register-worktree-catalog-handlers.tssrc/main/persistence/loading-store/profile-state-delayed-authority-fixture.tssrc/main/persistence/loading-store/profile-state-pty-retirement-finalization.test.tssrc/main/persistence/loading-store/pty-reattach-failure-routing.test.tssrc/main/persistence/loading-store/pty-retirement-async-durability.test.tssrc/main/persistence/loading-store/pty-spawn-exit-durability.test.tssrc/main/persistence/loading-store/pty-spawn-handle-publication.test.tssrc/main/persistence/loading-store/pty-spawn-replacement-durability.test.tssrc/main/persistence/loading-store/pty-spawn-restore-durability.test.tssrc/main/persistence/loading-store/workspace-session-write-listeners.test.tssrc/main/runtime/cli-terminal-create-host-session-binding.test.tssrc/main/runtime/graph-sync-live-daemon-pty-tab-preservation.test.tssrc/main/runtime/holder-external-write-reload.tssrc/main/runtime/orca-runtime-adopt-terminal-orphans-from-inventory.tssrc/main/runtime/orca-runtime-create-terminal-dependencies.tssrc/main/runtime/orca-runtime-create-terminal.tssrc/main/runtime/orca-runtime-get-unpersisted-tracked-title-for-pty.tssrc/main/runtime/orca-runtime-get-worktree-terminal-provisioning-host.tssrc/main/runtime/orca-runtime-headless-hydration-repo-gate.test.tssrc/main/runtime/orca-runtime-on-pty-exit.tssrc/main/runtime/orca-runtime-persist-headless-terminal-title.tssrc/main/runtime/orca-runtime-persist-terminal-surface-retirements.tssrc/main/runtime/orca-runtime-preserved-branch-cleanup.tssrc/main/runtime/orca-runtime-resolve-worktree-removal-target.tssrc/main/runtime/orca-runtime-split-pty-backed-terminal.tssrc/main/runtime/orca-runtime-terminal-rename-retention.test.tssrc/main/runtime/orca-runtime-terminal-retirement.test.tssrc/main/runtime/orca-runtime-tests/exit-retirement-activation.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-02.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-03.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-04.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-05.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-07.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-08.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-13.spec.tssrc/main/runtime/orca-runtime-tests/mobile-summaries-part-03.spec.tssrc/main/runtime/orca-runtime-tests/runtime-availability.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-04.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-05.spec.tssrc/main/runtime/orca-runtime-tests/terminal-handles.spec.tssrc/main/runtime/orca-runtime-tests/terminal-output-and-worker-recovery-part-02.spec.tssrc/main/runtime/orca-runtime-tests/terminal-output-and-worker-recovery-part-06.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-02.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/pane-title-facts.tssrc/main/runtime/runtime-pane-admission.tssrc/main/runtime/runtime-pane-start-attempts.tssrc/main/runtime/runtime-project-group-controller-folder-create.test.tssrc/main/runtime/runtime-project-group-controller-folder-delete.test.tssrc/main/runtime/runtime-project-group-controller.tssrc/main/runtime/runtime-pty-controller-contract.tssrc/main/runtime/runtime-resolved-worktree-cache.tssrc/main/runtime/runtime-store-contract.tssrc/main/runtime/runtime-terminal-orphan-adoption.tssrc/main/runtime/runtime-workspace-layout-pane-facts.tssrc/main/runtime/runtime-workspace-layout-publication.tssrc/main/runtime/runtime-workspace-layout-writer.tssrc/main/runtime/runtime-workspace-layouts.test.tssrc/main/runtime/runtime-workspace-layouts.tssrc/main/runtime/workspace-layout-stream.test.tssrc/main/runtime/workspace-layout-stream.tssrc/shared/workspace-layout/workspace-layout-published.test.tssrc/shared/workspace-layout/workspace-layout-published.tssrc/shared/workspace-layout/workspace-layout-stream-frames.test.tssrc/shared/workspace-layout/workspace-layout-transitions.test.tssrc/shared/workspace-layout/workspace-layout-transitions.ts
💤 Files with no reviewable changes (9)
- src/main/ipc/pty/ipc/spawn-commit.ts
- src/main/runtime/workspace-layout-stream.test.ts
- src/main/runtime/workspace-layout-stream.ts
- src/main/persistence/loading-store/profile-state-pty-retirement-finalization.test.ts
- src/main/runtime/orca-runtime-tests/terminal-output-and-worker-recovery-part-02.spec.ts
- src/main/persistence/loading-store/pty-retirement-async-durability.test.ts
- src/main/persistence/loading-store/profile-state-delayed-authority-fixture.ts
- src/main/ipc/pty/runtime/spawn-commit-run-facts.test.ts
- src/main/ipc/pty/runtime/spawn-options.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| adoptSession: (from, adopted) => { | ||
| const hostId = this.getWorkspaceSessionHostIdForWorktree(workspace.id) | ||
| const { layout, desktopView, facts, carried } = loadWorkspaceLayout( | ||
| hostId, | ||
| adopted, | ||
| nameBasedLoadContext() | ||
| ) | ||
| this.layoutHolder.transition( | ||
| hostId, | ||
| { | ||
| type: 'orphansAdopted', | ||
| from, | ||
| workspace: workspace.id, | ||
| adopted: layout.workspaces[workspace.id] | ||
| }, | ||
| // The adoption also sets focus and the topology revision, which live beside the layout. | ||
| { desktopView, facts, carried } | ||
| ) | ||
| return this.store.getWorkspaceSession(hostId) | ||
| }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Check the holder transition result before adoption reports success.
adoptSession ignores the HolderApplied that this.layoutHolder.transition(...) returns. The transition fails with workspace_not_found when the holder does not hold the partition, for example a frozen orcad source. In that case nothing is written. adoptSession still returns the unchanged Store session. adoptRuntimeTerminalOrphansFromInventory then reports adopted: true with the old topology revision. The removed rollback path threw in this case. The code also passes layout.workspaces[workspace.id] without a check. If the loaded session keys the workspace under another spelling, orphansAdopted stores undefined as a workspace. The next model walk then fails, for example boundElsewhere, which reads workspace.leaves.
Proposed fix
- this.layoutHolder.transition(
+ const adoptedLayout = layout.workspaces[workspace.id]
+ if (!adoptedLayout) {
+ throw new Error('workspace_session_unavailable')
+ }
+ const applied = this.layoutHolder.transition(
hostId,
{
type: 'orphansAdopted',
from,
workspace: workspace.id,
- adopted: layout.workspaces[workspace.id]
+ adopted: adoptedLayout
},
// The adoption also sets focus and the topology revision, which live beside the layout.
{ desktopView, facts, carried }
)
+ if (!applied.ok) {
+ throw new Error('workspace_session_unavailable')
+ }
return this.store.getWorkspaceSession(hostId)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| adoptSession: (from, adopted) => { | |
| const hostId = this.getWorkspaceSessionHostIdForWorktree(workspace.id) | |
| const { layout, desktopView, facts, carried } = loadWorkspaceLayout( | |
| hostId, | |
| adopted, | |
| nameBasedLoadContext() | |
| ) | |
| this.layoutHolder.transition( | |
| hostId, | |
| { | |
| type: 'orphansAdopted', | |
| from, | |
| workspace: workspace.id, | |
| adopted: layout.workspaces[workspace.id] | |
| }, | |
| // The adoption also sets focus and the topology revision, which live beside the layout. | |
| { desktopView, facts, carried } | |
| ) | |
| return this.store.getWorkspaceSession(hostId) | |
| }, | |
| adoptSession: (from, adopted) => { | |
| const hostId = this.getWorkspaceSessionHostIdForWorktree(workspace.id) | |
| const { layout, desktopView, facts, carried } = loadWorkspaceLayout( | |
| hostId, | |
| adopted, | |
| nameBasedLoadContext() | |
| ) | |
| const adoptedLayout = layout.workspaces[workspace.id] | |
| if (!adoptedLayout) { | |
| throw new Error('workspace_session_unavailable') | |
| } | |
| const applied = this.layoutHolder.transition( | |
| hostId, | |
| { | |
| type: 'orphansAdopted', | |
| from, | |
| workspace: workspace.id, | |
| adopted: adoptedLayout | |
| }, | |
| // The adoption also sets focus and the topology revision, which live beside the layout. | |
| { desktopView, facts, carried } | |
| ) | |
| if (!applied.ok) { | |
| throw new Error('workspace_session_unavailable') | |
| } | |
| return this.store.getWorkspaceSession(hostId) | |
| }, |
| const hostId = pane.connectionId ? toSshExecutionHostId(pane.connectionId) : 'local' | ||
| return this.layoutHolder.processExited( | ||
| hostId, | ||
| { | ||
| worktreeId: pane.worktreeId, | ||
| terminalTabId: pane.tabId, | ||
| leafId: pane.leafId, | ||
| ptyId: pane.ptyId, | ||
| ...(pane.incarnationId ? { incarnationId: pane.incarnationId } : {}) | ||
| }, | ||
| { | ||
| exitCode: UNVERIFIED_PROCESS_EXIT_CODE, | ||
| attachAbsent: true, | ||
| local: !pane.connectionId, | ||
| spawnedFresh: false, | ||
| restored: true, | ||
| inputWritten: false, | ||
| outputReceived: false | ||
| } | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- runtime method and nearby callers ---'
nl -ba src/main/runtime/orca-runtime.ts | sed -n '200,285p'
rg -n -F -- 'unbindAbsentTerminal' src test || true
rg -n -F -- 'processExited' src/main/runtime src || true
printf '%s\n' '--- holder processExited and partition handling ---'
rg -n -F -- 'processExited' src/main/runtime src/main | head -40
rg -n -F -- 'class RuntimeWorkspaceLayouts' src || true
rg -n -F -- 'RuntimeWorkspaceLayouts' src/main/runtime src/main | head -80
printf '%s\n' '--- stable owner attach/resolve and persistence ---'
rg -n -F -- 'attachStablePaneOwner' src test || true
rg -n -F -- 'resolveOwner' src/main src | head -80
rg -n -F -- 'terminal_pane_owner_changed' src test || true
rg -n -F -- 'retirePersistedStablePaneOwner' src test || true
rg -n -F -- 'stageTerminalSurfaceRetirements' src test || true
printf '%s\n' '--- relevant source excerpts ---'
for f in $(rg -l -F -- 'class RuntimeWorkspaceLayouts' src || true); do
echo "FILE $f"
nl -ba "$f" | sed -n '1,360p'
done
for f in $(rg -l -F -- 'attachStablePaneOwner' src || true); do
echo "FILE $f"
nl -ba "$f" | sed -n '180,310p'
done
printf '%s\n' '--- merge-base comparison for cited runtime region ---'
git diff --no-ext-diff d0306a8e567d57f689b514e1125146a10d3c3cde e3b13ce9b8f9da5e1909eabbce82a9dfc694438d -- src/main/runtime/orca-runtime.tsRepository: stablyai/orca
Length of output: 41989
🏁 Script executed:
set -eu
printf '%s\n' '--- complete holder processExited/partition/save ---'
nl -ba src/main/runtime/runtime-workspace-layouts.ts | sed -n '150,205p'
nl -ba src/main/runtime/runtime-workspace-layouts.ts | sed -n '270,350p'
printf '%s\n' '--- absence unbind helper and retirement fallback ---'
nl -ba src/main/ipc/pty/pane/stable-owner.ts | sed -n '1,190p'
nl -ba src/main/runtime/orca-runtime-persist-terminal-surface-retirements.ts | sed -n '1,120p'
rg -n -F -- 'retirePersistedStablePaneOwner' src/main || true
rg -n -F -- 'stageTerminalSurfaceRetirements' src/main || true
printf '%s\n' '--- frozen source predicate and related partition/host guards ---'
rg -n -F -- 'isFrozenOrcadSourceSessionPartition' src
rg -n -F -- 'orcad-retained-source' src/main src/shared
rg -n -F -- 'holds(' src/main/runtime src/main | head -100
rg -n -F -- 'toSshExecutionHostId' src/main/ipc src/main/runtime src/shared | head -120
printf '%s\n' '--- stable-owner callers and owner construction ---'
nl -ba src/main/ipc/pty/pane/adopt-stable.ts | sed -n '1,120p'
nl -ba src/main/ipc/pty/ipc/spawn-execute.ts | sed -n '1,100p'
nl -ba src/main/ipc/pty/runtime/spawn-execute.ts | sed -n '100,175p'
rg -n -F -- 'StablePaneOwner' src/main/ipc src/main/persistence | head -100
printf '%s\n' '--- relevant base implementations ---'
git show d0306a8e567d57f689b514e1125146a10d3c3cde:src/main/ipc/pty/pane/stable-owner.ts | sed -n '1,280p'
git show d0306a8e567d57f689b514e1125146a10d3c3cde:src/main/runtime/orca-runtime-persist-terminal-surface-retirements.ts | sed -n '1,120p' || trueRepository: stablyai/orca
Length of output: 42209
🏁 Script executed:
set -eu
printf '%s\n' '--- holder load/holds and dependency contract ---'
nl -ba src/main/runtime/runtime-workspace-layouts.ts | sed -n '1,155p'
nl -ba src/main/runtime/runtime-workspace-layout-pane-facts.ts | sed -n '1,140p'
printf '%s\n' '--- frozen source implementation ---'
nl -ba src/main/ssh/orcad-retained-source.ts | sed -n '1,260p'
printf '%s\n' '--- complete stable adoption caller ---'
nl -ba src/main/ipc/pty/pane/adopt-stable.ts | sed -n '1,115p'
printf '%s\n' '--- stable spawn caller contexts ---'
nl -ba src/main/ipc/pty/runtime/spawn-execute.ts | sed -n '1,175p'
nl -ba src/main/ipc/pty/pane/spawn-registration.ts | sed -n '1,110p'
printf '%s\n' '--- host/session ownership and frozen guards ---'
rg -n -F -- 'isFrozen' src/main/ipc/pty src/main/runtime src/main/ssh src/main/persistence | head -120
rg -n -F -- 'connectionId' src/main/ipc/pty/pane/adopt-stable.ts src/main/ipc/pty/runtime/spawn-execute.ts src/main/ipc/pty | head -160Repository: stablyai/orca
Length of output: 42436
🏁 Script executed:
set -eu
nl -ba src/main/ipc/pty/pane/adopt-stable.ts | sed -n '18,88p'
nl -ba src/main/ipc/pty/runtime/spawn-execute.ts | sed -n '24,68p'
nl -ba src/main/ipc/pty/runtime/spawn-execute.ts | sed -n '130,151p'Repository: stablyai/orca
Length of output: 5908
Keep a Store fallback for partitions not held by the layout holder.
adoptStablePane can attach a pane from a frozen SSH source partition. For such a partition, layoutHolder.processExited returns 'gone' without changing the Store binding. The following resolveOwner() still finds that binding and attachStablePaneOwner throws terminal_pane_owner_changed.
When the holder does not hold hostId, remove the matching persisted binding from the Store before returning success.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2123b3ce-7594-400e-a591-449f8f59bbb3
📒 Files selected for processing (12)
src/main/ipc/pty-launch-race-test-fixture.tssrc/main/ipc/pty/pane/spawn-registration.tssrc/main/persistence/loading-store/pty-binding-persistence.tssrc/main/persistence/loading-store/pty-spawn-exit-durability.test.tssrc/main/persistence/loading-store/workspace-session-write-listeners.test.tssrc/main/runtime/orca-runtime-adopt-terminal-orphans-from-inventory.tssrc/main/runtime/orca-runtime-on-pty-exit.tssrc/main/runtime/orca-runtime-persist-terminal-surface-retirements.tssrc/main/runtime/orca-runtime-terminal-retirement.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/runtime-held-pane-exits.tssrc/main/runtime/runtime-workspace-layouts.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/runtime/orca-runtime-terminal-retirement.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Move workspace records when adoption changes the key. · workspace-layout-transitions.ts:112
src/shared/workspace-layout/workspace-layout-transitions.ts:112
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winMove workspace records when adoption changes the key.
If
fromdiffers fromworkspace,removeWorkspacesdeletes records keyed byfrom. Installingadopteddoes not restore those records. An adopted workspace can therefore lose its default-tab marker or client-hosted browser-page records. Re-key the source records toworkspacebefore removing the source workspace.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b1ee28b0-7a63-4150-bfc7-a7756ca7bd16
📥 Commits
Reviewing files that changed from the base of the PR and between 4d4a218 and 9e3717cfafa87a0961ccb81e5f7e188ca374544f.
📒 Files selected for processing (11)
src/main/persistence/loading-store/session-host-partitions.tssrc/main/persistence/loading-store/session-snapshot-operations.tssrc/main/persistence/loading-store/workspace-session-snapshot-publication.tssrc/main/runtime/orca-runtime-persist-terminal-surface-retirements.tssrc/main/runtime/orca-runtime-terminal-retirement.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/runtime-held-pane-exits.tssrc/main/runtime/runtime-workspace-layout-writer.tssrc/shared/workspace-layout/workspace-layout-process-exit.tssrc/shared/workspace-layout/workspace-layout-transitions.test.tssrc/shared/workspace-layout/workspace-layout-transitions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/runtime/runtime-held-pane-exits.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| } | ||
| this.writing = true | ||
| try { | ||
| store.setWorkspaceSession(saveWorkspaceLayout(loaded), hostId, { fromLayoutHolder: true }) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Do not complete a layout change after its Store write fails.
If setWorkspaceSession rejects a write, write logs the error and returns. The holder has already installed the new layout and may have stopped terminals. It then publishes the change, although the Store still holds the old session. A restart can restore the old layout. Propagate the failure to RuntimeWorkspaceLayouts.commit, and do not commit terminal stops or publication until the Store accepts the write.
… before the window sees them; bridge reloads without diffing
… tests follow the holder
…worktrees at creation; restore Store durable-mutation tests; real-holder attach-absence test
… an unhandled rejection
…able retirement; a binding write publishes a new partition so the bridge sees it
- Log a failed terminal stop after a holder close instead of letting the rejection exit the headless server. - Holder saves skip the Store's binding replay, so an unbind is not undone. - Panes the window still owns retire on exit as main does, through a surfaceRetired transition that stops nothing (the process is gone). - A binding write publishes a new session object so the bridge sees it. - A process that exits during registration retires its pane.
…rfaceRetired stack-internal
306e594 to
b0544c1
Compare
…rship rebase; a sole pane that lost its binding keeps its row's terminal at load The Store's terminal-membership rebase kept the prior row ptyId for every save without a newer topology revision, so the holder's bind (no topology change) never reached the row: a created terminal's row stayed null on disk, and after a serve restart that lost the layout binding, phones got a pending-handle row with no ptyId (paired-remote-terminal-serve-restart-binding spec). The holder writes bindings, so its saves keep their row terminal; a renderer's save still cannot change one. The Loader also binds a sole pane with no stored binding to its row's terminal, as main's headless list did. Co-Authored-By: Claude <[email protected]>
Part of the PR 6 stack; merged as one unit, do not merge alone.
ELI5
Today many places in the main process edit the saved tab layout directly. This slice gives the main process one in-memory copy of each host's layout (the "holder"). It applies layout changes, saves them, and tells listeners which workspaces changed. The runtime's own terminal creates, splits, exits, orphan adoption and terminal titles now go through it. Everything else keeps working the old way until later slices move it.
What Changed
New holder (
src/main/runtime/runtime-workspace-layouts.tsplus its writer, publication, pane-facts and start-attempt modules). It loads every host partition the Store holds, except per-environmentruntime:partitions and frozen conversion sources. It applies layout commands and transitions with the shared pure layout module. It saves from its own memory and publishes only the workspaces that changed. The oldworkspace-layout-stream.tsis deleted andlayout.subscribereads from the holder.Published panes now carry a derived
status(starting / failed / exited / waiting for host / live) and the terminal's live title.Runtime terminal create and split: the holder adds the pane before the spawn and binds it after, using a per-pane start token. A spawn that lost its pane is killed instead of written into someone else's pane. The old runtime "persist the binding after spawn" step is removed.
Process exit: for partitions the holder holds, the exit rule runs as a holder transition, and the exit still waits for its retirement to be saved, as today. A pane the window still shows retires as it does today (the window decides those until 6f), through a
surfaceRetiredtransition that stops nothing because the process is gone.surfaceRetiredis stack-internal: it is in the temporary-code ledger and is removed in 6f. A process that exits while its pane's binding is being written retires its pane. Other partitions keep today's Store retirement.Closing a pane in the holder stops its terminal. A stop that fails is logged, as the worktree stop already does, so it can no longer crash the headless server.
Holder saves pass
fromLayoutHolder, so the Store does not re-add a binding the holder removed. A window binding write now publishes a new session object, so the bridge sees it.Orphan adoption and the stable-owner absence path are rerouted to the holder. Headless title changes go through the new
pane-title-facts.ts.Locally owned worktrees, folders, repo main worktrees and the floating terminal are seeded into the holder's catalog from the Store at startup. Later scans and folder creates add new ones.
Interim bridge
holder-external-write-reload.ts: when a writer that has not moved yet changes a held partition, the holder reloads it. Attempt tokens and exit facts are kept. It is in the temporary-code ledger and is deleted in 6g.A pane's published status follows what the runtime knows. A kept exit (for example a local shell that exits with code 2) publishes
exitedat once, even though the layout itself did not change. A terminal registering, connecting, disconnecting or turningunverifiablerepublishes the panes that show it.A worktree created or adopted through
worktrees:create,worktrees:adoptProvisionedRoot, the runtime'screateManagedWorktree(git and folder) or its provisioned-root adoption joins the layout catalog at the creation site, before the caller or the window hears about it.Users should see no difference yet.
Left on the Store for later slices (the bridge keeps the holder in step until 6g):
6b:
movePaneToNewTab, but no main caller sends it yet. Its side effects are not wired: the agent hook server's pane-authority transfer, the orchestration rekey andrekeyMovedLeafProfileRecords. They still run inipc/pty/ipc/leaf-move.ts.ipc/session.tsand the headless browser-tabs path.runtime:<env>partitions. The holder never loads those partitions, and it does not hold frozen orcad sources either.6f:
6g:
holder-external-write-reload.ts), listed in the temporary-code ledger. It must not exist at the stack top.setWorkspaceSessionForWorktree;patchWorkspaceSessionandstageWorkspaceSessionBeforeUnload;workspace-session-write-rollback.ts;persistPtyBindingpath (spawn-commit-persist);workspace-session-terminal-binding-replay.ts. Holder saves skip it already; other Store writes still run it.ssh-pty-binding-cleanup.ts), with the other Store-internal writers.ssh-target-reassignment.ts). It edits the Store's state in place and renames thessh:partition, so moving it means rewriting a Store transaction. Until then the holder keeps the old partition loaded after a reassignment.admitTerminalPane/withdrawTerminalPaneandterminal-pane-admission.ts. Nothing in production calls them now; only tests do.Why
The layout needs one owner so changes are applied in order and published once. Moving every writer at once would be a very large change, so later slices move the rest. The reload bridge keeps the holder correct in the meantime. It reloads only when a write happens, with no timers or diffing.
Linked Issue
Part of the terminal topology / PR 6 stack.
Visual Proof
N/A: no visible change yet. The holder publishes the same layouts. The new pane status and live title are not rendered until a later slice.
Testing
pnpm tcpasses. The changed-code gates, oxlint, the compat-boundary import check and the layout-writer ratchet pass.Review-round tests:
exited;ssh:partition;unverifiableverdict republish the pane;surfaceRetiredretires the pane without stopping anything, and leaves a pane that now shows another incarnation alone;The workspace-layout e2e oracle passes locally, 21 of 21, including the cold and live daemon-restart scenarios.
The two Store
runDurableMutationcontract tests (partial mutate, final flush) are restored inprofile-state-durable-mutation-failure.test.ts.New holder unit tests cover: load and status, start-token admission and superseded binds, the exit rule, close stopping the terminal, catalog publish and remove, fenced partitions, and bridge reloads.
Changed tests: runtime-path variants of the old "persist binding after spawn" durability tests were removed, because that step no longer exists. The window-path variants are kept. Two orphan-adoption tests that checked rollback after a failed save were removed: the holder keeps memory and logs the failure, as the plan specifies. Tests that read the store after attach absence now check that the runtime is asked to unbind the pane. That pane stays, unbound, and is no longer retired.
Full local
src/main+src/sharedrun: the 7 failing files also fail on the base commit here (browser-manager, packaged CLI, shell and live-shell tests). Two timing tests that failed under full load pass alone.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
SSH partitions are held and show "waiting for host" until their host connects.
runtime:partitions are untouched. Local only; no wire change.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)