Skip to content

fix(desktop): restore edit after cancelled turns - #7951

Closed
Nath-Vikky wants to merge 1 commit into
esengine:main-v2from
Nath-Vikky:fix/restore-cancelled-turn-edit
Closed

fix(desktop): restore edit after cancelled turns#7951
Nath-Vikky wants to merge 1 commit into
esengine:main-v2from
Nath-Vikky:fix/restore-cancelled-turn-edit

Conversation

@Nath-Vikky

@Nath-Vikky Nath-Vikky commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • carry the validated checkpoint turn on TurnDone
  • correlate Desktop submissions end-to-end with an opaque submission ID
  • apply checkpoint metadata only to the exact optimistic user item
  • remove the positional full-history checkpoint refresh from the TurnDone hot path

Problem

When a visible model turn was cancelled or failed, the backend retained both the user prompt and its checkpoint, but the Desktop frontend refreshed checkpoint-turn mappings only after successful TurnDone events.

Once a session contained any authoritative checkpoint mapping, positional fallback was intentionally disabled. The cancelled prompt therefore had no checkpointTurn, leaving Edit disabled until the session was switched or the application was restarted and hydrated again.

Refreshing the full positional mapping on errored turns is not safe: visible local commands such as shell messages do not consume backend checkpoint turns and can shift subsequent mappings.

Fix

Each guarded turn now records a checkpoint candidate and exposes it on TurnDone only after validating:

  • the same session and checkpoint store
  • the exact turn and message boundary
  • a committed, visible, user-authored message at that boundary

Desktop submissions also carry an opaque correlation ID through the Wails submission APIs and event sink. The frontend applies checkpointTurn only to the optimistic user item with that exact ID.

Missing, delayed, stale, local-only, or mismatched events fail closed instead of falling back to positional matching. Existing submission APIs remain available and delegate without correlation metadata.

Verification

  • backend coverage for success, provider errors, immediate cancellation, cancel-before-first-event fallback, blocked and parked turns, session replacement, store rebinding, and turn zero
  • Desktop coverage for rejected submissions, delayed TurnDone, tab/runtime rebinding, and no-TurnDone commands
  • frontend coverage for rapid cancel/resubmit, missing or out-of-order events, shell and management commands, send failures, history pagination, Edit, and inline resend
  • go test ./internal/control ./internal/eventwire
  • focused Desktop correlation tests repeated 20 times
  • frontend checkpoint, transcript, bridge, and send-failure suites: 156/156 passing
  • TypeScript typecheck, Hooks lint, repolint, production frontend build, and Windows Wails build
  • real Windows Desktop validation with DeepSeek: an immediately cancelled prompt became editable without a restart, rewound to its exact checkpoint, and the edited resend returned the expected marker

Documentation-impact: none - existing user documentation remains correct; this restores the intended live checkpoint metadata reconciliation.

Fixes #5790
Refs #7920

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) labels Aug 8, 2026
@SivanCola

Copy link
Copy Markdown
Collaborator

我来看下

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

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

#8001 carries your work onto the latest main-v2: checkpoint candidate validation, opaque submission-ID correlation, exact optimistic-user association, removal of unsafe positional checkpoint refresh, and the associated regression coverage. The integration also preserves the current base branch's model-activity telemetry and runtime-owner resume behavior.

Your contribution is credited in the #8001 PR body, and the integration commit includes a public Co-authored-by: Nath-Vikky trailer. Closing this source PR keeps one delivery path while preserving your attribution. Thank you @Nath-Vikky for the checkpoint-correlation fix.

@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

agent Core agent loop (internal/agent, internal/control) 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