Skip to content

fix(desktop): fix revert race condition for sessions with many files#20518

Open
natewill wants to merge 8 commits intoanomalyco:devfrom
natewill:revert-submit-block
Open

fix(desktop): fix revert race condition for sessions with many files#20518
natewill wants to merge 8 commits intoanomalyco:devfrom
natewill:revert-submit-block

Conversation

@natewill
Copy link
Copy Markdown
Contributor

@natewill natewill commented Apr 1, 2026

Issue for this PR

Closes #20315

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes a revert/restore race in the desktop app.

After #f0542fa made revert/restore optimistic on the client, the composer could refill before the server finished reverting the workspace. In long sessions with many file changes, that left a window where users could submit a new prompt while revert/restore was still in flight, causing client/server state to diverge.

This PR keeps the optimistic prompt refill, but temporarily blocks prompt submission while revert/restore is pending. Users can still start editing immediately after clicking revert, but they cannot submit until the backend operation settles. This prevents prompt work from overlapping with workspace rollback.

Note: #20551 is my PR for speeding up revert

How did you verify your code works?

  • Verified locally by reverting a message and confirming that the composer refills immediately while the send button switches to a loading state.

  • Verified submit is blocked during pending revert/restore via both mouse click and Enter.

  • Verified submit becomes available again once revert/restore finishes.

  • Kept the session review panel open during revert/restore and confirmed the session diff panel no longer flickers between loading/empty/review states.

  • Forced local revert/restore failures and confirmed the client rolls back the optimistic revert state, restores the previous prompt, re-enables submit, and shows the error toast.

  • Ran bun typecheck

  • Ran bun test --preload ./happydom.ts ./src/components/prompt-input/submit.test.ts

Screenshots / recordings

Before fix: (audio on for explanation)

0331.1.mov

After fix: (audio on for explanation)

0331.2.mov

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@natewill natewill requested a review from adamdotdevin as a code owner April 1, 2026 17:52
@natewill natewill changed the title fix(desktop): revert functionality race condition for sessions with many files fix(desktop): fix revert race condition for sessions with many files Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Reverting in a long session causes revert to be unusable in desktop app

1 participant