Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): Go usage shows once across environments sharing a Console workspace #44425

Mergedjuliusmarmingemerged 0 commits intomain fromrefs/pull/44425/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

When two linked environments were signed in to the same OpenCode Console workspace, Usage → Limits showed the OpenCode Go subscription once per environment: two bars per window, and a pooled percentage and forecast that counted the subscription twice. OpenCode 2 usage readings now carry the Console workspace id as their credential fingerprint, so the existing account merge shows the subscription once.

Fixes pingdotgg/t3code#44416

Reproduction on main

Commit 6696eefe21 (origin/main). Wrote a stub OpenCode 2 HTTP server on loopback: /api/info returns version 2.4.2; /api/experimental/usage/limits returns one Console workspace (id wrk_shared) with Go rolling/weekly/monthly meters, rolling alternating 96/97% per read. Started two T3 servers with fresh databases (T3CODE_DEV_SEED=0 vp run dev --home-dir <A> and node apps/server/src/bin.ts serve --base-dir <B>), each with settings.json providerInstances.opencode = {driver: opencode, enabled: true, config: {serverUrl: }}. Both servers polled the stub's usage endpoint. In A's web client: Settings → Environments → Add environment, entered B's host and a pairing code minted with t3 pair --base-dir <B>; 2 machines shown. Opened /usage, Limits tab, All environments. Observed one OpenCode section where every Go window (Session, Weekly, Monthly) shows two 'OpenCode' bars with the same reset time: Session 3% and 4% left, Weekly 82%/82%, Monthly 89%/89%. The pooled headline and forecast ('4% left, ↻ +49% in 2h 58m') are computed from both reports. Capture: https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/af8a258fb02c0bac/opencode-limits-two-envs.png ; stub script: https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/1d3d219d57191348/opencode2-stub.mjs . Failing test on factory/repro-44416 (OpenCode2Client.test.ts, 'reads the connected workspace and maps Go and Console budgets'): fails on main with 'expected undefined to be a string' at the credentialFingerprint assertion; returning credentialFingerprint workspace:<id> from readServerUsageLimits makes all 18 tests in the file pass (checked, then reverted).

Evidence

On each commit, start two fresh T3 environments pointing at the same synthetic OpenCode Console workspace, link them through Settings, then open Usage → Limits → All environments and refresh. Chromium, 1280×800, light theme.

Proven: scenarios:prove exited 0. Base displayed six bars; head displayed three. Base pooled duplicate reports and showed reset forecasts of +48%, +9%, and +6%; head displayed a single subscription without pooled forecasts.

BeforeAfter
6696eefe212f393cde29
Before: two OpenCode bars per Go windowAfter: one OpenCode bar per Go window
Assertion: expected 3 bars, received 6Assertion passed: 3 bars

Reproduction scenario, including stub and configuration.

Not shown:

  • Desktop and mobile clients were not run; this proof covers the real web client using the reported stub reproduction.

Tests

  • vp test run src/server/v2/OpenCode2Client.test.ts (packages/provider-opencode): fails without the fix (expected undefined to be a string); 18/18 pass with it
  • vp run check:changed: format, lint, knip, typecheck (10 packages) and tests (2 files) all pass
  • CI on 2f393cd: all 39 checks passed

Not in this change

  • The legacy OpenCode Go API-key reader fingerprints by key hash, so one environment on the legacy reader and another on OpenCode 2 for the same subscription still produce separate rows.
  • Open PR #37429 covers the same bug and needs a rebase; it was not used or changed.

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. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

      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: 7b8a637 · PR result: 2f393cd · 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.

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

      No actionable comments were generated in the recent review.

      Walkthrough

      OpenCode 2 usage-limit results now include a credential fingerprint derived from the Console workspace ID. The test verifies that the fingerprint changes with the workspace and matches across connections using the same workspace.

      Changes: OpenCode 2 workspace identity

      Layer / File(s)Summary
      Add and verify workspace fingerprint
      packages/provider-opencode/src/server/v2/usageLimits.ts, packages/provider-opencode/src/server/v2/OpenCode2Client.test.ts
      Successful usage-limit results include credentialFingerprint: [REDACTED]. The test checks that the fingerprint changes when the workspace changes and matches across connections using the same workspace.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Possibly related issues

      • pingdotgg/t3code#31040 — It describes duplicate OpenCode Go usage for one subscription. This change adds workspace-based identity for OpenCode 2 reports, but does not change the legacy API-key reader.

      Possibly related PRs

      • pingdotgg/t3code#37429 — It uses the same workspace-ID fingerprint for OpenCode usage reports through the other reader.
      • pingdotgg/t3code#14209 — It adds the existing credential-fingerprint merge behavior that this change uses.

      Suggested reviewers: macroscopeapp, nthewara

      Merge Risk: Minimal · up to 2f393

      OpenCode 2 usage from linked environments sharing a Console workspace should now merge into one account in Usage → Limits. No merge-blocking risk was found, and the change is small and easy to revert.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the fix and the affected area: OpenCode Go usage shown once across environments that share a Console workspace. The change adds a workspace-based credential fingerprint to OpenCode 2 u…
      Linked Issues checkPassedObjective [#44416]: OpenCode 2 usage from linked environments that share one Console workspace must merge into one OpenCode account, so Session, Weekly, and Monthly show one bar each and the pooled va…
      Out of Scope Changes checkPassedThe whole-PR changes are limited to the OpenCode 2 usage reader (one added fingerprint field with an explanatory comment) and its test file in OpenCode2Client.test.ts. The test change verifies the new…
      Description checkPassedThe description covers the problem, the change, scope, and verification. It states the bug (duplicate OpenCode bars and double-counted pooled percentages and forecasts when two linked environments sha…
      Full details: Title check

      Explanation

      The title names the fix and the affected area: OpenCode Go usage shown once across environments that share a Console workspace. The change adds a workspace-based credential fingerprint to OpenCode 2 usage readings so the existing account merge combines them, which matches the title's main point.

      Full details: Linked Issues check

      Explanation

      Objective [#44416]: OpenCode 2 usage from linked environments that share one Console workspace must merge into one OpenCode account, so Session, Weekly, and Monthly show one bar each and the pooled values count the subscription once. The root cause in the issue is that the OpenCode 2 workspace reader returns no credentialFingerprint, so collectLimitAccounts in packages/shared/src/usageLimits.ts falls back to the per-environment key. The reviewed diff of packages/provider-opencode/src/server/v2/usageLimits.ts adds credentialFingerprint: ***REDACTED_SECRET_ASSIGNMENT*** to the successful readServerUsageLimits result. Both environments now produce the same fingerprint, so the existing merge applies. The test file OpenCode2Client.test.ts was updated to expect a string fingerprint. Limits: I did not re-read the shared merge code in this review; the merge behavior relies on the issue's description of collectLimitAccounts. I did not re-run the tests; the author reports 18/18 passing. The legacy API-key variant (#31040/#31070) is explicitly excluded by the PR and the issue, so its absence is not a gap here.

      Full details: Out of Scope Changes check

      Explanation

      The whole-PR changes are limited to the OpenCode 2 usage reader (one added fingerprint field with an explanatory comment) and its test file in OpenCode2Client.test.ts. The test change verifies the new fingerprint, including that a different workspace yields a different fingerprint. Both changes connect directly to the linked objective. The PR description's documentation of reproduction, evidence, and factory attribution is not a code change and is not out of scope. No unrelated files were identified in the provided summary.

      Full details: Description check

      Explanation

      The description covers the problem, the change, scope, and verification. It states the bug (duplicate OpenCode bars and double-counted pooled percentages and forecasts when two linked environments share one Console workspace) and the fix (OpenCode 2 usage readings carry the Console workspace id as a credential fingerprint). It links issue #44416, gives a reproduction on main, and reports focused test results (18/18 pass with the fix, failing without it) plus check:changed and CI results. It also notes what is not covered: the legacy API-key reader and desktop/mobile clients. The template's attribution line for the agent is present. Minor gaps: the title is not shown in the provided text, and the Scope section explains the link to the bug but does not state a maintainer request.

      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 89e3557126ba8b24901a2d73bc375532881b22c1 and 2f393cde29533e2db9682d35b6d15da21d800554.

      Files selected for processing: 2

      • packages/provider-opencode/src/server/v2/OpenCode2Client.test.ts
      • packages/provider-opencode/src/server/v2/usageLimits.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

    3. juliusmarminge merged this0e15425

    4. juliusmarminge closed this

Sign in to join this conversation.