Skip to content
Source
Sign inSign up
pingdotgg/t3code

Usage → Limits hides OpenCode Console 401 auth failure behind generic "OpenCode could not read workspace usage." warning #40331

Closedheymaaz(GitHub profile, opens in a new tab) opened this issue 0 comments
heymaaz(GitHub profile, opens in a new tab)commented

What happened

On Usage → Limits (All environments / All providers, and filtered to OpenCode) in T3 Code Desktop, OpenCode displays the generic warning "OpenCode: OpenCode could not read workspace usage." on every refresh, with no indication of why the check failed or how to resolve it. The Cost and Tokens tabs are unaffected because they read local session logs instead of this endpoint.

opencode-limits-warning all-providers-limits-warning

Diagnosis

  • On OpenCode v2, T3 Code queries GET /api/experimental/usage/limits?location[directory]=<dir> in packages/provider-opencode/src/server/v2/usageLimits.ts (readServerUsageLimits, lines 69–193).
  • When a stored OpenCode Console login in ~/.local/share/opencode/opencode.db (credential table, integration_id = 'opencode') has expired or been revoked on opencode.ai, OpenCode v2.3.2 responds with HTTP 503 and a JSON body explaining the real upstream failure (401 GET https://opencode.ai/console/api/policies/current-budgets).
  • packages/provider-opencode/src/server/v2/usageLimits.ts:84-86 passes the response through HttpClientResponse.filterStatusOk(response) without reading the error payload.
  • Lines 185–191 then swallow every failure with Effect.orElseSucceed and return a hardcoded generic message:
    makeUnavailableUsageLimits({
      checkedAt,
      reason: "probeFailed",
      message: "OpenCode could not read workspace usage.",
    })
    (packages/provider-opencode/src/server/driver.ts:495-504 has a matching catch-all fallback.)
  • Because the response body and upstream 401 status are discarded, users with an expired OpenCode Console session have no actionable feedback. Surfacing OpenCode's error message—or detecting a Console 401 and suggesting opencode auth login opencode / opencode auth logout opencode—would make the warning self-serviceable.
  • Checked packages/provider-opencode/src/server/v2/usageLimits.ts on main / v0.1.12-nightly.20261121.5038: unchanged since b9f24b627f (2026-11-16).

Steps to reproduce

  1. Have OpenCode v2 (v2.3.2) installed with a stored OpenCode Console credential (opencode auth list shows OpenCode Console <account> stored) whose token has expired or been revoked on opencode.ai.
  2. Open T3 Code Desktop (0.1.11, local server) and go to Usage → Limits (All environments / All providers), then refresh.
  3. Observe that GET /api/experimental/usage/limits fails with HTTP 503 containing the upstream 401 Console error, while the T3 Code UI only shows "OpenCode could not read workspace usage.".

Version

0.1.11 (T3 Code Desktop + local server, commit 59651c17; unchanged in v0.1.12-nightly.20261121.5038)

Environment

macOS 27.2.1 (darwin arm64), Node v24.22.1, opencode v2.3.2, T3 Code Desktop 0.1.11 (local server)

Evidence

# server.trace.ndjson (redacted)
{"type":"effect-span","name":"GET","kind":"client","durationMs":298.8165,"attributes":{"http.request.method":"GET","url.full":"http://127.0.0.1:49754/api/experimental/usage/limits?location%5Bdirectory%5D=%2FUsers%2F<user>","url.path":"/api/experimental/usage/limits","http.response.status_code":503,"error.type":"503"},"exit":{"_tag":"Failure","cause":"HttpClientError: StatusCode error (503 GET http://127.0.0.1:49754/api/experimental/usage/limits)"}}

# Direct call to local opencode v2.3.2 server before logging out of Console
HTTP/1.1 503 Service Unavailable
content-type: application/json

{"_tag":"ServiceUnavailableError","message":"OpenCode Console budgets are unavailable: StatusCode: non 2xx status code (401 GET https://opencode.ai/console/api/policies/current-budgets)","service":"opencode"}

# Direct call after `opencode auth logout opencode Personal`
{"location":{"directory":"~"},"data":null} [200]

#14983 (OpenCode Go limits missing for OpenCode 2 Console logins) — not a duplicate; that tracks Go quota discovery for Console logins, whereas this is about readServerUsageLimits discarding OpenCode's 503/401 error body and showing a generic warning.

Fix applied or workaround

Logged out the expired OpenCode Console account (opencode auth logout opencode Personal) since Console was not needed. OpenCode then returned HTTP 200 with {"location":{"directory":"~"},"data":null}, which T3 Code treats as reason: "unsupported" and hides without a warning. Users who do want Console limits can re-authenticate with opencode auth login opencode.

Filed by

Antigravity (Gemini 4 Neon) via t3 triage (investigation assisted by Claude Opus 5.5)

  1. heymaaz(GitHub profile, opens in a new tab) added labelsvia-triage

  2. tanstack-source added labelsbug

  3. juliusmarminge closed this

Sign in to join this conversation.