Repository navigation
fix(shutdown): dispose the goal loop at quit, after sessions and the MCP host stop - #1449
Merged
Juliusolsson05 merged 3 commits intoSep 27, 2026
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…MCP host stop (#1372) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Juliusolsson05
force-pushed
the
fix/goal-loop-shutdown-dispose
branch
from
September 27, 2026 15:47
0056119 to
8d64650
Compare
Owner
Author
Review disposition (head fb3542b)
Residual: Merge order (q125): W3's #1430 work also edits |
Juliusolsson05
marked this pull request as ready for review
September 27, 2026 18:12
Juliusolsson05
changed the base branch from
main
to
integration/batch-2026-09-27-p
September 27, 2026 20:36
Juliusolsson05
merged commit Sep 27, 2026
4ced4c1
into
integration/batch-2026-09-27-p
2 checks passed
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.
Fixes #1372.
Plan (first commit):
docs/plans/2026-09-27-goal-loop-shutdown-dispose.md.Problem
The mechanism is recorded in #1341 (CI run 36156560842): a fire-and-forget
persist()that outlives its owner's teardown fails. There were 13persisting loop state failed: ENOENT … renamewarnings, with a test'safterEachas the owner. At quit the owner is process exit, which leaves no log line. No production quit that lost loop state has been recorded; this closes that window.#1371 gave
GoalLoopServiceadispose()that cancels its timers and drains an in-flight loop-state persist or continuation. The shutdown inventory (installApplicationShutdown) never called it, so a persist started just before quit could be cut off and the loop state lost.What merges
applicationShutdown.ts: adisposeGoalLoopentry in the inventory. It runs in the support-disposal wave with control and caffeinate:goal_looptool call reaches a disposed service.Quit waits for its drain.
index.ts: startup publishesdisposeGoalLooponce the service exists (thedisposeControlHostpattern). If startup never got that far, there is nothing to drain.Tests
applicationShutdown.test.ts: the goal loop is not disposed while sessions or the MCP host are still stopping, and quit waits for its drain. Checked at head8d646502:applicationShutdown.tsat the merge base) fails it (disposeGoalLoopcalled 0 times);The existing veto test now also covers it (an editor veto disposes nothing). The test models the inventory with deferred services, not a real quit.
npx tsc -bis clean;vitest run src/main/applicationShutdown.test.ts src/main/goalLoop src/renderer/src/features/global-editorpasses 14 files / 150 tests atfb3542b5(the gate's exact paths; the whole global-editor folder is included, not only its before-unload guard).Review a round 1 (fixed at fb3542b)
dispose()waited only for TRACKED work. The public mutators (goal_loop_start/goal_loop_completeover MCP) awaitedpersist()without tracking it, so quit could still cut off their write.persist()now tracks every write. Pinned by "dispose waits for a public complete/startLoop whose write is in flight", both red without the tracking.Overlap
W3's #1430 work also edits
src/main/index.ts, in different hunks (resolveRepoRoot/ conversation setup). Per B6 (q125), whichever is READY first merges first and they never share a batch. The second merges origin/main after the first lands, reruns tsc plus the startup and shutdown tests, and states that combined check here.🤖 Generated with Claude Code