Skip to content

Gate prompt dismissal on reply ack#28939

Closed
hichoe95 wants to merge 2 commits into
anomalyco:devfrom
hichoe95:codex/ack-gated-prompts
Closed

Gate prompt dismissal on reply ack#28939
hichoe95 wants to merge 2 commits into
anomalyco:devfrom
hichoe95:codex/ack-gated-prompts

Conversation

@hichoe95
Copy link
Copy Markdown

@hichoe95 hichoe95 commented May 23, 2026

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 /permission or /question no longer listed it.

Changes

  • Refresh pending permission and question lists during TUI bootstrap.
  • Expose TUI sync helpers to refresh or remove individual permission/question requests.
  • Make permission/question prompt actions wait for a successful reply acknowledgement before removing the local prompt.
  • Refresh pending state on reply errors or unexpected response shapes.
  • Return false for stale permission/question reply/reject requests so clients can refresh pending state without treating it as a typed not-found HTTP failure.
  • Route question replies/rejections through the active workspace.
  • Clear stale question edit state when switching tabs.
  • Publish permission/question removal events when pending asks are cleaned up by interruption, disposal, or reload.
  • Avoid duplicate cleanup events after normal permission/question replies.
  • Publish permission/question reply events only after the deferred request is actually completed.

Validation

  • bun run --cwd packages/opencode typecheck
  • bun test ./packages/opencode/test/question/question.test.ts
  • bun test ./packages/opencode/test/permission/next.test.ts
  • bun 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.ts
  • git diff --check
  • pre-push bun turbo typecheck with Bun 1.3.14

@github-actions github-actions Bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels May 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Gate prompt dismissal on reply ack doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions
Copy link
Copy Markdown
Contributor

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:

  1. fix(ui): clear permission after response (PR fix(ui): clear permission after response #26905)

    • Related to clearing permission prompts after responses
  2. fix(app): reply to subagent permission prompts (PR fix(app): reply to subagent permission prompts #28651)

    • Addresses replying to permission prompts, similar concern area
  3. fix(tui): clear question edit state on tab change (PR fix(tui): clear question edit state on tab change #28655)

    • Directly related—this appears to be a companion fix mentioned in the current PR's changes ("Clear stale question edit state when switching tabs")

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.

@hichoe95 hichoe95 marked this pull request as ready for review May 23, 2026 05:10
@github-actions
Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 23, 2026
@github-actions github-actions Bot closed this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant