fix(desktop): reconcile stale completed turns#4182
Merged
Conversation
Closed
esengine
approved these changes
Jun 12, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Nice fix — the root cause is exactly right: gating the watchdog on s.live meant a dropped turn_done after the final message (which clears live first) could never be reconciled, leaving the UI stuck "running". Switching the gate to turnActive, tracking activity per tab, and broadening the activity events so tool-heavy turns don't false-trip are all the right calls, and reconcileTabRuntime keeps it safe (it syncs from the backend rather than force-stopping). The red→green helper test is a good touch. CI is green across the board. Merging.
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.
Summary
turn_doneevent is missed after the message stream has already closed.Fixes #4167.
Root cause
The desktop frontend only reconciled a missed
turn_donewhenstate.livewas still present. After a final message or synthetic todo update,liveis cleared beforeturn_done; if that last event is dropped, the UI can show completed todos while still displaying the running/stop state.Verification
npx tsx src/__tests__/use-controller-meta.test.ts(red before the fix, green after)npm run test:allindesktop/frontendnpm run buildindesktop/frontendgo test ./...go test ./...indesktopgofmt -l .git diff --checkhttp://127.0.0.1:5173/loadsReasonixwith no console errors