fix(tui): undo latest pending prompt - #41344
Open
kitlangton wants to merge 1 commit into
Open
Conversation
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.
What
Make
/undoremove the newest pending user prompt before reverting projected session history. This applies equally to queued and steering follow-ups and restores the removed prompt to the composer.Fixes #39736.
Before / After
Before
/undoselected that user message but sent it to the history revert endpoint.MessageNotFoundErrorand the pending prompt remained.After
/undoselects the newest pending user input by admission order./undoretains its existing projected-history behavior.How
packages/tui/src/routes/session/index.tsxprioritizespendingUsers()when selecting the undo target.packages/tui/src/routes/session/undo.tsroutes pending targets to cancellation and handles only the expected promotion conflict as a revert fallback.packages/tui/test/cli/tui/undo.test.tscovers projected, pending, promotion-race, and transport-failure paths.Scope
session.pending.cancelAPI andsession.input.cancelledevent; no protocol or core lifecycle changes.Testing
packages/tui:bun run test, 612 passed and 5 skipped.packages/tui:bun typecheck.Demo
The recording uses OpenCode Drive with a simulated streaming model. The first two
/undoactions remove and restore a steering prompt, then a queued prompt. After streaming completes, the third/undofollows the existing history-revert path and displays1 message reverted.recording-89a775d2-ff93-4bb1-8746-a66298ebc869.mp4
Flow
flowchart TD Undo[/undo/] --> Pending{Pending user input?} Pending -->|Yes| Cancel[Cancel newest pending input] Cancel --> Conflict{Already promoted?} Conflict -->|No| Restore[Restore prompt to composer] Conflict -->|Yes| Revert[Stage history revert] Pending -->|No| Revert Revert --> Restore