Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): Go-key-only instances keep OpenCode Go usage on OpenCode 2 #36519

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/36519/headmerged by maria-rcks View on GitHub

juliusmarmingecommented

No 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.

BeforeAfter — synthetic Go response
a35fd811742ff58aca27
Before: no provider limitsAfter: Go Session, Weekly and Monthly windows
Refresh recordingRefresh 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

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Approved at 2ff58ac

      Macroscope'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).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: 2dd6cdd · PR result: 2ff58ac · Source CI: success

      Scenario 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.

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      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.ts
      checkUsageLimits falls 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 returns data: 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 to 2ff58

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedDirectly linked issue #36516 requires 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 checkPassedThe 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 checkPassedThe 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 #36516 requires 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 #36516 and 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

      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.ts
      • packages/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.

    6. maria-rcks merged this2123168

    7. maria-rcks closed this

Sign in to join this conversation.