Repository navigation
fix(runtime): a cold-restored terminal keeps its agent session without showing the old Done (STA-12043) - #33302
Merged
Merged
Conversation
…rt at spawn request
Contributor
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
1 task done
6 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (spawnRequestedAton 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.buildRuntimeMobileAgentStatuschecks 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.stateStartedAtand turn-end facts, so a client that saw that turn reads it as a replay, not a new completion.updatedAtmoves forward, to the process start, so a client's copy of the old Done cannot outrank it.done.web-session-tabs-sync/store-patch.ts) no longer forwards an unverifiabledoneto the completion coordinator. A cold restore therefore cannot fire a second "task complete" notification.Why
restoredUnconfirmedplus theagent-status.restored-unconfirmed.v1client 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 readsproviderSessionregardless. Clients without the capability keep receiving today's legacydonethroughprojectRestoredAgentStatusAsLegacyDone. So no new field, opcode or capability was needed.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 instore-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 withorca serve.done(the control case).restoredUnconfirmedwith the same session id, and a phone without the capability still sees the legacydone.This fails on origin/main at step 4 (
restoredUnconfirmed: false) and passes here. macOS only.Unit tests:
zsh), plus an attached process and a turn reported by the current process, which keepdone.donefor old clients.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:
tab.agentStatuspath (runtime-mobile-session-projection.ts). That path still carries whatever the host renderer holds, and the ticket's rig was a serve host.Review
Codex review and an independent Opus review; findings addressed (completion re-notification, spawn-request start time).
Agent skill upstream boundary
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 legacydone. Clients that already shipped with the capability render the row without a glyph. Folder workspaces: no workspace-type assumptions.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)