Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: bug(opencode): unresolved approval requests remain after error turn and block settlement #7657

ClosedXzese(GitHub profile, opens in a new tab) opened this issue 1 comment

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

Summary

Using OpenCode, when a turn ends in an error (content-blocked/runtime error path), approval prompts can remain marked as pending in thread metadata (pending_approval_count > 0) even though the turn is terminal (state=error) and no live user-input approval is actually waiting. This leaves chats in a “stuck awaiting approval” state.

What’s happening

  • Threads shown as unresolved approval state by UI.
  • projection_turns entries for affected turns are in state='error'.
  • There are unresolved approval activities with no matching approval.resolved for these turns.
  • In one thread, repeated content-blocked provider errors are visible in provider logs; requests are failing and no reconciliation seems to clear pending approvals.

Environment

  • Provider: opencode
  • App mode: desktop (macOS, current)
  • Observed on existing local state via t3code DB/logs

Repro (local evidence)

  1. Run opencode provider.
  2. Trigger action leading to permission request + provider runtime failure (e.g. content-blocked style error in provider session).
  3. Observe the turn transitions to error/completed terminal state.
  4. Check DB/log evidence:
    • pending approvals remain nonzero
    • unresolved approval.requested activity entries remain
    • no corresponding approval.resolved rows for affected request IDs.
  5. UI continues surfacing approval-like stale state instead of returning to normal done/error handling.

Actual behavior

  • Threads cannot settle / continue cleanly after error because stale pending approvals are not reconciled.
  • pending_approval_count does not reflect true runtime await state.

Expected behavior

  • Any terminal/error state should cancel or resolve outstanding approval requests deterministically.
  • Thread/session status should settle consistently and not show “awaiting approval” when no approval interaction is active.
  • Provider/runtime error paths should write symmetrical approval cleanup events.

Evidence (from local triage)

  • thread_id: 30bdf143-0409-4976-a934-01a33606e157 (pending_approval_count=5)
  • thread_id: 4e318839-a01c-45a6-b814-9bebf4f098a2 (pending_approval_count=7)
  • thread_id: 56ac7743-6ce2-4153-8f55-79c867708a5f (pending_approval_count=1)
  • provider events include repeated session.error ... content-blocked (request id: ...) with same request ids reflected in failed turn completions.

Relevant areas to inspect

  • apps/server/src/provider/... OpenCode provider adapter
  • approval projection writes (projection_threads, projection_turns, projection_pending_approvals, projection_thread_activities)
  • session/turn reconciliation path in error/stop handlers

Suggested fix

  1. On terminal/error completion for a run, reconcile every outstanding approval request for that run:
    • mark as resolved (cancelled/failure outcome) or remove from pending with clear state reason.
  2. Gate UI pending-approval state from active runtime/request state, not only stale counters.
  3. Add regression test:
    • inject content-blocked runtime error
    • assert no unresolved approval rows after turn terminalization
    • assert thread can accept next prompt post-recovery.

Expected behavior

Expected behavior

  • Any terminal/error state should cancel or resolve outstanding approval requests deterministically.
  • Thread/session status should settle consistently and not show “awaiting approval” when no approval interaction is active.
  • Provider/runtime error paths should write symmetrical approval cleanup events.

Actual behavior

Actual behavior

  • Threads cannot settle / continue cleanly after error because stale pending approvals are not reconciled.
  • pending_approval_count does not reflect true runtime await state.

Impact

Major degradation or frequent failure

Version or commit

0.0.34-nightly.20260820.1141

Environment

  • OS: macOS - App: T3 Code desktop - Provider/runtime: opencode

Logs or stack traces

Thread state mismatch observed in local triage DB:
  - projection_threads pending_approval_count:
    - 30bdf143-0409-4976-a934-01a33606e157 -> 5
    - 4e318839-a01c-45a6-b814-9bebf4f098a2 -> 7
    - 56ac7743-6ce2-4153-8f55-79c867708a5f -> 1
  - For these rows, approval activity has only `approval.requested` entries and no `approval.resolved`.
  - matching turns are in terminal `state='error'`.
  - provider/events.<thread>.log contains repeated `session.error` / `content-blocked` with request IDs:
    - 2026082015592712693224565m68ArWMYlm1
    - 20260820164922794879407dkckrBAd97b18
    - ... (latest failure id in logs mapped to same turn)

Screenshots, recordings, or supporting files

No response

Workaround

Archiving the chat instead of settling

  1. Xzese(GitHub profile, opens in a new tab) added labelsbug

  2. Xzese(GitHub profile, opens in a new tab) added labelsneeds-triage

  3. Note

    🤖 GPT-5.6 Sol in Codex responding on behalf of Theo

    Closing as a duplicate of #7113. The same OpenCode approval remains pending after a failed turn.

    Track the remaining work in #7113.

Sign in to join this conversation.