Skip to content

PR 6a: the runtime holds the tab layout (holder becomes the source in main) - #27759

Open
Jinwoo-H wants to merge 15 commits into
mainfrom
layout/pr6-6a
Open

Jinwoo-H wants to merge 15 commits into
mainfrom
layout/pr6-6a

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 60 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1091 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1292 $\color{#cf222e}{\Huge{\mathbf{−}}}$​201
Prod 64 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1406 $\color{#cf222e}{\Huge{\mathbf{−}}}$​473 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​933

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.ts plus its writer, publication, pane-facts and start-attempt modules). It loads every host partition the Store holds, except per-environment runtime: 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 old workspace-layout-stream.ts is deleted and layout.subscribe reads 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 surfaceRetired transition that stops nothing because the process is gone. surfaceRetired is 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 exited at once, even though the layout itself did not change. A terminal registering, connecting, disconnecting or turning unverifiable republishes the panes that show it.

  • A worktree created or adopted through worktrees:create, worktrees:adoptProvisionedRoot, the runtime's createManagedWorktree (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:

  • Moving a pane to a new tab: the holder applies 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 and rekeyMovedLeafProfileRecords. They still run in ipc/pty/ipc/leaf-move.ts.
  • Closing a tab: the holder's close does not yet mark the tab's agent launches closed by the user. Today's callers are ipc/session.ts and the headless browser-tabs path.
  • Per-view fields for runtime:<env> partitions. The holder never loads those partitions, and it does not hold frozen orcad sources either.
  • Focus and view fields (active group and tab, each pane's active and expanded state): still loaded and saved from the Store as data beside the layout. No view command changes them in the holder; orphan adoption is the one producer that passes them in.
  • Editor views: untouched.

6f:

  • Title producers (prompt-generated and AI-vault titles). Main has no per-pane orchestration labels and no dispatch task ids for the replace rules, and the AI-vault request must start carrying the tab.
  • Editor tabs follow a file rename (census U13). The language lookup needs a home in shared code, or the sender passes the new language.
  • The window clearing a pane's agent launch.
  • Whether a split had a sibling at connect is recorded only for holder-bound starts. Window-spawned splits read "no" until their starts are routed.

6g:

  • The temporary reload bridge (holder-external-write-reload.ts), listed in the temporary-code ledger. It must not exist at the stack top.
  • The old Store writers:
    • the write half of the runtime session controller and setWorkspaceSessionForWorktree;
    • patchWorkspaceSession and stageWorkspaceSessionBeforeUnload;
    • workspace-session-write-rollback.ts;
    • the window's persistPtyBinding path (spawn-commit-persist);
    • workspace-session-terminal-binding-replay.ts. Holder saves skip it already; other Store writes still run it.
  • Store call sites to move to the holder: workspace removal (census U10), orcad import (V3) and identity rename.
  • SSH lease scrubs (census V4, ssh-pty-binding-cleanup.ts), with the other Store-internal writers.
  • SSH target reassignment (ssh-target-reassignment.ts). It edits the Store's state in place and renames the ssh: partition, so moving it means rewriting a Store transaction. Until then the holder keeps the old partition loaded after a reassignment.
  • The Store's admitTerminalPane/withdrawTerminalPane and terminal-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 tc passes. The changed-code gates, oxlint, the compat-boundary import check and the layout-writer ratchet pass.

  • Review-round tests:

    • a kept local exit with code 2 publishes one event with status exited;
    • a real runtime with a real holder unbinds only the absent pane of a two-pane tab, locally and on an ssh: partition;
    • registration and an unverifiable verdict republish the pane;
    • each create path adds the worktree to the catalog before notifying;
    • a terminal stop that throws is logged and the other terminals still stop;
    • surfaceRetired retires the pane without stopping anything, and leaves a pane that now shows another incarnation alone;
    • a holder unbind of a tab's last bound pane stays unbound on disk, while a window snapshot that drops a binding still gets it restored.
  • The workspace-layout e2e oracle passes locally, 21 of 21, including the cold and live daemon-restart scenarios.

  • The two Store runDurableMutation contract tests (partial mutate, final flush) are restored in profile-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/shared run: 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

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

Notes

SSH partitions are held and show "waiting for host" until their host connects. runtime: partitions are untouched. Local only; no wire change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The runtime replaces WorkspaceLayoutStream with RuntimeWorkspaceLayouts, which loads and saves host partitions, tracks pane-start attempts, and publishes layouts with runtime pane status and live titles. Runtime pane spawning now admits panes through the holder. Workspace and worktree catalogs, external session reloads, orphan adoption, title updates, and terminal-exit handling are also connected to holder-backed operations.


Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 9e371

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 | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 31.48% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 54 functions across 81 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description explains the change, rationale, scope, testing, visual impact, and remaining work in detail. However, the required Linked Issue section does not contain an actual issue link or issue n… Add the actual linked issue in the required Fixes #... section. Keep the existing testing and scope details, and update the checklist if the listed commands passed in CI or locally.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the primary change: moving tab-layout ownership into the runtime holder. It is concise and specific.

Full details: Description check

Explanation

The description explains the change, rationale, scope, testing, visual impact, and remaining work in detail. However, the required Linked Issue section does not contain an actual issue link or issue number; it only references the PR 6 stack.


✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6e8a5ea0-969a-4e4b-ab35-aa72b84a3d47
📥 Commits

Reviewing files that changed from the base of the PR and between 983532a and e3b13ce.

📒 Files selected for processing (96)
  • config/main-layout-writer-baseline.txt
  • config/scripts/check-layout-writer-ratchets.mjs
  • src/main/ipc/pty-dead-owner-respawn.test.ts
  • src/main/ipc/pty-launch-parity.test-fixture.ts
  • src/main/ipc/pty-launch-parity.test.ts
  • src/main/ipc/pty-launch-race-parity.test.ts
  • src/main/ipc/pty-launch-race-test-fixture.ts
  • src/main/ipc/pty-pane-claim-arbitration.test.ts
  • src/main/ipc/pty-pane-materialization-race.test.ts
  • src/main/ipc/pty-pane-reservation-settlement.test.ts
  • src/main/ipc/pty-persisted-incarnation-repair.test.ts
  • src/main/ipc/pty-runtime-ssh-binding-persistence.test.ts
  • src/main/ipc/pty-spawn-placement-threading.test.ts
  • src/main/ipc/pty/ipc/spawn-commit.ts
  • src/main/ipc/pty/pane/spawn-registration.ts
  • src/main/ipc/pty/pane/stable-owner.ts
  • src/main/ipc/pty/pane/stable-pane-absence-respawn.test.ts
  • src/main/ipc/pty/runtime/spawn-commit-run-facts.test.ts
  • src/main/ipc/pty/runtime/spawn-commit.ts
  • src/main/ipc/pty/runtime/spawn-options.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/ipc/pty/runtime/spawn-state.ts
  • src/main/ipc/repos/folder-workspace-attachment-handlers.test.ts
  • src/main/ipc/repos/folder-workspace-handlers.ts
  • src/main/ipc/worktrees-canonical-ssh-listing.test.ts
  • src/main/ipc/worktrees-test-runtime-stub.ts
  • src/main/ipc/worktrees-windows.test.ts
  • src/main/ipc/worktrees/listing/register-worktree-catalog-handlers.ts
  • src/main/persistence/loading-store/profile-state-delayed-authority-fixture.ts
  • src/main/persistence/loading-store/profile-state-pty-retirement-finalization.test.ts
  • src/main/persistence/loading-store/pty-reattach-failure-routing.test.ts
  • src/main/persistence/loading-store/pty-retirement-async-durability.test.ts
  • src/main/persistence/loading-store/pty-spawn-exit-durability.test.ts
  • src/main/persistence/loading-store/pty-spawn-handle-publication.test.ts
  • src/main/persistence/loading-store/pty-spawn-replacement-durability.test.ts
  • src/main/persistence/loading-store/pty-spawn-restore-durability.test.ts
  • src/main/persistence/loading-store/workspace-session-write-listeners.test.ts
  • src/main/runtime/cli-terminal-create-host-session-binding.test.ts
  • src/main/runtime/graph-sync-live-daemon-pty-tab-preservation.test.ts
  • src/main/runtime/holder-external-write-reload.ts
  • src/main/runtime/orca-runtime-adopt-terminal-orphans-from-inventory.ts
  • src/main/runtime/orca-runtime-create-terminal-dependencies.ts
  • src/main/runtime/orca-runtime-create-terminal.ts
  • src/main/runtime/orca-runtime-get-unpersisted-tracked-title-for-pty.ts
  • src/main/runtime/orca-runtime-get-worktree-terminal-provisioning-host.ts
  • src/main/runtime/orca-runtime-headless-hydration-repo-gate.test.ts
  • src/main/runtime/orca-runtime-on-pty-exit.ts
  • src/main/runtime/orca-runtime-persist-headless-terminal-title.ts
  • src/main/runtime/orca-runtime-persist-terminal-surface-retirements.ts
  • src/main/runtime/orca-runtime-preserved-branch-cleanup.ts
  • src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
  • src/main/runtime/orca-runtime-split-pty-backed-terminal.ts
  • src/main/runtime/orca-runtime-terminal-rename-retention.test.ts
  • src/main/runtime/orca-runtime-terminal-retirement.test.ts
  • src/main/runtime/orca-runtime-tests/exit-retirement-activation.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-05.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-07.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-08.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-13.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-summaries-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/runtime-availability.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-05.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-handles.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-output-and-worker-recovery-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-output-and-worker-recovery-part-06.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/pane-title-facts.ts
  • src/main/runtime/runtime-pane-admission.ts
  • src/main/runtime/runtime-pane-start-attempts.ts
  • src/main/runtime/runtime-project-group-controller-folder-create.test.ts
  • src/main/runtime/runtime-project-group-controller-folder-delete.test.ts
  • src/main/runtime/runtime-project-group-controller.ts
  • src/main/runtime/runtime-pty-controller-contract.ts
  • src/main/runtime/runtime-resolved-worktree-cache.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/main/runtime/runtime-terminal-orphan-adoption.ts
  • src/main/runtime/runtime-workspace-layout-pane-facts.ts
  • src/main/runtime/runtime-workspace-layout-publication.ts
  • src/main/runtime/runtime-workspace-layout-writer.ts
  • src/main/runtime/runtime-workspace-layouts.test.ts
  • src/main/runtime/runtime-workspace-layouts.ts
  • src/main/runtime/workspace-layout-stream.test.ts
  • src/main/runtime/workspace-layout-stream.ts
  • src/shared/workspace-layout/workspace-layout-published.test.ts
  • src/shared/workspace-layout/workspace-layout-published.ts
  • src/shared/workspace-layout/workspace-layout-stream-frames.test.ts
  • src/shared/workspace-layout/workspace-layout-transitions.test.ts
  • src/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.

Comment on lines +70 to +89
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)
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

Suggested change
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)
},

Comment thread src/main/runtime/orca-runtime.ts Outdated
Comment on lines +243 to +262
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
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ts

Repository: 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' || true

Repository: 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 -160

Repository: 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2123b3ce-7594-400e-a591-449f8f59bbb3
📥 Commits

Reviewing files that changed from the base of the PR and between 23b1de7 and 4d4a218.

📒 Files selected for processing (12)
  • src/main/ipc/pty-launch-race-test-fixture.ts
  • src/main/ipc/pty/pane/spawn-registration.ts
  • src/main/persistence/loading-store/pty-binding-persistence.ts
  • src/main/persistence/loading-store/pty-spawn-exit-durability.test.ts
  • src/main/persistence/loading-store/workspace-session-write-listeners.test.ts
  • src/main/runtime/orca-runtime-adopt-terminal-orphans-from-inventory.ts
  • src/main/runtime/orca-runtime-on-pty-exit.ts
  • src/main/runtime/orca-runtime-persist-terminal-surface-retirements.ts
  • src/main/runtime/orca-runtime-terminal-retirement.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/runtime-held-pane-exits.ts
  • src/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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 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 win

Move workspace records when adoption changes the key.

If from differs from workspace, removeWorkspaces deletes records keyed by from. Installing adopted does 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 to workspace before 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.ts
  • src/main/persistence/loading-store/session-snapshot-operations.ts
  • src/main/persistence/loading-store/workspace-session-snapshot-publication.ts
  • src/main/runtime/orca-runtime-persist-terminal-surface-retirements.ts
  • src/main/runtime/orca-runtime-terminal-retirement.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/runtime-held-pane-exits.ts
  • src/main/runtime/runtime-workspace-layout-writer.ts
  • src/shared/workspace-layout/workspace-layout-process-exit.ts
  • src/shared/workspace-layout/workspace-layout-transitions.test.ts
  • src/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 })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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
…worktrees at creation; restore Store durable-mutation tests; real-holder attach-absence test
…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.
…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]>

This branch has not been deployed

No deployments
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.

1 participant