fix(tui): dismiss stale permission prompts - #40960
Merged
Merged
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
Dismiss stale TUI permission prompts when the server reports that the request no longer exists.
The full TUI now routes manual and automatic permission replies through its data layer. Once a reply succeeds, or returns
PermissionNotFoundError, that exact request is removed from local state. Other failures remain visible and surface through the existing toast.Before / After
Before
permission.askedand displayed the approval dialog.404 PermissionNotFoundError.After
How
packages/tui/src/context/data.tsxowns reply settlement and reuses one idempotent removal path for API outcomes andpermission.repliedevents.packages/tui/src/routes/session/permission.tsxcloses over the active request and passes only the varying reply and optional message.packages/tui/src/routes/session/index.tsxuses the same path for automatic approval.packages/tui/test/cli/tui/data.test.tsxreproduces a cached request whose reply returns the tagged 404 and verifies that it is dismissed without another list request.Scope
This PR does not change the server's ephemeral permission lifecycle or add a new cancellation event. It makes the full TUI robust when a reply races with server-side cleanup or a terminal permission event is missed. The Mini TUI has a separate transport projection and remains out of scope.
Testing
bun run test test/cli/tui/data.test.tsx test/cli/tui/permission.test.tsfrompackages/tui: 41 passedbun typecheckfrompackages/tui: passedbun run lint -- <changed files>: 0 errors; existing warnings remain in the touched large files0.0.0-next-16927: repeated replies for one expired permission returned 404; delivering its missing terminal event dismissed the prompt without restarting the shared serviceDemo
No recording is attached because the live reproduction contained a private session transcript and temporary filesystem paths. The regression test covers the exact visible transition: cached permission dialog to no pending permission after the tagged 404.
Flow
sequenceDiagram participant User participant TUI participant Server User->>TUI: Allow permission TUI->>Server: Reply with request ID alt Request is pending Server-->>TUI: Success else Request already disappeared Server-->>TUI: PermissionNotFoundError else Unexpected failure Server-->>TUI: Error TUI-->>User: Keep dialog and show toast end TUI->>TUI: Remove settled request ID TUI-->>User: Dismiss dialog