Repository navigation
Layout groundwork (switched off): main creates, starts and closes terminal tabs and panes itself - #31130
Conversation
|
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: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c85a6ff7-26c1-4255-a46e-f803b6a15cc8
📒 Files selected for processing: 54
src/main/ipc/pty/provider/bind-listeners.tssrc/main/ipc/pty/provider/local-configure.tssrc/main/persistence/loading-store/store-domain-composition.tssrc/main/persistence/terminal-topology/layout-command-persistence.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-layout-owner.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission.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-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.tssrc/main/runtime/pane-start-statuses.test.tssrc/main/runtime/pane-start-statuses.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.tssrc/main/runtime/runtime-pane-admission.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-tabs/terminal-surface-retirements.tssrc/main/runtime/terminal/launch/failed-start-pane.tssrc/main/runtime/terminal/launch/mobile-terminal-create.tssrc/main/runtime/terminal/launch/terminal-create.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/workspace-layout-stream.tssrc/main/runtime/workspaces/startup/workspace-terminal-provisioning.tssrc/renderer/src/components/terminal-pane/layout-owner-pane-close-command.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/pty-exit-hibernate.tssrc/renderer/src/runtime/layout-apply-send.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/rpc-contract/workspace-layout-terminal-tab-params.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-published.tssrc/shared/workspace-layout/workspace-layout-records.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; 2 remain after this review.
| function takenDefaultTabId( | ||
| layout: WorkspaceLayoutModel, | ||
| command: CommandOf<'applyDefaultTabs'> | ||
| ): LayoutApplyOutcome | null { | ||
| const ids = new Set(command.tabs.map((tab) => tab.tabId)) | ||
| const holds = Object.values(layout.workspaces).some((entry) => | ||
| entry.tabs.some((tab) => ids.has(tab.id) || ids.has(tab.entityId)) | ||
| ) | ||
| if (holds) { | ||
| return { ok: false, code: 'tab_exists' } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Check the applied mark before the held-id check.
takenDefaultTabId runs before applyDefaultTabs checks defaultTabsAppliedByWorkspace. Suppose a sender resends the same applyDefaultTabs command after the first one committed, for example after the reply was lost. The held-id check matches the tabs that the first command created and returns tab_exists. The command contract says main makes nothing once the workspace is marked, so the resend should succeed with createdTabs: []. A sender that treats tab_exists as a refusal logs "Main refused the default tabs" and starts no terminals in the panes that already exist.
Return null from takenDefaultTabId when the workspace is already marked. The pure command then returns { createdTabs: [] }.
🐛 Proposed fix
--- "a/src/main/persistence/terminal-topology/terminal-pane-admission.ts"
+++ "b/src/main/persistence/terminal-topology/terminal-pane-admission.ts"
@@ -228,11 +228,14 @@
}
/** Default tabs come once, so any proposed id another tab holds refuses them all. */
function takenDefaultTabId(
layout: WorkspaceLayoutModel,
command: CommandOf<'applyDefaultTabs'>
): LayoutApplyOutcome | null {
+ if (layout.records.defaultTabsAppliedByWorkspace?.[command.workspace]) {
+ return null
+ }
const ids = new Set(command.tabs.map((tab) => tab.tabId))
const holds = Object.values(layout.workspaces).some((entry) =>
entry.tabs.some((tab) => ids.has(tab.id) || ids.has(tab.entityId))
)📝 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.
| function takenDefaultTabId( | |
| layout: WorkspaceLayoutModel, | |
| command: CommandOf<'applyDefaultTabs'> | |
| ): LayoutApplyOutcome | null { | |
| const ids = new Set(command.tabs.map((tab) => tab.tabId)) | |
| const holds = Object.values(layout.workspaces).some((entry) => | |
| entry.tabs.some((tab) => ids.has(tab.id) || ids.has(tab.entityId)) | |
| ) | |
| if (holds) { | |
| return { ok: false, code: 'tab_exists' } | |
| } | |
| function takenDefaultTabId( | |
| layout: WorkspaceLayoutModel, | |
| command: CommandOf<'applyDefaultTabs'> | |
| ): LayoutApplyOutcome | null { | |
| if (layout.records.defaultTabsAppliedByWorkspace?.[command.workspace]) { | |
| return null | |
| } | |
| const ids = new Set(command.tabs.map((tab) => tab.tabId)) | |
| const holds = Object.values(layout.workspaces).some((entry) => | |
| entry.tabs.some((tab) => ids.has(tab.id) || ids.has(tab.entityId)) | |
| ) | |
| if (holds) { | |
| return { ok: false, code: 'tab_exists' } | |
| } |
| // Switch point: a start main could not make stays main's to show, never the window's. | ||
| ORCA_LAYOUT_OWNER_IS_MAIN ? undefined : startup && !didSpawnStartup ? startup : undefined, | ||
| ORCA_LAYOUT_OWNER_IS_MAIN ? undefined : failedSetup, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 '\breturnedSetup\b' --type=ts -g '!**/*.test.ts'Repository: stablyai/orca
Length of output: 4120
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- startup function ---'
nl -ba src/main/runtime/runtime-local-worktree-terminal-startup.ts | sed -n '1,245p'
printf '%s\n' '--- workspace creation result path ---'
nl -ba src/main/runtime/workspaces/workspace-creation.ts | sed -n '180,275p'
printf '%s\n' '--- setup result consumers ---'
rg -n -P -C6 'CreateWorktreeResult|\.setup\b|setupReceipt|awaitTerminalProvisioning' src --type=ts -g '!**/*.test.ts' | sed -n '1,320p'
printf '%s\n' '--- provisioning definition and callers ---'
rg -n -P -C8 'provisionWorktreeTerminals|keepPaneOnStartFailure|startFailure' src/main --type=ts -g '!**/*.test.ts' | sed -n '1,360p'Repository: stablyai/orca
Length of output: 42513
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- all non-test result/setup consumers ---'
rg -n -P -C8 'CreateWorktreeResult|createWorktree|create-worktree|result\.setup|setup:\s*result\.setup|\.setup\??\.' src --type=ts --type=tsx -g '!**/*.test.ts' -g '!**/*.spec.ts' | sed -n '1,420p'
printf '%s\n' '--- provisioning implementation ---'
nl -ba src/main/runtime/runtime-worktree-terminal-provisioning.ts | sed -n '1,330p'
printf '%s\n' '--- shared result contract ---'
rg -n -P -C12 'export\s+(type|interface)\s+CreateWorktreeResult|type\s+CreateWorktreeResult|interface\s+CreateWorktreeResult' src --type=ts --type=d.ts
printf '%s\n' '--- renderer/preload worktree creation handlers ---'
rg -n -P -C10 'worktree.*create|create.*worktree|setupReceipt|runSetup|setupAgent|setupCommand' src/renderer src/preload src/shared --type=ts --type=tsx -g '!**/*.test.ts' -g '!**/*.spec.ts' | sed -n '1,420p'Repository: stablyai/orca
Length of output: 12713
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- result contract and exact symbol references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' --glob '*.d.ts' 'CreateWorktreeResult' src || test "$?" -eq 1
printf '%s\n' '--- worktree creation result handling ---'
rg -n -P --glob '*.ts' --glob '*.tsx' --glob '*.d.ts' -C8 'createWorktree|create-worktree|result\.setup|\.setup\b|setupReceipt' src/renderer src/preload src/shared 2>/dev/null | sed -n '1,500p'
printf '%s\n' '--- shared create contract ---'
rg -n -P --glob '*.ts' --glob '*.tsx' --glob '*.d.ts' -C15 'export\s+(type|interface)\s+CreateWorktreeResult|type\s+CreateWorktreeResult|interface\s+CreateWorktreeResult' src || test "$?" -eq 1Repository: stablyai/orca
Length of output: 41892
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- renderer creation flow ---'
nl -ba src/renderer/src/lib/worktree-creation-flow-execute.ts | sed -n '1,230p'
printf '%s\n' '--- renderer create slice ---'
nl -ba src/renderer/src/store/slices/worktrees/create/create-worktree.ts | sed -n '1,190p'
printf '%s\n' '--- created-worktree merge ---'
nl -ba src/renderer/src/store/slices/worktrees/create/created-worktree-state-merge.ts | sed -n '1,180p'
printf '%s\n' '--- renderer setup/startup handling ---'
rg -n -P --glob '*.ts' --glob '*.tsx' -C10 'result\.setup|created\.setup|setupReceipt|activationSetup|setupTerminal|runSetup|start.*setup' src/renderer/src src/main/window src/main/ipc | sed -n '1,500p'Repository: stablyai/orca
Length of output: 42087
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- activation implementation ---'
rg -n -P --glob '*.ts' --glob '*.tsx' -C6 'export\s+(async\s+)?function\s+activateAndRevealWorktree|function\s+activateAndRevealWorktree|activateAndRevealWorktree\s*=' src/renderer/src
printf '%s\n' '--- activation setup handling ---'
rg -n -P --glob '*.ts' --glob '*.tsx' -C12 'setup\??:|args\.setup|options\.setup|setupOnly|createSetup|Setup' src/renderer/src/lib/worktree-activation* src/renderer/src/lib/worktree-initial-terminal-seeding.ts | sed -n '1,420p'Repository: stablyai/orca
Length of output: 41942
🏁 Script executed:
set -o pipefail
nl -ba src/renderer/src/lib/worktree-activation.ts | sed -n '120,245p'
printf '%s\n' '--- initial terminal seeding implementation ---'
nl -ba src/renderer/src/lib/worktree-initial-terminal-seeding.ts | sed -n '1,210p'Repository: stablyai/orca
Length of output: 16144
🏁 Script executed:
set -o pipefail
nl -ba src/renderer/src/lib/worktree-initial-terminal-seeding.ts | sed -n '205,390p'
printf '%s\n' '--- setup and issue command queue ---'
nl -ba src/renderer/src/lib/worktree-setup-issue-command-queue.ts | sed -n '1,300p'Repository: stablyai/orca
Length of output: 7319
Do not return setup after main has attempted its setup create.
When main owns the layout and setup creation fails, main retains the failed Setup pane, but didSpawnSetup remains false. The current code returns the same setup to the renderer. The renderer then creates another Setup tab beside the retained pane.
Track whether provisioning reached the setup create. Omit returnedSetup only when ORCA_LAYOUT_OWNER_IS_MAIN and that attempt occurred. Keep returning setup when main could not spawn terminals or did not attempt setup.
| return { | ||
| exitCode, | ||
| freshSpawn: run.freshSpawn, | ||
| inputSeen: run.firstUserInputAt !== null || runs.readLastInputAt(ptyId) !== null, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C3 '\brecordInput\s*\(' --type=ts src/main
rg -nP -C2 "inputKind|TerminalInputKind" --type=ts src/main/runtime | head -80Repository: stablyai/orca
Length of output: 28551
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- target rule ---'
nl -ba src/main/runtime/terminal/lifecycle/exited-split-pane-rule.ts | sed -n '1,130p'
printf '%s\n' '--- run facts implementation ---'
nl -ba src/main/runtime/terminal-run-facts.ts | sed -n '1,180p'
printf '%s\n' '--- input kinds ---'
nl -ba src/shared/terminal-input-kind.ts | sed -n '1,120p'
printf '%s\n' '--- launch-related write call sites ---'
rg -n -P -C4 --type=ts '(inputKind\s*:\s*['"'"']launch['"'"'"]|write(?:WithSettlement)?\s*\([^;\n]*['"'"'"]launch['"'"'"]|sendTerminalAgentPrompt|launch)' src/main/runtime src/main/ipc/pty src/shared | head -240Repository: stablyai/orca
Length of output: 31456
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- launch write producers ---'
rg -n -F --glob '*.ts' -e "inputKind: 'launch'" -e "inputKind='launch'" -e ", 'launch')" -e ", 'launch'," src/main || test "$?" -eq 1
printf '%s\n' '--- startup readiness implementation ---'
rg -n -F --glob '*.ts' -e 'writeWorktreeStartupPrompt' -e 'startup prompt' -e 'sendTerminalAgentPrompt' src/main/runtimeRepository: stablyai/orca
Length of output: 34987
Count only driving input for a fresh spawn.
readLastInputAt includes launch writes, but firstUserInputAt records only driving input. Therefore, a fresh pane that receives only a launch command sets inputSeen to true. Both newborn keep branches then close the pane instead of keeping its exit card.
Use the fallback only for non-fresh runs.
🐛 Suggested fix
--- "a/src/main/runtime/terminal/lifecycle/exited-split-pane-rule.ts"
+++ "b/src/main/runtime/terminal/lifecycle/exited-split-pane-rule.ts"
@@ -46,7 +46,9 @@
return {
exitCode,
freshSpawn: run.freshSpawn,
- inputSeen: run.firstUserInputAt !== null || runs.readLastInputAt(ptyId) !== null,
+ inputSeen:
+ run.firstUserInputAt !== null ||
+ (!run.freshSpawn && runs.readLastInputAt(ptyId) !== null),
outputSeen: pty?.lastOutputAt != null,
shown: options.viewShown === true
}📝 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.
| inputSeen: run.firstUserInputAt !== null || runs.readLastInputAt(ptyId) !== null, | |
| inputSeen: | |
| run.firstUserInputAt !== null || | |
| (!run.freshSpawn && runs.readLastInputAt(ptyId) !== null), |
| export const ApplyDefaultTabsCommand = z.object({ | ||
| type: z.literal('applyDefaultTabs'), | ||
| workspace, | ||
| tabs: z.array( | ||
| z.object({ | ||
| tabId: z.string().refine(isValidHostTerminalTabId), | ||
| leafId: z.string().refine(isTerminalLeafId), | ||
| title: z.string().trim().min(1).optional(), | ||
| color: z.string().min(1).optional(), | ||
| creation: TerminalCreation.optional() | ||
| }) | ||
| ) | ||
| }) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Reject duplicate ids inside one applyDefaultTabs batch.
LayoutApplyParams accepts applyDefaultTabs from the window, so the window controls tabs. The schema does not require unique tabId or leafId values across entries. takenDefaultTabId compares the proposed ids only against tabs that already exist in the layout. It does not compare the entries with each other. createTerminalTab runs no id check of its own. Two entries with the same tabId therefore persist two tabs with one id. Two entries with the same leafId persist two panes with one leaf id. Both results break pane-key identity in the saved session.
Add a uniqueness check at the boundary. The check can be a schema refine, or the same check in takenDefaultTabId.
🛡️ Proposed schema refine
- tabs: z.array(
- z.object({
+ tabs: z
+ .array(
+ z.object({
tabId: z.string().refine(isValidHostTerminalTabId),
leafId: z.string().refine(isTerminalLeafId),
title: z.string().trim().min(1).optional(),
color: z.string().min(1).optional(),
creation: TerminalCreation.optional()
- })
- )
+ })
+ )
+ .refine(
+ (tabs) =>
+ new Set(tabs.map((tab) => tab.tabId)).size === tabs.length &&
+ new Set(tabs.map((tab) => tab.leafId)).size === tabs.length
+ )…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)
f482089 to
288be57
Compare
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:
ef10b0ec-9323-44c2-bfbc-d9e5034b95c5
📒 Files selected for processing: 9
src/main/persistence/loading-store/terminal-close-async-durability.test.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/store/terminals/terminal-tab-close-intent.test.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/rpc-contract/workspace-layout-terminal-tab-params.tssrc/shared/workspace-layout/workspace-layout-command-types.tssrc/shared/workspace-layout/workspace-layout-records.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.
| return layoutApplyTestTransport.sentOfType('closeTabs').map((command) => ({ | ||
| worktreeId: command.workspace, | ||
| tabId: command.tabIds[0]!, | ||
| reason: command.recordClose === 'cleanup' ? 'cleanup' : 'user' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not treat an absent recordClose as a user close.
If main receives closeTabs without recordClose, this helper reports reason: 'user'. The user-close assertions then pass even though the command did not request a close record. Preserve the optional value in sentCloses so those assertions detect the missing field.
… reads a shared import (dark)
…ts old terminal (dark)
…back a closed pane by design
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ed4140e1-234d-4558-b030-3222be1b32ec
📒 Files selected for processing: 9
config/scripts/check-id-only-store-write-ratchet.mjsconfig/scripts/check-id-only-store-write-ratchet.test.mjssrc/main/persistence/terminal-topology/terminal-layout-create-resend.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission.tssrc/main/runtime/orca-runtime-layout-owner-start-fixture.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/pane-start-statuses.test.tssrc/main/runtime/pane-start-statuses.tssrc/renderer/src/store/terminals/terminal-tab-close-intent.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| .trim() | ||
| .split(/\s+as\s+/) | ||
| .at(-1) | ||
| ) | ||
| .filter(Boolean) | ||
| .map((name) => [name, m[2]]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect whether findIdOnlyWrites uses its className argument to select a declaration.
ast-grep outline config/scripts/check-id-only-store-write-ratchet.mjs --match findIdOnlyWrites --view expanded
sed -n '114,194p' config/scripts/check-id-only-store-write-ratchet.mjsRepository: stablyai/orca
Length of output: 3360
🏁 Script executed:
sed -n '1,125p' config/scripts/check-id-only-store-write-ratchet.mjs
printf '\n--- references and tests ---\n'
rg -n -F --glob '*.mjs' -e 'listStoreOperationClasses' -e 'collectIdOnlyStoreWrites' -e 'findIdOnlyWrites' -e 'as LocalOps' -e 'RowOps as' config test tests 2>/dev/null || test "$?" -eq 1Repository: stablyai/orca
Length of output: 8381
Preserve the imported declaration name for aliased classes.
findIdOnlyWrites searches for export class ${className}. For import { RowOps as LocalOps }, listStoreOperationClasses returns LocalOps, but the source declares RowOps. collectIdOnlyStoreWrites then misses all writes in that class.
Keep the composition name for import lookup, but pass the imported declaration name to findIdOnlyWrites. Add an aliased-class test case.
Suggested fix
- .map((name) =>
- name
- .trim()
- .split(/\s+as\s+/)
- .at(-1)
- )
- .filter(Boolean)
- .map((name) => [name, m[2]])
+ .map((raw) => {
+ const [importedName, localName] = raw.trim().split(/\s+as\s+/)
+ return [localName ?? importedName, importedName, m[2]]
+ })
+ .filter(([localName]) => Boolean(localName))
+ .map(([localName, importedName, specifier]) => [
+ localName,
+ { importedName, specifier }
+ ])
@@
- const specifier = imports.get(name)
- if (!specifier) {
+ const imported = imports.get(name)
+ if (!imported) {
throw new Error(`${COMPOSITION}: no import for ${name}`)
}
- return [name, path.posix.join(path.posix.dirname(COMPOSITION), `${specifier}.ts`)]
+ return [
+ imported.importedName,
+ path.posix.join(path.posix.dirname(COMPOSITION), `${imported.specifier}.ts`)
+ ]| set(paneKey: string, fact: PaneStartFact): void { | ||
| this.byPaneKey.set(paneKey, { fact }) | ||
| this.changed() | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
fd -i 'workspace-layout-stream.ts' src --exec rg -n -C6 'paneStartFact|subscribe\(|markLiveTitlesDirty|settledSeq|listeners' {}
rg -nP -C4 'paneStartStatuses\s*=' src/main/runtimeRepository: stablyai/orca
Length of output: 7818
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- pane-start-statuses.ts ---'
nl -ba src/main/runtime/pane-start-statuses.ts
printf '%s\n' '--- stream projection and flush ---'
nl -ba src/main/runtime/workspace-layout-stream.ts | sed -n '250,355p'
printf '%s\n' '--- status writes and binding-related calls ---'
rg -n -F --glob '*.ts' -e 'paneStartStatuses' -e 'paneStartStatusArgs' -e 'paneStartFactsOf' -e 'bindingOf(' -e 'ptyGeneration' src/main/runtime src/shared
printf '%s\n' '--- owning launch implementation ---'
nl -ba src/main/runtime/terminal/launch/failed-start-pane.ts | sed -n '1,190p'Repository: stablyai/orca
Length of output: 23344
Pin the pane binding when set runs.
set stores the fact without a binding, and get pins it to the first binding it receives. WorkspaceLayoutStream reads the fact only while projection is active. Without a subscriber, markLiveTitlesDirty() returns without reading it. A later subscriber can therefore read the fact after the pane has rebound and publish the stale failed status over the running terminal.
Pass a bindingAt(paneKey) reader to PaneStartStatuses and capture that binding in set. Keep get bound to the captured value so a later bind clears the fact.
…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.
…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.
… 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.
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.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments: 1
src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts: 1
456-474: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRun the runtime aggregator with the layout-owner switch enabled.
The normal unit command does not set
ORCA_LAYOUT_OWNER, soORCA_LAYOUT_OWNER_IS_MAINis false and the new switch-on assertions are skipped. Add an equivalent CI invocation:ORCA_LAYOUT_OWNER=main pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
79c6ade6-6552-43fe-abe8-7b0e1106a19b
📒 Files selected for processing: 20
src/main/persistence/terminal-topology/terminal-close-write-failure-switch-off.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/runtime/exited-split-pane-layout-close.test.tssrc/main/runtime/exited-split-pane-layout-close.tssrc/main/runtime/orca-runtime-default-tab-agent-status.test.tssrc/main/runtime/orca-runtime-exited-split-pane-close.test.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/runtime-local-worktree-terminal-startup.test.tssrc/main/runtime/runtime-pane-admission.tssrc/main/runtime/session-tabs/terminal-surface-retirements.tssrc/main/runtime/terminal-intentional-stop-exit.test.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/workspaces/startup/workspace-terminal-provisioning.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| const endVouched = | ||
| stopRequested || | ||
| options.hostExitConfirmed === true || | ||
| this.ptyLivenessVerdictByPtyId.get(ptyId)?.verdict.status === 'exited' |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Find every write and clear of the liveness verdict register.
rg -nP -C4 'ptyLivenessVerdictByPtyId\s*\.(set|delete|clear)|rememberPtyLivenessVerdict\s*\(' --type=ts -g '!**/*.test.ts'Repository: stablyai/orca
Length of output: 11102
🏁 Script executed:
set -e
printf '%s\n' '--- registration declaration and body ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-registration.ts | sed -n '1,125p'
printf '%s\n' '--- registration references ---'
rg -n -F --glob '*.ts' -e 'registerPty' -e 'pty-registration' src/main/runtime/terminal
printf '%s\n' '--- exit context ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts | sed -n '40,105p'
nl -ba src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts | sed -n '205,252p'
printf '%s\n' '--- incarnation fields and registration-related calls ---'
rg -n -F --glob '*.ts' -e 'exitIncarnationId' -e 'incarnationId' src/main/runtime/terminal/lifecycle src/main/runtime/terminal | head -160Repository: stablyai/orca
Length of output: 33868
🏁 Script executed:
set -e
printf '%s\n' '--- recordPtyWorktree callers ---'
rg -n -F --glob '*.ts' -e 'recordPtyWorktree(' src/main/runtime/terminal src/main/runtime | head -240
printf '%s\n' '--- record implementation and direct identity updates ---'
nl -ba src/main/runtime/terminal/identity/pty-worktree-record.ts | sed -n '1,180p'
printf '%s\n' '--- controller inventory refresh ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-controller-inventory-refresh.ts | sed -n '150,245p'
printf '%s\n' '--- recovery and adoption references ---'
rg -n -F --glob '*.ts' -e 'adopt' -e 'restore' -e 'reattach' src/main/runtime/terminal/recovery src/main/runtime/terminal/adoption src/main/runtime/terminal/lifecycle | head -240Repository: stablyai/orca
Length of output: 25846
🏁 Script executed:
set -e
printf '%s\n' '--- recordPtyWorktree continuation ---'
nl -ba src/main/runtime/terminal/identity/pty-worktree-record.ts | sed -n '120,245p'
printf '%s\n' '--- exited split-pane rule and consumers ---'
nl -ba src/main/runtime/terminal/lifecycle/exited-split-pane-rule.ts | sed -n '1,130p'
rg -n -F --glob '*.ts' -e 'exitedSplitPaneOutcome' -e 'endVouched' src/main/runtime/terminal src/main/runtime | head -160
printf '%s\n' '--- inventory refresh entry and surrounding flow ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-controller-inventory-refresh.ts | sed -n '1,155p'Repository: stablyai/orca
Length of output: 21461
🏁 Script executed:
set -e
printf '%s\n' '--- liveness live writer ---'
nl -ba src/main/runtime/terminal/layout/terminal-input-floor.ts | sed -n '1,65p'
printf '%s\n' '--- direct live-record callers ---'
nl -ba src/main/runtime/terminal/output/pty-output-ingestion.ts | sed -n '140,205p'
nl -ba src/main/runtime/terminal/lifecycle/floating-session-liveness.ts | sed -n '1,90p'
nl -ba src/main/runtime/session-graph/session-window-graph.ts | sed -n '155,205p'
nl -ba src/main/runtime/terminal/launch/terminal-create-deduplication.ts | sed -n '90,165p'
printf '%s\n' '--- registration assertion and incarnation fence ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-registration.ts | sed -n '170,235p'Repository: stablyai/orca
Length of output: 19978
🏁 Script executed:
set -e
printf '%s\n' '--- acceptPtyIncarnationForExit callers ---'
rg -n -F --glob '*.ts' -e 'acceptPtyIncarnationForExit(' src/main/runtime
printf '%s\n' '--- terminal deduplication class and callers ---'
nl -ba src/main/runtime/terminal/launch/terminal-create-deduplication.ts | sed -n '1,130p'
rg -n -F --glob '*.ts' -e 'adoptExistingControllerTerminal' -e 'adoptControllerTerminalHandle' -e 'launchAgentTerminal' src/main/runtime/terminal src/main/runtime | head -220
printf '%s\n' '--- reconnect attach lifecycle references ---'
rg -n -P --glob '*.ts' 'reattach|attach.*reply|attach.*result|incarnation' src/main/runtime/terminal/lifecycle src/main/runtime/terminal/launch src/main/runtime/terminal/recovery | head -260Repository: stablyai/orca
Length of output: 22497
🏁 Script executed:
set -e
printf '%s\n' '--- adopted handle method ---'
nl -ba src/main/runtime/workspaces/known-workspace-file-target.ts | sed -n '195,235p'
printf '%s\n' '--- exit consumer block ---'
nl -ba src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts | sed -n '252,282p'Repository: stablyai/orca
Length of output: 3644
Scope the liveness verdict to the PTY incarnation.
registerPty clears the verdict, but controller reconciliation can admit a live replacement through recordPtyWorktree without clearing it. A stale exited verdict can then make an uncertified negative exit close the replacement pane.
Clear or replace the verdict whenever a new live incarnation is accepted, including restore, adoption, and reconnect paths. Alternatively, store the incarnation with the verdict and require it to match the exiting exitIncarnationId.
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.
…e, the window only attaches (#31258) * feat(terminal): the window's store shows main's pane start status (layout-owner build) A status-only frame changes one store entry and no pane tree, so the pane's view stays mounted. * refactor(terminal): keep the frame sync within its line budget * feat(terminal): every pane main starts shows 'starting' from before it is written (layout-owner build) * feat(terminal): a pane main is starting waits and attaches; a failed start shows why (layout-owner build) Fixes owner-visible row 15: a failed agent or setup start no longer opens a plain shell. * test(terminal): iterate store listeners directly * fix(terminal): an exit that reports no code keeps its pane, as lost contact (layout-owner build) * test(terminal): a pane main started attaches to main's terminal at its own grid * test(terminal): detach census tests assert main's move and frame with the switch on * test(terminal): exited-pane tests assert main's close with the switch on These 8 have failed switch-on since #31130 moved the exit close to main. * feat(terminal): main writes and starts every split of a pane it holds; 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. * fix(terminal): the attach-only wait leaves sleeping, resuming and held panes to their restore path * fix(terminal): a split pane attaches to the terminal main bound it to; 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. * fix(terminal): a window split main cannot start still shows its pane, failed, with why * fix(terminal): check a taken pane id first, keep the start's own error, clear a gone pane's status Three test stores gain the pane-start field the window's store always has. * test(terminal): the admission stub answers whether its pane is still written; a closed pane's failed start clears * refactor(terminal): the rebound workspaces' bindings show through one call in the bindings module * test(terminal): a pane main wrote and the user closed mid-start drops its failed status * fix(terminal): a split main starts is listed to phones and session.tabs without a window's report * fix(terminal): a reconnect shows its pane starting and why it failed; a lost owner race shows no failure; a split no one asked to see keeps the phones' tab * fix(terminal): a kept create another owner won shows no failure; the window attaches to the winner
…, and the window only attaches and paints the host's history (#31567) * feat(terminal): the window's store shows main's pane start status (layout-owner build) A status-only frame changes one store entry and no pane tree, so the pane's view stays mounted. * refactor(terminal): keep the frame sync within its line budget * feat(terminal): every pane main starts shows 'starting' from before it is written (layout-owner build) * feat(terminal): a pane main is starting waits and attaches; a failed start shows why (layout-owner build) Fixes owner-visible row 15: a failed agent or setup start no longer opens a plain shell. * test(terminal): iterate store listeners directly * fix(terminal): an exit that reports no code keeps its pane, as lost contact (layout-owner build) * test(terminal): a pane main started attaches to main's terminal at its own grid * test(terminal): detach census tests assert main's move and frame with the switch on * fix(terminal): a restored pane paints history only from its terminal's host, never the window's copy (layout-owner build only) * fix(terminal): main releases a painted cold restore only for the pane's current terminal (layout-owner build only) * test(terminal): typed ack args in the painted cold-restore test * test(terminal): exited-pane tests assert main's close with the switch on These 8 have failed switch-on since #31130 moved the exit close to main. * feat(layout): main starts the panes a client's startPane or wake names, 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. * fix(layout): a window's wake of a pane it resumed itself is record-only, so main does not start it again (layout-owner build only) * test(layout): a client's startPane starts the pane before any other trigger * Revert "fix(terminal): a restored pane paints history only from its terminal's host, never the window's copy (layout-owner build only)" This reverts commit a646d89. * test(terminal): the cold-restore repaint ack names its pane in the layout-owner build * fix(layout): a wake keeps the pane's resume record in the pane-owned form, so a host crash resumes the agent again (layout-owner build only) * test(layout): a failing start in the pane-start runner test throws * feat(terminal): main writes and starts every split of a pane it holds; 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. * fix(terminal): the attach-only wait leaves sleeping, resuming and held panes to their restore path * fix(terminal): a split pane attaches to the terminal main bound it to; 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. * Reapply "fix(terminal): a restored pane paints history only from its terminal's host, never the window's copy (layout-owner build only)" This reverts commit 420e605. * fix(layout): a trigger between a restored pane's start and its bind write joins that start, not a second one (layout-owner build only) * fix(terminal): a window split main cannot start still shows its pane, failed, with why * fix(terminal): keep the switch import the D1b-1 merge dropped from the layout restore * feat(layout): main's starter shows a restored pane starting before any await, and a failed start with its reason; startPane starts a pane whose bound terminal ended (layout-owner build only) * feat(terminal): a window's attach-only view of a pane attaches to its terminal or starts nothing, keeping the binding for main's start (layout-owner build only) * feat(terminal): a restored pane with no live terminal asks main to start it and attaches once main binds it; the window's wake, hibernated wake, restart-on-show and gone-terminal fallbacks route through main (layout-owner build only) * fix(terminal): check a taken pane id first, keep the start's own error, clear a gone pane's status Three test stores gain the pane-start field the window's store always has. * test(terminal): the admission stub answers whether its pane is still written; a closed pane's failed start clears * test(terminal): with the switch on, the window's restores, wakes and restart replacements ask main to start the pane and attach to the terminal main binds, starting and resuming nothing themselves * refactor(terminal): the rebound workspaces' bindings show through one call in the bindings module * fix(terminal): a held pane connects as today so main's refusal holds it; main's start follows output; a capacity death after main's resume keeps the resume (layout-owner build only) * fix(layout): main passes its start options only for commands that start panes; a windowed open resumes the agent under main (layout-owner build only) * refactor(terminal): break the pane start module cycle; typed test fixtures * test(terminal): a pane main wrote and the user closed mid-start drops its failed status * fix(terminal): every waiter on main's start runs, a failed or refused start settles and is asked again on the next view, a hidden gone pane waits for its view, a twin main hands back stays on today's path, and lost contact never starts a pane (layout-owner build only) * test(terminal): iterate the store listeners directly * test(terminal): a cold-restore paint applies no window resume with the switch on * fix(terminal): a split main starts is listed to phones and session.tabs without a window's report * test(terminal): name the main pane start test helper as a fixture * fix(terminal): a reconnect shows its pane starting and why it failed; a lost owner race shows no failure; a split no one asked to see keeps the phones' tab * fix(terminal): a kept create another owner won shows no failure; the window attaches to the winner * fix(terminal): a pane main starts at relaunch keeps its full history and starts before the window's graph lists its tab (layout-owner build only) * feat(terminal): main replaces the empty shell a hibernated agent left and resumes the agent when a view asks; a start main could not attach shows main's own terminal_not_started (layout-owner build only) * test(terminal): main seeds its copy of a restored pane even when a window declared one, with the switch on * fix(terminal): a pane main started hidden paints once when its view attaches (switch-on builds only) The view's attach snapshot, taken after main unmarks the hidden gate, already holds the bytes main dropped, so the reveal no longer asks a second restore from main's buffer. * refactor(terminal): main's pane start reads the pane from its own layout, not the client projection (switch-on builds only) * fix(terminal): a pane restart stops its terminal before writing the pane unbound, so a stop that fails keeps the pane (switch-on builds only) * test(terminal): a start main could not bind shows terminal_not_started through the window's wait, from one copy site (switch-on builds only) * fix(terminal): main's pane start resumes an agent recorded under the pane's number, as the window did; stale switch-on tests show main's start and the known banner loss (switch-on builds only) * fix(terminal): review round: a visible view alone retires main's hidden-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) * fix(terminal): main's start of a pane a window view is attaching to leaves it visible, so the view paints once (switch-on builds only) * fix(terminal): a window view that attaches while main starts its pane takes main's start, with no second provider attach (switch-on builds only) * fix(terminal): review round: a view takes main's start only when it carries 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) * test(terminal): checked test doubles in the view-join and numbered-record tests; reattach options fit the file budget * test(e2e): with the switch on, the mount-authority spec keeps the window's bindings, which only main's frames write Claude-Session: W5b * test(e2e): the mount-authority spec fits its line budget; the layout-owner build check is one helper Claude-Session: W5b * test(layout): an unbound pane holding a resume record starts and keeps the record, since main's start resumes from it Claude-Session: W5b * fix(terminal): a pane main resumed holds a running agent's record, so it reads awake, not sleeping (switch-on builds only) Claude-Session: W5b * fix(terminal): in a split where no pane owns a numbered record, main resumes the tab's one conversation in pane 1 only (switch-on builds only) Claude-Session: W5b * fix(terminal): main marks only the record a resume started from live, never a sleep captured after it (switch-on builds only) Claude-Session: W5b * test(terminal): with the switch on, a windowless resume leaves the pane's record a running agent's Claude-Session: W5b * test(terminal): the resumed-record test double typechecks Claude-Session: W5b * refactor(terminal): with the switch off, main's pane start reads no resume record for the live mark Claude-Session: W5b * refactor(terminal): the merged files fit their line budget: the folder-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 * refactor(runtime): the window's layout apply fits the runtime's line budget after the main merge Claude-Session: W5b
…tart resumed a pane's agent, so the restored banner and reopen count come back (#31908) * feat(terminal): the window's store shows main's pane start status (layout-owner build) A status-only frame changes one store entry and no pane tree, so the pane's view stays mounted. * refactor(terminal): keep the frame sync within its line budget * feat(terminal): every pane main starts shows 'starting' from before it is written (layout-owner build) * feat(terminal): a pane main is starting waits and attaches; a failed start shows why (layout-owner build) Fixes owner-visible row 15: a failed agent or setup start no longer opens a plain shell. * test(terminal): iterate store listeners directly * fix(terminal): an exit that reports no code keeps its pane, as lost contact (layout-owner build) * test(terminal): a pane main started attaches to main's terminal at its own grid * test(terminal): detach census tests assert main's move and frame with the switch on * fix(terminal): a restored pane paints history only from its terminal's host, never the window's copy (layout-owner build only) * fix(terminal): main releases a painted cold restore only for the pane's current terminal (layout-owner build only) * test(terminal): typed ack args in the painted cold-restore test * test(terminal): exited-pane tests assert main's close with the switch on These 8 have failed switch-on since #31130 moved the exit close to main. * feat(layout): main starts the panes a client's startPane or wake names, 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. * fix(layout): a window's wake of a pane it resumed itself is record-only, so main does not start it again (layout-owner build only) * test(layout): a client's startPane starts the pane before any other trigger * Revert "fix(terminal): a restored pane paints history only from its terminal's host, never the window's copy (layout-owner build only)" This reverts commit a646d89. * test(terminal): the cold-restore repaint ack names its pane in the layout-owner build * fix(layout): a wake keeps the pane's resume record in the pane-owned form, so a host crash resumes the agent again (layout-owner build only) * test(layout): a failing start in the pane-start runner test throws * feat(terminal): main writes and starts every split of a pane it holds; 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. * fix(terminal): the attach-only wait leaves sleeping, resuming and held panes to their restore path * fix(terminal): a split pane attaches to the terminal main bound it to; 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. * Reapply "fix(terminal): a restored pane paints history only from its terminal's host, never the window's copy (layout-owner build only)" This reverts commit 420e605. * fix(layout): a trigger between a restored pane's start and its bind write joins that start, not a second one (layout-owner build only) * fix(terminal): a window split main cannot start still shows its pane, failed, with why * fix(terminal): keep the switch import the D1b-1 merge dropped from the layout restore * feat(layout): main's starter shows a restored pane starting before any await, and a failed start with its reason; startPane starts a pane whose bound terminal ended (layout-owner build only) * feat(terminal): a window's attach-only view of a pane attaches to its terminal or starts nothing, keeping the binding for main's start (layout-owner build only) * feat(terminal): a restored pane with no live terminal asks main to start it and attaches once main binds it; the window's wake, hibernated wake, restart-on-show and gone-terminal fallbacks route through main (layout-owner build only) * fix(terminal): check a taken pane id first, keep the start's own error, clear a gone pane's status Three test stores gain the pane-start field the window's store always has. * test(terminal): the admission stub answers whether its pane is still written; a closed pane's failed start clears * test(terminal): with the switch on, the window's restores, wakes and restart replacements ask main to start the pane and attach to the terminal main binds, starting and resuming nothing themselves * refactor(terminal): the rebound workspaces' bindings show through one call in the bindings module * fix(terminal): a held pane connects as today so main's refusal holds it; main's start follows output; a capacity death after main's resume keeps the resume (layout-owner build only) * fix(layout): main passes its start options only for commands that start panes; a windowed open resumes the agent under main (layout-owner build only) * refactor(terminal): break the pane start module cycle; typed test fixtures * test(terminal): a pane main wrote and the user closed mid-start drops its failed status * fix(terminal): every waiter on main's start runs, a failed or refused start settles and is asked again on the next view, a hidden gone pane waits for its view, a twin main hands back stays on today's path, and lost contact never starts a pane (layout-owner build only) * test(terminal): iterate the store listeners directly * test(terminal): a cold-restore paint applies no window resume with the switch on * fix(terminal): a split main starts is listed to phones and session.tabs without a window's report * test(terminal): name the main pane start test helper as a fixture * fix(terminal): a reconnect shows its pane starting and why it failed; a lost owner race shows no failure; a split no one asked to see keeps the phones' tab * fix(terminal): a kept create another owner won shows no failure; the window attaches to the winner * fix(terminal): a pane main starts at relaunch keeps its full history and starts before the window's graph lists its tab (layout-owner build only) * feat(terminal): main replaces the empty shell a hibernated agent left and resumes the agent when a view asks; a start main could not attach shows main's own terminal_not_started (layout-owner build only) * test(terminal): main seeds its copy of a restored pane even when a window declared one, with the switch on * fix(terminal): a pane main started hidden paints once when its view attaches (switch-on builds only) The view's attach snapshot, taken after main unmarks the hidden gate, already holds the bytes main dropped, so the reveal no longer asks a second restore from main's buffer. * refactor(terminal): main's pane start reads the pane from its own layout, not the client projection (switch-on builds only) * fix(terminal): a pane restart stops its terminal before writing the pane unbound, so a stop that fails keeps the pane (switch-on builds only) * test(terminal): a start main could not bind shows terminal_not_started through the window's wait, from one copy site (switch-on builds only) * fix(terminal): main's pane start resumes an agent recorded under the pane's number, as the window did; stale switch-on tests show main's start and the known banner loss (switch-on builds only) * fix(terminal): review round: a visible view alone retires main's hidden-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) * fix(terminal): main's start of a pane a window view is attaching to leaves it visible, so the view paints once (switch-on builds only) * fix(terminal): a window view that attaches while main starts its pane takes main's start, with no second provider attach (switch-on builds only) * fix(terminal): review round: a view takes main's start only when it carries 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) * test(terminal): checked test doubles in the view-join and numbered-record tests; reattach options fit the file budget * test(e2e): with the switch on, the mount-authority spec keeps the window's bindings, which only main's frames write Claude-Session: W5b * test(e2e): the mount-authority spec fits its line budget; the layout-owner build check is one helper Claude-Session: W5b * test(layout): an unbound pane holding a resume record starts and keeps the record, since main's start resumes from it Claude-Session: W5b * fix(terminal): a pane main resumed holds a running agent's record, so it reads awake, not sleeping (switch-on builds only) Claude-Session: W5b * fix(terminal): in a split where no pane owns a numbered record, main resumes the tab's one conversation in pane 1 only (switch-on builds only) Claude-Session: W5b * fix(terminal): main marks only the record a resume started from live, never a sleep captured after it (switch-on builds only) Claude-Session: W5b * test(terminal): with the switch on, a windowless resume leaves the pane's record a running agent's Claude-Session: W5b * test(terminal): the resumed-record test double typechecks Claude-Session: W5b * refactor(terminal): with the switch off, main's pane start reads no resume record for the live mark Claude-Session: W5b * fix(terminal): main publishes whether its start of a pane resumed the agent, for the window's banner (switch-on builds only) Claude-Session: W5b * fix(terminal): a pane main started shows its "session restored" or "resume unavailable" banner again (switch-on builds only) Claude-Session: W5b * test(terminal): the resume-banner store double carries no type assertion Claude-Session: W5b * fix(terminal): main records a resume outcome only when its start wakes the pane's own sleeping record, and each new start clears the old one (switch-on builds only) Claude-Session: W5b * fix(terminal): a renderer reload shows no resume banner again for a pane main started, and the window stops waiting once that pane holds another terminal (switch-on builds only) Claude-Session: W5b * refactor(terminal): the merged files fit their line budget: the folder-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 * fix(terminal): main's resume outcome arrives in the same frame as the terminal it names, a same-id respawn included (switch-on builds only) Claude-Session: W5b * fix(terminal): the reopened-terminals toast counts agent sessions main resumed again (switch-on builds only) Claude-Session: W5b * refactor(terminal): the attach's resume check names the window's resume type Claude-Session: W5b * test(terminal): pin the resume outcome's wire contract: an outcome alone rebinds nothing, it shows once per start, and no saved session holds it Claude-Session: W5b * refactor(runtime): the window's layout apply fits the runtime's line budget after the main merge Claude-Session: W5b * test(terminal): any create through main that wakes a pane's record publishes its outcome, and the sidebar resume keeps its restored banner (switch-on builds) Claude-Session: W5b * refactor(runtime): the layout stream takes main's pane facts from one source, keeping the runtime in its line budget Claude-Session: W5b * fix(terminal): a relaunch resume into a pane kept under its saved terminal id shows its banner again, and a start whose bind fails leaves no outcome (switch-on builds only) Claude-Session: W5b * fix(terminal): the reopen toast counts only a resume main made for the attached terminal since the attach began, and the banner reads main's outcome once at attach (switch-on builds only) Claude-Session: W5b * test(terminal): two pane test stores carry main's resume outcomes, which every attach now reads Claude-Session: W5b * test(terminal): the hidden-output repro's test store carries main's resume outcomes Claude-Session: W5b * fix(terminal): an SSH same-id resume whose bind writes nothing new keeps its banner, and a start that lost its pane leaves the winner's outcome (switch-on builds only) Claude-Session: W5b
ELI5
This is groundwork for the layout rewrite and stays switched off in every build that ships. With the switch on, the main process now decides when a terminal tab or pane is created or closed and starts the terminal itself. The window no longer makes those calls and reports them back. Users see no change today.
What Changed
All of this happens only with the layout-owner build switch (
ORCA_LAYOUT_OWNER=main) on:retireTerminalSurfaceFromPersistence). Kept: a failed process (its "Terminal exited" card stays), a brand-new pane that dies before anyone uses it (a split only while on screen, a tab's last pane always), and a negative exit code nothing vouches for. A negative code closes only when a stop was asked for or the host confirmed the death; a raw-1from the terminal provider can mean a closed socket, and the shipped window keeps every negative exit. A kept pane sends the phone no retirement notice.failedstatus with the reason, whether the failure came before or after the pane was written. The window no longer receives the start to retry (owner-visible row 15). The kept pane counts as the workspace's terminal, so no extra shell opens next to it.status(startingorfailed) and a reason. It is live state that is never saved, and it rides the pane's binding record. It lasts only while the binding it was first published with stands; any later bind ends it, including a same-id respawn, since every bind raises the pane's generation.tab_closed) on every way a pane is written. The check sits inapplyToSession(terminal-pane-admission.ts), which every pane write goes through:applyCommandToSession(a client'slayout.apply, and the renderer shutdown checkpoint),admitPaneToSession(Store.admitTerminalPane, the terminals main starts itself) andwithdrawPaneFromSession, all reached through terminal-topology-commit.ts. So a paired desktop'sterminal.createretried after another client closed the tab is refused before anything spawns, and the caller getstab_closed. The held-id checks (tab_exists,pane_in_other_tab) stay on the client-command path only: a paired host legitimately starts each pane of a client's tab as a create under that tab's id, and refusing it there stopped the second pane of a split. Pane creates are not refused: a create lifts the closed-pane fence by design (A pane closed while its terminal starts stays closed (dark, layout-owner build only) #30560).automaticflag on pane closes is removed. Main now closes exited panes itself, so every close the window sends is the user's.Bugs fixed with the switch on, found by running every main-process runtime and persistence test with the switch on against main: default tabs lost their title and colour on the phone and in the window; an exited pane closed through the layout model mishandled shared terminals and
-1exits; a create replayed after a close brought the tab back.Why
Under the final design, main is the only process that changes the layout, with or without a window. Each of these was a place where the window still made the decision and main learned about it afterwards. That is what lets a closed tab come back, or a failed pane disappear, when no window is open. Starting the failed pane in main, instead of handing the start back to the window, keeps a single implementation. The alternative was to keep the window hand-off for the windowed case and add a separate no-window path, which would mean two implementations to keep in sync. The exit rule only decides "keep" and falls back to the shipped retirement, rather than closing through the layout model, so a pane main does not keep goes exactly where it goes today.
Linked Issue
N/A (internal design work).
Visual Proof
N/A: switched off in every shipped build, so nothing a user sees changes. With the switch on, the behaviour is covered by the unit tests below.
Testing
ci-static-gate(typecheck, the type-aware oxlint baseline, code-quality, layout-writer and max-lines ratchets, census, routing, stub and import-closure tests) passes.Every test under
src/main/runtimeandsrc/main/persistence(about 16,300), at this head and at main, in both builds:returns the exact pre-minted leaf for concurrent renderer-backed splits(tracked for D1b) and two tmp-path tests that fail on macOS.New tests fail on main and pass on this branch: the exit rule (kept card, unvouched
-1kept, requested stop and host-confirmed-1close, no phone retirement for a kept pane), default tabs, a paired desktop's create replayed after a close (no spawn, no tab,tab_closed; a retry before any close returns the same terminal), the closed-tab guard on both pane write paths, a failed start keeping its pane, start status in the published layout, and a close that survives a real failed profile write.Switch-on tests that asserted the window hand-off or the window rename now assert the same outcome through main's layout and start status (owner-visible row 15): the setup and agent failed-start tests in orca-runtime and runtime-local-worktree-terminal-startup, the default-tab tests, and the unclaimed daemon-wide
-1in terminal-intentional-stop-exit (the pane is kept, as the window keeps it).Switch-off bundle diff: renderer and preload are identical apart from the embedded build commit. Main differs only in the changes listed under Notes.
Latency, layout oracle e2e in a hidden window, Apple M5 Pro, 40 samples per condition, median of 3 runs at 6b8c37f, p95 drawn time switch on minus off (idle / output flood / title flood): split -1 / -1 / +2 ms; new tab -24 to -43 ms; rename +3 / +2 / -1 ms. Not gate operations: close tab +2 / +9 / +17 ms, close pane +5 / +5 / +12 ms; where that time goes is being investigated separately.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
One independent review per head, plus a review of each fix delta.
Agent skill upstream boundary
Notes
Switch-off main bundle changes (renderer and preload are identical). Each either cannot be reached with the switch off or gives the same result:
closedCreatereturns null when the switch is off (terminal-pane-admission.ts,if (!ORCA_LAYOUT_OWNER_IS_MAIN) return null). A switch-off test closes a tab as the user and then creates the same tab id through bothlayout.applyand the runtime admission; both are written, as on main (the test passes unchanged on main).spawnInAdmittedPanesurfacestab_closed, which cannot occur switch-off; every other refusal keepsterminal_split_source_not_found. ItsstartStatusis undefined switch-off, so it takes its existing path with the same spawn args.stageTerminalSurfaceRetirementsandretireMobileSessionSurfacesForPtytake anexitargument passed asundefined; the keep branch is gated on the switch, sokeptis always empty and every retirement proof is sent as before.onPtyExitnamesstopRequestedand computes an unused expression.LayoutCommandPersistencegets a third argument that isundefined; its only reader is gated on the switch.createTerminalpasses through a new runtime layer (failed-start-pane.ts). With the switch off it returnssuper.createTerminal(...)directly. It is not async, so it adds no await.|| false,&& true). A launch error still throws before the create.paneStartFact) is never called with the switch off.layout.applyschema acceptsapplyDefaultTabsand dropsautomatic, andmarkAgentLaunchesClosedByUsernow runs for every closePane.layout.applyis registered only in a layout-owner build.SSH: closes and refusals use the partition of the host that owns the workspace. The exit rule skips workspaces served by a paired server, and an SSH
-1the host did not confirm is kept before the rule runs. Folder workspaces get the same failed-start handling as git worktrees.Visible with the switch on, compared with the shipped (switch-off) build:
failedwith the reason. The window doesn't draw that status until D1b, so in this PR the window mounts the empty pane as it would any unbound pane and starts a plain shell in it. The user sees a shell tab where the agent would have been, with no failure message. This comes from reading the code; I have not run it in the app.-1nothing vouches for keeps the pane, and everything else is retired as main does today.Senders of pane creates, and whether any replays one it already sent:
layout.applycreateTerminalTabtab_exists/tab_closedlayout.applycreateTerminalTab (initial)layout.applysplitPanenewLeafId: the same split changes nothinglayout.applysplitPanenewLeafIdterminal.createtab_closedafter a closesession.tabs.createTerminalclientMutationId, 60 s result cachesession.tabs.createTerminal,terminal.splitterminal.create,terminal.splitChecklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)