Skip to content

Refactor Limits page#296

Merged
sarimrmalik merged 30 commits intomainfrom
refactor/limits-page
Apr 24, 2026
Merged

Refactor Limits page#296
sarimrmalik merged 30 commits intomainfrom
refactor/limits-page

Conversation

@sarimrmalik
Copy link
Copy Markdown
Collaborator

@sarimrmalik sarimrmalik commented Apr 14, 2026

Ticket

  • Refactors the limits page into separate usage-limit and usage-alert sections, replacing the older card-based flow with simpler inline controls.
  • Adds dedicated forms and confirmation dialogs for setting, editing, and removing limits and alerts, improving focus behavior, cancel handling, and overall interaction clarity.
  • Cleans up the surrounding page structure and shared currency formatting so limit values are displayed and edited more consistently across the dashboard.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Apr 24, 2026 3:31pm
web-juliett Ready Ready Preview, Comment Apr 24, 2026 3:31pm

Request Review

…VGs, improving accessibility and layout. Adjusted font size and line height for better visual consistency.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 151d6883d8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/features/dashboard/limits/limit-section.tsx Outdated
Comment thread src/features/dashboard/limits/limit-section.tsx Outdated
Comment thread src/features/dashboard/limits/alert-ascii-icon.tsx Outdated
…onent and replacing it with UsageLimitForm and UsageAlertForm components. Introduce a new RemoveUsageLimitDialog for handling limit removals. Update the limit-section to utilize the new forms and adjust the UsageLimits component accordingly. Enhance currency formatting utilities for better input handling.
…n component and replacing it with separate UsageLimitSection and UsageAlertSection components. Update imports in UsageLimits to reflect the new structure. Enhance currency formatting in UsageLimitForm and UsageAlertForm for improved consistency.
…lity. Introduce shouldShowCancel logic to determine when the cancel button should be displayed, ensuring a clearer user experience when editing alert and limit values.
Introduce a new SetUsageLimitDialog component to facilitate setting usage limits within the dashboard. This dialog includes confirmation and cancellation options, enhancing user interaction when managing API limits. Update UsageLimitForm to integrate the new dialog and streamline the limit-setting process, replacing the previous confirmation dialog implementation.
…r displaying currency values. Update setDraftValue to format currency correctly when editing values, enhancing user experience and consistency in currency formatting.
…teraction. Introduce controlled dialog state management and update button icons for consistency. Improve editing experience by focusing input fields when editing, and streamline the handling of alert and limit removals.
…solidate loading and limits rendering logic into a single conditional block, and adjust layout for better responsiveness by changing max-width. This enhances user experience during data fetching.
Introduce a ref to track component mount status, ensuring that the effect for focusing the input field only runs after the component has mounted. This improves the user experience by preventing unintended focus behavior during the initial render.
… layout consistency. Update spacing in RemoveUsageLimitDialog and SetUsageLimitDialog for better alignment. Enhance UsageAlertForm and UsageLimitForm to manage input editability and focus behavior more intuitively, ensuring a smoother interaction when setting and removing usage limits.
@vojtabohm
Copy link
Copy Markdown
Collaborator

Feedback:

  1. Missing hover state, but I reckon this will become resolved once we merge in the design system integration and update textfields
Figma - 2026-04-19 at 08 28 06@2x
  1. The hit area of the block is smaller than the actual block
Arc.-.2026-04-19.at.08.29.21.mp4
  1. Dialogs should appear 180px from the top, not in the center. But again, if this is given by some more entangled logic, you can skip this in this PR.
Arc - 2026-04-19 at 08 30 31@2x
  1. Minor: when a limit is active, it's corresponding icons should change coloring:
Figma - 2026-04-19 at 08 32 14@2x Arc - 2026-04-19 at 08 32 20@2x
  1. Minor: spacing between related buttons should always be 4px
Arc - 2026-04-19 at 08 34 00@2x
  1. Change copy to 'Alert set/removed succesfully. Always use the same action verb in toast/status confirmations.
Arc - 2026-04-19 at 08 34 55@2x

…improved user interaction. Update border styles to include hover states, ensuring a more responsive design when users interact with the forms.
Introduce a new utility function to focus the first editable input on mouse down events, enhancing user interaction. Integrate this functionality into both forms to improve the editing experience by ensuring the correct input field is focused when users click outside of interactive elements.
…nd user experience. Adjust the top position of the dialog content and set a maximum height with overflow handling to enhance visibility and interaction.
…w AsciiIcon component for rendering ASCII art. Update active and inactive line definitions for improved visual representation based on state. Enhance UsageAlertSection and UsageLimitSection to conditionally render icons based on value presence, improving user feedback.
…oved clarity. Change messages to reflect successful actions more directly, enhancing user feedback when limits and alerts are set or removed.
Copy link
Copy Markdown
Member

@ben-fornefeld ben-fornefeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nits, lgtm otherwise!

Comment thread src/features/dashboard/limits/usage-limits.tsx Outdated
Comment thread src/features/dashboard/limits/currency-input.ts
Comment thread src/ui/primitives/dialog.tsx
…d alert dialogs

- Changed button variants from 'outline' and 'default' to 'secondary' and 'primary' respectively for consistency.
- Updated loading states to display descriptive messages ('Removing...' and 'Setting...') for better user feedback.
- Adjusted button classes to remove unnecessary size specifications, aligning with design system updates.
- Moved `CurrencyInputSchema` and `sanitizeCurrencyInput` to a new file for better structure.
- Removed the `formatCurrencyValue` function from tests and updated usages in `UsageAlertForm` and `UsageLimitForm` to use `formatNumber` instead.
- Adjusted related tests to reflect these changes, ensuring consistent currency formatting across the application.
- Updated the width class in the DialogContent component to ensure it adapts correctly across different screen sizes, enhancing the overall user experience.
@sarimrmalik sarimrmalik merged commit 7461111 into main Apr 24, 2026
10 checks passed
@sarimrmalik sarimrmalik deleted the refactor/limits-page branch April 24, 2026 15:37
ben-fornefeld added a commit that referenced this pull request Apr 29, 2026
## Summary
- Coerces missing `limit_amount_gte` / `alert_amount_gte` fields from
the billing API to `null` at the repository boundary so the rest of the
limits page can rely on the typed `number | null` contract.
- Fixes a client-side `Cannot read properties of undefined (reading
'toLocaleString')` crash on `/dashboard/[teamSlug]/limits` for any team
that has never set a usage limit or alert.

## Why this happened
The billing API's `BillingLimit` struct uses `*int64` with
`json:",omitempty"`, so unset limits are **omitted from the JSON
response entirely**, not serialized as explicit `null`. The recent
limits page refactor (#296) replaced the previous
`originalValue?.toLocaleString()` / `?? ''` pattern with strict `value
!== null` checks followed by `formatNumber(value)` — which lets
`undefined` slip through and throws inside `toLocaleString`.

I verified two weeks of `e2b-dev/belt` history (#654 sqlc migration,
#690 SupabaseDB cleanup, #693 oapi-codegen upgrade); none of them
changed the `BillingLimit` JSON shape. The API has always omitted unset
fields — the dashboard refactor is what removed the tolerance for
`undefined`.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants