Repository navigation
fix(workflows): show cancelled in-flight agents as stopped in run tree - #16215
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the engine never marks a run [DESIGN-REVIEWED] 5d59797 Description read[DESCRIPTION-READ] 71d4884e8e1b8995bff4465095a77af81525ee59722c282713d6bcc195cb27e0 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify a What this change shipsInventory (8 items) — 8 justifiedIntent: FIX — after cancelling a workflow run, the run tree and graph show interrupted agents as stopped and the interrupted phase as not completed, instead of a spinner and a green check.
Evidence checked: the mechanism claim is real ( [FIRST-PRINCIPLES-REVIEWED] 5d59797 Description read[DESCRIPTION-READ] d8cdc36a878a72ecd6f237154da2539653f3a041ac85bc443537a62284575c98 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Eyeball the ceiling-failed run once (stopped squares under a red-X phase) — the only new state combination no screenshot shows, pinned only by tests. [UX-REVIEWED] 5d59797 Description read[DESCRIPTION-READ] d5fb86a3d8a16fb74970376a790d8b25e6617b25f8efcc219fc0a0e44d20f525 That sha256 names everything this verdict read: the PR description, plus the 8 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
CI note on
Both files are untouched by this diff, which changes only No rerun: the merge commit takes both files from main, so a rerun fails identically. The next push rebases the branch onto the fixed main. |
1bf4fda to
23c6a75
Compare
After a workflow run is cancelled, the run tree kept a running spinner on every agent that was in flight and drew a success check on the interrupted phase. The runner records no agent_finished for work a cancel or a ceiling cuts off, and the views read "no finish event" as "still running" without consulting the run's status; phaseStatus() returned ok for every terminal status except failed. Derive the stopped state from the run's terminal status, which both views already have: an agent with no finish reads as running only while the run is active and as stopped once it is terminal, drawn with the Square stop mark the subagent surfaces use and named with the chat stop card's catalog entry. The current phase of a cancelled run reads as stopped, never as a success. The graph mode showed the same stale state and takes the same rule through the shared helper. A run that finishes or fails with every agent accounted for renders as before, pinned by tests. Backend untouched. Fixes #16174
23c6a75 to
5d59797
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed: view-only fix. Tree and graph share one agentState helper, agents with no finish event in an ended run read as stopped, and a cancel marks the interrupted phase stopped rather than done. Real failures (ok=false) still render red and failed runs keep a red phase; the backend has only five run statuses, so nothing else can fall into stopped. Gap: no test for a failed agent inside a cancelled run, which should stay red.
Problem / Motivation
Goal: After a workflow run is cancelled, the run tree shows the agents that were still working as stopped and the interrupted phase as not completed, instead of a running spinner and a green check.
Cancel a run while a phase has agents in flight and the run tree keeps a spinner on every one of those agents for as long as the run is shown, while the interrupted phase carries a success check. The run header says
cancelled; the rows say work is still running and the phase says it completed. The graph mode of the Workflows run panel reads the same run the same wrong way (running chips, phase ok).Mechanism:
_RunContext.agent()recordsagent_finishedonly after the agent call returns, and a cancel leaves that call byasyncio.CancelledError, which itsexcept Exceptionhandler does not catch; the wall-clock ceiling cancels the script task, so it leaves agents the same way (a budget ceiling raisesBudgetExceededbeforeagent_startedand cannot). The stream therefore endsagent_startedx N,run_cancelled, with no finish for the interrupted agents.groupByPhasesets an agent'sokonly onagent_finished, and both views renderedok === undefinedas running without looking at the run's status;phaseStatus()returnedokfor every terminal status exceptfailed, although its own comment said a cancelled current phase is not ok.Why it matters
Anyone who cancels a fan-out run (the chat side panel, the Workflows tab,
workflow_cancel) is told the opposite of what happened: the tree looks like the run is still consuming agents and that the interrupted phase delivered. That also applies to a run a budget or wall-clock ceiling stops. The record of past runs is read long after the cancel, so the wrong picture persists.Not a goal
agent_finished(ok=False, errorcancelled) in_RunContext.agent()onCancelledError.agent_finishedhas many readers (runModel.ts,SubagentRunCard.tsx, the graph model,workflows/service.py, the auto-research campaign mode),ok=Falsewould turn a cancelled phase intofailed, and the change would have to keep the checkpoint rule and never swallow the cancel. The backend is untouched; the view derives the stopped state from the run status it already has.finished/failedfromrun.okand never passescancelled.What changed (motivation → approach → change)
Symptom: a cancelled run's in-flight agents spin forever and their phase shows a check. Root cause: the views read "no
agent_finishedyet" as "still running" regardless of whether the run is over, andphaseStatus()collapsedcancelledintook.Approach (design rule): the view derives "stopped" from the run's terminal status, not from a new event. The run status already reaches both views.
runModel.ts: two pure helpers.isTerminalRunStatus(status)(anything but the two active states,runningandpaused) andagentState(row, runStatus):ok === undefinedreads asrunningonly while the run is active and asstoppedonce it is terminal; a recordedokstill readsok/failed.WorkflowRunTree.tsx: agent rows render fromagentState; a stopped agent gets the filledSquarestop mark intext-muted(fill="currentColor", the exact rule the chat stop card draws its stopped glyph with;ActivityViewerandSubagentProgressBardraw the same square in outline) withrole="img"and an accessible name.phaseStatus()returns a distinctstoppedstate for a cancelled run's current phase (finishedstaysok,failedstaysfailed), drawn with the same mark; an earlier phase readsstoppedtoo when the run ended while one of its agents was still in flight (pipeline()has no barrier between stages), so a header never shows a check above a stopped row.pages.chat.stopEventCard.stopped("Stopped", shipped in all 12 languages). It is already thearia-labelof the chat's stop card for the same state with the same glyph, so no catalog key is added.planModel.ts/WorkflowRunGraph.tsx: the sibling graph showed the same stale state (traced:actualStatereturnedrunningforok === undefined,startedPhaseStatereturnedokfor a cancelled current phase). Fixed the same way:stoppedis added toGraphNodeStateandGraphPhaseState, node state comes from the sharedagentState, every phase the run ended inside readsstopped(the same non-last rule as the tree), and the icons mirror the tree's. A stopped chip keeps a solid border (it ran; dashed means planned).docs/system-specs/modules/workflows.md: the dashboard section now states the rule and names the pinning tests.A run that finishes normally or fails with every agent accounted for renders byte-identically (see the frames below) and is pinned by tests.
Backwards compatibility
Compatible: no wire shape, event, prop or key changes; two exported union types gain a value (
stopped) and module-private graph helpers gain a status parameter.Removes nothing: the diff adds a state and two pure helpers; no key, function, route or rendered path goes away.
Tests
Red first.
website/src/test/WorkflowRunTree.cancelledAgents.test.tsxwas written before the fix and run against the unfixed tree (its Round 1 shape; Round 2 adds a ninth case, see Review lanes): 4 of its 8 tests failed, the 4 baseline tests (running, paused, finished-complete, failed-complete) passed, which is what pins "renders exactly as today":The graph tests were also run against the unfixed
planModel.ts: 6 failed (expected 'ok' to be 'stopped',expected [ 'unknown', 'ran_ok', 'running' ] to deeply equal [ 'unknown', 'ran_ok', 'stopped' ], a spinner found where none may be).What each locks in:
WorkflowRunTree.cancelledAgents.test.tsxagent_startedwithoutagent_finished: no.animate-spinanywhere; each interrupted row hasrole="img"named "Stopped" and no ok icon; the agent that finished before the cancel keeps its check.Reviewstill has an agent in flight whenVerifystarts, then a cancel): both headers carry the stop mark and no ok icon; the review that finished keeps its check, the one in flight reads stopped.failedrun (ceiling) with the same stream: no spinner, stopped rows, the phase keeps its failed mark.de→ "Gestoppt").runningandpausedruns with the same stream: spinners exactly as before (3), no stop marks.finishedandfailedruns with complete events: explicit icon assertions per row and per phase (all ok; the failed agent and its phase marked, the rest ok), no spinner, no stop mark.workflowPlanModel.test.tsstopped(was assertingok); a finished run's current phase staysok.cancelled/failedreadsstopped; the phase readsstoppedon a cancel andfailedon a ceiling;running/pausedkeeprunning; the same reading applies past anunknownfence.Review(one agent still in flight whenVerifystarted) andVerifyboth readstopped.WorkflowRunGraph.test.tsxdata-node-state="stopped", a solid (not dashed) border and the labelled stop mark; the phase hasdata-phase-state="stopped"and no ok icon; the finished node keepsran_ok. The same run whilerunningkeeps its spinner.Gates run from the worktree in Round 1 (Round 2's run is in Review lanes):
npx tsc -p tsconfig.app.jsonclean;npm run lintclean;npm run lint:i18nOK (407 untranslated strings, at or below the baseline);npm run buildgreen;npm run test: jscpd 0 clones, website vitest suite with coverage 2579 files / 43,474 tests passed (1 expected fail, 2 skipped, 0 failed), Electron node:test suite 2392 passed / 0 failed / 3 skipped (afternpm ciinwebsite/electron, which the first run lacked);scripts/docs-lint.sh: all documentation checks passed. Lanes skipped in Round 1:scripts/local-gate.py(dry-run selects 319 frontend files, all inside the fullnpm run testsuite that ran, plus 747 backend files only because the spec markdown falls in the backend bucket; no Python changed, so the backend run was skipped); the i18n style tests withI18N_BASE_REFwere not run because no catalog value is added. Comment hygiene:check_comment_history.pycovers Python only (0 files in scope); the added TS/TSX/markdown lines were swept by hand for history narration, issue or PR numbers and SHAs (none).Manual verification
Rendered the real
WorkflowRunTreeandWorkflowRunGraphwith a local, uncommitted Vite + Playwright harness (onecapture/*.tsxentry on the dev server, headless Chromium at 2x, dark and light; the harness also reads the DOM facts beside each frame). Same run in both scenes: aPlanphase whose agent finished, then aresearch-fanoutphase with four agents of which one finished.ok, ok; graph 3runningnodes, phasesok, ok.Planstill ok; graph 0 spinners, nodesran_ok, unknown(for), ran_ok, stopped, stopped, stopped, phasesok, stopped.cmpreports the PNGs byte-identical in both themes (8 ok icons, 0 spinners, 0 stop marks).ok, stopped), and the finished frames are byte-identical to Round 1's.Full
npm run test(website suite + Electron suite) green on this head; counts in the Tests section.Screenshots / video
Method: static render of the real components through the local harness above (no pod; a component-level change). Frames carry no hostnames, paths or session keys.
Each frame shows the tree view on top and the graph view below it.
Finished run, after (byte-identical to before in both themes)
Related Issues
Fixes #16174
Pattern harvest
Rule candidate: review-prompt
Pattern: a view that renders "no end event yet" as "still running" without consulting the parent's terminal status; any per-item spinner derived from a missing event should be gated on the container being non-terminal.
Review lanes
Round 1 (
1bf4fda7d027): GPT 5.6, Design and First Principles passed with no items. Opus 5 passed with one advisory finding, which Round 2 fixes. UX returned one WATCH item on the shape of the stop mark, held for the owner's decision (below).Round 2 (
23c6a75dc918on04b6588096f1): a phase the run ended inside is stopped even when a later phase had started52e60f259d3f,website/src/apps/workflows/WorkflowRunTree.tsx:71):phaseStatus()returnedokfor every non-last phase before looking at the run. In the shippedpipeline()pattern (examples/workflows/01_review_changes.pysetsphase="Review"/phase="Verify"per call, anddsl.pypinspipeline()as having no barrier between stages) a Verify agent can start while a Review agent is still in flight, so a cancel then leavesReviewas a non-last phase holding an unfinished agent: its header drew the success check while its row drew the stop mark, the two-ways reading this change exists to remove.startedPhaseState()inplanModel.tshad the sameif (!isLast) return 'ok'.stoppedwhen the run is terminal and one of the phase's agents has no verdict,okotherwise. The last-phase rule is unchanged (afinishedrun's current phase is ok, afailedrun's is failed, acancelledrun's is stopped), as is thefailedshort-circuit. The doc comments on both functions and the rule paragraph indocs/system-specs/modules/workflows.mdstate the exception. No new state, prop or key.WorkflowRunTree.cancelledAgents.test.tsx(anOVERLAPPINGstream: two Review agents, one finished,Verifystarted, runcancelled; both headers must carry the stop mark and no ok icon, the in-flight review row reads stopped, the finished one keeps its check) and one inworkflowPlanModel.test.ts(both phasesstopped). With the two source files reverted to the Round 1 head exactly those two cases fail (AssertionError: expected 1 to be +0on the Review header's ok icon;expected [ [ 'Review', 'ok' ], …(1) ] to deeply equal [ [ 'Review', 'stopped' ], …(1) ]), 2 failed / 45 passed across the three workflow test files; with the fix all 67 pass.8ad8d863529e): the lane reads the outlineSquareas ambiguous against a filled stop glyph. The mark is drawn as in Round 1; whether the stop square is filled is a product-shape call for the owner, so nothing changes here and the item is dispositioned once the lane re-reads this head.npx tsc -p tsconfig.app.jsonclean;eslinton the four changed TS/TSX files clean;npm run buildgreen;scripts/docs-lint.shall checks passed;check_comment_history.pyagainst the merge-base passes (no Python in the diff).npm run test: jscpd 0 clones; website vitest suite with coverage 2579 files / 43,476 tests passed (1 expected fail, 2 skipped, 0 failed); Electron node:test suite 2392 passed / 0 failed / 3 skipped.scripts/local-gate.pyunder the CI-parity interpreter: backend related set of 747 files in two batches. Batch 1: 50280 passed, 168 skipped, 59 failed, every one in a file this diff does not touch and every one failing identically on a detached checkout of the base commit04b6588096f1(test_file_explorer_app.py31,test_design_tweak_backend.py21,test_design_tweak_devproc.py3: id sets compared, no difference; the twoTestSpecCheckRunsWhereTheGateIsImportablecases of the pipeline skill's contract file,test_mcp_gateway_adopted_daemon_repair.py1,test_auto_improvement_members.py1: the same four fail-n0on the base). The gate stops after a red batch, so batch 2 (test_snapshot_purpose.py,test_snapshot_recovery_link_roots.py) ran by hand with the planner's argv: 27 passed. The frontend related set (319 files) is inside the full suite above.Frontend Tests (1)and(2)failed onsrc/test/SessionActionsMenu.duplicate.test.tsxandsrc/test/hoverVariantPolicy.test.ts, two files this diff does not touch; both were last changed by fix(website): gate hover so iOS taps land on the first try #14807 (57d71bb54e, main's tip when that run's merge commit was built), which landed on top of fix(sidebar): name the session-row fork action "Fork chat" #16101 and fix(chat): keep floating composer chrome off the transcript and hero #15820 without seeing them, and main's own run on57d71bb54efails the same two tests (run 37037258753). fix: repair two frontend tests broken by the hover-gate cross-merge #16210 was the open test-only fix at the time. Coverage Merge, Coverage Gate and PR Readiness were downstream of those two. Not rebased:mainhas moved 25 commits past the base without touching any file in this diff, and the two red tests come frommainitself, so the branch stays on04b6588096f1and picks the fix up with its next rebase once fix: repair two frontend tests broken by the hover-gate cross-merge #16210 lands.Round 3 (
5d59797870bcon9eb318e377eb): filled stop squares, rebased onto the healed main23c6a75dc918: GPT 5.6, Design, First Principles, UX and Security Scope passed with no items; Opus 5 did not re-print the Round 2 finding and raised one advisory item on the spec paragraph (below).8ad8d863529e, Round 1): the three stop squares (tree row, tree phase header, graphStoppedIcon) are now drawn withfill="currentColor", the exact ruleStopEventCard.tsxuses for the stopped glyph whose catalog entry this mark already borrows for its accessible name. No new component or second drawing; the twoaria-labels, therole="img"and thetext-mutedcolour are unchanged, so every Round 1 test still passes as written (tree + graph + plan model, 67 tests). The cancelled "after" frames above were re-rendered from the same harness; the finished frames are byte-identical to Round 1's.04f89979fc20,docs/system-specs/modules/workflows.md): fixed. The paragraph this PR added said a cancel or a ceiling leaves the call byCancelledError/BudgetExceeded, "which are not theExceptionits handler catches". Checked against the runner:BudgetExceededis anExceptionsubclass that escapes through an explicit re-raise, and every place that raises it (AgentCounter.increment,budget.would_exceed();Budget.chargehas no production caller) runs beforeagent_startedis recorded, so a budget ceiling can never leave an agent in flight, as the spec's own order-of-operations bullet already says. The wall-clock ceiling can: it cancels the script task and then recordsrun_failed(where="ceiling"). The paragraph now attributes the orphan solely toCancelledError(operator cancel or the wall-clock ceiling) and states the budget rule; the ceiling test's comment says the same and its fixture error readsrun exceeded 600s. Prose and a fixture string only; no behaviour change. The Mechanism paragraph above was corrected the same way.9eb318e377eb(the merge commit of test(website): update two frontend tests left red on main #16227):mainhad moved 27 commits past the Round 1 base without touching any file in this diff; the commit's added and removed lines are byte-identical before and after the rebase (474 lines compared). On the rebased tree the three workflow test files and the two healed files (SessionActionsMenu.duplicate.test.tsx,hoverVariantPolicy.test.ts) pass: 5 files, 107 tests.mainby test(website): update two frontend tests left red on main #16227 (9eb318e377, merged 23:31 UTC; tracked in test: hoverVariantPolicy and SessionActionsMenu.duplicate red on main since #14807 #16274), so this head no longer inherits them; fix: repair two frontend tests broken by the hover-gate cross-merge #16210 is superseded.npm run build(tsc + vite) green;eslinton the four changed TS/TSX files clean;scripts/docs-lint.shall checks passed;check_comment_history.pyagainst the merge-base passes (no Python in the diff).npm run teston the rebased head: jscpd 0 clones; website vitest suite with coverage 2581 files / 43,556 tests passed (1 expected fail, 2 skipped, 0 failed); Electron node:test suite 2397 passed / 0 failed / 3 skipped.scripts/local-gate.pywas not re-run this round: the diff still contains no Python, its backend related set exists only because the spec markdown falls in the backend bucket, and CI runs that surface on the merge ref regardless.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement