fix(opencode): Go-key-only instances keep OpenCode Go usage on OpenCode 2 #36519
main fromrefs/pull/36519/head·merged by maria-rcks View on GitHubNo changes were needed. The brief listed nothing to fix, so I watched PR #36519. All 37 checks passed on 2ff58ac, including the 8 required ones. Macroscope approved with no line comments. CodeRabbit generated no actionable comments, rated merge risk minimal, and passed its title, description, linked-issue and scope checks; it noted the PR description's Evidence section is still a placeholder to fill in before merge. The thread-transfer impact comment reports everything within limits. The fix itself is unchanged: checkUsageLimits in driver.ts falls back to the Go-key reader when the OpenCode 2 server reports 'unsupported' (data: null), and keeps the server result only when the Go-key reader is also 'unsupported'. I stopped watching after the reviews came back clean.
Fixes pingdotgg/t3code#36516
Reproduction on main#
Commit a35fd81174 (origin/main). Installed @opencode/cli 2.3.0 into a scratch dir and created an isolated XDG_DATA_HOME whose opencode/auth.json held only {"opencode-go":{"type":"api","key":}}. (1) Ran opencode serve with that data home: GET /api/experimental/usage/limits?location[directory]= returned 200 {"location":...,"data":null}; /api/provider listed opencode-go. (2) Started T3CODE_DEV_SEED=0 vp run dev in a fresh worktree with settings.json defining one OpenCode instance (binaryPath = the 2.3.0 binary, XDG_* env pointing at the isolated dirs). T3 spawned opencode serve 2.3.0 for it. Opened /usage → Limits in the preview browser after pairing: 'No provider on the selected environments reports subscription limits.' (3) As a control, temporarily added a fallback to the Go-key reader when the server result is 'unsupported' in driver.ts checkUsageLimits; after the server restarted, the same panel showed 'OpenCode: OpenCode Go could not read usage.' (the Go-key reader's own probeFailed message, because the fake key gets a 401), proving that on main the Go-key reader never runs. Reverted the change. Added a driver test (local v2 server answers data: null, auth content holds a Go key, Go endpoint returns 3 windows): it fails on main with unavailable {reason: 'unsupported', message: 'No OpenCode Console workspace is signed in.'} and passed with the one-line fallback applied locally.
Evidence#
Real web app, Chromium, 1280×800 CSS viewport, light theme; separate fresh T3 databases; real OpenCode 2.3.0 and isolated Go-key-only credentials. Open Usage → Limits and refresh on each commit. The real OpenCode server returns HTTP 200 with data:null. For the successful-window comparison below, only the Go usage HTTP response is synthetic and identical on both sides (23%, 41%, 62% used). Base never requests it; head renders all three windows.
| Before | After — synthetic Go response |
|---|---|
| a35fd81174 | 2ff58aca27 |
![]() | ![]() |
| Refresh recording | Refresh recording |
Live-endpoint control without the fixture: base shows no limits; head reaches the Go reader and reports the fake-key failure.
Reproduction artifacts: seed script, Go response fixture, real OpenCode endpoint transcript, request summary.
Successful live Go subscription usage remains unverified; the three-window capture uses synthetic response data.
Not shown:
- Successful usage retrieval for a real OpenCode Go subscription: no valid Go subscription credential was available. The live-endpoint comparison used triage's fake-key control; the successful three-window comparison used an explicitly synthetic HTTP response.
Tests#
No new runs this round; the code is unchanged. CI on 2ff58ac: all 37 checks passed, including the 8 required ones. Earlier round: driver.test.ts 39/39 pass and vp run check:changed passes.
Not in this change#
- Open PR #36002 proposes a similar fallback; it was not looked at or changed here.
- Open PR #36002 proposes a similar fallback; not touched.
- CodeRabbit noted the PR description's Evidence section is still a placeholder; the PR description belongs to the pipeline, not this step.
Who did the work#
- Written by Claude Opus 5.5, in Claude Code
- Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
- Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
Run by the t3code factory in T3 Code.
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
2ff58acMacroscope's review found this PR approvable — Restores OpenCode Go usage reporting when OpenCode 2 cannot provide workspace usage. The fallback reuses the existing read-only usage integration and retains external-server credential isolation and timeouts.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
2dd6cdd· PR result:2ff58ac· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review.
Walkthrough
-
The OpenCode usage check now uses legacy Go usage limits when server limits are absent or marked unsupported. A regression test covers a key-only account when the local usage endpoint returns
data: null.Changes: OpenCode Go usage fallback
Layer / File(s) Summary Usage fallback and regression coverage
packages/provider-opencode/src/server/driver.ts,packages/provider-opencode/src/server/driver.test.tscheckUsageLimitsfalls back to legacy Go limits when OpenCode server limits are absent or marked unsupported. If both sources report unsupported, it keeps the OpenCode result. The test verifies that a key-only account returns session, weekly, and monthly usage windows when the server endpoint returnsdata: null.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
yash-singh1,t3dotgg
Merge Risk:
Minimal · up to2ff58-
This restores Go usage windows for OpenCode instances authenticated only with a Go API key, while Console-authenticated instances keep using the server path. The change is small and covered by a regression test, and no merge-blocking risk remains.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: Go-key-only local OpenCode instances keep OpenCode Go usage on OpenCode 2. The change adds a fallback in checkUsageLimits to the Go-key reader when the server reports … Linked Issues check Directly linked issue #36516requires Go-key-only local OpenCode instances to show Go usage windows. Console-authenticated instances must keep the server path. The reviewed head changes checkUsageLimi…Out of Scope Changes check The whole-PR diff against the merge base a35fd811749c2b65d917652cbdb90b28d65b2e0c touches the OpenCode driver usage-limit path (4 lines in driver.ts) and adds a driver regression test in driver.test.t… Description check The description covers the problem (OpenCode 2 server returns data: null, so Go-key usage never loads), the change (checkUsageLimits falls back to the Go-key reader when the server result is unsupport… Full details: Title check
-
Explanation
The title names the main change: Go-key-only local OpenCode instances keep OpenCode Go usage on OpenCode 2. The change adds a fallback in checkUsageLimits to the Go-key reader when the server reports 'unsupported', which matches the title. The title follows the conventional commit form and is specific.
Full details: Linked Issues check
-
Explanation
Directly linked issue
#36516requires Go-key-only local OpenCode instances to show Go usage windows. Console-authenticated instances must keep the server path. The reviewed head changes checkUsageLimits in packages/provider-opencode/src/server/driver.ts. When the server result is 'unsupported', the change calls readOpenCodeGoUsageLimits (legacyUsageLimits). It returns the Go-key result unless that result is also 'unsupported'. In that case it keeps the server result. Server results that are not 'unsupported' return unchanged. Undefined server results still return the legacy result, as before. This matches the issue's suggested fallback option. The regression test in driver.test.ts (per the change summary) covers data: null with a stored Go key and three Go windows. I did not run the tests. The test result rests on the author's report and the diff summary. The Evidence section of the PR description is still pending, which does not block the code requirement. The issue has no non-coding acceptance criteria.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff against the merge base a35fd811749c2b65d917652cbdb90b28d65b2e0c touches the OpenCode driver usage-limit path (4 lines in driver.ts) and adds a driver regression test in driver.test.ts. Both directly implement
#36516. The PR description mentions open PR#36002. It states that the PR does not change that work, so no out-of-scope code is present.
Full details: Description check
-
Explanation
The description covers the problem (OpenCode 2 server returns data: null, so Go-key usage never loads), the change (checkUsageLimits falls back to the Go-key reader when the server result is unsupported), scope (links issue
#36516and a fix for it), and verification (a reproduction on main, a driver regression test that fails on main and passes with the fix, and 39/39 test runs). Visual evidence is provided, although the Evidence section is partly synthetic and the author notes it is still in progress. Some sections are wordy and contain duplicated lines, but the required information is present.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-36516
- File: .coderabbit.config.ts
- Commit: 2ff58ac
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
2fe2e057-e208-4614-be58-e17bf90f8bf6
Commits-
Reviewing files that changed from the base of the PR and between 2dd6cddbc3fc20a4c8a330dc7361750cccfe35e3 and 2ff58aca2745a31bc1ccac3a43d60f48a4ceaaf0.
Files selected for processing: 2-
packages/provider-opencode/src/server/driver.test.tspackages/provider-opencode/src/server/driver.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
-
-
maria-rcks merged this2123168
maria-rcks closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes