fix(tui): dismiss stale forms after failed reply#36591
Draft
kitlangton wants to merge 1 commit into
Draft
Conversation
This was referenced Jul 13, 2026
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
Dismiss a stale TUI form when submitting it returns
FormNotFoundError.Before this change, a form lost during a managed-service restart remained mounted and trapped the user outside the composer. After this change, the TUI refreshes the server's authoritative form list, removes the missing form, and restores the composer.
Fixes #36585.
How
packages/tui/src/routes/session/form.tsxhandles the generated V2FormNotFoundErrorfor both immediate single-question replies and review-style form submissions.data.session.form.refresh(...), which uses the existing V2/api/session/:sessionID/formor location-scoped form list endpoint and replaces local form state.packages/tui/test/cli/tui/form.test.tsxreproduces a stale form reply and verifies that the form is dismissed.Scope
This does not make forms or suspended tool execution durable across server restarts. It only ensures that a user is not trapped by a form the replacement server no longer owns.
Testing
bun run test test/cli/tui/form.test.tsx(3passed)bun run test test/cli/tui/data.test.tsx(32passed)bun typecheckfrompackages/tuibun turbo typecheck --concurrency=3(31packages passed)git diff --checkFlow
sequenceDiagram participant User participant TUI participant Client as V2 client participant Server User->>TUI: Submit stale form TUI->>Client: form.reply(...) Client->>Server: POST form reply Server-->>Client: FormNotFoundError Client-->>TUI: Typed error TUI->>Client: form.list / form.request.list Client->>Server: Refresh authoritative forms Server-->>TUI: Empty form list TUI-->>User: Remove form and restore composer