Skip to content

Layout groundwork (switched off): main starts and restores every pane, and the window only attaches and paints the host's history - #31567

Merged
Jinwoo-H merged 80 commits into
mainfrom
fd/c1c-restore-view-attach
Oct 22, 2026
Merged

Jinwoo-H merged 80 commits into
mainfrom
fd/c1c-restore-view-attach

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2661 $\color{#cf222e}{\Huge{\mathbf{−}}}$​90 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2571
Prod 63 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1295 $\color{#cf222e}{\Huge{\mathbf{−}}}$​212 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1083

ELI5

This is groundwork for the layout rewrite, and it stays switched off in every build that ships. With the switch on, the window stops restoring, waking or restarting terminals itself. The main process starts every pane's terminal, and the window only attaches to it and shows the history that the terminal's host returns. Nothing changes for users today.

What Changed

All of this happens only with the layout-owner build switch (ORCA_LAYOUT_OWNER=main) on:

  • History comes only from the terminal's host (L236). The window never paints its own saved copy of a pane's output. Main seeds its own copy from the host's restore reply, so later attaches (phones, paired clients) get the same history. The confirmation that a cold restore was painted now goes to main, which releases the host's cached restore only for the pane's current terminal.
  • The window's view is attach-only (L237). At mount, a pane attaches to its live terminal or starts nothing, and it keeps its binding. A sleeping pane asks main to start it on its first view, waits, then attaches to the terminal main bound. A hidden sleeping pane waits for its first view, as today.
  • Wake, restart and resume go through main (L241). A wake from sleep, a hibernated agent's wake, a restart-on-show and a reattach that finds its terminal gone all ask main to start the pane. Main resumes the agent, including an agent recorded under the pane's old number in a one-pane tab. Main also replaces the empty shell a hibernated agent left behind.
  • One paint per restore. A view that attaches while main is starting the same pane uses main's start result. It makes no second provider attach and gets no second copy of the history. Main's hidden-start mark stays off while a view is attaching, so the view is not hidden from its own paint.
  • A resumed pane reads awake (live-on-bind). Once main's start has resumed a slept agent and bound the pane, that pane's record becomes a running agent's resume record. The pane then lists as connected, not sleeping, and a host crash still resumes the agent. A sleep captured after the start is left alone.
  • Old numbered records in a split. These are records an older build saved under a pane's number. Each pane takes the record saved under its own number. If no pane in the tab has one, the tab's one conversation goes to pane 1 only.
    • This improves on the window. The window gave it to whichever pane connected first, so a record saved for pane 2 could resume in pane 1 and leave pane 2 a plain shell.
  • A pane restart stops its terminal before writing the pane unbound (L244). If the stop fails, main refuses with pane_already_bound and keeps the pane.
  • Main's start reads the pane from its own layout, not from the window's copy.
  • A start main could not bind shows "The terminal could not start: terminal_not_started" (owner-visible row 27). It goes through the window's one failure path, so it uses the same string.

Why

Under the final design main owns every terminal start, and every view, with or without a window, only attaches. Before this, with the switch on, both the window and main could restore, wake or resume the same pane, and they could paint two different histories.

The view uses main's start result rather than making its own attach, which removed both the second paint and the second provider round trip. Making main wait for the window, or keeping two restore paths and deduplicating their output, would keep two processes deciding the same start.

Linked Issue

N/A (internal design work).

Visual Proof

N/A: switched off in every shipped build, so nothing a user sees changes today. With the switch on, the behaviour is covered by the tests and the restore paint measurements below.

Testing

  • ci-static-gate passes. It runs every static-analysis step of the PR workflow plus pnpm tc.
  • New tests, each shown to fail without its change. They cover:
    • a view that joins main's start (one provider request, with its cold restore);
    • a start a window view is attaching to stays visible;
    • a failed attach re-hides only what it kept visible;
    • a restart whose stop fails keeps its pane;
    • the numbered-record resume in a one-pane tab, and its refusal in a split;
    • a start main could not bind shows terminal_not_started;
    • main's start reads its own layout.
  • Switch-on comparison against main at 3d6a945, per test with diff-tests.mjs (vitest JSON reporter), over renderer terminal-pane, runtime, store and lib, main ipc, runtime, persistence and terminal-topology, plus shared and preload. There were 56,055 tests at main and 56,130 at head; no failing test exists only at head. Two tests failed only at head in the loaded full run, and both are timing flakes in code this PR does not touch. runtime-environment-preference (a file watcher) also fails 2 of 5 runs at main when run alone. pty-pane-materialization-race passes 8 of 8 alone at head. One switch-on test was converted: it expected a resumed pane's record to stay a sleep.
  • Stale switch-on tests were converted, never deleted. The banner tests and the reattach park/reveal test now show main's start. Their switch-on branches cite L251 for the known banner loss.
  • Server specs: switch-on, built fresh at each commit (build:electron-vite:parallel --mode e2e plus build:cli), run through the app slot at head 12f7f13 and at the merge-base 3d6a945:
    • paired-mobile-desktop-tab-composition: base pass, head pass.
    • paired-desktop-server-layout-frames: base pass, head pass.
    • headless-serve-focused-terminal-create: base pass, head pass.
    • live-background-terminal-mount-authority: base pass, head pass.
    • With the switch on, this spec no longer deletes the window's pane bindings by hand, because only main's frames write them. The switch-off path is unchanged.
  • Restore paint time (switch on): one pane and a 4-pane tab at 1.3 MB of coloured output each, cold restore after the terminal service is replaced. Measured interleaved (main, branch, main, branch), 5 samples each, view to paint median in ms:

Clean run at 43cbe4f against 0abe700: the first run started at load 16.6; the rest ran at 22-27.

case main 1 branch 1 main 2 branch 2 main spread delta 1 delta 2 counts
1 pane 325 375 275 356 50 +50 +81 borderline: repeats (pooled +53)
4 panes 554 601 708 569 154 +47 -139 no (pooled +14)

Where the 1-pane time goes, from one traced sample on each side (ms after the view):

step main branch
attach probe to the terminal service +51 +77
spawn request reaches the terminal service +58 +117
the terminal service's restore +67 to +105 +140 to +311
the view's attach answered none +361
paint +282 +582

The branch spends about 50 ms before the restore (the window asks main, then main's own create path runs) and about 50 ms after it (main's rebind and binding write). The terminal service's restore itself took longer in these samples. CPU profiles of main show it mostly idle: 1292 of 1628 ms on a 4-pane start. Profiles of the terminal service are idle about 1200-1271 of 1519 ms, on both main and this branch.

The binding write is not new. On main, the window's own spawn waits on the same serial save queue before it answers.

The request is the same as the window's. On one restored pane, I compared the terminal service request from main with the window's request, field by field:

  • Identical: size (135×60, taken from the restore), working folder, the 615,748-byte history seed, history isolation, the environment variables it removes, startup colours, no command, no shell-ready wait, and the attach probe before it.
  • One extra field: main also sets commandDelivery, which never reaches the terminal service.
  • One missing environment variable: main omits ORCA_WORKSPACE_ID (L265; see Notes).
  • Duration: with identical fields, the request took 94 and 302-305 ms from main against 47 and 73 ms from the window. The difference is in when the request runs, not in what is sent.

This is accepted for this PR because the change is switched off in every shipped build. Ledger row L264 blocks the flip. Before the switch is turned on, add timestamps inside the terminal service and profile it, then remove the extra per-start traffic, or the owner accepts the final numbers.

Restore markers and late writes are at main's level: one paint per pane.

Review

One independent review per head, plus a review of each fix delta. Findings at medium or above are fixed with tests.

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

Code that runs with the switch off. I diffed the bundles: this head against main at 84af8ef, both built with the switch off and unminified (main and renderer), with cross-chunk import names normalized. Every hunk was reviewed. None changes switch-off behaviour.

  • commitLayoutCommand moved files and gained optional stopBeforeWrite / onEffects hooks. Every switch-off caller passes none.
  • The pane-create reservation resolves with a result that nothing sets or reads with the switch off.
  • attachOnlyView is always undefined. The new attaching-view count is never written.
  • The painted cold-restore confirmation skips a missing id. The window still sends {id}.
  • The sleeping-record lookup moved to a shared module. The moved claim-key function is byte-identical, and the legacy lookup returns the same record.
  • The window's wake, restart and connect wrappers return the existing path's value directly. The main-start gates return false.
  • The layout command schema gains a startPane member. Older peers never send it, and a switch-off host does not serve layout.apply.

SSH and paired servers: a server's main restores a dead pane from its own disk with the stored session id. This was checked headless, 3 of 3 runs. A tab main does not hold (a paired server's) keeps today's path. Folder workspaces take the same path as git worktrees.

Visible with the switch on, compared with the shipped build:

  • Terminal history after a restart (row 19, owner-accepted). Local panes are unchanged. Managed-server SSH and paired-server panes get their history from the host, including a dead pane restored from the server's disk on first view.
    • Legacy-relay SSH panes woken after sleep come back empty instead of showing the window's old copy. This affects only panes slept on 1.4.224 or earlier and never woken since. That path is retired along with the relay bridge.
  • Resume banners (L251, blocks the flip). Main resumes the agent but does not yet publish the outcome. So the "resume unavailable" and "session restored" banners do not show, and the start-failure message loses its resume suffix. A follow-up PR publishes the outcome.
  • A start main could not bind shows "The terminal could not start: terminal_not_started" (row 27).
  • An empty shell left by a hibernated agent is replaced, and the agent is resumed when a view asks.
  • An improvement over the window: old numbered records in a split. These are records an older build saved under a pane's number.
    • The window gave such a record to whichever pane connected first, so a record saved for pane 2 could resume in pane 1 and leave pane 2 a plain shell.
    • Main gives each pane the record saved under its own number. If no pane has one, the tab's one conversation goes to pane 1 only.
  • A pane holding a running agent's resume record starts and resumes from it. It is no longer refused with pane_sleeping. That refusal only protected the record from a plain start that would lose it. Main's start resumes from the record, as the desktop resumes 'live' and 'quit' records. The test from main that expected the refusal now expects the start.
  • A cold restore paints about 53 ms later for one pane (see Testing). It blocks the flip until it is traced or accepted (L264).
  • Restored git-worktree terminals lack ORCA_WORKSPACE_ID. Main's create path sets it only for folder workspaces. That is already true today for terminals started from a phone or the CLI. With the switch on, it also applies to every restored pane. This is a known switch-on gap outside this PR, ledger row L265 (blocks the flip). Its fix also changes switch-off terminals, so it waits on an owner question.

Twin k (the window's by-id restore of a pane that moved between tabs) moves to C1d. It is dead once the window stops restoring by id.

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)

…yout-owner build)

A status-only frame changes one store entry and no pane tree, so the pane's view stays mounted.
…start shows why (layout-owner build)

Fixes owner-visible row 15: a failed agent or setup start no longer opens a plain shell.
…s host, never the window's copy (layout-owner build only)
…'s current terminal (layout-owner build only)
These 8 have failed switch-on since #31130 moved the exit close to main.
…s, through its one restored-pane starter (layout-owner build only)

The model's start and stop effects reach the runtime once the command is written, never the
reply. startPane starts a pane whose binding has a start status, and a slept pane from its record.
A wake keeps a pane's resume record until its start binds; a failed start keeps it and shows why.
With the switch on, main owns a running agent's wake even with a window open.
…ly, so main does not start it again (layout-owner build only)
…erminal's host, never the window's copy (layout-owner build only)"

This reverts commit a646d89.
…form, so a host crash resumes the agent again (layout-owner build only)
…; the window attaches (layout-owner build)

The window's split, a startup split with its command, and a CLI split all go through main's
terminal.split; main's frame mounts the pane, with or without a window intent. Deletes the
window's split wait and withdraw, the split appear intents, and the queued-split skip and cancel.
The e2e helper uses the real split. A startup split leaves focus on its source pane.
…; a taken pane id is refused

Also restores the proof that a split closed while it starts gets one answer and leaves no
pane or start status behind.
…terminal's host, never the window's copy (layout-owner build only)"

This reverts commit 420e605.
…rite joins that start, not a second one (layout-owner build only)
…y await, and a failed start with its reason; startPane starts a pane whose bound terminal ended (layout-owner build only)
…out, not the client projection (switch-on builds only)
…ane unbound, so a stop that fails keeps the pane (switch-on builds only)
…d through the window's wait, from one copy site (switch-on builds only)
…pane's number, as the window did; stale switch-on tests show main's start and the known banner loss (switch-on builds only)
…en-start drops, by episode; main reads a split pane's numbered record by its number; the window keeps a shell main kept (switch-on builds only)
…eaves it visible, so the view paints once (switch-on builds only)
… takes main's start, with no second provider attach (switch-on builds only)
…arries a payload and still owns its terminal; attaching views are counted, keep main's pre-spawn mark off, and a failed attach hides only what it kept visible (switch-on builds only)
…cord tests; reattach options fit the file budget
…dow's bindings, which only main's frames write

Claude-Session: W5b
…owner build check is one helper

Claude-Session: W5b
startPane keeps C1c's start-from-record rule over the merged pane_sleeping refusal, and its resume-record test now asserts the start; wake starts only slept panes and a recordOnly wake drops either record; isHibernationDoneRecord uses isPaneSleepRecord in its shared home.

Claude-Session: W5b
…s the record, since main's start resumes from it

Claude-Session: W5b
… it reads awake, not sleeping (switch-on builds only)

Claude-Session: W5b
…resumes the tab's one conversation in pane 1 only (switch-on builds only)

Claude-Session: W5b
… never a sleep captured after it (switch-on builds only)

Claude-Session: W5b
…ne's record a running agent's

Claude-Session: W5b
…esume record for the live mark

Claude-Session: W5b
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 980d6298-9a92-48ec-a17e-fe7912e909f1
📥 Commits

Reviewing files that changed from the base of the PR and between 0bcbbeb and c535512.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

The pull request adds main-owned pane startup and wake flows. Main can start or restore panes through layout commands, while renderer views attach with attachOnlyView. Layout persistence now carries live-binding state, stop-before-write handling, and start effects. Sleeping-record lookup supports stable and legacy pane keys. Cold-restore acknowledgements include pane context and validate current bindings. Tests cover IPC, runtime, persistence, restore, wake, visibility, and renderer reattachment behavior.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 09d7f

When main owns layout, legacy pane resumes can retain stale sleep state or resume the same provider session twice; both paths should be fixed before enabling this mode.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 70 functions across 60 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly describes the main change: groundwork for main-owned pane startup and window attach-only behavior behind a disabled switch. It is somewhat long but specific and relevant.
Description check Passed The description is detailed and covers the required explanation, changes, rationale, testing, review, compatibility notes, and checklist. The Linked Issue section says N/A despite the template request…
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.
Full details: Description check

Explanation

The description is detailed and covers the required explanation, changes, rationale, testing, review, compatibility notes, and checklist. The Linked Issue section says N/A despite the template requesting an actual issue, but the rest of the description is substantially complete.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f620fc9f-8472-42ef-9986-aac21c72f2b6
📥 Commits

Reviewing files that changed from the base of the PR and between 50b07c0 and 2584e4c.

📒 Files selected for processing: 110
  • src/main/ipc/pty-attach-view-joins-main-start.test.ts
  • src/main/ipc/pty-hidden-delivery-gate.ts
  • src/main/ipc/pty-painted-cold-restore-ack-layout-owner.test.ts
  • src/main/ipc/pty-restore-record-seeding.test.ts
  • src/main/ipc/pty-runtime-hidden-at-spawn-mark.test.ts
  • src/main/ipc/pty/delivery/visibility-state.ts
  • src/main/ipc/pty/ipc/painted-cold-restore-ack.test.ts
  • src/main/ipc/pty/ipc/painted-cold-restore-ack.ts
  • src/main/ipc/pty/ipc/resize-visibility.ts
  • src/main/ipc/pty/ipc/spawn-begin.ts
  • src/main/ipc/pty/ipc/spawn-execute.ts
  • src/main/ipc/pty/ipc/spawn-run.ts
  • src/main/ipc/pty/ipc/spawn-types.ts
  • src/main/ipc/pty/ipc/spawn.ts
  • src/main/ipc/pty/pane/adopt-stable.ts
  • src/main/ipc/pty/pane/attach-only-view.test.ts
  • src/main/ipc/pty/pane/attach-only-view.ts
  • src/main/ipc/pty/pane/spawn-reservation.ts
  • src/main/ipc/pty/pane/stable-owner.ts
  • src/main/ipc/pty/pane/stable-pane-attach.ts
  • src/main/ipc/pty/pane/terminal-spawn-restore.test.ts
  • src/main/ipc/pty/pane/terminal-spawn-restore.ts
  • src/main/ipc/pty/runtime/spawn-commit-response.ts
  • src/main/ipc/pty/runtime/spawn-hidden-delivery.ts
  • src/main/persistence/terminal-topology/layout-command-persistence.ts
  • src/main/persistence/terminal-topology/terminal-layout-sleep-wake.test.ts
  • src/main/persistence/terminal-topology/terminal-pane-admission.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts
  • src/main/persistence/terminal-topology/topology-partition-write.ts
  • src/main/runtime/layout-command-pane-starts-layout-owner.test.ts
  • src/main/runtime/orca-runtime-test-fixtures.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-windowless-sleep-resume.spec.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/runtime-layout-apply.ts
  • src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts
  • src/main/runtime/session-lifecycle/projection/pane-sleeping-record.test.ts
  • src/main/runtime/session-lifecycle/projection/pane-sleeping-record.ts
  • src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts
  • src/main/runtime/session-lifecycle/projection/window-wake-sleep-record.test.ts
  • src/main/runtime/session-lifecycle/projection/window-wake-sleep-record.ts
  • src/main/runtime/terminal/launch/failed-start-pane.ts
  • src/main/runtime/terminal/recovery/layout-command-pane-starts.test.ts
  • src/main/runtime/terminal/recovery/layout-command-pane-starts.ts
  • src/main/runtime/terminal/recovery/restored-pane-start.test.ts
  • src/main/runtime/terminal/recovery/restored-pane-start.ts
  • src/preload/api/pty-api.ts
  • src/preload/api/pty-bridge-session-control.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-spawn-request.ts
  • src/renderer/src/components/terminal-pane/pty-connection-agent-session-resume.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-cold-restore-agent-resume.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-cold-restore-repaint.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-hibernation-wake.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-hidden-replay.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-hidden-sleeping-resume.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-input-and-repaint.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-layout-owner-wake.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-main-pane-restore-start.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-main-pane-start.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-pty-exit-teardown.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-reattach-binding.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-reattach-mode-reset.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-restart-replacement.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-sleeping-resume-banner.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-spawn-deferred-sleep.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-main-pane-start-fixtures.ts
  • src/renderer/src/components/terminal-pane/pty-connection/apply-reattach-payload.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-newer-daemon-hold.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-startup-snapshot.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/empty-reattach-retire-evidence.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/empty-reattach-retire-evidence.ts
  • src/renderer/src/components/terminal-pane/pty-connection/in-place-resume-hold-wiring.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/main-pane-start-request.ts
  • src/renderer/src/components/terminal-pane/pty-connection/main-pane-start-wait.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/main-pane-start-wait.ts
  • src/renderer/src/components/terminal-pane/pty-connection/main-starts-pane.ts
  • src/renderer/src/components/terminal-pane/pty-connection/painted-cold-restore-ack.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/painted-cold-restore-ack.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-payload-session.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler-park-reveal-verdict.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts
  • src/renderer/src/components/terminal-pane/pty-connection/run-deferred-connect.ts
  • src/renderer/src/components/terminal-pane/pty-connection/session-reconcile-dispose.ts
  • src/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.ts
  • src/renderer/src/components/terminal-pane/pty-connection/spawn-deferred-sleep.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-restore.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-restore.ts
  • src/renderer/src/lib/sleeping-agent-pane-ownership.ts
  • src/renderer/src/runtime/layout-apply-send.ts
  • src/renderer/src/runtime/layout-apply-test-transport.test-fixture.ts
  • src/renderer/src/runtime/sleeping-records-to-layout-owner.test.ts
  • src/renderer/src/store/terminals/terminal-sleep-layout-owner.test.ts
  • src/renderer/src/store/terminals/terminal-sleep-layout-owner.ts
  • src/shared/hibernation-done-record.ts
  • src/shared/painted-restore-ack.ts
  • src/shared/pane-attach-only-view.ts
  • src/shared/rpc-contract/workspace-layout-params.ts
  • src/shared/rpc-contract/workspace-layout-sleep-wake-params.ts
  • src/shared/sleeping-record-legacy-pane-key.test.ts
  • src/shared/sleeping-record-legacy-pane-key.ts
  • src/shared/workspace-layout/workspace-layout-command-types.ts
  • src/shared/workspace-layout/workspace-layout-commands.test.ts
  • src/shared/workspace-layout/workspace-layout-process-commands.ts
  • src/shared/workspace-layout/workspace-layout-resume-record.test.ts
  • tests/e2e/helpers/layout-owner-build.ts
  • tests/e2e/live-background-terminal-mount-authority.spec.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.

Comment on lines +159 to +164
// Switch point: the record a resume starts from (after any claim), marked live once it runs.
const paneKey = `${tab.parentTabId}:${tab.leafId}`
const resumedRecord =
ORCA_LAYOUT_OWNER_IS_MAIN && resumeStartup && 'resumeProviderSession' in resumeStartup
? this.getWorkspaceSessionForWorktree(worktreeId)?.sleepingAgentSessionsByPaneKey?.[paneKey]
: undefined

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

Mark the record the resume actually used, including a numbered (legacy) record.

resumedRecord reads only sleepingAgentSessionsByPaneKey[\${tab.parentTabId}:${tab.leafId}`]. resolvePaneOwnedResumeStartupfinds records throughfindPaneSleepingRecord, which also returns numbered records such as host-tab:2. For a pane that resumes from a numbered record, resumedRecordisundefined. markResumedRecordLive` therefore never runs for that pane.

Consequences under the switch:

  • The record keeps origin: 'worktree-sleep'. The pane still reads as asleep while its agent runs, which breaks the "a woken running pane reads live" contract.
  • isDeliberatelyParkedPane still returns true for this running pane. An automatic activation then treats the pane as parked.

Look up the record through the same helper. Then mark it under its own key (record.paneKey).

🐛 Proposed fix
-    const paneKey = `${tab.parentTabId}:${tab.leafId}`
-    const resumedRecord =
-      ORCA_LAYOUT_OWNER_IS_MAIN && resumeStartup && 'resumeProviderSession' in resumeStartup
-        ? this.getWorkspaceSessionForWorktree(worktreeId)?.sleepingAgentSessionsByPaneKey?.[paneKey]
-        : undefined
+    const resumedRecord =
+      ORCA_LAYOUT_OWNER_IS_MAIN && resumeStartup && 'resumeProviderSession' in resumeStartup
+        ? findPaneSleepingRecord(this.getWorkspaceSessionForWorktree(worktreeId), worktreeId, tab)
+            ?.record
+        : undefined
-        void markResumedRecordLive(
-          (edit) => this.commitWorkspaceSessionEdit(hostId, edit),
-          paneKey,
-          resumedRecord
-        )
+        void markResumedRecordLive(
+          (edit) => this.commitWorkspaceSessionEdit(hostId, edit),
+          resumedRecord.paneKey,
+          resumedRecord
+        )

The numbered aliases (aliases) of that conversation also keep their sleep origin. Decide whether they also need marking. Add a test for this case: the "pre-stable-id" test in layout-command-pane-starts-layout-owner.test.ts does not check the origin value after the start.

…c-restore-view-attach

Main's layout-command-commit.ts is the one commit module now: it gains C1c's run hooks (live facts, stop-before-write, noted effects), and topology-partition-write.ts is gone. The restored-pane starter keeps its started-terminal cache over main's StartedPty result, and materialize returns main's create result after marking a resumed record live.

Claude-Session: W5b
…r-fallback notice and a hidden pane's wait for its first view are helpers, and the answering-transport lookup moves to its one test caller

Claude-Session: W5b
…tore-view-attach

apply-mobile-session-tab-navigation.ts takes main's renamed selection-projection import; C1c's numbered-record lookup keeps replacing the stable-key read, so main's makePaneKey import is unused and dropped.

Claude-Session: W5b
…budget after the main merge

Claude-Session: W5b

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

Caution

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

⚠️ Outside diff range comments (1)

🟡 Minor · Consume equivalent legacy aliases in the wake claim… · window-wake-sleep-record.ts:46-63

src/main/runtime/session-lifecycle/projection/window-wake-sleep-record.ts:46-63
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Consume equivalent legacy aliases in the wake claim transaction.

When ORCA_LAYOUT_OWNER_IS_MAIN is enabled, a numbered legacy record reaches claimWindowWakeRecordForPane, which writes only record.paneKey. findLegacyNumericSleepingRecord leaves equivalent numeric aliases such as tab-1:3 persisted. A later pane can select that alias, and the alias exclusion in the shared-session guard allows the same provider session to resume again.

Pass the aliases into the claim and remove only aliases for the same provider session in the same commit. markResumedRecordLive is separate: it updates the stable pane key after materialization and cannot consume legacy numeric aliases.

Suggested fix
diff --git a/src/main/runtime/session-lifecycle/projection/window-wake-sleep-record.ts b/src/main/runtime/session-lifecycle/projection/window-wake-sleep-record.ts
@@
 export async function claimWindowWakeRecordForPane(
   commit: SessionEdit,
   windowOwnsWake: () => boolean,
-  record: SleepingAgentSessionRecord
+  record: SleepingAgentSessionRecord,
+  aliases: readonly string[] = []
 ): Promise<boolean> {
@@
       }
       owned = true
+      const records = { ...session.sleepingAgentSessionsByPaneKey }
+      for (const alias of aliases) {
+        const aliasRecord = records[alias]
+        if (
+          aliasRecord &&
+          aliasRecord.agent === record.agent &&
+          agentProviderSessionsEqual(record.agent, aliasRecord.providerSession, record.providerSession)
+        ) {
+          delete records[alias]
+        }
+      }
+      records[record.paneKey] = claimed
       return {
         ...session,
-        sleepingAgentSessionsByPaneKey: {
-          ...session.sleepingAgentSessionsByPaneKey,
-          [record.paneKey]: claimed
-        }
+        sleepingAgentSessionsByPaneKey: records
       }
     })
diff --git a/src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts b/src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts
@@
       () => !ORCA_LAYOUT_OWNER_IS_MAIN && Boolean(this.getAvailableAuthoritativeWindow()),
-      record
+      record,
+      aliases
     )

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3d25bf04-e92f-4d6e-81bc-97e6da1e3c9c
📥 Commits

Reviewing files that changed from the base of the PR and between 12f7f13 and 09d7f73.

📒 Files selected for processing: 2
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts
💤 Files with no reviewable changes: 1
  • src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit ed13ca1 into main Oct 22, 2026
60 checks passed
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