fix: preserve revert consistency - #46974
Open
CasualDeveloper wants to merge 1 commit into
Open
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: The search found PR #42461 "fix: make revert boundaries chronological" which is the related PR mentioned in the current PR's description as being superseded. This is expected since PR #46974 explicitly states it "Supersedes #42461" and folds in that fix. No other duplicate or competing PRs were found that are addressing the same revert consistency and session prompt ordering issue. No duplicate PRs found |
Serialize per-session revert and admission changes, commit staged reverts atomically with their replacement admission, preserve queued work across reverts, and compare undo boundaries chronologically instead of by message ID. Plugin activation completes before session changes are blocked so plugin setup can still admit its own input. Includes the anomalyco#42461 boundary fix; supersedes that PR. Closes anomalyco#37751. Continues the approach from anomalyco#37752.
CasualDeveloper
force-pushed
the
fix/37751-revert-consistency
branch
from
September 3, 2026 04:42
4821120 to
7c3cb99
Compare
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 #37751
Supersedes #42461
Type of change
What does this PR do?
A V2 session could accept a new prompt while an undo was still being saved. Undo a message, edit it, and send it again. The server could record the new message before it finished recording the undo, so the two landed in the wrong order. #37752 tried to fix this by running the operations one at a time. GitHub closed that PR as stale; maintainers did not reject it. This branch finishes that approach.
For each session, one undo or message change now finishes before the next one starts. When a prompt replaces a staged undo, the server commits the undo and admits the prompt in one transaction. Queued work that sits before the undo boundary is kept instead of dropped. The undo boundary is chosen by position in the message list, not by message ID, so a later message with a smaller ID can no longer move the boundary backwards. That last part is the #42461 fix. It is folded in here because a bot opened that PR on a three-week-old base and its branch cannot be updated.
Running operations one at a time would deadlock a plugin that sends a message during its own setup: that message would queue behind the prompt that is waiting for the plugin to load. So plugin setup and prompt hooks get a narrow bypass that admits their own messages directly. The bypass is scoped to the running setup or hook and expires when it returns. Current
v2already waits for plugin activation before preparing a prompt; this PR extends the same wait to undo staging, undo clearing, and shell start.On the client side, the TUI and the web composer show the prompt in the chat right away, then run agent setup, model setup, and prompt admission in order. A failed send is retried under the same message ID, so a lost response cannot create a duplicate prompt.
API surface:
session.promptgains an optionalcontextfield. It is a synthetic message that the server admits in the same transaction as the prompt. A newContextDeliveryErrorrejectscontextwhen the prompt uses queued delivery. OpenAPI and the generated clients are regenerated.How did you verify your code works?
bun typecheckin core, plugin, client, tui, app, schema, protocol, and serverbun run testinpackages/core: 4075 pass. The 6session-shelltimeouts also fail on cleanv2.bun testinpackages/tui: 1197 pass. The onesession-homefailure is pre-existing onv2.bun testinpackages/client: 150 passbun run test:unitinpackages/app: 704 passbun testinpackages/server: 50 passbun run check:generatedinpackages/protocolandpackages/client: no driftNew tests cover successful and failed replacement prompts, retries under the same message ID, concurrent submissions, revert staging ordered against prompt admission, Effect and Promise plugin hooks that admit input during prompt preparation, and undo boundaries that fall outside the loaded message page.
Screenshots / recordings
Not a visual change.
Checklist
Process: human-directed and reviewed, with agentic assistance from Anthropic/Claude.