Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): merge usage reports from the same workspace #36053

Closedproxynico(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/36053/headopened View on GitHub

Problem

Usage → Limits shows one OpenCode Go workspace once per connected environment when those environments use OpenCode 2's workspace-usage API. The repeated rows also make the pooled reset forecast treat one shared allowance as several accounts.

readServerUsageLimits decodes workspace.id but discards it. OpenCode reports no account email here, so collectLimitAccounts receives neither an email nor a credential fingerprint and falls back to separate environment/instance keys.

Change

Publish opencode-workspace:${workspace.id} in the existing credentialFingerprint field. The existing shared account collector can then combine reports from the same workspace and keep different workspaces separate. Web, desktop and mobile already consume this field.

Extend the existing connected-workspace test to require a stable identity on repeated reads and a different identity after switching workspaces.

Scope

This is a small fix for an omitted identity in an existing API adapter, with no new feature or workflow. It uses the existing contribution exception for obvious bug fixes.

Related: #31070 groups legacy Go readings from different API keys. That change still requires credentialFingerprint; it does not supply the missing identity from the OpenCode 2 workspace API. This patch leaves the legacy credential reader unchanged.

Verification

  • The new assertion fails on unchanged main with expected undefined to equal 'opencode-workspace:wrk_remote' and passes with the fix.
  • OpenCode2Client.test.ts and driver.test.ts: 56 passed with OPENCODE_AUTH_CONTENT={} to isolate tests from the host's credentials.
  • The existing shared account-collector test passes: matching OpenCode fingerprints produce one account and one member per pooled window, while distinct fingerprints stay separate.
  • The OpenCode package type check, changed-file lint, formatting and whitespace checks pass.
  • vp run check:changed --concurrency 1 passes on current main: format, lint, both knip checks, type checks for 10 affected packages, and 20 tests across two files. The unused dependency-patch check is skipped because no dependency files changed; full builds and test suites remain with CI.

The installed T3 app was not rebuilt or restarted. No live multi-environment desktop or native mobile verification is claimed; this changes the server's identity data, not the render path.

Blast Radius

Only OpenCode 2 workspace-usage reports gain an identity. Reports for the same workspace now share a quota row; different workspace IDs remain separate. No credentials, persisted data or schemas change. Reverting the added field restores the previous grouping behavior.

Created with GPT-6.1 Sol in the Codex harness through T3 Code.

    1. tanstack-source added labelsbug

    2. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented
      Codex Review Summary: ✅ Completed

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-11-13T07:04:20.349592Z45ca354PR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

    4. Approvability

      Verdict: Approved at 45ca354

      Macroscope's review found this PR approvable — OpenCode 2 reports now include workspace identity so connected environments share one quota row and pooled forecast. The change uses existing report-grouping logic without altering charges, permissions, or stored data.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The usage-limits result now includes a credential fingerprint derived from the OpenCode workspace ID. The test checks that the fingerprint stays the same for the same workspace and changes when the workspace ID changes.

      Changes: OpenCode workspace fingerprint

      Layer / File(s)Summary
      Fingerprint generation and validation
      packages/provider-opencode/src/server/v2/usageLimits.ts, packages/provider-opencode/src/server/v2/OpenCode2Client.test.ts
      readServerUsageLimits returns a fingerprint prefixed with opencode-workspace: and containing the workspace ID. The test checks that repeated calls for one workspace return the same fingerprint and that a different workspace ID changes it.

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

      Change: Bug fix

      Suggested labels: bugfix

      Suggested reviewers: yash-singh1, macroscopeapp

      Merge Risk: Minimal · up to 45ca3

      OpenCode usage reports from the same workspace are now grouped under one account, and different workspaces stay separate. No concrete merge-blocking risk was found.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: OpenCode usage reports from the same workspace are merged. The PR adds a workspace-based credentialFingerprint so the shared account collector groups reports from one …
      Description checkPassedThe description follows the repository template. It has Problem, Change, Scope, Verification, and Blast Radius content. The Problem section explains the repeated usage rows and the root cause in readS…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title names the main change: OpenCode usage reports from the same workspace are merged. The PR adds a workspace-based credentialFingerprint so the shared account collector groups reports from one workspace and keeps different workspaces separate. The title is short, specific, and uses a conventional commit format.

      Full details: Description check

      Explanation

      The description follows the repository template. It has Problem, Change, Scope, Verification, and Blast Radius content. The Problem section explains the repeated usage rows and the root cause in readServerUsageLimits. The Change section names the new credentialFingerprint value and the affected behavior. Scope cites the bug-fix exception and a related PR. Verification gives specific test commands and observed results, including a failing assertion before the fix and the passing checks after it. It also states what was not verified. The template's agent-attribution line is present. The description does not link a tracking issue in Scope, but it does explain why none is needed, which the template allows for small obvious fixes. The Verification section relies on local runs, and the template does not require more.

      Finishing Touches

      Generate unit tests (beta)

      • 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 a2be070f30778bfb0502bd7453e130e897c8d4df and 45ca3547be3de2b8be9f953d0a0a8f248e8a413e.

      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; 9 remain after this review.

Sign in to join this conversation.