Repository navigation
fix(automations): settle chat runs left running when Orca restarts mid-run - #49298
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
… settle unmatched runs only once the chat is idle
ELI5
If Orca restarted while an automation was running in a chat, the run stayed "running" forever, even after the chat finished. Now Orca checks those runs again when it starts, the same way it already does for runs in a terminal.
What Changed
run-completion-watcher.ts,reconcileRetainedRuns). The only thing watching a chat run was an in-memory promise, which a restart loses, so the row stayeddispatchedwith nothing left to settle it.observeAutomationChatRun, viaruntime-automation-service.ts), which reads the run's turn from the chat: a finished chat settles as completed (or failed), a chat still working is watched until it ends, and the existing 6-hour limit still applies.automationRunOperationId(run, 'run-message'), the scheme reused-chat runs already use), so restart recovery reads that run's own turn and settles it completed or failed by how it ended.dispatch_failed("could not confirm this run's prompt").dispatch_failedwith "Orca restarted before this run's result was recorded. Open 's chat to see how it ended." No new run status.Why
The filter is the cause: it was the only thing keeping chat runs out of restart recovery, and the observer for them already exists. Removing it fixes this in one place, with no new recovery path.
Linked Issue
Fixes #48894
Visual Proof
N/A: no UI change. The run history row moves from "running" to its real result after a restart.
Testing
run-completion-watcher-quit.test.ts: a restart with two dispatched chat runs, one whose chat already finished (settles at once) and one still working (settles when it ends). It fails without this change (no run settles) and passes with it.runtime-chat-run-observer.test.ts, after a restart: a run found by its derived id settles completed (with its reply) or failed by its turn; a room run reserves its turn under the same derived id and is found by it; a run sent before this change is not settled while its chat is busy, then settlesdispatch_failedwith the note once the chat's turn ends; a launched Chat run with a missing or failed receipt staysdispatch_failed. The last three fail on the previous head.pnpm check:changedpasses.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because this only runs once at startup for unfinished chat runs, and each one gets the same single chat watch it would have had before the restart.
Risk
Level: Low
A chat run that was left
dispatchedbefore this change now settles on the next start, as completed or failed; one sent before this change settles failed with a restart note once its chat is idle. No stored data format changes: the derived id is computed from the run's id and creation time, nothing new is saved. Back out with a plain revert.Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)