fix(desktop): reconcile immediately cancelled turns / 修复立即中断回合的历史与操作 - #7991
Closed
SivanCola wants to merge 2 commits into
Closed
fix(desktop): reconcile immediately cancelled turns / 修复立即中断回合的历史与操作#7991SivanCola wants to merge 2 commits into
SivanCola wants to merge 2 commits into
Conversation
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
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.
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
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. |
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
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 --noEmitpnpm lint:hooksRelated: #7951
Documentation-impact: none - This restores existing desktop cancellation, edit, and rewind behavior; no user documentation changes are required.