Skip to content

fix(desktop): reconcile immediately cancelled turns / 修复立即中断回合的历史与操作 - #7991

Closed
SivanCola wants to merge 2 commits into
esengine:main-v2from
SivanCola:fix/desktop-cancelled-turn-reconcile
Closed

fix(desktop): reconcile immediately cancelled turns / 修复立即中断回合的历史与操作#7991
SivanCola wants to merge 2 commits into
esengine:main-v2from
SivanCola:fix/desktop-cancelled-turn-reconcile

Conversation

@SivanCola

@SivanCola SivanCola commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Reconcile authoritative history and checkpoints after an immediate cancellation race.
  • Keep Edit/rewind actions available for checkpointed turns without assistant text.
  • Hide the empty assistant copy action.

Problem

When a desktop turn is stopped before turn_started, the optimistic user bubble can disappear after cancellation. The turn then has no visible Edit or rewind action even though the backend persisted the prompt and checkpoint.

Root cause

Cancel reconciliation stopped after runtime teardown and did not reload authoritative history/checkpoints. Turn action rendering also required assistant text, so checkpoint-only interrupted turns had no action toolbar.

Fix

Reload the authoritative transcript and checkpoints once cancellation settles, render turn actions for checkpointed turns without assistant content, and omit copy for empty assistant content. Added deterministic regressions for immediate cancellation and action rendering.

Verification

  • pnpm exec tsx src/__tests__/use-controller-cancel-reconcile.test.tsx (11 passed)
  • pnpm exec tsx src/__tests__/turn-actions-rendering.test.ts (12 passed)
  • pnpm exec tsc --noEmit
  • pnpm lint:hooks

Related: #7951

Documentation-impact: none - This restores existing desktop cancellation, edit, and rewind behavior; no user documentation changes are required.

Problem:
An immediately cancelled desktop turn can leave its optimistic user bubble discarded, with Edit and rewind actions unavailable. Empty interrupted assistant output also rendered a misleading copy action.

Root cause:
Cancel reconciliation stopped after runtime teardown and did not rehydrate the authoritative history/checkpoint state when cancellation raced turn_started. Turn action rendering also required assistant text, even when a checkpoint existed.

Fix:
Reload authoritative history and checkpoints after cancellation settles, keep turn actions visible for checkpointed turns without assistant text, and hide copy for empty assistant content. Add regressions for immediate cancellation and action rendering.

Verification:
pnpm exec tsc --noEmit
pnpm lint:hooks
focused use-controller-cancel-reconcile and turn-actions-rendering tests
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) and removed v2 Go rewrite (1.x) — main-v2 branch, active development labels Aug 8, 2026
Problem:
A cancellation reconciliation could replace a newer optimistic submission or clear the visible transcript when the history read failed.

Root cause:
The cancellation hydrate had no generation tied to the cancelled turn, and reset ran before the authoritative history request succeeded.

Fix:
Invalidate cancellation hydrations when a new turn is submitted and defer cancellation reset until history is available. Add deterministic deferred-history and failure regressions, and advance the existing useController repolint baseline for the intentional carry-forward.

Verification:
Focused cancel reconciliation 14/14, turn actions 12/12, tab hydration 80/80, new-session race 28/28, controller meta 139/139, tsc, hooks lint, and repolint.
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Aug 8, 2026
SivanCola added a commit that referenced this pull request Aug 8, 2026
Problem: The integrated cancellation regression still mocked the legacy submission method and expected a pending marker after the ID-aware submit had already resolved.

Root cause: #7951 changed optimistic submission confirmation to use opaque submission IDs, while #7991's fixture predated that bridge contract.

Fix: Mock SubmitToTabWithID and assert the immediate-cancel optimistic user item rather than an implementation-specific pending marker. Advance the repolint carry-forward by the nine lines introduced by the combined controller changes.

Verification:
- pnpm exec tsx src/__tests__/use-controller-cancel-reconcile.test.tsx
- go run ./tools/repolint
- go test ./...
- cd desktop && go test ./...
- go test -race ./internal/control ./internal/eventwire
- git diff --check
@SivanCola

Copy link
Copy Markdown
Collaborator Author

Superseded by #8001, the maintained integration PR for this fix.

#8001 keeps and adapts the durable parts of this PR: authoritative history/checkpoint reconciliation after immediate cancellation, generation guards against stale hydration, checkpoint-only turn actions, empty assistant Copy suppression, and the deterministic regression tests.

Your authorship and contribution are explicitly credited in #8001. Closing this source PR keeps the combined implementation and verification in one delivery path. Thank you @SivanCola for the cancellation-reconciliation work.

@SivanCola SivanCola closed this Aug 8, 2026
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.

1 participant