Skip to content

fix(desktop): reconcile stale completed turns#4182

Merged
esengine merged 1 commit into
esengine:main-v2from
GTC2080:GTC/issue-4167-agent-stop
Jun 12, 2026
Merged

fix(desktop): reconcile stale completed turns#4182
esengine merged 1 commit into
esengine:main-v2from
GTC2080:GTC/issue-4167-agent-stop

Conversation

@GTC2080

@GTC2080 GTC2080 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix stale desktop running state when the final turn_done event is missed after the message stream has already closed.
  • Rework the stale-turn watchdog to reconcile any quiet active turn, not only turns with a live text/reasoning stream.
  • Track turn activity per tab so background-tab events do not delay recovery for the active tab.

Fixes #4167.

Root cause

The desktop frontend only reconciled a missed turn_done when state.live was still present. After a final message or synthetic todo update, live is cleared before turn_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:all in desktop/frontend
  • npm run build in desktop/frontend
  • go test ./...
  • go test ./... in desktop
  • gofmt -l .
  • git diff --check
  • Browser smoke: http://127.0.0.1:5173/ loads Reasonix with no console errors

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 12, 2026

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@esengine esengine merged commit d042d5b into esengine:main-v2 Jun 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 已经执行完了,不停止

2 participants