Skip to content

TUI: pending permission/question prompts lost after detach + reattach, wedging the session #36604

Closed

Description

@Mykhol

Description

If you detach the TUI while a permission prompt or interactive question is pending — or one is raised while you're detached — re-attaching leaves the session stuck. The agent is still blocked server-side waiting for a reply, but no prompt is shown and the input looks idle, so there's no way to answer. The only escape is forking the session, which discards the in-flight run.

The cause is that pending permission/question state is transient server memory (a Deferred the tool awaits), announced with a single permission.asked/question.asked event at ask time. The event stream doesn't replay pending state to a client that connects afterwards, and the TUI's bootstrap() hydrates everything on connect except these two stores — so a client that missed the live event never learns about the prompt.

Steps to reproduce

  1. Start a run that will trigger a permission prompt (e.g. an edit/bash on ask), or one that uses the question tool.
  2. Detach the TUI before answering (or detach, then let a subagent raise a prompt).
  3. Re-attach to the session.
  4. The session sits idle with no prompt; the agent is blocked and only forking recovers it.

Operating System

macOS

Activity

  1. github-actions commented on Jul 13, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. Mykhol commented on Jul 13, 2026

    @Mykhol
    Author

    I've raised a PR with a focussed change to resolve this

  3. khalilgharbaoui commented on Aug 19, 2026

    @khalilgharbaoui

    Adding evidence for a case that may be broader than the detach/reattach framing here: on my machine the question form does not render even when the TUI was attached the whole time, so there is no missed live event to replay. If you consider that a separate bug I am happy to file it separately, but the root cause you describe (pending question state is transient and only announced once) fits what I see, so I would rather add data here first. Noting that #36603 is closed unmerged.

    Still reproducing on 1.18.18, most recently today (2026-08-19).

    The server path is fine; only the TUI render is missing. A --pure (no plugins) headless opencode serve drives the whole flow green: the tool blocks, question.asked publishes, GET /question lists the pending question, and POST /question/{id}/reply {"answers":[["Alpha"]]} completes the tool with the answer and emits question.replied. Everything the client needs is exposed and working.

    Not provider- or plugin-specific. github-copilot/gpt-5.5, a native provider, fails identically: Tool execution aborted, metadata.interrupted: true, ~27s.

    The regression brackets to v1.14.24…v1.15.5. From ~/.local/share/opencode/opencode.db, question tool parts by day and status:

    period completed aborted
    2026-03-31 … 2026-04-25 59 a handful (normal dismissals)
    2026-05-18 … 2026-08-19 1 every other one

    The single completed after that boundary is the headless POST /question/{id}/reply test above, i.e. not a TUI render. Every TUI-driven one since 2026-05-18 ends Tool execution aborted with metadata.interrupted: true, after 8s to 5300s depending on how long I waited before giving up. The only escape is interrupting.

    Worth distinguishing from a healthy failure: The user dismissed this question means the form did render and the operator declined. That is not this. This is silence, then an abort.

    Happy to run anything specific against a build if it helps.

  4. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    In v2, reattaching the TUI fetches pending permission requests and question forms from the server, including requests from subagents, so prompts no longer depend only on receiving the original live event. To get v2: npm i -g @opencode/cli@latest or curl -fsSL https://opencode.ai/v2/install | bash (desktop: update the app). If you still see this on v2, please open a new issue with the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions