-
Notifications
You must be signed in to change notification settings - Fork 5k
feat(web): prototype plan usage indicator in sidebar #8138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
roni-estein
wants to merge
3
commits into
pingdotgg:main
from
roni-estein:feat/provider-usage-indicator
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { normalizeClaudePlanUsage, normalizeCodexPlanUsage } from "./providerPlanUsage.ts"; | ||
|
|
||
| const checkedAt = "2026-08-24T18:00:00.000Z"; | ||
|
|
||
| describe("provider plan usage", () => { | ||
| it("normalizes Codex primary and weekly windows", () => { | ||
| expect( | ||
| normalizeCodexPlanUsage( | ||
| { | ||
| rateLimits: { | ||
| limitId: "codex", | ||
| primary: { usedPercent: 31, windowDurationMins: 300, resetsAt: 1_777_000_000 }, | ||
| secondary: { usedPercent: 72, windowDurationMins: 10_080, resetsAt: 1_777_500_000 }, | ||
| }, | ||
| }, | ||
| checkedAt, | ||
| ), | ||
| ).toEqual({ | ||
| checkedAt, | ||
| windows: [ | ||
| { | ||
| id: "codex:primary", | ||
| label: "5-hour", | ||
| usedPercent: 31, | ||
| resetsAt: "2026-04-24T03:06:40.000Z", | ||
| windowDurationMinutes: 300, | ||
| }, | ||
| { | ||
| id: "codex:secondary", | ||
| label: "Weekly", | ||
| usedPercent: 72, | ||
| resetsAt: "2026-04-29T22:00:00.000Z", | ||
| windowDurationMinutes: 10_080, | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| it("keeps named Codex buckets distinct and clamps percentages", () => { | ||
| const usage = normalizeCodexPlanUsage( | ||
| { | ||
| rateLimitsByLimitId: { | ||
| codex: { limitName: "Codex", primary: { usedPercent: -1 } }, | ||
| codex_fast: { limitName: "Fast", primary: { usedPercent: 120 } }, | ||
| }, | ||
| }, | ||
| checkedAt, | ||
| ); | ||
|
|
||
| expect(usage?.windows).toEqual([ | ||
| { | ||
| id: "codex:primary", | ||
| label: "Primary", | ||
| usedPercent: 0, | ||
| resetsAt: null, | ||
| }, | ||
| { | ||
| id: "codex_fast:primary", | ||
| label: "Fast · Primary", | ||
| usedPercent: 100, | ||
| resetsAt: null, | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it("normalizes Claude all-models and forward-compatible Fable windows", () => { | ||
| expect( | ||
| normalizeClaudePlanUsage( | ||
| { | ||
| seven_day: { utilization: 10, resets_at: "2026-08-29T01:00:00Z" }, | ||
| seven_day_fable: { utilization: 18, resets_at: "2026-08-29T01:00:00Z" }, | ||
| extra_usage: { utilization: 70 }, | ||
| }, | ||
| checkedAt, | ||
| ), | ||
| ).toEqual({ | ||
| checkedAt, | ||
| windows: [ | ||
| { | ||
| id: "seven_day", | ||
| label: "All models", | ||
| usedPercent: 10, | ||
| resetsAt: "2026-08-29T01:00:00.000Z", | ||
| windowDurationMinutes: 10_080, | ||
| }, | ||
| { | ||
| id: "seven_day_fable", | ||
| label: "Fable", | ||
| usedPercent: 18, | ||
| resetsAt: "2026-08-29T01:00:00.000Z", | ||
| windowDurationMinutes: 10_080, | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| it("omits unavailable and malformed usage", () => { | ||
| expect(normalizeCodexPlanUsage({}, checkedAt)).toBeUndefined(); | ||
| expect(normalizeClaudePlanUsage(null, checkedAt)).toBeUndefined(); | ||
| expect( | ||
| normalizeClaudePlanUsage({ seven_day: { utilization: "10" } }, checkedAt), | ||
| ).toBeUndefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage probe can break Claude auth
High Severity
After a successful
initializationResult(), the probe awaits the experimental usage API inside the same timed Effect. A hang or slowget_usageresponse burns the shared 25s budget, so the whole probe returnsundefinedeven though account data was already fetched. That surfaces Claude as unverified (warning/auth: unknown) and is cached for five minutes.Additional Locations (1)
apps/server/src/provider/Layers/ClaudeProvider.ts#L782-L794Reviewed by Cursor Bugbot for commit 9d9d5da. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e774eb9. Account initialization remains authoritative; the experimental usage request now has its own short timeout inside the remaining probe budget. If usage hangs, the probe preserves the account and slash commands and returns no rate-limit data. The SDK-boundary test now covers that case.