Repository navigation
Main starts each restored terminal pane once, at its last size, and names sleeping and held panes (layout-owner build only) - #31171
Conversation
…efuses a taken one
… starts them, window or none (dark; twin e)
… starts them, window or none (dark; twin e)
…nt fails to start; no window takes over (dark)
…ne; a terminal close stands after a failed write (dark)
…te; switch off still refuses
…abs start once; a tab's last pane keeps its card (dark)
…l; main starts it whatever failed
…so a closed tab stays closed (dark)
…ives (both builds)
…ts binding generation (dark, layout-owner build only)
…taches or the terminal service is replaced (dark, layout-owner build only) Headless servers had no retry: a terminal the startup pass declined stayed tabless until the next restart. The pass now also runs when a client authenticates and after the local terminal provider is installed or replaced, one pass at a time. A terminal whose pane record fails to save after main bound it is no longer reported as left without a pane.
…rk, layout-owner build only) A new main-only setPaneGrid command records the grid a pane's terminal was last sized to, on its leaf. It is saved as the layout's optional lastGridsByLeafId, which older builds drop on read, so a downgrade loses only the hint. It moves with its pane.
…d starts the pane at it (dark, layout-owner build only) Each accepted resize, from a window or a client, is written once per burst as the pane's last grid. A pane main holds starts at that grid, after a size the caller measured and before its group's size, then 120x40.
… reads a shared import (dark)
…rid change publishes nothing (dark, layout-owner build only) The desktop and serve quit and orcad's shutdown write any grid still inside its one-second burst before the final store flush; a quit with none waiting adds no await. A grid is main's own record: it is not in a published pane, so a resize burst sends no layout frame, and its write patches only the pane's tab.
…what a status on a bound pane means (dark, layout-owner build only)
…ts old terminal (dark)
…pace's terminal (dark, layout-owner build only) The window's restore rule, now in main for every host: a pane whose stored terminal id was minted for another workspace is unbound, so it starts fresh, and that terminal, if live, is placed in its own workspace. The id check moves to shared, which the window now imports.
… may still run the pane shows it held, not failed (dark, layout-owner build only)
…estore starter returns the terminal it started (layout-owner build) An SSH terminal id names its connection, not a workspace, so the rule that drops another workspace's terminal no longer releases it or starts the pane fresh. The starter now resolves to the id its start registered instead of re-reading the stored layout, whose bind write can still be in flight, and a tab saved with no layout counts as one held pane.
…ayout switch on An exited pane closes through the legacy retirement unless the keep rule holds; the default tab's title and color still reach the window and the phone's live tabs.
…s live terminals, so activation opens no extra shell beside one (layout-owner build) A window activating a workspace before main's placement pass had read the host census found no tab and asked main for the first one; main admitted it into the still-empty workspace, then the pass added the live terminal's own tab beside it. An initial create now waits out a pass in flight.
…s live terminal, and a first view of a pane main dropped is refused (layout-owner build)
… with its declared type
…and keeps the runtime file under the line limit
…vouched -1 Main's taken and closed-id guard now runs where every pane write goes, so a runtime create replayed after its tab closed is refused before it spawns. An exit code nothing vouches for keeps the pane, as the window does; a kept pane sends the phone no retirement. Converts the switch-on tests that asserted the deleted window hand-off and title bridge.
… pass running when it arrives, and the switch-off build applies commands as before
… checks on client commands A paired host starts each pane of a client's tab as a create under the tab's id, so a held tab id is refused only for a client's own layout command.
…econd, and orcad awaits nothing for them when none wait The grid flush before the final save (desktop and serve quit, orcad stop) is now raced against a 1 s budget; a grid it misses only means that pane restarts at the default size. With the switch off no grid is ever recorded, so the flush is null and orcad no longer awaits even that.
Only a requested stop or a host-confirmed death closes a pane on a negative exit code. Pins that the closed-tab guard never fires in the shipped build.
… budget timer live, and the quit's no-await note names it
…, and a workspace's first tab waits at most 0.5 s for main's placement pass The quit's grid flush (still capped at 1 s) now runs before beginSshShutdown, so nothing is awaited between it and the final save; with no grid waiting, both start synchronously as before. A first tab waits for the running placement pass at most 500 ms, then is admitted. The quit test's SSH mock now names the module the quit imports.
…turn as the SSH shutdown, in order after the PTY kill
# Conflicts: # src/renderer/src/runtime/workspace-layout-frame-binding.test.ts # src/renderer/src/runtime/workspace-layout-frame-changes.ts
…ative-chat formatting is #31184's)
…fd/c1b-main-starts-panes
# Conflicts: # src/main/persistence/terminal-topology/layout-command-persistence.ts # src/main/runtime/orca-runtime-failed-start-pane-layout-owner.test.ts # src/main/runtime/pane-start-statuses.ts # src/main/runtime/runtime-pane-admission.ts # src/main/runtime/terminal/launch/failed-start-pane.ts # src/shared/workspace-layout/workspace-layout-published.ts
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
40b45e74-2495-4119-af64-afa3271aa0f6
📒 Files selected for processing: 121
config/scripts/check-id-only-store-write-ratchet.mjsconfig/scripts/check-id-only-store-write-ratchet.test.mjssrc/main/daemon/daemon-pty-adapter-cold-restore-reanchor.test.tssrc/main/ipc/pty-launch-race-parity.test.tssrc/main/ipc/pty/provider/bind-listeners.tssrc/main/ipc/pty/provider/listener-lifecycle.tssrc/main/ipc/pty/provider/local-configure.tssrc/main/ipc/pty/provider/local-provider-rebound.test.tssrc/main/ipc/pty/provider/local-provider-rebound.tssrc/main/ipc/pty/pty-first-size.tssrc/main/orcad/orcad-duplicate-pty-repair-startup.test.tssrc/main/orcad/orcad-entry.tssrc/main/orcad/orcad-push-startup.test.tssrc/main/persistence/loading-store/pty-binding-generations.tssrc/main/persistence/loading-store/store-domain-composition.tssrc/main/persistence/loading-store/terminal-close-async-durability.test.tssrc/main/persistence/terminal-topology/layout-command-binding-generations.tssrc/main/persistence/terminal-topology/layout-command-persistence.tssrc/main/persistence/terminal-topology/pane-last-grid.test.tssrc/main/persistence/terminal-topology/terminal-close-write-failure-store.test.tssrc/main/persistence/terminal-topology/terminal-close-write-failure-switch-off.test.tssrc/main/persistence/terminal-topology/terminal-close-write-failure.test.tssrc/main/persistence/terminal-topology/terminal-close-write-failure.tssrc/main/persistence/terminal-topology/terminal-layout-create-resend.test.tssrc/main/persistence/terminal-topology/terminal-layout-create.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission-taken-ids-switch-off.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission-taken-ids.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission.tssrc/main/persistence/terminal-topology/unshown-live-terminal-placement-restart.test.tssrc/main/runtime/exited-split-pane-layout-close.test.tssrc/main/runtime/exited-split-pane-layout-close.tssrc/main/runtime/orca-runtime-create-terminal-dependencies.tssrc/main/runtime/orca-runtime-default-tab-agent-status.test.tssrc/main/runtime/orca-runtime-default-tabs-layout-owner.test.tssrc/main/runtime/orca-runtime-exited-split-pane-close.test.tssrc/main/runtime/orca-runtime-failed-start-pane-layout-owner.test.tssrc/main/runtime/orca-runtime-layout-owner-start-fixture.tssrc/main/runtime/orca-runtime-terminal-create-replay-after-close.test.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-single-creator.spec.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/pane-start-statuses.test.tssrc/main/runtime/pane-start-statuses.tssrc/main/runtime/restored-pane-start-layout-owner.test.tssrc/main/runtime/runtime-folder-worktree-create-layout-owner.test.tssrc/main/runtime/runtime-folder-worktree-create.tssrc/main/runtime/runtime-layout-apply.test.tssrc/main/runtime/runtime-layout-apply.tssrc/main/runtime/runtime-local-worktree-terminal-startup-layout-owner.test.tssrc/main/runtime/runtime-local-worktree-terminal-startup.test.tssrc/main/runtime/runtime-local-worktree-terminal-startup.tssrc/main/runtime/runtime-pane-admission.tssrc/main/runtime/runtime-rpc-client-attach-placement.test.tssrc/main/runtime/runtime-rpc/runtime-rpc-lifecycle.tssrc/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/runtime-worktree-default-tabs-layout-owner.test.tssrc/main/runtime/runtime-worktree-terminal-provisioning.tssrc/main/runtime/session-lifecycle/projection/perform-mobile-session-pty-records-refresh.tssrc/main/runtime/session-lifecycle/projection/restored-pane-materialize.tssrc/main/runtime/session-tabs/terminal-surface-retirements.tssrc/main/runtime/terminal-intentional-stop-exit.test.tssrc/main/runtime/terminal/adoption/unshown-live-terminal-placement.tssrc/main/runtime/terminal/launch/failed-start-pane.tssrc/main/runtime/terminal/launch/mobile-terminal-create.tssrc/main/runtime/terminal/launch/terminal-create-pane-last-grid.test.tssrc/main/runtime/terminal/launch/terminal-create.tssrc/main/runtime/terminal/layout/pane-grid-recording.test.tssrc/main/runtime/terminal/layout/pane-grid-recording.tssrc/main/runtime/terminal/layout/terminal-display-mode.tssrc/main/runtime/terminal/layout/terminal-layout-application.tssrc/main/runtime/terminal/lifecycle/exited-split-pane-rule.test.tssrc/main/runtime/terminal/lifecycle/exited-split-pane-rule.tssrc/main/runtime/terminal/lifecycle/pty-exit-lifecycle.tssrc/main/runtime/terminal/recovery/foreign-pane-bindings.tssrc/main/runtime/terminal/recovery/restored-pane-start.test.tssrc/main/runtime/terminal/recovery/restored-pane-start.tssrc/main/runtime/workspace-layout-stream.test.tssrc/main/runtime/workspace-layout-stream.tssrc/main/runtime/workspaces/persisted-surfaces/live-terminal-placement-before-initial-tab.test.tssrc/main/runtime/workspaces/persisted-surfaces/restored-terminal-placement.test.tssrc/main/runtime/workspaces/persisted-surfaces/restored-terminal-placement.tssrc/main/runtime/workspaces/startup/workspace-terminal-provisioning.tssrc/main/startup/main-process-ipc-bootstrap.tssrc/main/startup/main-process-quit-pending-writer.test.tssrc/main/startup/main-process-quit.tssrc/main/startup/main-process-runtime-launch.tssrc/renderer/src/components/terminal-pane/layout-owner-pane-close-command.tssrc/renderer/src/components/terminal-pane/pending-pane-close-confirmation.test.tssrc/renderer/src/components/terminal-pane/pending-split-close-test-fixture.tssrc/renderer/src/components/terminal-pane/pending-split-close.test.tssrc/renderer/src/components/terminal-pane/pty-connection/exited-split-pane-close.test.tssrc/renderer/src/components/terminal-pane/pty-connection/exited-split-pane-close.tssrc/renderer/src/components/terminal-pane/pty-connection/paired-parked-terminal-restore.tssrc/renderer/src/components/terminal-pane/pty-connection/pty-exit-hibernate.tssrc/renderer/src/lib/worktree-agent-activation-gate-layout-owner.test.tssrc/renderer/src/lib/worktree-agent-activation-gate.test-fixture.tssrc/renderer/src/lib/worktree-agent-activation-gate.test.tssrc/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.tssrc/renderer/src/runtime/layout-apply-send.tssrc/renderer/src/runtime/workspace-layout-frame-binding.test.tssrc/renderer/src/store/terminals/terminal-tab-close-intent.test.tssrc/shared/pty-session-id-format.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/rpc-contract/workspace-layout-terminal-tab-params.tssrc/shared/terminal-layout-snapshot-schema.tssrc/shared/terminal-tab-types.tssrc/shared/workspace-layout/workspace-layout-command-types.tssrc/shared/workspace-layout/workspace-layout-commands.tssrc/shared/workspace-layout/workspace-layout-default-tabs.test.tssrc/shared/workspace-layout/workspace-layout-default-tabs.tssrc/shared/workspace-layout/workspace-layout-disk-fields.tssrc/shared/workspace-layout/workspace-layout-fact-locations.test.tssrc/shared/workspace-layout/workspace-layout-load-bindings.tssrc/shared/workspace-layout/workspace-layout-model.tssrc/shared/workspace-layout/workspace-layout-pane-commands.tssrc/shared/workspace-layout/workspace-layout-published.tssrc/shared/workspace-layout/workspace-layout-records.tssrc/shared/workspace-layout/workspace-layout-round-trip-check.tssrc/shared/workspace-layout/workspace-layout-save-tabs.tssrc/shared/workspace-session-schema.ts
💤 Files with no reviewable changes: 1
- src/main/runtime/runtime-layout-apply.test.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.
| const layout = session?.terminalLayoutsByTabId?.[tabId] | ||
| // Why: a tab saved with no layout is one pane, the one the projection lists for it. | ||
| return layout ? layout.ptyIdsByLeafId?.[leafId] : (row.ptyId ?? undefined) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Return null when the layout no longer contains the leaf.
The doc comment says storedPaneBinding returns null "once main no longer holds it". The code only checks the tab row. If the tab row and layout still exist but the user closed this split leaf, layout.ptyIdsByLeafId?.[leafId] is undefined. RestoredPaneStarter then treats the pane as unbound and calls start. Whether that start succeeds depends on mobileSessionTabsByWorktree still listing the leaf. A non-forced hydrate can leave a stale snapshot. The result can be a PTY started for a pane that is no longer in the layout, or a misleading error instead of tab_not_found.
Check the layout tree itself. Do not rely on ptyIdsByLeafId, because a live but unbound leaf has no entry there.
Proposed fix
--- "a/src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts"
+++ "b/src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts"
@@ -80,9 +80,12 @@
if (!row) {
return null
}
const layout = session?.terminalLayoutsByTabId?.[tabId]
+ if (layout && !collectLeafIds(layout.root).includes(leafId)) {
+ return null
+ }
// Why: a tab saved with no layout is one pane, the one the projection lists for it.
return layout ? layout.ptyIdsByLeafId?.[leafId] : (row.ptyId ?? undefined)
}
/** Starts a pending terminal row in its own pane, resuming the agent the host recorded there. */import { collectLeafIds } from '../../../../shared/terminal-pane-layout-tree'| export function paneShowingTerminal( | ||
| session: WorkspaceSessionState, | ||
| ptyId: string | ||
| ): ShownPane | null { | ||
| for (const [workspace, rows] of Object.entries(session.tabsByWorktree ?? {})) { | ||
| for (const row of rows) { | ||
| const bindings = session.terminalLayoutsByTabId?.[row.id]?.ptyIdsByLeafId ?? {} | ||
| const leafId = Object.keys(bindings).find((leaf) => bindings[leaf] === ptyId) | ||
| if (leafId) { | ||
| return { workspace, tabId: row.id, leafId } | ||
| } | ||
| } | ||
| } | ||
| return null | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C6 'export function findTerminal\s*\(' --type=ts
rg -nP -C3 'getWorkspaceSessionHostIdsForTab\s*\(' --type=ts -g '!**/*.test.ts' | head -60
rg -nP -C3 'entityId:\s' src/shared/workspace-layout --type=ts | head -80Repository: stablyai/orca
Length of output: 14189
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- pane-grid-recording.ts ---'
nl -ba src/main/runtime/terminal/layout/pane-grid-recording.ts | sed -n '1,150p'
printf '%s\n' '--- setPaneGrid and paneTab bindings ---'
rg -n -C5 -F -e 'setPaneGrid' -e 'paneTab' src/shared/workspace-layout src/main/runtime || test "$?" -eq 1
printf '%s\n' '--- layout loading and terminal tab construction ---'
nl -ba src/shared/workspace-layout/workspace-layout-load-tabs.ts | sed -n '1,100p'
rg -n -C4 -F -e 'tabsByWorktree' -e 'type WorkspaceSessionState' -e 'interface WorkspaceSessionState' src/shared src/main/runtime | head -240
printf '%s\n' '--- terminal row type and row-to-layout projection ---'
rg -n -C5 -F -e 'interface TerminalRow' -e 'type TerminalRow' -e 'tabsByWorktree:' src || test "$?" -eq 1
rg -n -C5 -F -e 'terminalIdOf' src/main/runtime/terminal src/main/runtime || test "$?" -eq 1Repository: stablyai/orca
Length of output: 45668
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- terminalIdOf ---'
nl -ba src/main/runtime/runtime-layout-apply.ts | sed -n '205,250p'
printf '%s\n' '--- layout tab and terminal row declarations ---'
rg -n -C5 -F -e 'export type LayoutTerminalTab' -e 'export interface LayoutTerminalTab' -e 'export type TerminalTab' -e 'export interface TerminalTab' src/shared/workspace-layout src/shared/terminal-tab-types.ts src/shared/tab-types.ts
rg -n -C3 -F -e 'export type WorkspaceSessionState' -e 'export interface WorkspaceSessionState' src/shared/workspace-session-state-types.ts
printf '%s\n' '--- loadTerminalTab callers and identity mapping ---'
rg -n -C6 -F -e 'loadTerminalTab(' src/shared/workspace-layout
rg -n -C4 -F -e 'terminalIdOf(' src/main/runtime/runtime-layout-apply.tsRepository: stablyai/orca
Length of output: 8790
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- workspace layout row-to-entry join ---'
nl -ba src/shared/workspace-layout/workspace-layout-load-workspace.ts | sed -n '65,135p'
printf '%s\n' '--- session unifiedTabs declaration ---'
nl -ba src/shared/workspace-session-state-types.ts | sed -n '35,125p'
printf '%s\n' '--- unified Tab declaration ---'
nl -ba src/shared/tab-types.ts | sed -n '1,95p'
printf '%s\n' '--- setPaneGrid lookup and refusal ---'
nl -ba src/shared/workspace-layout/workspace-layout-pane-commands.ts | sed -n '30,38p;155,180p'
nl -ba src/shared/workspace-layout/workspace-layout-command-steps.ts | sed -n '45,60p'Repository: stablyai/orca
Length of output: 15665
Use the unified tab ID for setPaneGrid.
loadTabs joins a terminal row by entry.entityId, then builds the layout tab with entry.id. When those IDs differ, paneShowingTerminal passes the row ID to setPaneGrid. findTerminal looks up only LayoutTab.id, so the command returns tab_not_found. PaneGridRecorder.write ignores the result, and the grid is not saved. Resolve the matching terminal entry's ID before returning the pane.
🐛 Suggested fix
const bindings = session.terminalLayoutsByTabId?.[row.id]?.ptyIdsByLeafId ?? {}
const leafId = Object.keys(bindings).find((leaf) => bindings[leaf] === ptyId)
if (leafId) {
- return { workspace, tabId: row.id, leafId }
+ const tabId =
+ session.unifiedTabs?.[workspace]?.find(
+ (entry) => entry.contentType === 'terminal' && entry.entityId === row.id
+ )?.id ?? row.id
+ return { workspace, tabId, leafId }
}📝 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.
| export function paneShowingTerminal( | |
| session: WorkspaceSessionState, | |
| ptyId: string | |
| ): ShownPane | null { | |
| for (const [workspace, rows] of Object.entries(session.tabsByWorktree ?? {})) { | |
| for (const row of rows) { | |
| const bindings = session.terminalLayoutsByTabId?.[row.id]?.ptyIdsByLeafId ?? {} | |
| const leafId = Object.keys(bindings).find((leaf) => bindings[leaf] === ptyId) | |
| if (leafId) { | |
| return { workspace, tabId: row.id, leafId } | |
| } | |
| } | |
| } | |
| return null | |
| } | |
| export function paneShowingTerminal( | |
| session: WorkspaceSessionState, | |
| ptyId: string | |
| ): ShownPane | null { | |
| for (const [workspace, rows] of Object.entries(session.tabsByWorktree ?? {})) { | |
| for (const row of rows) { | |
| const bindings = session.terminalLayoutsByTabId?.[row.id]?.ptyIdsByLeafId ?? {} | |
| const leafId = Object.keys(bindings).find((leaf) => bindings[leaf] === ptyId) | |
| if (leafId) { | |
| const tabId = | |
| session.unifiedTabs?.[workspace]?.find( | |
| (entry) => entry.contentType === 'terminal' && entry.entityId === row.id | |
| )?.id ?? row.id | |
| return { workspace, tabId, leafId } | |
| } | |
| } | |
| } | |
| return null | |
| } |
| export function isPtyIdMintedForAnotherWorkspace(ptyId: string, worktreeId: string): boolean { | ||
| return ( | ||
| !isRemoteRuntimePtyId(ptyId) && | ||
| !parseAppSshPtyId(ptyId) && | ||
| !isPtySessionIdOwnedByWorktree(ptyId, worktreeId) | ||
| ) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
fd -i 'deferred-session-reattach-choice' --exec sed -n '1,120p' {}
rg -nP -C3 '\bisPtySessionIdOwnedByWorktree\s*\(' --type=ts
rg -nP -C2 'legacy raw worktree|canonical WorkspaceKey|worktreeIdentityKey\s*\(' --type=ts -g '!**/*.test.ts' | head -60Repository: stablyai/orca
Length of output: 12874
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\\n' '--- foreign-pane-bindings.ts ---'
nl -ba src/main/runtime/terminal/recovery/foreign-pane-bindings.ts | sed -n '1,180p'
printf '%s\\n' '--- WorkspaceSessionState declarations and contract ---'
rg -n -F -- 'WorkspaceSessionState' src
rg -n -F -- 'legacy raw worktree' src
rg -n -F -- 'canonical WorkspaceKey' src
printf '%s\\n' '--- workspace identity helper ---'
rg -n -F -- 'function worktreeIdentityKey' src
rg -n -F -- 'const worktreeIdentityKey' src
rg -n -F -- 'export function worktreeIdentityKey' src
printf '%s\\n' '--- PTY session ID minting and ownership declarations ---'
nl -ba src/shared/pty-session-id-format.ts | sed -n '1,100p'
rg -n -F -- 'mintPtySessionId' src
rg -n -F -- 'createPtySessionId' src
printf '%s\\n' '--- placement and release flow ---'
nl -ba src/main/runtime/workspaces/persisted-surfaces/restored-terminal-placement.ts | sed -n '145,195p'
rg -n -F -- 'panesBoundToAnotherWorkspace' src/main
rg -n -F -- 'releasePaneTerminal' src/mainRepository: stablyai/orca
Length of output: 42206
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\\n' '--- session key type ---'
nl -ba src/shared/workspace-session-state-types.ts | sed -n '34,58p'
printf '%s\\n' '--- workspace identity helper ---'
nl -ba src/shared/worktree/id.ts | sed -n '1,100p'
printf '%s\\n' '--- workspace key parser ---'
rg -n -F -- 'export function parseWorkspaceKey' src/shared
rg -n -F -- 'export function' src/shared/workspace-scope.ts
nl -ba src/shared/workspace-scope.ts | sed -n '1,140p'
printf '%s\\n' '--- PTY ID minting ---'
nl -ba src/main/daemon/pty-session-id.ts | sed -n '1,70p'
nl -ba src/main/daemon/daemon-pty-session-spawn.ts | sed -n '25,48p'
nl -ba src/main/ipc/pty/ipc/spawn-preflight.ts | sed -n '1,90p'
printf '%s\\n' '--- window-side ownership helper ---'
rg -n -F -- 'function isSessionOwnedByWorktree' src/main/runtime/terminal
rg -n -F -- 'isSessionOwnedByWorktree' src/main/runtime/terminal
nl -ba src/main/runtime/terminal/recovery/paired-parked-terminal-restore.ts | sed -n '1,130p'
printf '%s\\n' '--- canonical-row hydration and worktree key handling ---'
nl -ba src/renderer/src/store/slices/terminals-hydration-canonical-rows.test.ts | sed -n '1,220p'
rg -n -F -- 'worktreeIdentityKey(' src/shared src/main src/renderer/src/store/slices | head -80Repository: stablyai/orca
Length of output: 32209
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\\n' '--- foreign ownership predicate consumers ---'
rg -n -F -- 'isPtyIdMintedForAnotherWorkspace' src
rg -n -F -- 'restoredPaneStartPlan' src/main
rg -n -F -- 'isOwnLive' src/main/runtime/workspaces src/main/runtime/terminal
printf '%s\\n' '--- release command declarations and consumers ---'
rg -n -F -- 'releasePaneTerminal' src/main src/shared src/renderer/src
rg -n -F -- 'releasePaneTerminal' src/main/runtime/workspaces/persisted-surfaces/restored-terminal-placement.test.ts
printf '%s\\n' '--- deferred window ownership check ---'
rg -n -F -- 'function isSessionOwnedByWorktree' src/main/runtime
rg -n -F -- 'isSessionOwnedByWorktree' src/main/runtime/terminalRepository: stablyai/orca
Length of output: 3464
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\\n' '--- restored pane startup decision ---'
nl -ba src/main/runtime/terminal/recovery/restored-pane-start.ts | sed -n '1,115p'
printf '%s\\n' '--- releasePaneTerminal behavior ---'
nl -ba src/shared/workspace-layout/workspace-layout-pane-commands.ts | sed -n '165,225p'
nl -ba src/shared/workspace-layout/workspace-layout-command-types.ts | sed -n '98,118p'
printf '%s\\n' '--- exact binding predicate and imports ---'
nl -ba src/main/runtime/terminal/recovery/foreign-pane-bindings.ts | sed -n '1,34p'Repository: stablyai/orca
Length of output: 9929
Compare normalized workspace identities before releasing a pane’s PTY.
tabsByWorktree may use a canonical worktree: key, while mintPtySessionId preserves the raw worktree ID. The exact-string comparison can therefore classify a pane’s own PTY as foreign. Placement can then unbind the PTY, and the restored-pane start plan omits its sessionId, preventing reattachment through that path. releasePaneTerminal does not stop the PTY.
🐛 Suggested fix
--- "a/src/main/runtime/terminal/recovery/foreign-pane-bindings.ts"
+++ "b/src/main/runtime/terminal/recovery/foreign-pane-bindings.ts"
@@ -2,19 +2,28 @@
// reattaches to a terminal another workspace owns (the window's rule,
// deferred-session-reattach-choice.ts), and one whose local terminal is gone shows as sleeping.
-import { isPtySessionIdOwnedByWorktree } from '../../../../shared/pty-session-id-format'
+import { PTY_SESSION_ID_SEPARATOR } from '../../../../shared/pty-session-id-format'
import { isRemoteRuntimePtyId } from '../../../../shared/remote-runtime-pty-id'
import { parseAppSshPtyId } from '../../../../shared/ssh-pty-id'
+import { normalizeWorkspaceSessionKeyToWorkspaceId } from '../../../../shared/workspace-scope'
+import { worktreeIdsEqual } from '../../../../shared/worktree/id'
import type { WorkspaceSessionState } from '../../../../shared/workspace-session-state-types'
/** An SSH id names its connection, never a workspace, so only a local minted id can be foreign. */
export function isPtyIdMintedForAnotherWorkspace(ptyId: string, worktreeId: string): boolean {
+ const separatorIdx = ptyId.lastIndexOf(PTY_SESSION_ID_SEPARATOR)
+ const sessionWorktreeId =
+ separatorIdx === -1 ? null : ptyId.slice(0, separatorIdx)
return (
!isRemoteRuntimePtyId(ptyId) &&
!parseAppSshPtyId(ptyId) &&
- !isPtySessionIdOwnedByWorktree(ptyId, worktreeId)
+ sessionWorktreeId !== null &&
+ !worktreeIdsEqual(
+ normalizeWorkspaceSessionKeyToWorkspaceId(sessionWorktreeId),
+ normalizeWorkspaceSessionKeyToWorkspaceId(worktreeId)
+ )
)
}
export type PaneBinding = { worktreeId: string; tabId: string; leafId: string; ptyId: string }
| * terminal, so every caller ends bound to the same one. | ||
| */ | ||
| ensureStarted(pane: RestoredPane, trigger: RestoredPaneTrigger = {}): Promise<string | null> { | ||
| const key = makePaneKey(pane.tabId, pane.leafId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Is a non-UUID leaf ID still accepted or migrated anywhere in session loading or mobile tabs?
rg -nP -C3 '\bisTerminalLeafId\s*\(' --type=ts -g '!**/*.test.ts'
rg -nP -C3 'legacy.*leaf(Id)?|leafId.*legacy' --type=ts -g '!**/*.test.ts' | head -60Repository: stablyai/orca
Length of output: 42318
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- changed file diff against supplied merge base ---'
git diff --no-ext-diff --unified=30 38034167e7aa0c2d5159d23e8d7cb4d765dcc6df b938d1db325db744ee13fc78ede1f27d7eb7409d -- src/main/runtime/terminal/recovery/restored-pane-start.ts
printf '%s\n' '--- restored starter source ---'
nl -ba src/main/runtime/terminal/recovery/restored-pane-start.ts | sed -n '1,180p'
printf '%s\n' '--- references to starter and activation ---'
rg -n -F --glob '*.ts' -e 'ensureRestoredPaneStarted' -e 'ensureStarted(' src/main
printf '%s\n' '--- mobile activation symbol locations ---'
rg -n -F --glob '*.ts' 'activateMobileSessionTab' src/main
printf '%s\n' '--- leaf ID contract ---'
nl -ba src/shared/stable-pane-id.ts | sed -n '1,65p'
printf '%s\n' '--- restoration normalization declaration and call references ---'
nl -ba src/main/persistence/restoring-sessions/terminal-layout-normalization.ts | sed -n '115,175p'
rg -n -F --glob '*.ts' -e 'normalizeTerminalLayout' -e 'terminal-layout-normalization' src/main/persistence src/main/runtimeRepository: stablyai/orca
Length of output: 29554
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- restored-pane materializer ---'
nl -ba src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts | sed -n '1,125p'
printf '%s\n' '--- activation and refresh caller ---'
nl -ba src/main/runtime/session-lifecycle/projection/perform-mobile-session-pty-records-refresh.ts | sed -n '105,225p'
printf '%s\n' '--- workspace pane normalization call path ---'
nl -ba src/main/persistence/restoring-sessions/workspace-pane-normalization.ts | sed -n '1,190p'
printf '%s\n' '--- callers of workspace normalization ---'
rg -n -F --glob '*.ts' 'normalizeWorkspacePane' src/main
printf '%s\n' '--- layout-owner starter binding and mobile projection wiring ---'
rg -n -F --glob '*.ts' -e 'RestoredPaneMaterializer' -e 'restoredPanes:' -e 'ensureRestoredPaneStarted:' src/main/runtime src/mainRepository: stablyai/orca
Length of output: 22226
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- mobile terminal projection ---'
nl -ba src/renderer/src/runtime/sync-runtime-graph/mobile-session-terminal-tabs.ts | sed -n '1,130p'
printf '%s\n' '--- hydration function and callers ---'
rg -n -F --glob '*.ts' 'hydrateHeadlessMobileSessionTabsFromWorkspaceSession' src/main
printf '%s\n' '--- hydration owner outline and surrounding declaration ---'
rg -n -F --glob '*.ts' -e 'hydrateHeadlessMobileSessionTabsFromWorkspaceSession' -e 'buildHeadlessMobileSession' src/main/runtime/session-lifecycle
printf '%s\n' '--- persisted identity normalization callers ---'
rg -n -F --glob '*.ts' -e 'normalizePersistedPaneIdentityState' -e 'normalizeWorkspaceSessionPaneIdentities' src
printf '%s\n' '--- remainder of persisted-state normalization ---'
nl -ba src/main/persistence/restoring-sessions/workspace-pane-normalization.ts | sed -n '177,275p'
printf '%s\n' '--- runtime projection tab type/use sites ---'
rg -n -F --glob '*.ts' -e 'RuntimeMobileSessionTerminalTab' -e 'parentLayout' src/main/runtime/session-lifecycle/projection/build-headless-mobile-session-browser-tabs.ts src/main/runtime/session-lifecycle/projectionRepository: stablyai/orca
Length of output: 30657
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- runtime leaf resolver ---'
rg -n -F --glob '*.ts' 'getRuntimeLeafIdsForTerminal' src/renderer/src/runtime
nl -ba src/renderer/src/runtime/sync-runtime-graph/mobile-session-surfaces.ts | sed -n '1,190p'
printf '%s\n' '--- terminal layout snapshot normalizer ---'
rg -n -F --glob '*.ts' 'function normalizeTerminalLayoutSnapshot' src/renderer/src
nl -ba src/renderer/src/components/terminal-pane/layout-serialization.ts | sed -n '1,190p'
printf '%s\n' '--- headless mobile session hydration ---'
nl -ba src/main/runtime/session-tabs/mobile-session-hydration.ts | sed -n '1,245p'Repository: stablyai/orca
Length of output: 28169
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- headless terminal projection definitions ---'
rg -n -F --glob '*.ts' 'buildHeadlessMobileSessionTerminalTabs' src/main/runtime
nl -ba src/main/runtime/mobile-session-terminal-projection.ts | sed -n '1,270p'
printf '%s\n' '--- actual terminal layout snapshot normalizer ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-layout-leaf-ids.ts | sed -n '180,285p'
printf '%s\n' '--- session snapshot publication normalization ---'
nl -ba src/main/persistence/loading-store/workspace-session-snapshot-publication.ts | sed -n '1,115p'
printf '%s\n' '--- persisted store loading normalization ---'
nl -ba src/main/persistence/loading-store/store.ts | sed -n '85,145p'Repository: stablyai/orca
Length of output: 20194
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- persisted terminal leaf helper declarations ---'
rg -n -F --glob '*.ts' -e 'collectPersistedTerminalLeafIds' -e 'deriveHeadlessLegacyTerminalLeafId' src/main/runtime
nl -ba src/main/runtime/mobile-session-layout-projection.ts | sed -n '1,155p'Repository: stablyai/orca
Length of output: 8204
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- mobile snapshot assignment and publication entrypoints ---'
rg -n -F --glob '*.ts' -e 'mobileSessionTabsByWorktree.set' -e 'mobileSessionTabsByWorktree =' -e 'setMobileSessionTabs' -e 'RuntimeMobileSessionTabsSnapshot' src/main
printf '%s\n' '--- mobile session snapshot RPC/input handlers ---'
rg -n -F --glob '*.ts' -e 'session.tabs' -e 'mobile-session-tabs' -e 'mobileSessionTabs' src/main/runtime/rpc src/main/ipc
printf '%s\n' '--- pane capture leaf ID source ---'
nl -ba src/renderer/src/runtime/sync-runtime-graph/mobile-session-capture.ts | sed -n '1,150p'Repository: stablyai/orca
Length of output: 42174
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- graph sync source files ---'
rg --files src/main/runtime | rg 'graph-sync|runtime-identity-state'
printf '%s\n' '--- snapshot storage implementation ---'
nl -ba src/main/runtime/construction/runtime-identity-state.ts | sed -n '95,130p'
printf '%s\n' '--- graph-sync callers and snapshot fields ---'
rg -n -F --glob '*.ts' -e 'storeMobileSessionSnapshot' -e 'mobileSessionTabs:' -e 'syncWindowGraph' src/main/runtime
printf '%s\n' '--- mobile terminal tab type ---'
rg -n -F --glob '*.ts' -e 'type RuntimeMobileSessionTerminalTab' -e 'interface RuntimeMobileSessionTerminalTab' src/shared/runtime-types.ts src/sharedRepository: stablyai/orca
Length of output: 41911
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- syncWindowGraph implementation ---'
nl -ba src/main/runtime/session-graph/session-window-graph.ts | sed -n '35,90p'
nl -ba src/main/runtime/session-graph/session-window-graph.ts | sed -n '260,315p'
printf '%s\n' '--- mobile terminal tab contract ---'
nl -ba src/shared/runtime-mobile-session-tab-contracts.ts | sed -n '1,75p'
printf '%s\n' '--- graph sync mobile snapshot gating contract ---'
nl -ba src/main/runtime/runtime-mobile-session-projection-contract.ts | sed -n '1,90p'Repository: stablyai/orca
Length of output: 12005
🏁 Script executed:
nl -ba src/main/runtime/session-graph/session-window-graph.ts | sed -n '308,355p'Repository: stablyai/orca
Length of output: 2350
🏁 Script executed:
rg -n -C8 -F --glob '*.ts' 'graph.mobileSessionTabs' src/main/runtime/session-graph/session-window-graph.tsRepository: stablyai/orca
Length of output: 1846
🏁 Script executed:
rg -n -C12 -F --glob '*.ts' 'syncMobileSessionTabs' src/main/runtimeRepository: stablyai/orca
Length of output: 26655
🏁 Script executed:
nl -ba src/main/runtime/session-tabs/mobile-session-reconciliation.ts | sed -n '40,190p'Repository: stablyai/orca
Length of output: 8473
🏁 Script executed:
nl -ba src/main/runtime/session-tabs/mobile-session-reconciliation.ts | sed -n '188,285p'Repository: stablyai/orca
Length of output: 4075
Use a non-validating key for restored-pane deduplication.
ensureStarted can receive a legacy leaf ID from an accepted mobile-session snapshot. Calling makePaneKey then throws before the pane can start.
🐛 Suggested fix
--- "a/src/main/runtime/terminal/recovery/restored-pane-start.ts"
+++ "b/src/main/runtime/terminal/recovery/restored-pane-start.ts"
@@ -53,7 +53,7 @@
* terminal, so every caller ends bound to the same one.
*/
ensureStarted(pane: RestoredPane, trigger: RestoredPaneTrigger = {}): Promise<string | null> {
- const key = makePaneKey(pane.tabId, pane.leafId)
+ const key = `${pane.tabId}\0${pane.leafId}`
const running = this.inFlight.get(key)
if (running) {
return running📝 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.
| const key = makePaneKey(pane.tabId, pane.leafId) | |
| const key = `${pane.tabId}\0${pane.leafId}` |
| if ( | ||
| !pane.leafId || | ||
| runtimeEnvironmentIdUnlessTwin(useAppStore.getState(), pane.worktreeId) !== null | ||
| ) { | ||
| return false | ||
| } | ||
| const close = (): void => { | ||
| // Why the leaf check: main's answer can land after the pane already went. | ||
| if (manager.getLeafId(paneId) !== leafId) { | ||
| return | ||
| } | ||
| // A sibling went, or is going, while main answered: this pane is now the tab's last. | ||
| if ( | ||
| panesLeftAfterPendingCloses( | ||
| args.tabId, | ||
| manager.getPanes().map((pane) => pane.leafId) | ||
| ) <= 1 | ||
| ) { | ||
| args.closeTab() | ||
| return | ||
| } | ||
| manager.closePane(paneId) | ||
| } | ||
| // Main holds this pane alone while the window has more: its copy lags, so close as today. | ||
| return sendPaneCloseToLayoutOwner( | ||
| { worktreeId: args.worktreeId, tabId: args.tabId, leafId, kind: 'exit' }, | ||
| { asToday: close, lastPane: close, closeHere: close } | ||
| ) | ||
| expectPaneToClose(pane.tabId, pane.leafId, 'exit') | ||
| return true |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C3 '\blayoutFramesFlowing\s*\(' src/renderer
fd -i 'exited-split-pane-rule.ts' src/main --exec cat -n {}Repository: stablyai/orca
Length of output: 12315
🏁 Script executed:
printf '%s\n' '--- helper ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/exited-split-pane-close.ts
printf '%s\n' '--- caller references ---'
rg -n -F -- 'expectExitedSplitPaneClose' src/renderer
printf '%s\n' '--- caller and close-intent definitions/usages ---'
rg -n -C 5 -F -e 'expectPaneToClose' -e "closing" src/renderer/src/components/terminal-pane/pty-connection src/renderer/src/components/terminal-pane
printf '%s\n' '--- frame stream lifecycle and snapshot handling ---'
nl -ba src/renderer/src/runtime/layout-frame-position.ts
rg -n -C 5 -F -e 'layoutSnapshotFrame' -e 'onFrame' -e 'stream.onFrame' src/renderer/src/runtime/workspace-layout-frame-sync.ts
printf '%s\n' '--- main exited-pane outcome consumers ---'
rg -n -C 6 -F -e 'exitedSplitPaneOutcome' -e 'closeExitedSplit' src/main src/renderer'Repository: stablyai/orca
Length of output: 41683
🏁 Script executed:
printf '%s\n' '--- exit caller ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/pty-exit-hibernate.ts | sed -n '330,390p'
printf '%s\n' '--- main rule references ---'
rg -n -F -- 'exitedSplitPaneOutcome(' src/main
printf '%s\n' '--- close intents declaration/consumer ---'
rg -n -F -e 'function expectPaneToClose' -e 'expectPaneToClose' -e 'exit' src/renderer/src/runtime/layout-owner-pane-intents.ts src/renderer/src/runtime
printf '%s\n' '--- layout sync definitions ---'
rg -n -F -e 'beginLayoutFramePositions' -e 'endLayoutFramePositions' -e 'noteLayoutFramePosition' src/renderer/src/runtime src/renderer/src/hooks
printf '%s\n' '--- relevant layout sync implementation ---'
rg --files src/main src/renderer | rg 'layout.*(frame|owner|intent|command)|frame.*layout' | head -80Repository: stablyai/orca
Length of output: 22444
🏁 Script executed:
printf '%s\n' '--- main layout close rule consumer ---'
nl -ba src/main/runtime/exited-split-pane-layout-close.ts
rg -n -F -e 'closeExitedSplitPane' -e 'exitedSplitPaneLayout' -e 'exitedSplitPaneFacts' src/main
printf '%s\n' '--- renderer keep branches and close call ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/pty-exit-hibernate.ts | sed -n '280,375p'
printf '%s\n' '--- pane intent implementation ---'
nl -ba src/renderer/src/runtime/layout-owner-pane-intents.ts
printf '%s\n' '--- renderer close intent consumer ---'
rg -n -F -e 'takePaneCloseIntent' -e 'planTerminalLiveLayoutRemovals' -e 'terminal-pane-frame-reconciliation' src/renderer/src
printf '%s\n' '--- frame stream subscription/open/reconnect ---'
nl -ba src/renderer/src/runtime/layout-frame-stream.ts
printf '%s\n' '--- main frame publish behavior ---'
rg -n -F -e 'publishWorkspaceLayout' -e 'layoutSnapshotFrame' -e 'subscribeWorkspaceLayout' src/main/runtime/workspace-layout-frame-observer.ts src/main/runtimeRepository: stablyai/orca
Length of output: 22678
🏁 Script executed:
printf '%s\n' '--- renderer exit path before close branch ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/pty-exit-hibernate.ts | sed -n '220,375p'
printf '%s\n' '--- main lifecycle exit facts and retirement ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts | sed -n '235,305p'
printf '%s\n' '--- owner resolution symbol ---'
rg -n -F -- 'runtimeEnvironmentIdUnlessTwin' src/renderer/src/lib
printf '%s\n' '--- main close decision caller ---'
rg -n -F -- 'keepsExitedPane(' src/main
printf '%s\n' '--- renderer frame reconciliation ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-frame-reconciliation.ts
printf '%s\n' '--- runtime layout stream subscription contract ---'
nl -ba src/main/runtime/rpc/methods/workspace-layout.ts | sed -n '1,100p'
nl -ba src/main/runtime/orca-runtime.ts | sed -n '245,290p'
printf '%s\n' '--- owner declaration excerpt ---'
rg -n -l -F -- 'function runtimeEnvironmentIdUnlessTwin' src/renderer/src/lib | xargs -r -n1 sh -c 'nl -ba "$0" | sed -n "1,180p"'Repository: stablyai/orca
Length of output: 36343
🏁 Script executed:
printf '%s\n' '--- callback declarations and production bindings ---'
rg -n -F -- 'onPaneProcessDied' src/renderer/src
printf '%s\n' '--- exit handler wiring ---'
rg -n -F -e 'createPtyExitHibernate' -e 'pty-exit-hibernate' -e 'handlePtyExit' src/renderer/src/components/terminal-pane
printf '%s\n' '--- main lifecycle close decision ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts | sed -n '250,295p'
printf '%s\n' '--- main rule ---'
nl -ba src/main/runtime/terminal/lifecycle/exited-split-pane-rule.ts | sed -n '19,60p'Repository: stablyai/orca
Length of output: 8426
Close the pane locally when layout frames stop.
For a previously used split pane that exits with code 0, main’s rule closes the pane. If the layout stream has ended, expectExitedSplitPaneClose still records an 'exit' intent and returns true. pty-exit-hibernate.ts then returns before session.manager.closePane(...). No frame can remove the dead pane while the stream is ended, and the intent can remain pending. Check layoutFramesFlowing() before recording the intent so the caller takes the local-close path.
Suggested fix
import { runtimeEnvironmentIdUnlessTwin } from '@/lib/resolve-owner'
+import { layoutFramesFlowing } from '@/runtime/layout-frame-position'
import { expectPaneToClose } from '@/runtime/layout-owner-pane-intents'
import { useAppStore } from '@/store'
@@
if (
!pane.leafId ||
+ !layoutFramesFlowing() ||
runtimeEnvironmentIdUnlessTwin(useAppStore.getState(), pane.worktreeId) !== null
) {Main's layout-owner groundwork (#31130, #31171, #31187, dark) and the binding fast lane (#31033) touched the same files. Binding retirement keeps this branch's incarnation fence and uses main's dirty marking; a failed start keeps its pane for main's keep-on-failure starts and for owner contention; the fresh launch path takes main's pane start status arguments.
ELI5
When Orca restarts, the main process now decides how each saved terminal pane comes back, but only in the build where main owns the layout. Released builds are unchanged. It starts each pane once, at the size it last had. It also says plainly when a pane's terminal is gone ("sleeping") or is still held by a newer Orca ("held").
What Changed
All of this applies only in the layout-owner build (
ORCA_LAYOUT_OWNER_IS_MAIN). The released build behaves exactly as before.ensureRestoredPaneStartedinrestored-pane-materialize.ts.tab_not_found, the code older phones already handle.initialcreate) now waits for main's placement pass that is running when it arrives, for at most 500 ms.Before: a window activating a workspace whose live terminal the pass had not placed yet got a fresh shell tab, and then the live terminal's tab beside it.
If the pass takes longer than 500 ms, the first tab is admitted anyway, and an extra tab may appear next to the restored terminal (owner-visible row 21).
At startup the window already waits for the pass. The cap covers passes started by a client attach or a terminal-service rebind.
A pass that starts after the first tab was admitted can likewise add a tab beside it. That needs a live terminal with no pane to appear after startup.
Measured in the desktop app (layout-owner dev build, hidden window, macOS, through the window's own
layout.applyIPC, 3 runs each):A headless server on a fresh profile showed passes of 0.9-24 ms.
lastGridsByLeafId) beside its title on the saved tab layout. A resize is written at most once per second per pane, and quit flushes any pending write. The grid is never published to clients. A restarted pane opens at this size: a size the caller measured wins, then the last grid, then the group's size, then 120x40.sleeping: the host's census answered and the pane's local terminal is gone.held: a newer build's terminal service may still be running it.starting/resuming/failed: as before.releasePaneTerminal, and starts fresh. This is the window's existing rule. SSH ids name a connection, not a workspace, so they keep reattaching over the relay.daemon-pty-session-control.tsanddaemon-pty-spawn-result.ts. Moving the acknowledgement into main is C1c's job.Why
heldis a separate status because today's window already shows something distinct for it:daemon-router-newer-daemon-hold.ts:13-34holds the spawn;newer-daemon-hold-pane.ts:28disables input and:49-57reads the held screen;TerminalPaneRuntimePortals.tsx:76shows theNewerDaemonHoldBanner.Ledger rows owned by later steps:
Linked Issue
Part of the terminal-layout final design (C1b). Stacked on #31130.
Visual Proof
N/A. This is dark behind the layout-owner build switch, and nothing changes in released builds.
Testing
ci-static-gate --with-slowpasses on the head, along with the census, routing and stub tests and every unit test that imports a changed file.ORCA_LAYOUT_OWNER=main) at the head and at the merge-base in a clean worktree. Every file that fails at the head but not at the base also fails at Layout groundwork (switched off): main creates, starts and closes terminal tabs and panes itself #31130's head6b8c37f5f05with the same tests, so this PR adds no switch-on regressions. Two regressions this PR introduced were fixed:Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reason for visuals