Repository navigation
Layout groundwork (switched off): main starts and restores every pane, and the window only attaches and paints the host's history - #31567
Conversation
…yout-owner build) A status-only frame changes one store entry and no pane tree, so the pane's view stays mounted.
…t is written (layout-owner build)
…start shows why (layout-owner build) Fixes owner-visible row 15: a failed agent or setup start no longer opens a plain shell.
…ontact (layout-owner build)
…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.
…d panes to their restore path
…; 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)
… failed, with why
…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
Claude-Session: W5b
…esume record for the live mark Claude-Session: W5b
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
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:
f620fc9f-8472-42ef-9986-aac21c72f2b6
📒 Files selected for processing: 110
src/main/ipc/pty-attach-view-joins-main-start.test.tssrc/main/ipc/pty-hidden-delivery-gate.tssrc/main/ipc/pty-painted-cold-restore-ack-layout-owner.test.tssrc/main/ipc/pty-restore-record-seeding.test.tssrc/main/ipc/pty-runtime-hidden-at-spawn-mark.test.tssrc/main/ipc/pty/delivery/visibility-state.tssrc/main/ipc/pty/ipc/painted-cold-restore-ack.test.tssrc/main/ipc/pty/ipc/painted-cold-restore-ack.tssrc/main/ipc/pty/ipc/resize-visibility.tssrc/main/ipc/pty/ipc/spawn-begin.tssrc/main/ipc/pty/ipc/spawn-execute.tssrc/main/ipc/pty/ipc/spawn-run.tssrc/main/ipc/pty/ipc/spawn-types.tssrc/main/ipc/pty/ipc/spawn.tssrc/main/ipc/pty/pane/adopt-stable.tssrc/main/ipc/pty/pane/attach-only-view.test.tssrc/main/ipc/pty/pane/attach-only-view.tssrc/main/ipc/pty/pane/spawn-reservation.tssrc/main/ipc/pty/pane/stable-owner.tssrc/main/ipc/pty/pane/stable-pane-attach.tssrc/main/ipc/pty/pane/terminal-spawn-restore.test.tssrc/main/ipc/pty/pane/terminal-spawn-restore.tssrc/main/ipc/pty/runtime/spawn-commit-response.tssrc/main/ipc/pty/runtime/spawn-hidden-delivery.tssrc/main/persistence/terminal-topology/layout-command-persistence.tssrc/main/persistence/terminal-topology/terminal-layout-sleep-wake.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission.tssrc/main/persistence/terminal-topology/terminal-topology-commit.tssrc/main/persistence/terminal-topology/topology-partition-write.tssrc/main/runtime/layout-command-pane-starts-layout-owner.test.tssrc/main/runtime/orca-runtime-test-fixtures.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-windowless-sleep-resume.spec.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/runtime-layout-apply.tssrc/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.tssrc/main/runtime/session-lifecycle/projection/pane-sleeping-record.test.tssrc/main/runtime/session-lifecycle/projection/pane-sleeping-record.tssrc/main/runtime/session-lifecycle/projection/restored-pane-materialize.tssrc/main/runtime/session-lifecycle/projection/window-wake-sleep-record.test.tssrc/main/runtime/session-lifecycle/projection/window-wake-sleep-record.tssrc/main/runtime/terminal/launch/failed-start-pane.tssrc/main/runtime/terminal/recovery/layout-command-pane-starts.test.tssrc/main/runtime/terminal/recovery/layout-command-pane-starts.tssrc/main/runtime/terminal/recovery/restored-pane-start.test.tssrc/main/runtime/terminal/recovery/restored-pane-start.tssrc/preload/api/pty-api.tssrc/preload/api/pty-bridge-session-control.tssrc/renderer/src/components/terminal-pane/ipc-pty-spawn-request.tssrc/renderer/src/components/terminal-pane/pty-connection-agent-session-resume.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-agent-resume.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-repaint.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-hibernation-wake.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-hidden-replay.test.tssrc/renderer/src/components/terminal-pane/pty-connection-hidden-sleeping-resume.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-input-and-repaint.test.tssrc/renderer/src/components/terminal-pane/pty-connection-layout-owner-wake.test.tssrc/renderer/src/components/terminal-pane/pty-connection-main-pane-restore-start.test.tssrc/renderer/src/components/terminal-pane/pty-connection-main-pane-start.test.tssrc/renderer/src/components/terminal-pane/pty-connection-pty-exit-teardown.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-reattach-binding.test.tssrc/renderer/src/components/terminal-pane/pty-connection-reattach-mode-reset.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-restart-replacement.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-sleeping-resume-banner.spec.tssrc/renderer/src/components/terminal-pane/pty-connection-spawn-deferred-sleep.test.tssrc/renderer/src/components/terminal-pane/pty-connection-test-main-pane-start-fixtures.tssrc/renderer/src/components/terminal-pane/pty-connection/apply-reattach-payload.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-newer-daemon-hold.test.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-startup-snapshot.test.tssrc/renderer/src/components/terminal-pane/pty-connection/empty-reattach-retire-evidence.test.tssrc/renderer/src/components/terminal-pane/pty-connection/empty-reattach-retire-evidence.tssrc/renderer/src/components/terminal-pane/pty-connection/in-place-resume-hold-wiring.test.tssrc/renderer/src/components/terminal-pane/pty-connection/main-pane-start-request.tssrc/renderer/src/components/terminal-pane/pty-connection/main-pane-start-wait.test.tssrc/renderer/src/components/terminal-pane/pty-connection/main-pane-start-wait.tssrc/renderer/src/components/terminal-pane/pty-connection/main-starts-pane.tssrc/renderer/src/components/terminal-pane/pty-connection/painted-cold-restore-ack.test.tssrc/renderer/src/components/terminal-pane/pty-connection/painted-cold-restore-ack.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.test.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-session.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler-park-reveal-verdict.test.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.tssrc/renderer/src/components/terminal-pane/pty-connection/run-deferred-connect.tssrc/renderer/src/components/terminal-pane/pty-connection/session-reconcile-dispose.tssrc/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.tssrc/renderer/src/components/terminal-pane/pty-connection/spawn-deferred-sleep.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/terminal-pane-layout-restore.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-layout-restore.tssrc/renderer/src/lib/sleeping-agent-pane-ownership.tssrc/renderer/src/runtime/layout-apply-send.tssrc/renderer/src/runtime/layout-apply-test-transport.test-fixture.tssrc/renderer/src/runtime/sleeping-records-to-layout-owner.test.tssrc/renderer/src/store/terminals/terminal-sleep-layout-owner.test.tssrc/renderer/src/store/terminals/terminal-sleep-layout-owner.tssrc/shared/hibernation-done-record.tssrc/shared/painted-restore-ack.tssrc/shared/pane-attach-only-view.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/rpc-contract/workspace-layout-sleep-wake-params.tssrc/shared/sleeping-record-legacy-pane-key.test.tssrc/shared/sleeping-record-legacy-pane-key.tssrc/shared/workspace-layout/workspace-layout-command-types.tssrc/shared/workspace-layout/workspace-layout-commands.test.tssrc/shared/workspace-layout/workspace-layout-process-commands.tssrc/shared/workspace-layout/workspace-layout-resume-record.test.tstests/e2e/helpers/layout-owner-build.tstests/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.
| // 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 |
There was a problem hiding this comment.
🎯 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. isDeliberatelyParkedPanestill 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
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 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 winConsume equivalent legacy aliases in the wake claim transaction.
When
ORCA_LAYOUT_OWNER_IS_MAINis enabled, a numbered legacy record reachesclaimWindowWakeRecordForPane, which writes onlyrecord.paneKey.findLegacyNumericSleepingRecordleaves equivalent numeric aliases such astab-1:3persisted. 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.
markResumedRecordLiveis 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
📒 Files selected for processing: 2
src/main/runtime/orca-runtime.tssrc/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.
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:pane_already_boundand keeps the pane.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-gatepasses. It runs every static-analysis step of the PR workflow pluspnpm tc.terminal_not_started;terminal-pane,runtime,storeandlib, mainipc,runtime,persistenceandterminal-topology, plussharedandpreload. 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-racepasses 8 of 8 alone at head. One switch-on test was converted: it expected a resumed pane's record to stay a sleep.build:electron-vite:parallel --mode e2eplusbuild: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.Clean run at 43cbe4f against 0abe700: the first run started at load 16.6; the rest ran at 22-27.
Where the 1-pane time goes, from one traced sample on each side (ms after the view):
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:
commandDelivery, which never reaches the terminal service.ORCA_WORKSPACE_ID(L265; see Notes).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
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.
commitLayoutCommandmoved files and gained optionalstopBeforeWrite/onEffectshooks. Every switch-off caller passes none.attachOnlyViewis always undefined. The new attaching-view count is never written.{id}.startPanemember. Older peers never send it, and a switch-off host does not servelayout.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:
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.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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)