Repository navigation
Conversation
Co-authored-by: mmarabel <mmarabel@users.noreply.github.com>
9 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Usage popovers can show OpenCode Zen credit balances and Claude extra usage. Go quotas remain visible when billing cannot be fetched; an unknown Zen balance appears as Unavailable rather than zero.
What Changed
Parse the optional console billing response independently from Go quotas, preserving signed USD microcent amounts and limiting the extra request to five seconds. Parse Claude's supplied spend/legacy extra_usage payloads with their currency exponent, preserving missing balances. Share the popover section and currency formatting; the compact segment reveals a spendable balance only after a quota caps.
Why
Quota windows alone do not describe paid fallback spending. Keeping optional billing separate prevents a billing failure from erasing valid quotas. This ports the Claude/OpenCode portion of @mmarabel's #9363, with original author credit; its Codex probe changes are outside this focused scope.
Linked Issue
#8145 and #9362; continues the relevant parts of #9363.
Visual Proof
Real hidden Orca IPC quota snapshot, rendered with the baseline component:
Same source rendered with this component:
Explicit numerical fixture, not a real account balance:
Testing
132 focused tests in seven files pass: signed/zero microcent values, optional billing timeout/errors, balance-only console accounts, unknown balances, capped/disabled compact display, currency formatting and Claude payloads.
pnpm tc, changed-code quality, formatting, diff-check and commit hooks pass. Rebuilt hidden Electron app used disposable home/profile and CDP; no user config or shared OpenCode service changed.Installed OpenCode v2.0.16 and read-only reference source inspected. A direct private request with the isolated copied key returned403; Orca's Electron request independently returned valid Go quotas but no balance. Neither proves real console billing success. Real Go login from the account worker proves connection/persistence only. The official deployed console client now independently confirms the scoped billing endpoint and signed decimal-string microcent wire contract. This source inspection does not prove successful account authentication.
Review
Hold this draft for real authorized billing proof. The expected new-console contract is precisely tested:
/console/api/billing/status, console cookie plusx-org-id, prepaid/pay-as-you-go mode, signed integer-stringbalanceMicroCents, divided by100,000,000 for USD. Its wire schema and console-prefixed URL are independently confirmed in the official deployed console client: signed BigInt values encode as strings, USD conversion divides by100,000,000, and workspace scope uses x-org-id. A successful authenticated matched-workspace response remains unverified. No zero balance is inferred from failure.The successful API-key Go path has no verified Zen balance endpoint or identity match to a separate console cookie; it displays Unavailable rather than mixing two possibly different accounts. No successful billing fetch, live Claude credit response, or full issue resolution is claimed.
Agent skill upstream boundary
Notes
Preserves @mmarabel credit. No merge or closure performed; do not close the original PR until its remaining scope has a disposition.
Checklist
Review correction: commit
0c87d15fa19preserves the currency of a balance-only spend response and refuses inconsistent currencies across balance, spend and cap. Nine focused tests, full typecheck and changed-code quality pass; this is mapper fixture evidence and does not satisfy the authenticated billing merge hold.Review correction:
caf1d8bc9f8treats non-string currency fields as unavailable optional spending data. Real fetcher response fixtures with null and numeric currencies preserve valid quotas and return unavailable extra usage; 11 focused tests across two files, typecheck and changed-code quality pass. Authenticated billing proof remains pending.