fix(opencode): Go usage shows once across environments sharing a Console workspace #44425
main fromrefs/pull/44425/head·merged by juliusmarminge View on GitHubWhen 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.
| Before | After |
|---|---|
| 6696eefe21 | 2f393cde29 |
![]() | ![]() |
| Assertion: expected 3 bars, received 6 | Assertion 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 itvp 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
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
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.tsSuccessful 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 to2f393-
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:
4-
Check name Status Explanation Title check 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 u… Linked Issues check 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 va…Out of Scope Changes check 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… Description check 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 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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-44416
- File: .coderabbit.config.ts
- Commit: 2f393cd
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
93cedf00-2908-4ca0-853f-373fe2888c31
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.tspackages/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.
-
-
juliusmarminge merged this0e15425
juliusmarminge closed this
Sign in to join this conversation.


Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
short turn resumeWebSocket decodedshort turn resumeWebSocket messageslong turn running, cold openHTTP decodedlong turn running, cold openrowslong turn running, history pageHTTP decodedlong turn running, history pagerowslong turn finished, cold openHTTP decodedlong turn finished, cold openrowslong turn finished, socket cold openWebSocket decodedlong turn finished, socket cold openWebSocket messageslong turn finished, socket cold openrowslong turn finished, work pageHTTP decodedlong turn finished, work pagerowsidle thread resumeWebSocket decodedidle thread resumeWebSocket messagesfleet shell snapshotHTTP decodedfleet shell snapshotrowsfleet shell subscribeWebSocket decodedfleet shell subscribeWebSocket messagesfleet shell resume checkHTTP decodedfleet shell resume checkrowsstale shell reloadHTTP decodedstale shell reloadrowsstale shell resumeWebSocket decodedstale shell resumeWebSocket messagesstale todo list cold openHTTP decodedstale todo list cold openrowsstale todo list cold opennodesstale todo list cold opensubagentsstale todo list cold openplansstale todo list cold openproviderTurnsstale todo list cold opencheckpointsshort turn resumeWebSocket decodedshort turn resumeWebSocket messageslong turn running, cold openHTTP decodedlong turn running, cold openrowslong turn running, history pageHTTP decodedlong turn running, history pagerowslong turn finished, cold openHTTP decodedlong turn finished, cold openrowslong turn finished, socket cold openWebSocket decodedlong turn finished, socket cold openWebSocket messageslong turn finished, socket cold openrowslong turn finished, work pageHTTP decodedlong turn finished, work pagerowsidle thread resumeWebSocket decodedidle thread resumeWebSocket messagesfleet shell snapshotHTTP decodedfleet shell snapshotrowsfleet shell subscribeWebSocket decodedfleet shell subscribeWebSocket messagesfleet shell resume checkHTTP decodedfleet shell resume checkrowsstale shell reloadHTTP decodedstale shell reloadrowsstale shell resumeWebSocket decodedstale shell resumeWebSocket messagesstale todo list cold openHTTP decodedstale todo list cold openrowsstale todo list cold opennodesstale todo list cold opensubagentsstale todo list cold openplansstale todo list cold openproviderTurnsstale todo list cold opencheckpointsBaseline:
7b8a637· PR result:2f393cd· 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.