fix(desktop): fix revert race condition for sessions with many files#20518
Open
natewill wants to merge 8 commits intoanomalyco:devfrom
Open
fix(desktop): fix revert race condition for sessions with many files#20518natewill wants to merge 8 commits intoanomalyco:devfrom
natewill wants to merge 8 commits intoanomalyco:devfrom
Conversation
added 7 commits
March 31, 2026 13:51
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.
Issue for this PR
Closes #20315
Type of change
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 typecheckRan
bun test --preload ./happydom.ts ./src/components/prompt-input/submit.test.tsScreenshots / recordings
Before fix: (audio on for explanation)
0331.1.mov
After fix: (audio on for explanation)
0331.2.mov
Checklist