Skip to content

fix(runtime): a cold-restored terminal keeps its agent session without showing the old Done (STA-12043) - #33302

Merged
nwparker merged 3 commits into
mainfrom
nwparker/sta-12043-restored-shell-no-done
Oct 25, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/sta-12043-restored-shell-no-done

Conversation

@nwparker

@nwparker nwparker commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​470 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​466
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​125 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​116

ELI5

If a paired Orca server is stopped together with its terminal daemon and then started again, each terminal comes back as a brand-new shell. The agent that used to run there is gone. Clients kept showing that agent's old "Done" next to the fresh shell. Now the server still tells clients which conversation the pane had, so native chat can find it, but it no longer claims a status.

What Changed

Before: after a cold restore (the process is gone, so a new shell starts in the pane), phone and paired desktop tabs showed Done before anyone typed anything. They showed it whether the pane had no title or a shell title, and whether the old row named its agent or not.

After: those tabs show no status. The provider session still comes through, so mobile and desktop native chat find the conversation. A pane whose process survived the restart (the daemon reattached it) keeps its Done exactly as before.

How it works:

  • TerminalRunFactsRegister (src/main/runtime/terminal-run-facts.ts) now records when main started a pane's process. That covers a spawn, a split or a cold restore. It is stamped when the spawn is requested (spawnRequestedAt on the spawn state), so a fast agent's first hook can never land before it. A process main attached to (reattach or an adopted agent session) has no start time.
  • buildRuntimeMobileAgentStatus checks this first. If every hook row for the pane was received before the current process started, and the PTY shows no agent title status of its own, the rows belong to an earlier run. The host then publishes an identity-only row: restoredUnconfirmed: true, the provider session, and the agent type when known.
    • The row keeps the superseded turn's stateStartedAt and turn-end facts, so a client that saw that turn reads it as a replay, not a new completion.
    • Only updatedAt moves forward, to the process start, so a client's copy of the old Done cannot outrank it.
  • The existing "a newer shell title retires a restored turn" path now publishes the same identity-only row instead of done.
  • The paired renderer (web-session-tabs-sync/store-patch.ts) no longer forwards an unverifiable done to the completion coordinator. A cold restore therefore cannot fire a second "task complete" notification.

Why

  • The wire already has this meaning. restoredUnconfirmed plus the agent-status.restored-unconfirmed.v1 client capability is exactly "keep identity, show no status". Desktop tab and sidebar flags and the mobile tab strip already render it without a glyph, and native chat reads providerSession regardless. Clients without the capability keep receiving today's legacy done through projectRestoredAgentStatusAsLegacyDone. So no new field, opcode or capability was needed.
  • Returning no status was not an option. It would lose the provider session that mobile chat needs to find the conversation.
  • Process start, not title or host boot time, is the evidence. A shell title can't prove an agent isn't running: some shells keep a fixed title while a command runs. Host boot time can't tell a cold restore from a daemon reattach. A process that survived must keep its status, because losing contact is never evidence of an exit. Only "main started this process after the evidence" proves the evidence is about an earlier one.

This is complementary to #32936 (keyed status owner plus root exit-evidence service). That PR scopes STA-12043 out, and its renderer-side exit owner can only clear launchAgent. This change is host-side. The only renderer change is the 5-line completion gate in store-patch.ts, which #32936 also edits, so expect a trivial rebase there.

Existing tests changed on purpose: "retires to done once the leaf PTY paints a newer shell title" (builder) and "lets a shell title retire a restored turn as done" (runtime projection) now expect the identity-only row. A Done beside a shell claimed a completion nobody saw, which is this ticket's symptom.

Linked Issue

Fixes STA-12043 (Linear). Reported by brennanb2025 during the review of #32936.

Visual Proof

N/A. The visible change is a Done dot disappearing from a cold-restored terminal tab. It was verified through the session-tabs wire in the paired e2e below rather than a screenshot.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New e2e, hidden and headless (tests/e2e/paired-serve-cold-restore-agent-status.spec.ts): a phone paired directly with orca serve.

    1. A Codex turn completes with a session.
    2. A plain serve restart reattaches the same shell and the tab still shows done (the control case).
    3. The serve process and its daemon are stopped, then restored, and the tab is opened.
    4. The phone now sees restoredUnconfirmed with the same session id, and a phone without the capability still sees the legacy done.

    This fails on origin/main at step 4 (restoredUnconfirmed: false) and passes here. macOS only.

  • Unit tests:

    • Builder: four cases (named or anonymous, no title or zsh), plus an attached process and a turn reported by the current process, which keep done.
    • Run facts: only started processes are dated; a re-registration keeps the date.
    • Spawn-commit funnel: the start is the spawn request, not the commit.
    • Runtime integration: identity-only on the wire, legacy done for old clients.
    • Renderer completion gate: no completion announced for an unverifiable done.
  • Renderer contract test (host-unverifiable-agent-row-presentation.test.ts): the mirrored Done is replaced by no tab status, and native chat still resolves the session. It passes on main as well, because it pins the existing client behaviour this fix relies on.

  • Not verified:

    • A headed desktop host's own renderer-published tab.agentStatus path (runtime-mobile-session-projection.ts). That path still carries whatever the host renderer holds, and the ticket's rig was a serve host.
    • Windows, Linux and SSH, live.

Review

Codex review and an independent Opus review; findings addressed (completion re-notification, spawn-request start time).

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

Cross-platform: no platform-specific code. Remote/SSH: rows relayed over SSH or replayed after a relay reconnect only get a later receivedAt, which keeps today's status (fails safe). Mixed versions: old clients get the legacy done. Clients that already shipped with the capability render the row without a glyph. Folder workspaces: no workspace-type assumptions.

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)

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 75049068-876c-4a49-a97a-3cef8c26c86b
Commits

Reviewing files that changed from the base of the PR and between e18752a and 141aad0.

Files selected for processing: 17
  • src/main/ipc/pty/ipc/spawn-state.ts
  • src/main/ipc/pty/runtime/spawn-commit-run-facts.test.ts
  • src/main/ipc/pty/runtime/spawn-state.ts
  • src/main/ipc/pty/spawn-commit-assembly.ts
  • src/main/ipc/pty/spawn-commit-publication.ts
  • src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts
  • src/main/runtime/orca-runtime-mobile-agent-status-title-truthfulness.test.ts
  • src/main/runtime/runtime-mobile-agent-status-builder.test.ts
  • src/main/runtime/runtime-mobile-agent-status-builder.ts
  • src/main/runtime/session-lifecycle/projection/prune-mobile-session-tab-group-layout.ts
  • src/main/runtime/terminal-run-facts.test.ts
  • src/main/runtime/terminal-run-facts.ts
  • src/renderer/src/runtime/host-unverifiable-agent-row-presentation.test.ts
  • src/renderer/src/runtime/web-session-tabs-agent-completion-notifications.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/store-patch.ts
  • src/shared/agent-status-types.ts
  • tests/e2e/paired-serve-cold-restore-agent-status.spec.ts
  • 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.

@nwparker
nwparker merged commit ba43f85 into main Oct 25, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant