Skip to content

Conversation

@olweraltuve
Copy link
Contributor

@olweraltuve olweraltuve commented Mar 18, 2025

Introduce a new RateLimitControl component to manage per-profile rate limiting. The API configuration now includes a rateLimitSeconds option, allowing users to set a custom rate limit. This change also updates the AdvancedSettings and ApiOptions components to integrate the new rate limit functionality.

Add translations for the new rate limit settings in multiple languages.


Important

Adds rate limit control to API configurations with a new RateLimitControl component and updates translations across multiple languages.

  • Behavior:
    • Adds rateLimitSeconds option to ApiHandlerOptions in api.ts for per-profile rate limiting.
    • Updates API_CONFIG_KEYS in api.ts to include rateLimitSeconds.
    • Removes rate limit control from AdvancedSettings.tsx.
    • Integrates RateLimitControl in ApiOptions.tsx.
  • Components:
    • Introduces RateLimitControl component in RateLimitControl.tsx for managing rate limits.
  • Translations:
    • Adds translations for rate limit settings in ca/settings.json, de/settings.json, en/settings.json, es/settings.json, fr/settings.json, hi/settings.json, it/settings.json, ja/settings.json, ko/settings.json, pl/settings.json, pt-BR/settings.json, tr/settings.json, vi/settings.json, zh-CN/settings.json, zh-TW/settings.json.

This description was created by Ellipsis for 9efc90d. It will automatically update as commits are pushed.

Introduce a new RateLimitControl component to manage per-profile rate limiting. The API configuration now includes a rateLimitSeconds option, allowing users to set a custom rate limit. This change also updates the AdvancedSettings and ApiOptions components to integrate the new rate limit functionality.

Add translations for the new rate limit settings in multiple languages.
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2025

⚠️ No Changeset found

Latest commit: 733f2de

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 18, 2025
@olweraltuve olweraltuve changed the title feat(settings): add rate limit control for API configuration feat(settings): add rate limit control for Profile configuration Mar 20, 2025
@mrubens
Copy link
Collaborator

mrubens commented Mar 20, 2025

I think we should do the migration for the current value into all profiles. And are there more places to remove references to the global state?

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Mar 21, 2025
Add support for migrating global rate limit settings to individual API profiles. Introduce a migrations object to track migration status and apply rate limits during configuration saves. New tests ensure correct migration behavior for existing and new profiles.
Added mock global state to prevent rate limit errors during tests. Updated assertions to verify rate limit values in stored configurations. This ensures that the ConfigManager behaves correctly when handling rate limits in various scenarios.
@olweraltuve
Copy link
Contributor Author

I think everything looks good now; the migration of the previous value is already in place @mrubens


// If no global rate limit, use default value of 5 seconds
if (rateLimitSeconds === undefined) {
rateLimitSeconds = 5 // Default value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Default should be 0

// Apply rate limit migration if needed
if (!config.migrations.rateLimitMigrated) {
await this.migrateRateLimit(config)
config.migrations.rateLimitMigrated = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should clear out the global state rate limit too right?

Comment on lines +157 to +196
// If this is a new config or doesn't have rate limit, try to apply the global rate limit
if (!existingConfig || config.rateLimitSeconds === undefined) {
// Apply rate limit if not specified explicitly in the config being saved
if (config.rateLimitSeconds === undefined) {
let globalRateLimit: number | undefined

// First check if we have an existing migrated config to copy from
const anyExistingConfig = Object.values(currentConfig.apiConfigs)[0]
if (anyExistingConfig?.rateLimitSeconds !== undefined) {
globalRateLimit = anyExistingConfig.rateLimitSeconds
console.log(
`[RateLimitMigration] Using existing profile's rate limit value: ${globalRateLimit}s`,
)
} else {
// Otherwise check global state
try {
globalRateLimit = await this.context.globalState.get<number>("rateLimitSeconds")
console.log(
`[RateLimitMigration] Using global rate limit for new profile: ${globalRateLimit}s`,
)
} catch (error) {
console.error(
"[RateLimitMigration] Error getting global rate limit for new profile:",
error,
)
}

// Use default if not found
if (globalRateLimit === undefined) {
globalRateLimit = 5 // Default value
console.log(
`[RateLimitMigration] Using default rate limit value for new profile: ${globalRateLimit}s`,
)
}
}

// Apply the rate limit to the new config
config.rateLimitSeconds = globalRateLimit
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't need this code. After we do the migration, we should just remove the idea of a global rate limit.


<Section>
<div>
<div className="flex flex-col gap-2">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this just an empty section now? Can we get rid of it?

useDebounce(() => onChange(inputValue), 50, [onChange, inputValue])
// Sync internal state with prop changes when switching profiles
useEffect(() => {
const hasCustomRateLimit = value !== undefined && value !== null
Copy link
Collaborator

Choose a reason for hiding this comment

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

This checkbox doesn't seem to be serializing correctly

Screen.Recording.2025-03-24.at.3.10.38.PM.mov

@mrubens
Copy link
Collaborator

mrubens commented Apr 7, 2025

Completed in #2376. Thanks for pushing for this!

@mrubens mrubens closed this Apr 7, 2025
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants