Skip to content

restore(usage): bring back OpenUsage rate-limits panel + sidebar entry#80

Open
aaditagrawal wants to merge 2 commits intomainfrom
restore/openusage-rate-limits
Open

restore(usage): bring back OpenUsage rate-limits panel + sidebar entry#80
aaditagrawal wants to merge 2 commits intomainfrom
restore/openusage-rate-limits

Conversation

@aaditagrawal
Copy link
Copy Markdown
Owner

Summary

PR #77's merge of upstream's multi-provider SPI silently dropped 9 files for the OpenUsage rate-limits feature. This PR restores them, adapts to upstream's branded SPI, and wires the panel into the sidebar.

Restored from `97f179fd` (9 files)

  • `components/RateLimitsPanel.tsx` (collapsible sidebar group)
  • `components/RateLimitsPanel.test.tsx`
  • `components/RateLimitSummaryList.tsx`
  • `components/chat/RateLimitBanner.tsx` (banner — restored, not yet mounted)
  • `lib/openUsageRateLimits.ts` + `.test.ts` (local OpenUsage HTTP snapshot parser)
  • `lib/openUsageReactQuery.ts` (TanStack Query options)
  • `lib/rateLimits.ts` (`account.rate-limited` activity → `ProviderRateLimit[]`)
  • `lib/icons.tsx` (lucide aliases — distinct from the app's custom monochrome `Icons.tsx`)

Adaptation

Only API drift: `ProviderKind` → `ProviderDriverKind` (now branded via `ProviderDriverKind.make(...)`).

Wiring

  • New `SidebarProjectsContent` prop `threadsWithActivities` typed `readonly Pick<Thread, "activities">[]`.
  • Parent computes via `selectThreadsAcrossEnvironments` mapped to activities slice, wrapped in `useShallow` for stable refs.
  • Mounts as a `SidebarGroup` between the search row and projects section. Auto-hides when no rate-limit activities have arrived.

Test plan

  • `bunx tsc --noEmit` from `apps/web` — exit 0
  • `bunx vitest run` from `apps/web` — 995/995 pass (incl. 8 restored OpenUsage tests)
  • Manual smoke: trigger a rate-limit response from a provider, confirm panel appears in sidebar

Restored from commit 97f179f (pre-PR #77 state), with one adaptation
for upstream's new SPI:

  ProviderKind  →  ProviderDriverKind  (now branded; uses .make())

Adapted files:
- lib/openUsageRateLimits.ts (provider id → driver kind mapping)
- lib/openUsageReactQuery.ts (query key driver kind)

Restored verbatim:
- components/RateLimitsPanel.tsx (sidebar collapsible)
- components/RateLimitsPanel.test.tsx
- components/RateLimitSummaryList.tsx
- components/chat/RateLimitBanner.tsx (in-chat banner)
- lib/openUsageRateLimits.test.ts
- lib/rateLimits.ts (snapshot parsing core)
- lib/icons.tsx (lucide aliases — distinct from components/Icons.tsx
  which is the app's custom monochrome icon set)

Not yet wired: panel + banner are not mounted anywhere. Sidebar
integration follows in a subsequent commit.

Local: `bunx tsc --noEmit` clean from apps/web.
Mounts the restored OpenUsage rate-limits panel as a SidebarGroup
between the search row and the projects section. Conditional render —
the panel auto-hides itself when no rate-limit activities have
arrived (returns null), and the wrapper SidebarGroup also hides when
no threads-with-activities are subscribed, so the sidebar stays
clean for users who never hit a provider rate limit.

Plumbing:
- New SidebarProjectsContent prop `threadsWithActivities` typed as
  `readonly Pick<Thread, "activities">[]`.
- Parent computes it via `selectThreadsAcrossEnvironments` mapped
  to just the activities slice, wrapped in `useShallow` so the
  reference stays stable when activity slices are unchanged.

Tests: 995/995 web, including the restored 8 OpenUsage tests
(2 panel + 6 derivation).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Warning

Rate limit exceeded

@aaditagrawal has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 12 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6acca4d-abc9-4e21-a8aa-d30ea8939ff4

📥 Commits

Reviewing files that changed from the base of the PR and between ed24c37 and ce828fa.

📒 Files selected for processing (10)
  • apps/web/src/components/RateLimitSummaryList.tsx
  • apps/web/src/components/RateLimitsPanel.test.tsx
  • apps/web/src/components/RateLimitsPanel.tsx
  • apps/web/src/components/Sidebar.tsx
  • apps/web/src/components/chat/RateLimitBanner.tsx
  • apps/web/src/lib/icons.tsx
  • apps/web/src/lib/openUsageRateLimits.test.ts
  • apps/web/src/lib/openUsageRateLimits.ts
  • apps/web/src/lib/openUsageReactQuery.ts
  • apps/web/src/lib/rateLimits.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch restore/openusage-rate-limits

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 effective changed lines (test files excluded in mixed PRs). labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant