Fix graph progress state after interruption - #452
Conversation
Emit terminal progress for full and incremental graph subprocesses on both success and interruption. Add regression coverage for aborted and completed runs.
Code Review — Fix graph progress state after interruptionThe interrupt-path fix is correct and well-tested. Three findings, most severe first. 1. Parent terminal
|
…ccess On a successful graph build the child (build_ast_graph._graph_pass_progress) already emits its own terminal kind=graph pass=6/6 status=done in its finally, which the relay parses (--verbose is passed by default) and routes to on_progress. The renderer keys terminality on kind+status alone, so the child's line already terminates the graph kind. The parent's finally then fired a second terminal event, breaking the one-terminal-event-per-kind invariant: a duplicate non-TTY 'graph done' line and two events for programmatic consumers (MCP). Gate the parent's emission on code != 0 in both run_build_ast_graph and run_incremental_graph, so the parent emits only on the failure/interrupt path (where the child did not reach a healthy finally). Also drop the stray blank line after the inline cli_format import in both functions. Extend the success test to simulate the child emitting its terminal graph event so child events actually flow, and assert on_progress receives exactly one terminal graph event on success; the interrupt test still asserts its single failed event.
|
Thanks for the detailed writeup — the duplicate-terminal-event analysis was spot on. Finding 1 (the blocker): fixed. Gated the parent's terminal-event finally on The test miss: you nailed why it was invisible — the old success test mocked _popen_capturing_stderr to return ('','',0) so no child events flowed. Rewrote it so the fake capture emits the child's kind=graph pass=6/6 status=done, then asserts exactly one terminal graph event. Confirmed it fails (2 == 1) without the fix and passes with it. Finding 3 (stray blank line): removed. Finding 2 (hoist the triplicated try/finally into _popen_capturing_stderr): I held off on this one deliberately. It also touches the cocoindex caller, which legitimately needs a parent-side terminal event because that flow can't self-emit (and it fires even on spawn failure). Folding all three into the helper with a kind param risks regressing that path, so I'd rather do it as a focused follow-up than smuggle a structural refactor into this fix. Happy to pick it up separately if you'd like. 17 tests green. |
Verification — all three findings addressed ✅Checked out Finding 1 (duplicate terminal event — the blocker) — FIXED & provenThe
Regression test is real, not a tautology. I reverted the gate in Restored the fix → 4/4 graph-progress tests pass. The rewritten Finding 3 (stray blank line) — FIXEDNo blank line between the inline import and Finding 2 (hoist into
|
HumanBean17
left a comment
There was a problem hiding this comment.
Approved. Thanks to contributing. Feel free to commit more or open issues with ideas or bugs :)
Closes #415.
Full and incremental graph builds now emit a terminal
graphprogress event from afinallyblock, so interrupted subprocesses stop the renderer instead of leaving a running task. Regression tests cover failed events on interruption and done events on success for both runners; all 11 pipeline tests and changed-file Ruff checks pass.