Gate prompt dismissal on reply ack#28939
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: I found a few potentially related PRs that touch on similar prompt/permission handling:
These are related PRs in the same problem domain (prompt/permission sync and state management), though they appear to be separate issues rather than exact duplicates of the current PR #28939. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
Fix stale permission/question prompts by making prompt dismissal depend on an acknowledged server reply, resynchronizing pending prompt state from the server, and publishing prompt-removal events when server-side pending requests are cleaned up without a user reply.
Root Cause
The TUI could get out of sync with the server-side pending permission/question state. A reply could be sent for a request that was already gone or routed to a stale local prompt. If the client treated the UI selection itself as success, the prompt could disappear while the server-side deferred request was not actually resolved, leaving the conversation blocked.
There was a second cleanup path: when a pending permission/question ask was interrupted by fiber cancellation, instance disposal, or reload, the service removed the pending entry silently. Because no reply/reject event was published, a TUI that had already rendered the prompt could keep showing a stale prompt even though
/permissionor/questionno longer listed it.Changes
falsefor stale permission/question reply/reject requests so clients can refresh pending state without treating it as a typed not-found HTTP failure.Validation
bun run --cwd packages/opencode typecheckbun test ./packages/opencode/test/question/question.test.tsbun test ./packages/opencode/test/permission/next.test.tsbun test ./packages/opencode/test/server/httpapi-instance.test.ts -t 'returns false for stale permission and question requests'bun test ./packages/opencode/test/server/httpapi-public-openapi.test.tsgit diff --checkbun turbo typecheckwith Bun 1.3.14