[GH-ISSUE #586] TUI doesn't show pending permissions or questions when attaching to a session #928

Closed
opened 2026-03-14 09:04:00 +03:00 by kerem · 2 comments
Owner

Originally created by @tensor-ninja on GitHub (Jan 25, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/586

When using opencode attach to connect to a running server, the TUI does not display permissions or questions that were asked while no TUI was attached. This blocks the detach/reattach workflow.

You can reproduce by:

  • Start opencode in server mode: opencode serve
  • Attach in another terminal: opencode attach http://127.0.0.1:4096
  • Send a prompt that triggers the AI to ask a question
  • Detach from the TUI
  • Reattach: opencode attach http://127.0.0.1:4096 --session

Expected: The pending question should be displayed in the TUI
Actual: The question is not shown; the session appears stuck on N questions asked

The TUI's sync context src/cli/cmd/tui/context/sync.tsx only populates store.permission and store.question from SSE events permission.asked, question.asked. When a TUI attaches after the event has already fired, it never receives the event and doesn't know about pending items.

The server already has endpoints to list pending items:

  • GET /permission - Lists all pending permission requests
  • GET /question - Lists all pending question requests

But the TUI doesn't call these during bootstrap.

I think we should add API calls to the bootstrap sequence in sync.tsx to fetch pending permissions and questions:

sdk.client.permission.list().then((x) => {
  const grouped: Record<string, PermissionRequest[]> = {}
  for (const p of x.data ?? []) {
    if (!grouped[p.sessionID]) grouped[p.sessionID] = []
    grouped[p.sessionID]!.push(p)
  }
  setStore("permission", reconcile(grouped))
}),
sdk.client.question.list().then((x) => {
  const grouped: Record<string, QuestionRequest[]> = {}
  for (const q of x.data ?? []) {
    if (!grouped[q.sessionID]) grouped[q.sessionID] = []
    grouped[q.sessionID]!.push(q)
  }
  setStore("question", reconcile(grouped))
}),
Originally created by @tensor-ninja on GitHub (Jan 25, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/586 When using `opencode attach` to connect to a running server, the TUI does not display permissions or questions that were asked while no TUI was attached. This blocks the detach/reattach workflow. You can reproduce by: - Start opencode in server mode: opencode serve - Attach in another terminal: opencode attach http://127.0.0.1:4096 - Send a prompt that triggers the AI to ask a question - Detach from the TUI - Reattach: opencode attach http://127.0.0.1:4096 --session <session-id> Expected: The pending question should be displayed in the TUI Actual: The question is not shown; the session appears stuck on N questions asked The TUI's sync context `src/cli/cmd/tui/context/sync.tsx` only populates `store.permission` and `store.question` from SSE events `permission.asked`, `question.asked`. When a TUI attaches after the event has already fired, it never receives the event and doesn't know about pending items. The server already has endpoints to list pending items: - GET /permission - Lists all pending permission requests - GET /question - Lists all pending question requests But the TUI doesn't call these during bootstrap. I think we should add API calls to the bootstrap sequence in `sync.tsx` to fetch pending permissions and questions: ```javascript sdk.client.permission.list().then((x) => { const grouped: Record<string, PermissionRequest[]> = {} for (const p of x.data ?? []) { if (!grouped[p.sessionID]) grouped[p.sessionID] = [] grouped[p.sessionID]!.push(p) } setStore("permission", reconcile(grouped)) }), sdk.client.question.list().then((x) => { const grouped: Record<string, QuestionRequest[]> = {} for (const q of x.data ?? []) { if (!grouped[q.sessionID]) grouped[q.sessionID] = [] grouped[q.sessionID]!.push(q) } setStore("question", reconcile(grouped)) }), ```
kerem closed this issue 2026-03-14 09:04:05 +03:00
Author
Owner

@msmps commented on GitHub (Jan 25, 2026):

@tensor-ninja this belongs in https://github.com/anomalyco/opencode

<!-- gh-comment-id:3796919127 --> @msmps commented on GitHub (Jan 25, 2026): @tensor-ninja this belongs in https://github.com/anomalyco/opencode
Author
Owner

@tensor-ninja commented on GitHub (Jan 25, 2026):

oops. My bad. Thanks @msmps

<!-- gh-comment-id:3796922599 --> @tensor-ninja commented on GitHub (Jan 25, 2026): oops. My bad. Thanks @msmps
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#928
No description provided.