Skip to content

Layout groundwork (switched off): main tells the window whether its start resumed a pane's agent, so the restored banner and reopen count come back - #31908

Merged
Jinwoo-H merged 97 commits into
mainfrom
fd/l251-resume-outcome
Oct 22, 2026
Merged

Jinwoo-H merged 97 commits into
mainfrom
fd/l251-resume-outcome

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​897 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​879
Prod 28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​480 $\color{#cf222e}{\Huge{\mathbf{−}}}$​114 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​366

ELI5

In the build where the main process owns terminal layouts (switched off by default), main is the one that restarts a sleeping agent's terminal. The window used to be the one that knew whether the agent's session came back, and it showed a "session restored" or "resume unavailable" banner. Once main does the restart, the window no longer knows, so the banner and the "N agent sessions resumed." count disappeared. With this change, main tells the window what happened.

What Changed

Before (switch-on builds only):

  • A pane that main woke from its sleeping record showed no "session restored" or "resume unavailable" banner.
  • After reopening held panes, the toast didn't count agent sessions that main resumed.

After:

  • Main records the result of its start, restored or resume-unavailable, but only when that start wakes the pane's own sleeping record (resumesSleepingRecord).
  • The result is pinned to the terminal binding the start produces (terminal id plus binding generation). It's published on the pane's binding record in the layout stream, as an optional resumeOutcome field.
  • The spawn reports the result before the bind is written, so it arrives in the same frame as the new terminal.
  • The window shows the banner once per terminal binding. The reopen toast counts only a restored result for the terminal it attached to, recorded since that attach began.

Mechanism:

  • PaneLiveFacts is a new generic base for main's live, per-pane facts that are never saved. Start statuses and resume outcomes both use it.
  • A new start clears the old outcome. A start that fails after reporting also clears it, unless it lost the pane to another owner.
  • If the bind writes nothing new (an SSH same-id rebind that takes the fast lane), the outcome is pinned to the binding the pane already shows.
  • A resume dropped silently because it named another agent's session shows no banner. Nothing came back, and nothing is owed. This matches today's window path, which drops it without a notice.

Why

  • The outcome rides the binding record because a start always ends in a binding or a failure. The banner then appears exactly when the window attaches, with no extra request and no ordering race between a separate message and the frame.
  • The alternative was to return the outcome in the spawn reply. Only the caller that asked for the start would see it. A second window, or a view that attaches later, would miss it.
  • The next PR in this series (window-tab terminal.create) will send resumesSleepingRecord as an explicit optional parameter. This PR leaves that hook in place.

Linked Issue

Internal refactor (layout-owner series), no issue.

Visual Proof

N/A. The change is switched off in every shipped build. With the switch on, it restores the existing banners and toast count (no new copy).

Testing

Switch-off: no behaviour change. These hunks run with the switch off:

  • spawn-preflight.ts: sets ctx.codexResumeUnavailable, which is read only with the switch on.
  • spawn-commit.ts: calls reportRuntimeResumeOutcome, which returns early with the switch off.
  • reattach-result-handler.ts: calls showMainPaneResumeOutcome, which returns when mainStartsPane is false.
  • deferred-session-reattach-connect.ts: attachResumeCheck gives the same result as before with the switch off.
  • workspace-layout-frame-sync.ts: uses framePaneFactsShown(), a shape-only change.
  • Renderer store: initializes an empty terminalPaneResumeOutcomesByPaneKey.
  • splitPublishedLayout: copies resumeOutcome, which is never set with the switch off.
  • orca-runtime.ts: passes paneFactSources, which the stream reads only with the switch on.
  • terminal-surface-index.ts: changes only an import path.

Wire compatibility: resumeOutcome is a new optional field. Older peers ignore it, and older hosts never send it.

Server specs: 4/4 pass at the head and at the merge base, on fresh switch-on builds: paired-mobile-desktop-tab-composition, paired-desktop-server-layout-frames, headless-serve-focused-terminal-create and live-background-terminal-mount-authority.

Per-test switch-on comparison (renderer terminal-pane, runtime, store and lib; main ipc, runtime and terminal-topology; shared; preload):

  • 56,433 tests at the base and 56,467 at the head.
  • No new failures from this change. One test (filesystem-watcher-real aliased root) failed only in the head run. It touches nothing here, and rerun alone it fails at both the base and the head on this machine.

Switch-off run of the touched suites (971 files):

  • 9,052 tests pass.
  • Two files fail, both outside this change's path:
    • remote-snapshot-alt-screen-host-chain times out in setup, the same as with the switch on.
    • terminal-tail-redraw-wall-time is a wall-time test that passes on its own.
  • The machine's load average was about 55 during the run.

Wire contract for resumeOutcome: each condition is pinned by a test.

  1. An outcome alone rebinds nothing: workspace-layout-frame-binding.test.ts.
  2. It shows once per start, meaning once per terminal binding: main-pane-resume-banner.test.ts and pane-resume-outcome-layout-owner.test.ts.
  3. No saved session holds it: workspace-session-resume-outcome.test.ts.
  4. It is recorded only when main's start wakes the pane's own sleeping record: orca-runtime-resume-outcome-layout-owner.test.ts and sleeping-agent-session-launch-layout-owner.test.ts.
  5. It is pinned to the binding the start produces, a same-id respawn included: pane-live-facts.test.ts.

Unit tests: new tests cover the outcome contract, the pin to the binding (including a same-id respawn, a never-bound relaunch and a fast-lane rebind), clearing on a failed start, the contention winner keeping its outcome, show-once, the toast count, and the switch-on branches of pty-connection-sleeping-resume-banner.spec.ts. Each behaviour test fails without its change.

Static checks: the CI static-analysis steps and pnpm tc pass locally.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

  • An independent review of the full diff was done, plus a review of each fix round. The last round's verdict was ship.
  • Known edge cases left as follow-ups:
    • The re-pin, and the contention-skip of the clear, act on whatever entry the pane holds. A compare-and-swap would close interleavings of two starts on one pane.
    • A re-pinned outcome shares its banner key with an earlier banner on the same binding.
    • A newer-daemon hold that releases after main resumed the pane on its own can undercount the toast.

Agent skill upstream boundary

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

Notes

  • SSH: covered, including the fast-lane rebind for relay terminals that have no incarnation id.
  • Mobile and remote: the field is optional and older peers ignore it.
  • Cross-platform: no platform-specific code.
  • Performance: at most one small entry per pane.

Checklist

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

…yout-owner build)

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

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

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

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

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

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

This reverts commit 420e605.
…rite joins that start, not a second one (layout-owner build only)
…y await, and a failed start with its reason; startPane starts a pane whose bound terminal ended (layout-owner build only)
…esume record for the live mark

Claude-Session: W5b
… agent, for the window's banner (switch-on builds only)

Claude-Session: W5b
…esume unavailable" banner again (switch-on builds only)

Claude-Session: W5b
…s the pane's own sleeping record, and each new start clears the old one (switch-on builds only)

Claude-Session: W5b
…c-restore-view-attach

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

Claude-Session: W5b
…ane main started, and the window stops waiting once that pane holds another terminal (switch-on builds only)

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

Claude-Session: W5b
… terminal it names, a same-id respawn included (switch-on builds only)

Claude-Session: W5b
…n resumed again (switch-on builds only)

Claude-Session: W5b
…one rebinds nothing, it shows once per start, and no saved session holds it

Claude-Session: W5b
…tore-view-attach

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

Claude-Session: W5b
…budget after the main merge

Claude-Session: W5b
…blishes its outcome, and the sidebar resume keeps its restored banner (switch-on builds)

Claude-Session: W5b
… source, keeping the runtime in its line budget

Claude-Session: W5b
…minal id shows its banner again, and a start whose bind fails leaves no outcome (switch-on builds only)

Claude-Session: W5b
…e attached terminal since the attach began, and the banner reads main's outcome once at attach (switch-on builds only)

Claude-Session: W5b
…ich every attach now reads

Claude-Session: W5b
…eps its banner, and a start that lost its pane leaves the winner's outcome (switch-on builds only)

Claude-Session: W5b
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds main-process reporting for restored and unavailable resume outcomes. It stores those outcomes as live pane facts tied to terminal bindings, publishes them through layout frames, and records them in renderer state. Renderer attach and reattach flows use the outcomes for resume checks, banners, and reopened-terminal toast descriptions. Tests cover outcome capture, binding behavior, frame updates, and renderer handling.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 165dc

With this feature enabled, some resume banners can repeat or disappear, and a start without a resume command can be reported as restored. These bounded issues warrant fixes or explicit acceptance before enabling the feature.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 43.90% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 44 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: main reports pane resume outcomes so the window can restore the existing banner and reopen count. It is somewhat long but remains specific and relevant.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description is complete and follows the repository template. It explains the change, user impact, rationale, linked-issue context, visual-proof status, testing, compatibility, known l…
Full details: Description check

Explanation

The pull request description is complete and follows the repository template. It explains the change, user impact, rationale, linked-issue context, visual-proof status, testing, compatibility, known limitations, and checklist results.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 99763eb8-2610-4a5e-a923-765443c13de9
📥 Commits

Reviewing files that changed from the base of the PR and between 2078db9 and 165dc2a.

📒 Files selected for processing: 44
  • src/main/ipc/pty/runtime/spawn-commit-response.test.ts
  • src/main/ipc/pty/runtime/spawn-commit-response.ts
  • src/main/ipc/pty/runtime/spawn-commit.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/ipc/pty/runtime/spawn-state.ts
  • src/main/runtime/orca-runtime-layout-owner-start-fixture.ts
  • src/main/runtime/orca-runtime-resume-outcome-layout-owner.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/pane-live-facts.test.ts
  • src/main/runtime/pane-live-facts.ts
  • src/main/runtime/pane-resume-outcome-layout-owner.test.ts
  • src/main/runtime/pane-start-statuses.test.ts
  • src/main/runtime/pane-start-statuses.ts
  • src/main/runtime/runtime-pane-admission.ts
  • src/main/runtime/runtime-pty-controller-contract.ts
  • src/main/runtime/runtime-terminal-contracts.ts
  • src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts
  • src/main/runtime/terminal/launch/failed-start-pane.ts
  • src/main/runtime/terminal/launch/mobile-terminal-owned-create.ts
  • src/main/runtime/terminal/surface/terminal-surface-index.ts
  • src/main/runtime/workspace-layout-stream.ts
  • src/renderer/src/components/terminal-pane/fish-color-scheme-child-stdin.node-pty.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-sleeping-resume-banner.spec.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-main-pane-start-fixtures.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-store-fixtures.ts
  • src/renderer/src/components/terminal-pane/pty-connection-test-store-state.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.ts
  • src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-newer-daemon-hold.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/main-pane-resume-banner.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/main-pane-resume-banner.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler-park-reveal-verdict.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts
  • src/renderer/src/components/terminal-pane/remote-hidden-output-restore-outcomes.test.ts
  • src/renderer/src/components/terminal-pane/remote-hidden-output-restore-unavailable-banner.repro.test.ts
  • src/renderer/src/lib/sleeping-agent-session-launch-layout-owner.test.ts
  • src/renderer/src/lib/workspace-session-resume-outcome.test.ts
  • src/renderer/src/runtime/workspace-layout-frame-binding.test.ts
  • src/renderer/src/runtime/workspace-layout-frame-pane-resume-outcomes.test.ts
  • src/renderer/src/runtime/workspace-layout-frame-pane-starts.ts
  • src/renderer/src/runtime/workspace-layout-frame-sync.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/store/terminals/terminal-state.ts
  • src/shared/workspace-layout/workspace-layout-published.ts
  • src/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; 7 remain after this review.

return 'resume-unavailable'
}
// A resume dropped silently named another agent's session: nothing came back, and nothing is owed.
return ctx.codexResumeArgvDropped ? null : 'restored'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect launch planning and sleeping-record callers; do not execute repository code.
rg -n -C 6 -g '*.ts' \
  '\bresolvePaneOwnedResumeStartup\s*\(|\bresolvePtySpawnHostEnv\s*\(|\bresumeProviderSession\b' \
  src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts \
  src/main/runtime/runtime-pane-admission.ts \
  src/main/ipc/pty/runtime

Repository: stablyai/orca

Length of output: 12350


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- declarations and references ---'
rg -n -F --glob '*.ts' \
  -e 'resolvePaneOwnedResumeStartup' \
  -e 'function resolvePtySpawnHostEnv' \
  -e 'const resolvePtySpawnHostEnv' \
  -e 'resolvePtySpawnHostEnv =' \
  -e 'codexResumeArgvDropped' \
  src/main/runtime src/main/ipc/pty src/main | head -240

printf '%s\n' '--- restored materialization ---'
sed -n '120,225p' src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts

printf '%s\n' '--- host environment resolver ---'
rg -l -F --glob '*.ts' 'resolvePtySpawnHostEnv' src/main | while read -r f; do
  echo "FILE $f"
  rg -n -C 8 -F -- 'resolvePtySpawnHostEnv' "$f"
done

printf '%s\n' '--- spawn preflight and commit relevant blocks ---'
sed -n '1,175p' src/main/ipc/pty/runtime/spawn-preflight.ts
sed -n '1,310p' src/main/ipc/pty/runtime/spawn-commit.ts

Repository: stablyai/orca

Length of output: 31916


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- exact resolver definitions ---'
rg -n -F --glob '*.ts' \
  -e 'resolvePaneOwnedResumeStartup' \
  -e 'resolvePtySpawnHostEnv' \
  -e 'codexResumeArgvDropped' \
  src/main/runtime src/main/ipc/pty | head -320

printf '%s\n' '--- materialization logical block ---'
sed -n '145,220p' src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts

printf '%s\n' '--- all resolver owners ---'
for f in $(rg -l -F --glob '*.ts' 'resolvePaneOwnedResumeStartup' src/main); do
  echo "FILE $f"
  sed -n '1,260p' "$f" | rg -n -C 18 -F -- 'resolvePaneOwnedResumeStartup'
done

printf '%s\n' '--- host-env call and definition candidates ---'
for f in $(rg -l -F --glob '*.ts' 'resolvePtySpawnHostEnv' src/main); do
  echo "FILE $f"
  rg -n -C 25 -F -- 'resolvePtySpawnHostEnv' "$f"
done

Repository: stablyai/orca

Length of output: 21397


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- pane-owned resume resolver ---'
sed -n '145,255p' src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts

printf '%s\n' '--- host environment resolver complete ---'
sed -n '1,230p' src/main/ipc/pty/spawn-host-env.ts

printf '%s\n' '--- resume launch contracts and implementations ---'
rg -n -F --glob '*.ts' \
  -e 'resolveCodexResumeLaunch' \
  -e 'prepareCodexResumeHome' \
  -e 'noCodexResumeLaunch' \
  -e 'stripSequencedStartupResumeArgv' \
  src/main | head -240

Repository: stablyai/orca

Length of output: 20181


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- Codex resume launch implementation ---'
sed -n '1,155p' src/main/ipc/pty/host-env/codex-resume.ts

printf '%s\n' '--- mobile resume command declarations and producer ---'
rg -n -F --glob '*.ts' \
  -e 'resolveMobileSessionResumeCommand' \
  -e 'MobileTerminalResumeCommand' \
  -e 'AgentProviderSessionMetadata' \
  src/main src/shared | head -260

printf '%s\n' '--- producer definitions ---'
for f in $(rg -l -F --glob '*.ts' 'resolveMobileSessionResumeCommand' src/main); do
  echo "FILE $f"
  rg -n -C 35 -F -- 'resolveMobileSessionResumeCommand' "$f"
done

Repository: stablyai/orca

Length of output: 26452


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- production resume metadata assignments and spawn entrypoints ---'
rg -n -C 8 -F --glob '*.ts' \
  -e 'resumeProviderSession:' \
  -e 'resumeProviderSession?' \
  -e 'createRuntimeOwnedMobileSessionTerminal' \
  -e 'RuntimePtySpawnArgs' \
  src/main src/shared | head -420

printf '%s\n' '--- mobile terminal create and owned-create contracts ---'
sed -n '1,190p' src/main/runtime/terminal/launch/mobile-terminal-create.ts
sed -n '1,150p' src/main/runtime/terminal/launch/mobile-terminal-owned-create.ts
sed -n '1,115p' src/main/ipc/pty/ipc/spawn-types.ts

Repository: stablyai/orca

Length of output: 41741


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- launch command through spawn execution ---'
rg -n -C 10 -F --glob '*.ts' \
  -e 'ctx.launchCommand' \
  -e 'launchCommand' \
  -e 'command: args.command' \
  -e 'command: ctx' \
  -e 'provider.spawn' \
  src/main/ipc/pty | head -320

printf '%s\n' '--- PTY provider command contract and default handling ---'
rg -n -C 12 -F --glob '*.ts' \
  -e 'command?: string' \
  -e 'command: string | undefined' \
  -e 'command ??' \
  -e 'spawn(args' \
  -e 'spawn(options' \
  src/main/providers src/main/ipc/pty src/main | head -360

printf '%s\n' '--- relevant no-command IPC test body ---'
sed -n '220,280p' src/main/ipc/pty-spawn-codex-home-unavailable.test.ts

Repository: stablyai/orca

Length of output: 41763


Do not report restored without an actual resume launch.

The pty:spawn contract allows resumeProviderSession without command. resolveCodexResumeLaunch preserves command: undefined, and assemblePtySpawnLaunchOptions omits spawnOptions.command. The PTY then starts without a resume command, but resumeOutcomeOf still returns restored because the metadata exists and codexResumeArgvDropped is false.

The sleeping-record path supplies a required command, but the broader PTY spawn path does not. Require an actual resume launch before reporting restored.

Comment on lines +171 to +189
startStatus?.resumeOutcomes?.clear(paneKey)
const resumeOutcomes = startStatus?.resumesSleepingRecord ? startStatus.resumeOutcomes : undefined
// A pane never bound in this process is at 0: every bind here is numbered from 1.
const generationNow = (): number | undefined =>
store?.getPtyBindingGeneration
? (store.getPtyBindingGeneration(
normalizeExecutionHostId(hostIdOf(args)) ?? LOCAL_EXECUTION_HOST_ID,
args.leafId
) ?? 0)
: undefined
const afterGeneration = resumeOutcomes ? generationNow() : undefined
let reported: { ptyId: string; outcome: PaneResumeOutcome } | undefined
if (resumeOutcomes) {
// Why the generation now: a respawn may keep the terminal id, so only a later bind is this one.
spawnArgs.onResumeOutcome = (ptyId, outcome) => {
reported = { ptyId, outcome }
resumeOutcomes.set(paneKey, outcome, { ptyId, afterGeneration })
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '135,255p' src/main/runtime/runtime-pane-admission.ts
rg -n 'PaneOwnerContentionError|spawnInAdmittedPane|getPtyBindingGeneration' src/main/runtime

Repository: stablyai/orca

Length of output: 9978


🏁 Script executed:

set -e
printf '%s\n' '--- runtime-pane-admission imports and admission definitions ---'
sed -n '1,170p' src/main/runtime/runtime-pane-admission.ts
printf '%s\n' '--- resume outcome definitions/usages ---'
rg -n -F --glob '*.ts' -e 'class PaneResumeOutcomes' -e 'type PaneResumeOutcome' -e 'interface PaneResumeOutcomes' -e 'resumeOutcomes' -e 'resumesSleepingRecord' src
printf '%s\n' '--- relevant tests ---'
sed -n '1,250p' src/main/runtime/pane-start-statuses.test.ts
sed -n '1,240p' src/main/runtime/pane-live-facts.test.ts
printf '%s\n' '--- direct callers ---'
sed -n '80,145p' src/main/runtime/terminal/launch/terminal-create.ts
sed -n '40,125p' src/main/runtime/terminal/launch/terminal-split-surface.ts
sed -n '80,125p' src/main/runtime/terminal/launch/terminal-split-in-main.ts
printf '%s\n' '--- changed diff ---'
git diff --no-ext-diff --unified=80 ed13ca1e6f6085b23d6892627ea969f7119c5b82 165dc2acf50bdf8de8ccddf82688baf17913929b -- src/main/runtime/runtime-pane-admission.ts src/main/runtime/pane-start-statuses.test.ts src/main/runtime/pane-live-facts.test.ts

Repository: stablyai/orca

Length of output: 41847


🏁 Script executed:

set -e
printf '%s\n' '--- admission implementations and callers ---'
rg -n -F --glob '*.ts' -e 'admitTerminalPane' -e 'getPtyBindingGeneration' src/main src/shared
printf '%s\n' '--- outcome/fact implementation ---'
sed -n '1,220p' src/main/runtime/pane-start-statuses.ts
sed -n '1,240p' src/main/runtime/pane-live-facts.ts
printf '%s\n' '--- renderer outcome consumption ---'
sed -n '1,190p' src/renderer/src/runtime/workspace-layout-frame-pane-starts.ts
rg -n -F --glob '*.ts' -e 'resumeOutcome' -e 'resumeOutcomes' src/renderer src/main | head -160
printf '%s\n' '--- complete caller blocks ---'
sed -n '90,145p' src/main/runtime/terminal/launch/terminal-create.ts
sed -n '95,140p' src/main/runtime/terminal/launch/terminal-split-in-main.ts
sed -n '90,145p' src/main/runtime/terminal/launch/failed-start-pane.ts
printf '%s\n' '--- generation implementation context ---'
rg -n -F --glob '*.ts' -e 'ptyBindingGeneration' -e 'bindingGeneration' src/main | head -160

Repository: stablyai/orca

Length of output: 28685


🏁 Script executed:

set -e
printf '%s\n' '--- concrete admission and scheduling ---'
sed -n '220,330p' src/main/persistence/loading-store/pty-binding-persistence.ts
sed -n '1,125p' src/main/persistence/loading-store/write-scheduling.ts
sed -n '1,130p' src/main/persistence/terminal-topology/layout-command-binding-generations.ts
rg -n -F --glob '*.ts' -e 'withRuntimePaneAdmission' -e 'PaneOwnerContentionError' -e 'terminal_pane_owner_changed' src/main
printf '%s\n' '--- pane owner claim/arbitration ---'
rg -n -F --glob '*.ts' -e 'claimPane' -e 'ownerChanged' -e 'owner changed' -e 'pane owner' src/main/ipc src/main/persistence | head -200
sed -n '1,260p' src/main/ipc/pty/pane/pane-spawn-operation.ts
printf '%s\n' '--- restored-pane launch path ---'
sed -n '170,235p' src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts
sed -n '90,145p' src/main/runtime/terminal/launch/failed-start-pane.ts
rg -n -F --glob '*.ts' -e 'ensureRestoredPaneStarted' -e 'resumesSleepingRecord' src/main/runtime src/main | head -120
printf '%s\n' '--- concurrency and contention tests ---'
sed -n '110,180p' src/main/ipc/pty-pane-claim-arbitration.test.ts
sed -n '450,525p' src/main/ipc/pty-pane-claim-arbitration.test.ts

Repository: stablyai/orca

Length of output: 40030


🏁 Script executed:

set -e
printf '%s\n' '--- admitPane implementation and durable mutation runner ---'
rg -n -F --glob '*.ts' -e 'function admitPane' -e 'const admitPane' -e 'runDurableMutation' src/main/persistence
sed -n '1,240p' src/main/persistence/terminal-topology/terminal-pane-admission.ts
rg -n -F --glob '*.ts' -e 'async runDurableMutation' -e 'runDurableMutation<' -e 'runDurableMutation(' src/main/persistence/loading-store src/main/persistence/terminal-topology | head -120
printf '%s\n' '--- pane spawn contention checks ---'
sed -n '1,125p' src/main/ipc/pty/runtime/spawn-execute.ts
sed -n '130,215p' src/main/ipc/pty/runtime/spawn-commit.ts
sed -n '285,330p' src/main/ipc/pty/runtime/spawn-commit.ts
sed -n '1,125p' src/main/ipc/pty/ipc/spawn-commit-persist.ts
printf '%s\n' '--- pane start invocation and overlap guards ---'
sed -n '1,135p' src/main/runtime/session-lifecycle/projection/restored-pane-materialize.ts
sed -n '170,220p' src/main/runtime/session-lifecycle/projection/perform-mobile-session-pty-records-refresh.ts
rg -n -F --glob '*.ts' -e 'ensureRestoredPaneStarted' -e 'startedPane' -e 'starting' src/main/runtime/session-lifecycle src/main/runtime/terminal | head -160

Repository: stablyai/orca

Length of output: 42121


🏁 Script executed:

set -e
printf '%s\n' '--- restored starter implementation ---'
sed -n '1,180p' src/main/runtime/terminal/recovery/restored-pane-start.ts
printf '%s\n' '--- durable mutation implementation ---'
sed -n '1,115p' src/main/persistence/loading-store/primary-state-writes.ts
sed -n '1,150p' src/main/persistence/loading-store/store.ts
printf '%s\n' '--- mobile terminal spawn option propagation ---'
sed -n '1,190p' src/main/runtime/terminal/launch/mobile-terminal-owned-create.ts
sed -n '1,180p' src/main/runtime/terminal/launch/failed-start-pane.ts
printf '%s\n' '--- all spawnInAdmittedPane call contexts ---'
rg -n -F --glob '*.ts' 'spawnInAdmittedPane(' src/main/runtime

Repository: stablyai/orca

Length of output: 33918


🏁 Script executed:

set -e
printf '%s\n' '--- exact second-start caller ---'
nl -ba src/main/runtime/terminal/launch/failed-start-pane.ts | sed -n '132,175p'
nl -ba src/main/runtime/terminal/launch/failed-start-pane.ts | sed -n '180,215p'
printf '%s\n' '--- exact contention path ---'
nl -ba src/main/ipc/pty/runtime/spawn-commit.ts | sed -n '292,323p'
nl -ba src/main/ipc/pty/runtime/spawn-execute.ts | sed -n '45,70p'
printf '%s\n' '--- exact clear, generation, and outcome publication ---'
nl -ba src/main/runtime/runtime-pane-admission.ts | sed -n '165,192p'
nl -ba src/main/runtime/runtime-pane-admission.ts | sed -n '214,250p'
nl -ba src/main/persistence/loading-store/primary-state-writes.ts | sed -n '48,72p'

Repository: stablyai/orca

Length of output: 10770


🏁 Script executed:

set -e
printf '%s\n' '--- callers of the existing-pane window start ---'
rg -n -F --glob '*.ts' 'startWindowTabTerminal(' src
printf '%s\n' '--- outcome state consumers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'terminalPaneResumeOutcomesByPaneKey' -e 'resumeOutcome' src/renderer/src | head -240

Repository: stablyai/orca

Length of output: 6686


Preserve the incumbent resume outcome when an existing-pane start loses ownership.

startWindowTabTerminal can start a pane that main already owns. The current code clears that pane's outcome before the asynchronous admission. If the incumbent binding wins before the new spawn persists, persistFreshPaneBinding throws PaneOwnerContentionError. The contention handler skips its later clear, but the incumbent outcome was already deleted. The renderer then removes the resume outcome, so the resume banner is lost.

Move the general clear to successful or non-contention completion. Keep a reported outcome when the spawn produced one.

Suggested fix
   let admittedAs: TerminalPaneAdmissionOutcome | undefined
   startStatus?.sink.set(paneKey, { status: 'starting' })
-  startStatus?.resumeOutcomes?.clear(paneKey)
   const resumeOutcomes = startStatus?.resumesSleepingRecord ? startStatus.resumeOutcomes : undefined
@@
     // lost the pane to another owner leaves the winner's outcome alone.
     if (!(error instanceof PaneOwnerContentionError)) {
-      resumeOutcomes?.clear(paneKey)
+      startStatus?.resumeOutcomes?.clear(paneKey)
     }
@@
   if (elsewhere) {
-    resumeOutcomes?.clear(paneKey)
+    startStatus?.resumeOutcomes?.clear(paneKey)
   } else if (reported && afterGeneration !== undefined && generationNow() === afterGeneration) {
     // A bind that matched the pane's existing one (an SSH relay's same-id reattach) writes and
     // publishes nothing new: the outcome holds for the binding the pane already shows.
     resumeOutcomes?.set(paneKey, reported.outcome, { ptyId: reported.ptyId })
+  } else if (!reported) {
+    startStatus?.resumeOutcomes?.clear(paneKey)
   }

Comment on lines +37 to +42
const live = new Set(Object.values(outcomes).map(startOf))
try {
globalThis.sessionStorage.setItem(
SHOWN_STARTS_KEY,
JSON.stringify([...shown.filter((key) => live.has(key)), start])
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -u
printf '%s\n' '--- target file ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/main-pane-resume-banner.ts

printf '%s\n' '--- relevant symbols and callers ---'
rg -n -F --glob '*.{ts,tsx}' \
  -e 'showFramePaneStarts' \
  -e 'terminalPaneResumeOutcomesByPaneKey' \
  -e 'source.draws(state)' \
  -e 'noteShown' \
  -e 'showMainPaneResumeOutcome' \
  src/renderer/src || test "$?" -eq 1

printf '%s\n' '--- changed-file diff ---'
git diff --unified=40 ed13ca1e6f6085b23d6892627ea969f7119c5b82..165dc2acf50bdf8de8ccddf82688baf17913929b -- src/renderer/src/components/terminal-pane/pty-connection/main-pane-resume-banner.ts

printf '%s\n' '--- tests mentioning shown starts or reload ---'
rg -n -F --glob '*.{test,spec}.{ts,tsx}' \
  -e 'SHOWN_STARTS_KEY' \
  -e 'shown starts' \
  -e 'sessionStorage' \
  -e 'reload' \
  -e 'showMainPaneResumeOutcome' \
  src/renderer/src || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 41305


🏁 Script executed:

set -u
printf '%s\n' '--- frame pane starts producer ---'
nl -ba src/renderer/src/runtime/workspace-layout-frame-pane-starts.ts | sed -n '1,180p'

printf '%s\n' '--- frame sync draw gating and publication ---'
nl -ba src/renderer/src/runtime/workspace-layout-frame-sync.ts | sed -n '100,225p'

printf '%s\n' '--- focused banner tests ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/main-pane-resume-banner.test.ts | sed -n '1,220p'

printf '%s\n' '--- relevant state reset and layout draw declarations ---'
rg -n -F --glob '*.{ts,tsx}' \
  -e 'terminalPaneResumeOutcomesByPaneKey:' \
  -e 'draws(state)' \
  -e 'function draws' \
  -e 'draws:' \
  src/renderer/src/runtime src/renderer/src/store src/renderer/src | head -200

Repository: stablyai/orca

Length of output: 25828


🏁 Script executed:

nl -ba src/renderer/src/runtime/workspace-layout-frame-pane-starts.ts | sed -n '95,140p'
nl -ba src/renderer/src/runtime/workspace-layout-frame-sync.ts | sed -n '120,215p'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/main-pane-resume-banner.test.ts | sed -n '50,180p'

Repository: stablyai/orca

Length of output: 11964


🏁 Script executed:

nl -ba src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts | sed -n '305,335p'

Repository: stablyai/orca

Length of output: 1294


Do not prune shown starts by the current outcome store.

The frame sync adds a workspace to changed only when drawn(key) is true. An undrawn workspace can therefore be absent from terminalPaneResumeOutcomesByPaneKey. When another pane attaches, noteShown can remove that workspace's previously shown start from session storage. A later reload can then show its banner again.

Keep a bounded history instead of filtering by store membership.

Suggested fix
 const SHOWN_STARTS_KEY = 'orca.mainPaneResumeBannersShown'
+const MAX_SHOWN_STARTS = 500
 /** This document's shown starts, for when session storage is unavailable. */
 const shownHere = new Set<string>()
@@
-function noteShown(start: string, outcomes: Outcomes): boolean {
+function noteShown(start: string): boolean {
   const shown = readShownStarts()
   if (shownHere.has(start) || shown.includes(start)) {
     return false
   }
   shownHere.add(start)
-  const live = new Set(Object.values(outcomes).map(startOf))
   try {
     globalThis.sessionStorage.setItem(
       SHOWN_STARTS_KEY,
-      JSON.stringify([...shown.filter((key) => live.has(key)), start])
+      JSON.stringify([...shown, start].slice(-MAX_SHOWN_STARTS))
     )
@@
-  if (found?.ptyId === ptyId && noteShown(startOf(found), outcomes)) {
+  if (found?.ptyId === ptyId && noteShown(startOf(found))) {

@Jinwoo-H
Jinwoo-H merged commit 4165c95 into main Oct 22, 2026
55 checks passed
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Switch-off per-test comparison, head 165dc2a against base ed13ca1. Same folders as the switch-on comparison.

  • 56,433 tests at base and 56,467 at head; 6 failed at base and 6 at head.
  • Passed at base but failed at head: 0.
  • New tests that fail at head: 0.
  • One test is listed as present only at base: orcad-profile-preflight's readiness test. Its name includes a random value that changes every run, so it is not really missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant