Skip to content

feat(web): surface provider rate limit usage in composer#73

Merged
tyulyukov merged 3 commits into
mainfrom
marcode/pr-provider-rate-limit-meter
Apr 29, 2026
Merged

feat(web): surface provider rate limit usage in composer#73
tyulyukov merged 3 commits into
mainfrom
marcode/pr-provider-rate-limit-meter

Conversation

@tyulyukov
Copy link
Copy Markdown
Owner

Summary

Ports t3code#2193 by @zaun (cherry-picks 7ae56af6 + 21162586) to MarCode.

Wires the account.rate-limits.updated events — already emitted by the Claude and Codex provider adapters — through the orchestration layer to the composer footer. Previously these events were silently dropped because ProviderRuntimeIngestion had no case for 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.

  • Codex: Displays both Session (5 hrs) and Weekly windows with accurate usedPercent, windowDurationMins, and resetsAt from the account/rateLimits/updated JSON-RPC notification.
  • Claude: Displays Session (5 hrs) window from the SDK's rate_limit_event. Weekly quota is not exposed by the Claude Agent SDK; usage is estimated from the status field when utilization is absent.

What changed

File Change
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Add account.rate-limits.updated case to create thread activities
apps/web/src/session-logic.ts Filter rate limit activities from the work log
apps/web/src/lib/providerUsage.ts (new) Parse + normalize rate limit data from both providers
apps/web/src/components/chat/ProviderUsageMeter.tsx (new) Bar graph icon + hover tooltip
apps/web/src/components/chat/ChatComposer.tsx Wire new meter into the composer footer

MarCode adjustments

  • Renamed import @t3tools/contracts@marcode/contracts in providerUsage.ts (only delta vs the upstream cherry-pick).

Test plan

  • bun --cwd apps/web run typecheck — clean
  • bun --cwd apps/web run test — 1104 passing
  • Manual smoke (reviewer): trigger Claude / Codex agent runs and verify the new meter appears next to the context window meter in the composer; hovering shows session/weekly bars with reset times.

Upstream

Original PR: pingdotgg#2193

zaun added 2 commits April 29, 2026 19:42
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
@tyulyukov tyulyukov merged commit a58106b into main Apr 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants