feat(web): surface provider rate limit usage in composer#73
Merged
Conversation
Wire `account.rate-limits.updated` events from Claude and Codex through the orchestration layer to the frontend. Previously these events were emitted by the provider adapters but silently dropped because the orchestration ingestion had no handler for them. - Add `account.rate-limits.updated` case to ProviderRuntimeIngestion - Filter rate limit activities from the work log - Add providerUsage.ts lib to normalize Claude (rate_limit_event with utilization 0-1, rate_limit_type, resets_at) and Codex (primary/ secondary windows with usedPercent, windowDurationMins, resetsAt) into a common ProviderUsageSnapshot shape - Merge multiple Claude events (one per window type) into a single multi-window snapshot - Add ProviderUsageMeter component with bar graph icon and hover tooltip showing session % and weekly % with reset times - Render to the left of the existing ContextWindowMeter in the composer
The Claude SDK sends camelCase fields (rateLimitType, resetsAt) not
snake_case, and the utilization field may be absent entirely. The Codex
adapter double-nests the payload as { rateLimits: { rateLimits: {...} } }.
Fixed the normalizer to:
- Accept both camelCase and snake_case field names from Claude
- Handle missing utilization by estimating from status field
- Unwrap double-nested Codex rateLimits payloads
- Detect Codex format via nested rateLimits.limitId
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.
Summary
Ports t3code#2193 by @zaun (cherry-picks
7ae56af6+21162586) to MarCode.Wires the
account.rate-limits.updatedevents — already emitted by the Claude and Codex provider adapters — through the orchestration layer to the composer footer. Previously these events were silently dropped becauseProviderRuntimeIngestionhad nocasefor them.Adds a bar graph icon to the left of the existing context window meter in the composer footer. Hovering shows a tooltip with session % and weekly % usage bars plus reset times.
usedPercent,windowDurationMins, andresetsAtfrom theaccount/rateLimits/updatedJSON-RPC notification.rate_limit_event. Weekly quota is not exposed by the Claude Agent SDK; usage is estimated from thestatusfield whenutilizationis absent.What changed
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.tsaccount.rate-limits.updatedcase to create thread activitiesapps/web/src/session-logic.tsapps/web/src/lib/providerUsage.ts(new)apps/web/src/components/chat/ProviderUsageMeter.tsx(new)apps/web/src/components/chat/ChatComposer.tsxMarCode adjustments
@t3tools/contracts→@marcode/contractsinproviderUsage.ts(only delta vs the upstream cherry-pick).Test plan
bun --cwd apps/web run typecheck— cleanbun --cwd apps/web run test— 1104 passingUpstream
Original PR: pingdotgg#2193