fix(tui): always dismiss stale forms#36588
Open
kitlangton wants to merge 2 commits 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 Escape an unconditional local exit from a form prompt, even when the background server has restarted or can no longer find the form.
Before / After
Trigger: The TUI receives and displays a pending form, then the background server restarts. The form is process-local, so the replacement server no longer has its
frm_…ID, while the TUI still has the old form in client state.Before: Pressing Escape only sent
form.cancelto the server. The TUI waited for aform.cancelledevent before removing the prompt. The restarted server returnedFormNotFoundError, emitted no cancellation event, and the stale prompt remained onscreen. Repeated Escape presses repeated the same failed request, leaving no route back to the composer.After: Escape removes the form from TUI state first, so the prompt closes immediately and the composer becomes available regardless of server state. The TUI then attempts server cancellation as best-effort cleanup. Already missing, settled, or session-missing responses are terminal and ignored; unexpected failures still surface a toast.
How
packages/tui/src/context/data.tsxowns local form dismissal alongside form listing and refresh.packages/tui/src/routes/session/form.tsxcalls local dismissal before the cancellation request and routes every form-level Escape path through the same function.FormPromptdismissal to the shared data store.FormNotFoundError, presses Escape, and verifies the prompt disappears while cancellation is still attempted.sequenceDiagram participant U as User participant T as TUI participant S as Restarted server U->>T: Escape T->>T: remove stale form locally T-->>U: restore composer immediately T->>S: best-effort form.cancel(frm_old) S-->>T: FormNotFoundError T->>T: ignore terminal absenceScope
This changes TUI dismissal behavior only. It does not make process-local forms durable across server restarts or change server form lifecycle semantics.
Testing
cd packages/tui && bun run test test/cli/tui/form.test.tsx test/cli/tui/data.test.tsx(35 passed)cd packages/tui && bun typecheckgit diff --check