mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
refactor: use dedicated api_req_rate_limited message type instead of string matching
This commit is contained in:
parent
b17bed1438
commit
02785b962c
4 changed files with 9 additions and 11 deletions
|
|
@ -302,6 +302,7 @@ export const runTask = async ({ run, task, publish, logger, jobToken }: RunTaskO
|
|||
"condense_context",
|
||||
"condense_context_error",
|
||||
"api_req_retry_delayed",
|
||||
"api_req_rate_limited",
|
||||
"api_req_retried",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ export function isNonBlockingAsk(ask: ClineAsk): ask is NonBlockingAsk {
|
|||
* - `api_req_finished`: Indicates an API request has completed successfully
|
||||
* - `api_req_retried`: Indicates an API request is being retried after a failure
|
||||
* - `api_req_retry_delayed`: Indicates an API request retry has been delayed
|
||||
* - `api_req_rate_limited`: Indicates user-configured rate limiting countdown (not an error)
|
||||
* - `api_req_deleted`: Indicates an API request has been deleted/cancelled
|
||||
* - `text`: General text message or assistant response
|
||||
* - `reasoning`: Assistant's reasoning or thought process (often hidden from user)
|
||||
|
|
@ -155,6 +156,7 @@ export const clineSays = [
|
|||
"api_req_finished",
|
||||
"api_req_retried",
|
||||
"api_req_retry_delayed",
|
||||
"api_req_rate_limited",
|
||||
"api_req_deleted",
|
||||
"text",
|
||||
"image",
|
||||
|
|
|
|||
|
|
@ -3706,10 +3706,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
|
||||
// Only show rate limiting message if we're not retrying. If retrying, we'll include the delay there.
|
||||
if (rateLimitDelay > 0 && retryAttempt === 0) {
|
||||
// Show countdown timer
|
||||
// Show countdown timer using dedicated rate limit message type
|
||||
for (let i = rateLimitDelay; i > 0; i--) {
|
||||
const delayMessage = `Rate limiting for ${i} seconds...`
|
||||
await this.say("api_req_retry_delayed", delayMessage, undefined, true)
|
||||
await this.say("api_req_rate_limited", String(i), undefined, true)
|
||||
await delay(1000)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1087,15 +1087,11 @@ export const ChatRowContent = ({
|
|||
)}
|
||||
</>
|
||||
)
|
||||
case "api_req_rate_limited":
|
||||
// User-configured rate limiting countdown (not an API error)
|
||||
const rateLimitSeconds = parseInt(message.text || "0", 10)
|
||||
return <RateLimitCountdown seconds={rateLimitSeconds} />
|
||||
case "api_req_retry_delayed":
|
||||
// Check if this is user-configured rate limiting (not an API error)
|
||||
if (message.text?.startsWith("Rate limiting for")) {
|
||||
// Extract countdown from message text: "Rate limiting for X seconds..."
|
||||
const rateLimitMatch = message.text.match(/Rate limiting for (\d+) seconds/)
|
||||
const countdown = rateLimitMatch ? parseInt(rateLimitMatch[1], 10) : 0
|
||||
return <RateLimitCountdown seconds={countdown} />
|
||||
}
|
||||
|
||||
let body = t(`chat:apiRequest.failed`)
|
||||
let retryInfo, rawError, code, docsURL
|
||||
if (message.text !== undefined) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue