Skip to content

Commit 71ae746

Browse files
Added a new setting of rateLimitAfter which enable/disable recalculation of Task.lastGlobalApiRequestTime after the API stream has ended
1 parent ab3cb1d commit 71ae746

27 files changed

+133
-1
lines changed

packages/types/src/global-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const globalSettingsSchema = z.object({
135135
diagnosticsEnabled: z.boolean().optional(),
136136

137137
rateLimitSeconds: z.number().optional(),
138+
rateLimitAfter: z.boolean().optional(),
138139
diffEnabled: z.boolean().optional(),
139140
fuzzyMatchThreshold: z.number().optional(),
140141
experiments: experimentsSchema.optional(),

packages/types/src/provider-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ const baseProviderSettingsSchema = z.object({
183183
fuzzyMatchThreshold: z.number().optional(),
184184
modelTemperature: z.number().nullish(),
185185
rateLimitSeconds: z.number().optional(),
186+
rateLimitAfter: z.boolean().optional(),
186187
consecutiveMistakeLimit: z.number().min(0).optional(),
187188

188189
// Model reasoning.

src/core/task/Task.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,10 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
29882988
// effectively passes along all subsequent chunks from the original
29892989
// stream.
29902990
yield* iterator
2991-
Task.lastGlobalApiRequestTime = performance.now()
2991+
2992+
if (apiConfiguration?.rateLimitAfter) {
2993+
Task.lastGlobalApiRequestTime = performance.now()
2994+
}
29922995
}
29932996

29942997
// Checkpoints

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ import { BedrockCustomArn } from "./providers/BedrockCustomArn"
124124
import { KiloCode } from "../kilocode/settings/providers/KiloCode" // kilocode_change
125125
import { buildDocLink } from "@src/utils/docLinks"
126126
import { KiloProviderRouting, KiloProviderRoutingManagedByOrganization } from "./providers/KiloProviderRouting"
127+
import { RateLimitAfterControl } from "./RateLimitAfterSettings"
127128

128129
export interface ApiOptionsProps {
129130
uriScheme: string | undefined
@@ -880,6 +881,10 @@ const ApiOptions = ({
880881
maxValue={2}
881882
/>
882883
)}
884+
<RateLimitAfterControl
885+
rateLimitAfterEnabled={apiConfiguration.rateLimitAfter}
886+
onChange={(field, value) => setApiConfigurationField(field, value)}
887+
/>
883888
<RateLimitSecondsControl
884889
value={apiConfiguration.rateLimitSeconds || 0}
885890
onChange={(value) => setApiConfigurationField("rateLimitSeconds", value)}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { useAppTranslation } from "@/i18n/TranslationContext"
2+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
3+
import { useCallback } from "react"
4+
5+
interface RateLimitAfterControlProps {
6+
rateLimitAfterEnabled?: boolean
7+
onChange: (field: "rateLimitAfter", value: any) => void
8+
}
9+
10+
export const RateLimitAfterControl: React.FC<RateLimitAfterControlProps> = ({
11+
rateLimitAfterEnabled = false,
12+
onChange,
13+
}) => {
14+
const { t } = useAppTranslation()
15+
16+
const handleTodoListEnabledChange = useCallback(
17+
(e: any) => {
18+
onChange("rateLimitAfter", e.target.checked)
19+
},
20+
[onChange],
21+
)
22+
return (
23+
<div className="flex flex-col gap-1">
24+
<div>
25+
<VSCodeCheckbox checked={rateLimitAfterEnabled} onChange={handleTodoListEnabledChange}>
26+
<span className="font-medium">{t("settings:providers.rateLimitAfter.label")}</span>
27+
</VSCodeCheckbox>
28+
<div className="text-vscode-descriptionForeground text-sm">
29+
{t("settings:providers.rateLimitAfter.description")}
30+
</div>
31+
</div>
32+
</div>
33+
)
34+
}

webview-ui/src/i18n/locales/ar/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/cs/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@
465465
},
466466
"resetDefaults": "Reset to Defaults"
467467
},
468+
"rateLimitAfter": {
469+
"label": "Rate limit on end",
470+
"description": "Start rate limiting after the API stream ends."
471+
},
468472
"rateLimitSeconds": {
469473
"label": "Rate limit",
470474
"description": "Minimum time between API requests."

0 commit comments

Comments
 (0)