-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add rate limit countdown UI with neutral loading state #7923
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
base: main
Are you sure you want to change the base?
Conversation
- Created RateLimitCountdown component to display rate limit messages - Shows spinner with countdown timer and retry attempt info - Uses neutral styling instead of error colors - Added translations for rate limit messages - Updated ChatRow to properly handle api_req_retry_delayed messages Fixes #7922
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.
Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.
const isRetryingNow = message.toLowerCase().includes("retrying now") | ||
|
||
return ( | ||
<div |
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.
This component uses extensive inline styles instead of Tailwind CSS classes. Is this intentional? The rest of the codebase follows the Tailwind convention (as mentioned in the rules), so it would be more consistent to use classes like instead of inline styles.
isRetrying?: boolean | ||
} | ||
|
||
export const RateLimitCountdown: React.FC<RateLimitCountdownProps> = ({ message, isRetrying = false }) => { |
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.
The prop is passed in but never actually used in the component logic. Only is checked for determining the title. Could we either remove this prop or use it as intended?
// Parse the message to extract countdown seconds and retry attempt info | ||
const { seconds, attemptInfo } = useMemo(() => { | ||
// Match patterns like "Retrying in X seconds" or "Rate limiting for X seconds" | ||
const secondsMatch = message.match(/(\d+)\s+second/i) |
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.
These regex patterns might fail with unexpected message formats. Could we add more robust parsing or fallback behavior? For example:
isRetrying?: boolean | ||
} | ||
|
||
export const RateLimitCountdown: React.FC<RateLimitCountdownProps> = ({ message, isRetrying = false }) => { |
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.
Since this component will re-render frequently with countdown updates, could we wrap it in to improve performance? The component only needs to re-render when the message prop actually changes.
maxHeight: "200px", | ||
overflowY: "auto", | ||
}}> | ||
{message.split("\n\n")[0]} |
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.
This logic for extracting error details seems fragile. The component splits by "
" and shows the first part, but is this guaranteed to contain the actual error details? Could we make this more explicit or add a comment explaining the expected message format?
@@ -0,0 +1,113 @@ | |||
import React, { useMemo } from "react" |
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.
Missing test coverage for this new component. Could we add tests to verify:
- Correct parsing of countdown seconds
- Proper display of retry attempts
- Transition to "Retrying now..." state
- Error details expansion/collapse behavior
- Added rate limit translations to all locale files - Ensures consistency across all supported languages
@@ -390,5 +390,15 @@ | |||
"slashCommand": { | |||
"wantsToRun": "Roo 想要執行斜線指令:", | |||
"didRun": "Roo 執行了斜線指令:" | |||
}, | |||
"rateLimit": { |
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.
The new translation keys 'rateLimit' and 'rateLimitRetry' (lines 394-403) still contain English strings. Please provide proper Traditional Chinese translations to maintain localization consistency.
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
Fixes #7922
Summary
This PR improves the UI display when rate limits are triggered by replacing error-like text with a neutral loading state that includes a spinner and countdown timer.
Changes
RateLimitCountdown
component to display rate limit messages with neutral stylingChatRow
component to properly handleapi_req_retry_delayed
messagesTesting
Screenshots
The new component displays:
This provides a much better user experience compared to the previous error-like display.
Important
Adds
RateLimitCountdown
component for neutral rate limit UI with spinner and countdown, updatingChatRow
and translations.RateLimitCountdown
component inRateLimitCountdown.tsx
to display rate limit messages with a spinner and countdown timer.ChatRow.tsx
to handleapi_req_retry_delayed
messages usingRateLimitCountdown
.chat.json
forca
,de
, anden
.This description was created by
for 7c1dc63. You can customize this summary. It will automatically update as commits are pushed.