Skip to content

fix(web): thread details show a linked environment's fresher usage for the same account - #41082

Open
K1erans wants to merge 4 commits into
pingdotgg:mainfrom
K1erans:fix/thread-details-cross-env-usage
Open

K1erans wants to merge 4 commits into
pingdotgg:mainfrom
K1erans:fix/thread-details-cross-env-usage

Conversation

@K1erans

@K1erans K1erans commented Nov 22, 2026 •

Copy link
Copy Markdown

Problem

With two linked environments signed in to the same account, the thread details usage bars can disagree depending on which machine the thread runs on. I'm signed in to the same Google account for Antigravity on my Mac and on a Linux laptop, and both run 0.1.12-nightly.20261121.5051. At the same moment, a Mac thread showed Gemini 5-hour 69% / Weekly 90% remaining, and a Linux thread showed 92% / 97%. About 45 minutes later, the Linux thread still showed 92% / 97% while an Antigravity turn on the Linux laptop failed with "Individual quota reached … Resets in 2h58m39s". Nothing in the UI shows that one of the readings is stale.

/usage-limits already merges same-account readings across environments (collectProviderUsageLimits with accountKeyResolver). ThreadDetailsUsage only reads the provider snapshot from the thread's own environment, so a stale or failed reading on that machine is shown even when a linked environment has a fresher reading of the same account.

Change

  • packages/shared/src/usageLimits.ts: pulls the "readable beats unreadable, then newer checkedAt wins" rule out of collectProviderUsageLimits into fresherLimits, and adds accountUsageLimits(provider, own, peers). It returns the freshest readable limits that any enabled, same-driver, same-account (accountKeyResolver) provider reports across environments. It returns the provider's own reading when the provider is disabled, routed through a custom endpoint (auth.endpoint), or reports unsupported. Endpoint-routed peers are never borrowed.
  • ThreadDetailsUsage.logic.ts: resolveThreadDetailsLimits takes the peer providers and uses accountUsageLimits for the instance's own limits. Hub pooling is unchanged.
  • ThreadDetailsUsage.tsx: reads the providers of the other environments from environmentPresentations.presentationsWithProvidersAtom, the same source /usage-limits uses.

No contract, server or provider changes.

Scope

A bug fix. Linked environments on one account show conflicting usage for the same account in thread details, while /usage-limits merges them correctly. The fix is small and provider-agnostic: it keys on credentialFingerprint / email / workspace through the existing accountKeyResolver. It does not touch the Antigravity server-side refresh issues already covered by #39544, #40474, #39740 and #34389. It is separate from #39752 and #39793: endpoint- and hub-routed instances keep their current behaviour here.

Known limits, which are intended:

  • If the local provider has no account key (usageLimits missing, or a probeFailed reading with no credentialFingerprint and no auth.email, as Antigravity reports before fix(server): Antigravity shows the signed-in Google account email #38097), there is nothing to match peers on, so thread details keep showing the local reading.
  • The /usage-limits banner stays local-only.

Verification

  • Tests. The new accountUsageLimits cases in usageLimits.test.ts fail on main (accountUsageLimits is not a function) and pass on this branch (usageLimits.test.ts + ThreadDetailsUsage.logic.test.ts: 113 passed; check:changed green). They are the only layer tested: the component and resolveThreadDetailsLimits only pass the linked environments' providers through. The cases cover same-fingerprint peers for codex, claudeAgent and antigravity; email and workspace keys; a readable peer replacing a probeFailed own reading; and disabled, different-account, endpoint-routed and unsupported providers, which never borrow.

  • Real app, before (official nightly on both machines, same account, readings disagree):

    Thread on the Mac Thread on the Linux laptop
    Mac thread details: Gemini 5-hour 69%, Weekly 90% Linux thread details: Gemini 5-hour 92%, Weekly 97%

    About 45 minutes later, an Antigravity turn on the Linux laptop failed with this error while its thread details still showed 92% / 97%:

    Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 2h58m39s.

    Later the same night the two readings disagreed again, this time the other way round. Both screenshots are from the desktop app on the Mac, 18 seconds apart (23:57:15 and 23:57:33). A thread on the Linux laptop showed Gemini 5-hour 0% / Weekly 71%, and a thread on the Mac showed 100% / 100% for the same Google account. As before, nothing in thread details shows which reading is current.

    Thread on the Linux laptop (TsMint), 23:57:15 Thread on the Mac, 23:57:33
    23:57:15, TsMint thread details: Gemini 5-hour 0%, Weekly 71% 23:57:33, MacBook Air thread details: Gemini 5-hour 100%, Weekly 100%

Implementation by Claude Sonnet 5.5 and Gemini 4 Neon in T3 Code; reviewed by Claude Fable 5.2 and Gemini 4 Neon.

🤖 Generated with Claude Code

K1erans and others added 3 commits November 22, 2026 21:18
…imits

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 22, 2026
The browser test mocked the presentations atom and the logic test passed on
main; accountUsageLimits in usageLimits.test.ts covers both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds account-level usage-limit selection across provider environments. It compares readable limits for matching native accounts, reuses the freshness comparison for native usage snapshots, and passes peer providers from environment presentations into thread usage resolution. Tests cover selection cases and rendered thread usage.

Changes: Cross-Environment Usage Limits

Layer / File(s) Summary
Account usage selection
packages/shared/src/usageLimits.ts, packages/shared/src/usageLimits.test.ts
Adds accountUsageLimits to select the freshest readable limits for a matching native account. Native usage snapshot selection now uses the same freshness comparison; reset-credit selection is unchanged. Tests cover account matching, freshness, and excluded peers.
Thread usage integration
apps/web/src/components/chat/ThreadDetailsUsage.tsx, apps/web/src/components/chat/ThreadDetailsUsage.logic.ts, apps/web/src/components/chat/ThreadDetailsUsage.logic.test.ts, apps/web/src/components/chat/ThreadDetailsUsage.browser.test.tsx
Thread details passes providers from environment presentations to usage resolution. The resolver applies account-level selection in its no-notice or no-hub path. Tests cover failed local readings and rendered usage from a fresher linked reading.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant environmentPresentations
  participant ThreadDetailsUsage
  participant resolveThreadDetailsLimits
  participant accountUsageLimits
  ThreadDetailsUsage->>environmentPresentations: Read provider presentations
  environmentPresentations-->>ThreadDetailsUsage: Return peer providers
  ThreadDetailsUsage->>resolveThreadDetailsLimits: Pass peer providers
  resolveThreadDetailsLimits->>accountUsageLimits: Select account usage limits
  accountUsageLimits-->>resolveThreadDetailsLimits: Return selected limits
  resolveThreadDetailsLimits-->>ThreadDetailsUsage: Return resolved limits
Loading

Possibly related issues

  • pingdotgg/t3code#36297 — The change updates the thread usage selection path, but the provided summaries do not establish that it handles the reported case where no account matches the thread’s instance ID.

Suggested reviewers: bil0000, maria-rcks

Merge Risk: Minimal · up to b4cb3

Thread details now show the freshest readable usage reading for the same account across linked environments. Behavior is unchanged for disabled, endpoint-routed and unsupported providers. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: thread details now show a linked environment's fresher usage reading for the same account. It follows the conventional commit format and the changeset (ThreadDetailsUs…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the template's main sections (Problem, Change, Scope, Verification) and explains the bug, the fix, the scope boundaries, and the test evidence. It names the affected files and …
Full details: Title check

Explanation

The title names the main change: thread details now show a linked environment's fresher usage reading for the same account. It follows the conventional commit format and the changeset (ThreadDetailsUsage, accountUsageLimits) matches it. It is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the template's main sections (Problem, Change, Scope, Verification) and explains the bug, the fix, the scope boundaries, and the test evidence. It names the affected files and states what stays unchanged. The Verification section reports focused test results and before-state screenshots. It has gaps: the after-state real-app result is not shown, and the PR reports a later mismatch in the other direction without a resolution. The author also reports test counts that differ from the PR objectives (113 passed versus 115 passed, and a browser test file that the description does not mention). The description also does not state which conventional commit title is used. Overall the description is mostly complete.

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 dd19bce and b4cb3d2.

Files selected for processing: 6

  • apps/web/src/components/chat/ThreadDetailsUsage.browser.test.tsx
  • apps/web/src/components/chat/ThreadDetailsUsage.logic.test.ts
  • apps/web/src/components/chat/ThreadDetailsUsage.logic.ts
  • apps/web/src/components/chat/ThreadDetailsUsage.tsx
  • packages/shared/src/usageLimits.test.ts
  • packages/shared/src/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.

@K1erans

K1erans commented Nov 22, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant