Repository navigation
fix(ssh): a managed server restart no longer marks still-running agents done - #29604
Conversation
… after a server restart
… no Stop for unverifiable mobile turns
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
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:
6976d26e-ae8c-44e8-b2ae-0d2bd7c66061
📒 Files selected for processing: 6
mobile/src/session/use-mobile-native-chat-active-resolution.tssrc/main/runtime/orca-runtime-hook-agent-status-projection.test.tssrc/main/runtime/runtime-mobile-agent-status-builder.test.tssrc/main/runtime/runtime-mobile-agent-status-builder.tssrc/main/runtime/runtime-mobile-agent-status-projection.tssrc/main/runtime/session-lifecycle/projection/prune-mobile-session-tab-group-layout.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| const restored = !pty?.lastAgentStatus && !shellTitleRetiredRestored ? hookRow.restored : null | ||
| if (restored) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the renewal contract and the two status branches; do not run repository code.
ast-grep outline src/main/runtime/runtime-mobile-agent-status-builder.ts --items all --match 'buildRuntimeMobileAgentStatus|renewRuntimeMobileAgentStatusFromPtyTitle'
rg -n -C 8 'renewRuntimeMobileAgentStatusFromPtyTitle|const liveRow|const restored =' src/main/runtimeRepository: stablyai/orca
Length of output: 41760
🏁 Script executed:
nl -ba src/main/runtime/runtime-mobile-agent-status-builder.ts | sed -n '70,175p'
printf '\n--- projection helper ---\n'
nl -ba src/main/runtime/runtime-mobile-agent-status-projection.ts | sed -n '1,115p'Repository: stablyai/orca
Length of output: 11283
🏁 Script executed:
nl -ba src/main/runtime/runtime-mobile-agent-status-builder.ts | sed -n '1,75p'
printf '\n--- row selection and resolution ---\n'
rg -n -C 12 'function selectRuntimeHookAgentRowForPane|export function selectRuntimeHookAgentRowForPane|function resolveRuntimeHookLiveAgentRow|export function resolveRuntimeHookLiveAgentRow' src/main/runtime/runtime-mobile-agent-status-projection.ts
nl -ba src/main/runtime/runtime-mobile-agent-status-projection.ts | sed -n '115,245p'Repository: stablyai/orca
Length of output: 10873
🏁 Script executed:
rg -n -C 12 'buildRuntimeMobileAgentStatus\(' src/main/runtime
rg -n -C 8 'retained.*RuntimeAgentRowSnapshot|RuntimeAgentRowSnapshot.*retained|retained:' src/main/runtime/runtime-mobile-session-projection.ts src/main/runtimeRepository: stablyai/orca
Length of output: 41230
Give a newer restored row precedence over an older confirmed hook row.
selectRuntimeHookAgentRowForPane keeps both rows when the restored row is newer. The live branch runs first, and the renewal helper can return the older done status when no PTY agent status exists. Skip that branch when the restored hook row is newer. Keep an explicitly retained client row unchanged.
🐛 Suggested fix
const liveRow = retained ?? resolveRuntimeHookLiveAgentRow(hookRow.live, pty, nonAgentTitle)
- if (liveRow) {
+ const restoredRowIsNewer =
+ !retained &&
+ hookRow.restored !== null &&
+ liveRow !== null &&
+ hookRow.restored.updatedAt > liveRow.updatedAt
+ if (liveRow && !restoredRowIsNewer) {| entry.providerSessionOnly !== true && | ||
| entry.restoredUnconfirmed === true && | ||
| entry.state !== 'done' && | ||
| (entry.evidenceObservedAt ?? entry.receivedAt) >= freshAfter && |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not expire an unconfirmed turn into done based only on age.
If an SSH agent runs without another hook event past AGENT_STATUS_STALE_AFTER_MS, this check removes its restored row. The builder can then publish done from the remaining provider-session identity, although the agent may still be running. Keep the turn unconfirmed until a confirmed row or a later shell-title observation resolves it.
Based on learnings: “Timers cannot reliably distinguish a stalled task from one still legitimately running elsewhere.”
Source: Learnings
…ep the legacy done projection
…ws never pierce live client status
ELI5
When Orca's server on an SSH host restarts (a crash, or an update while terminals are open), the terminals keep running. Any coding agent that was still working in one of them was suddenly shown as finished, with a green check, on every connected client. This change shows "agent here, state unknown" instead, until the agent reports again.
What Changed
Before: an agent is working in a terminal on an SSH host. The host's managed Orca server restarts. Its separate terminal daemon keeps the shells and the agent alive, and output keeps streaming. Even so, every client (desktop, a second desktop, a phone) flips that agent to
done, with a green check and an empty prompt. A freshly connected client seesdoneas well.After: the agent keeps its identity and its last known state, marked unconfirmed. The sidebar and the tab show the agent without a spinner or a done check, exactly as a locally restored row already looks after a desktop restart. The next hook the agent sends (or a shell title painted after the turn) settles it as usual.
Mechanism: on startup the host's hook server reloads
last-status.jsonand marks every nonterminal rowrestoredUnconfirmed, which is correct. But thesession.tabsprojection (buildRuntimeMobileAgentStatus) only knew two kinds of hook evidence, "live" and "identity". A restored row is neither, so it fell through to the last-resort projection. That projection synthesisedstate: 'done'stamped withDate.now(). The fresh timestamp then beat the client's existingworkingrow in the renderer's merge (agent-status-patch.ts).selectRuntimeHookAgentRowForPanenow also returns the newest fresh, nonterminalrestoredrow, unless a confirmed row at least as new supersedes it.session.tabsprojection gates it behind a new client capability (below); mobile native chat no longer offers Stop for an unconfirmed turn.buildRuntimeMobileAgentStatuspublishes that row's state and prompt withrestoredUnconfirmed: true, dated by its ownreceivedAt, and without question fields (interactivePrompt,toolName). It does this before thedonefallback. A shell title painted after the turn still retires it todone. A restarted server's default "Terminal N" title does not.Why
The execution host owns agent status, and losing contact with a turn is not evidence that it ended. The verdict here is "unverifiable", not "exited". The renderer already renders
restoredUnconfirmedrows as identity-only: no spinner, no attention badge, no question card. So reusing that flag gives the honest display with no new wire field, opcode or renderer code.Alternatives considered:
agentStatusfor these panes. This drops the provider-session identity that native chat and resume need.done.Dating the row by its own evidence means it never outranks a client's newer status. Stripping the question fields keeps #12346 fixed: no question card is resurrected after a restart.
Mixed versions: an older client cannot read the flag, so it would take the last known state (
working) as live, show a spinner, and offer Stop. The new publication is therefore capability-gated. Clients advertisingagent-status.restored-unconfirmed.v1receive it: the desktop and web renderers, and mobile, whose native chat now withholds Stop for an unconfirmed turn. Every other client keeps exactly the legacydoneprojection it received before.Linked Issue
No pre-existing issue. Found in an SSH end-to-end soak.
Visual Proof
Before: after killing the managed server, both still-running agents show green "done" checks (tab bar and sidebar), and their titles reset.
After: a second client connecting after a forced managed-server update shows the agents without a spinner or a done check (unverifiable). The agents were still printing output.
(Screenshots from the isolated soak profile are in the PR comments.)
Testing
working+restoredUnconfirmedinstead ofdone.pnpm test src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts:done.done.runtime-mobile-agent-status-builder.test.ts(synced-leaf retirement, shell vs non-shell titles),session-tab-agent-status-projection.test.ts(capability gate),web-session-tabs-sync-remote-status-title-flap.test.ts(a restored block cannot pierce live client status). Each new behavioural test fails on main.pnpm tcbecause the local bun is too old for the CI compiler.Verified live vs only in tests: the end-to-end restart and fresh-client display were verified live on Linux (omarchy). These were verified only in unit tests: the capability gate, mobile Stop suppression, synced-leaf retirement and the client-authority fence.
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)