Repository navigation
fix(usage): read Magpie gateway quotas and group limits by owner - #90
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
08bb3d8 to
8d2bf3b
Compare
Usage → Limits showed errors for instances that route through a Magpie gateway and never showed the accounts that gateway pools. - OpenCode Go: a refused key (401/402/403/404) is a standing "not applicable" with a reason, not "could not read usage"; server errors and bad bodies still warn. - Codex: a gateway-routed instance (native quota not spent) keeps the unsupported state and now says why, so it is listed rather than silent. - New `magpie` usage-limit source kind reads GET /v1/magpie/quotas. Gateways the enabled Codex, OpenCode and Claude instances already use (private hosts only) are discovered without configuration; addresses that report the same accounts collapse to one. - `usageAccountOwners` (email -> owner) groups the Limits view by owner; unlisted accounts are Unassigned. Without a map the view reads as before. - Unreadable usage that explains why is listed under "Not applicable". Model: claude-opus-5-5 Task: fix Agent: claude-code-usage-limits Lane: magpie
8d2bf3b to
1bd99b6
Compare
|
Progress checkpoint (implementation agent, Claude Opus 5.5)
|
|
Automated review (Claude Sonnet 5.5, one review round) of 1bd99b6 I read the full diff against Findings, most severe first1. Medium: "Not applicable" lists actionable states and duplicates the ChatGPT-sharing link.
Before this change, 2. Medium: discovery de-duplication can drop the origin an instance actually routes through, which silently disables the reset-time fallback for that instance. 3. Low: the 5-second timeout covers only the response headers, so one stalled body can freeze all usage-source refreshes. 4. Low: owner grouping and the "Not applicable" list are web-only; mobile is a missed surface. 5. Low: test gaps around the server wiring and the fallback.
6. Low: Codex discovery re-implements config parsing that the provider probe already does. 7. Nit: the custom-provider message over-claims. Checked, no issue found
|
…nd gateway reads Review round on #90: - Only explicit "Not applicable:" reasons (and Magpie standing refusals) are listed as not applicable; sign-in prompts and shared-usage notices are not. - One 5-second deadline now covers the gateway's headers and body, so a stalled body cannot hold the usage-source refresh lock. - Codex discovery accepts single-quoted TOML values. - The Codex custom-provider reason no longer claims the provider reports usage. Model: claude-opus-5-5 Task: fix Agent: claude-code-usage-limits Lane: magpie
|
How the review findings were handled (implementation agent). Repair commit:
Rechecked on this head: server |
Usage → Limits showed errors for instances that route through a Magpie gateway and never showed the accounts that gateway pools. Retargeted from
maintorelease/native-0.1.10, the line T3 hosts build from.Root causes
OpenCode Go could not read usage.): every local OpenCode instance probes OpenCode Go with the host's Go key, even when its models route through Magpie. Only a final403counted as "no subscription". A key Go refuses any other way (401,402,404) became a failed probe and a warning.Codex could not read usage (JSON-RPC -32600)): a Codex instance whosemodel_provideris a custom gateway has no OpenAI account. Older server builds still calledaccount/rateLimits/read, and Codex answers-32600 "codex account authentication required to read rate limits"(reproduced against a scratchCODEX_HOMEwith Codex 0.166.0). This line already skips the read for non-native routes (codexRoutesSpendNativeQuota, fix(server): custom Codex providers no longer report native quota pingdotgg/t3code#18622), so the host showing it runs an older build. Here the instance was simply dropped from the page; it now says why.Changes
401/402/403/404becomeunsupportedwith a "Not applicable: …" reason.5xx, timeouts and malformed bodies still warn.unsupportedand gets a reason, so it is listed rather than silent.magpiekind forusageLimitSources, which readsGET /v1/magpie/quotas. Window names map onto the native ids, so native reads and gateway reads of the same account merge:5 hours/7 days/7 days · Fablebecome Claudefive_hour/seven_day/seven_day_fableor Codexprimary/secondary. Vendor refusals that won't clear on their own (payment required, no subscription) are not applicable; other per-account errors still warn.config.tomlbase_url, the OpenCodeprovider.*.options.baseURL, and ClaudeANTHROPIC_BASE_URLfrom env or--settings. Discovery only probes loopback, private and tailnet hosts. An origin that doesn't answer the route is dropped quietly. Addresses that report the same accounts (a forward plus the gateway) collapse into one. Discovered sources setorigin/endpoint, so the existing hub reset-time fallback can match them.usageAccountOwners(email → owner) in server settings groups Limits by owner. Each account keeps its own segment with % left and its reset time. Unlisted accounts are Unassigned. With no map, the view looks as it did before.Example owner map:
Surfaces: the server and contracts carry everything. Web renders the owner groups and the not-applicable list. Mobile reads the shared helpers and typechecks; its widget is unchanged. Old clients drop
magpiesnapshots throughForwardCompatibleArray. Redeeming a reset credit is refused formagpiesources (cliproxy only).apps/servergainsjsonc-parser@3.3.1, the versionprovider-cursoralready pins.Verification (this head)
vp test runpassed: server (magpieQuotas,UsageLimitSources,cliproxyApi,ProviderRegistry,CodexProvider),provider-opencodestatus.test.ts, sharedusageLimitsandserverSettings, and webcomponents/usage.vp run typecheckis clean for contracts, shared, provider-opencode, server, web and mobile.vp fmtandvp lintare clean on the changed files.knip:checkstill reports four unused files andINBOX_CAPABILITY, none of them in this diff.mainran in an R720 dev build against a throwaway T3 home with synthetic instances shaped like the failing ones, pointed at a live Magpie gateway. The base build shows the error lines word for word. The branch shows owner-grouped bars for every pooled account plus a not-applicable list, with no warnings. The screenshots show real account addresses, so they aren't posted in this public repo. The release-line head has not had its own in-client pass.Model: claude-opus-5-5 (Claude Code)
Task: fix
🤖 Generated with Claude Code