-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(config): migrate global rate limit to profile-specific settings #1720
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
Changes from all commits
b4a1506
2b5e373
e1f3199
6301998
ade26f5
700db7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -1331,7 +1331,14 @@ export class ClineProvider implements vscode.WebviewViewProvider { | |||
| await this.postStateToWebview() | ||||
| break | ||||
| case "rateLimitSeconds": | ||||
| await this.updateGlobalState("rateLimitSeconds", message.value ?? 0) | ||||
| // Update the current API configuration with the rate limit value | ||||
| const currentApiConfigName = (await this.getGlobalState("currentApiConfigName")) as string | ||||
| if (currentApiConfigName) { | ||||
| const apiConfig = await this.configManager.loadConfig(currentApiConfigName) | ||||
| apiConfig.rateLimitSeconds = message.value ?? 0 | ||||
| await this.configManager.saveConfig(currentApiConfigName, apiConfig) | ||||
| await this.updateApiConfiguration(apiConfig) | ||||
| } | ||||
| await this.postStateToWebview() | ||||
| break | ||||
| case "writeDelayMs": | ||||
|
|
@@ -2296,7 +2303,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { | |||
| enableMcpServerCreation, | ||||
| alwaysApproveResubmit, | ||||
| requestDelaySeconds, | ||||
| rateLimitSeconds, | ||||
| // rateLimitSeconds is now part of apiConfiguration | ||||
| currentApiConfigName, | ||||
| listApiConfigMeta, | ||||
| mode, | ||||
|
|
@@ -2357,7 +2364,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { | |||
| enableMcpServerCreation: enableMcpServerCreation ?? true, | ||||
| alwaysApproveResubmit: alwaysApproveResubmit ?? false, | ||||
| requestDelaySeconds: requestDelaySeconds ?? 10, | ||||
| rateLimitSeconds: rateLimitSeconds ?? 0, | ||||
| rateLimitSeconds: apiConfiguration.rateLimitSeconds ?? 0, | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this? |
||||
| currentApiConfigName: currentApiConfigName ?? "default", | ||||
| listApiConfigMeta: listApiConfigMeta ?? [], | ||||
| mode: mode ?? defaultModeSlug, | ||||
|
|
@@ -2515,7 +2522,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { | |||
| enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true, | ||||
| alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false, | ||||
| requestDelaySeconds: Math.max(5, stateValues.requestDelaySeconds ?? 10), | ||||
| rateLimitSeconds: stateValues.rateLimitSeconds ?? 0, | ||||
| // rateLimitSeconds is now part of the API configuration | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| currentApiConfigName: stateValues.currentApiConfigName ?? "default", | ||||
| listApiConfigMeta: stateValues.listApiConfigMeta ?? [], | ||||
| modeApiConfigs: stateValues.modeApiConfigs ?? ({} as Record<Mode, string>), | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,7 @@ export interface ApiHandlerOptions { | |
| export type ApiConfiguration = ApiHandlerOptions & { | ||
| apiProvider?: ApiProvider | ||
| id?: string // stable unique identifier | ||
| rateLimitSeconds?: number // Rate limit in seconds between API requests | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to add this here |
||
| } | ||
|
|
||
| // Import GlobalStateKey type from globalState.ts | ||
|
|
@@ -130,6 +131,7 @@ export const API_CONFIG_KEYS: GlobalStateKey[] = [ | |
| "modelTemperature", | ||
| "modelMaxTokens", | ||
| "modelMaxThinkingTokens", | ||
| "rateLimitSeconds", // Added for profile-specific rate limiting | ||
| ] | ||
|
|
||
| // Models | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { SectionHeader } from "./SectionHeader" | |
| import { Section } from "./Section" | ||
|
|
||
| type AdvancedSettingsProps = HTMLAttributes<HTMLDivElement> & { | ||
| rateLimitSeconds: number | ||
| rateLimitSeconds?: number | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should move this out of the advanced settings and move it up near the model temperature so it's clear that it's linked to the profile
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I'm going to place it below the temperature
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks! |
||
| diffEnabled?: boolean | ||
| fuzzyMatchThreshold?: number | ||
| setCachedStateField: SetCachedStateField<"rateLimitSeconds" | "diffEnabled" | "fuzzyMatchThreshold"> | ||
|
|
@@ -50,11 +50,11 @@ export const AdvancedSettings = ({ | |
| min="0" | ||
| max="60" | ||
| step="1" | ||
| value={rateLimitSeconds} | ||
| value={rateLimitSeconds || 0} | ||
| onChange={(e) => setCachedStateField("rateLimitSeconds", parseInt(e.target.value))} | ||
| className="h-2 focus:outline-0 w-4/5 accent-vscode-button-background" | ||
| /> | ||
| <span style={{ ...sliderLabelStyle }}>{rateLimitSeconds}s</span> | ||
| <span style={{ ...sliderLabelStyle }}>{rateLimitSeconds || 0}s</span> | ||
| </div> | ||
| </div> | ||
| <p className="text-vscode-descriptionForeground text-sm mt-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.