Skip to content

Commit 22ebf4e

Browse files
author
Chris Hasson
committed
refactor(ui): Consolidate API limit descriptions
Removed redundant description props from MaxCostInput and MaxRequestsInput components. The common description for both API limits is now handled in MaxLimitInputs, improving consistency and reducing duplication across i18n files.
1 parent b6e7f6e commit 22ebf4e

27 files changed

+106
-104
lines changed

webview-ui/src/components/chat/__tests__/AutoApproveMenu.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ vi.mock("@src/i18n/TranslationContext", () => ({
3434
"settings:autoApprove.updateTodoList.label": "Update todo list",
3535
"settings:autoApprove.apiRequestLimit.title": "API request limit",
3636
"settings:autoApprove.apiRequestLimit.unlimited": "Unlimited",
37-
"settings:autoApprove.apiRequestLimit.description": "Limit the number of API requests",
3837
"settings:autoApprove.readOnly.outsideWorkspace": "Also allow outside workspace",
3938
"settings:autoApprove.write.outsideWorkspace": "Also allow outside workspace",
4039
"settings:autoApprove.write.delay": "Delay",

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ interface MaxCostInputProps {
77
allowedMaxCost?: number
88
onValueChange: (value: number | undefined) => void
99
className?: string
10-
hideDescription?: boolean
1110
}
1211

13-
export function MaxCostInput({ allowedMaxCost, onValueChange, className, hideDescription }: MaxCostInputProps) {
12+
export function MaxCostInput({ allowedMaxCost, onValueChange, className }: MaxCostInputProps) {
1413
const { t } = useTranslation()
1514
const [inputValue, setInputValue] = useState("")
1615

@@ -72,7 +71,7 @@ export function MaxCostInput({ allowedMaxCost, onValueChange, className, hideDes
7271
)
7372

7473
return (
75-
<div className={`flex flex-col gap-3 pl-3 ${className || ""}`}>
74+
<div className={`flex flex-col gap-3 pl-3 flex-auto ${className || ""}`}>
7675
<div className="flex items-center gap-4 font-bold">
7776
<span className="codicon codicon-credit-card" />
7877
<div>{t("settings:autoApprove.apiCostLimit.title")}</div>
@@ -89,11 +88,6 @@ export function MaxCostInput({ allowedMaxCost, onValueChange, className, hideDes
8988
leftNodes={[<span key="dollar">$</span>]}
9089
/>
9190
</div>
92-
{!hideDescription && (
93-
<div className="text-vscode-descriptionForeground text-sm">
94-
{t("settings:autoApprove.apiCostLimit.description")}
95-
</div>
96-
)}
9791
</div>
9892
)
9993
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react"
2+
import { useTranslation } from "react-i18next"
23
import { MaxRequestsInput } from "./MaxRequestsInput"
34
import { MaxCostInput } from "./MaxCostInput"
45

@@ -15,18 +16,16 @@ export const MaxLimitInputs: React.FC<MaxLimitInputsProps> = ({
1516
onMaxRequestsChange,
1617
onMaxCostChange,
1718
}) => {
19+
const { t } = useTranslation()
20+
1821
return (
1922
<div className="space-y-2">
20-
<div className="flex">
21-
<MaxRequestsInput
22-
allowedMaxRequests={allowedMaxRequests}
23-
onValueChange={onMaxRequestsChange}
24-
hideDescription
25-
/>
26-
<MaxCostInput allowedMaxCost={allowedMaxCost} onValueChange={onMaxCostChange} hideDescription />
23+
<div className="flex justify-stretch">
24+
<MaxRequestsInput allowedMaxRequests={allowedMaxRequests} onValueChange={onMaxRequestsChange} />
25+
<MaxCostInput allowedMaxCost={allowedMaxCost} onValueChange={onMaxCostChange} />
2726
</div>
2827
<div className="text-xs text-vscode-descriptionForeground">
29-
Automatically make requests up to these limits before asking for approval to continue.
28+
{t("settings:autoApprove.maxLimits.description")}
3029
</div>
3130
</div>
3231
)

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ interface MaxRequestsInputProps {
77
allowedMaxRequests?: number
88
onValueChange: (value: number | undefined) => void
99
className?: string
10-
hideDescription?: boolean
1110
}
1211

13-
export function MaxRequestsInput({
14-
allowedMaxRequests,
15-
onValueChange,
16-
className,
17-
hideDescription,
18-
}: MaxRequestsInputProps) {
12+
export function MaxRequestsInput({ allowedMaxRequests, onValueChange, className }: MaxRequestsInputProps) {
1913
const { t } = useTranslation()
2014

2115
const handleValueChange = useCallback(
@@ -27,7 +21,7 @@ export function MaxRequestsInput({
2721
)
2822

2923
return (
30-
<div className={`flex flex-col gap-3 pl-3 ${className || ""}`}>
24+
<div className={`flex flex-col gap-3 pl-3 flex-auto ${className || ""}`}>
3125
<div className="flex items-center gap-4 font-bold">
3226
<span className="codicon codicon-pulse" />
3327
<div>{t("settings:autoApprove.apiRequestLimit.title")}</div>
@@ -42,11 +36,6 @@ export function MaxRequestsInput({
4236
data-testid="max-requests-input"
4337
/>
4438
</div>
45-
{!hideDescription && (
46-
<div className="text-vscode-descriptionForeground text-sm">
47-
{t("settings:autoApprove.apiRequestLimit.description")}
48-
</div>
49-
)}
5039
</div>
5140
)
5241
}

webview-ui/src/components/settings/__tests__/MaxRequestsInput.spec.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ vi.mock("@/utils/vscode", () => ({
99
vi.mock("react-i18next", () => ({
1010
useTranslation: () => {
1111
const translations: Record<string, string> = {
12-
"settings:autoApprove.apiRequestLimit.title": "Max API Requests",
12+
"settings:autoApprove.apiRequestLimit.title": "Max Count",
1313
"settings:autoApprove.apiRequestLimit.unlimited": "Unlimited",
14-
"settings:autoApprove.apiRequestLimit.description": "Limit the number of API requests",
1514
}
1615
return { t: (key: string) => translations[key] || key }
1716
},

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@
197197
},
198198
"apiRequestLimit": {
199199
"title": "أقصى الطلبات",
200-
"description": "عدد طلبات API قبل طلب الموافقة.",
201200
"unlimited": "غير محدود"
202201
},
203202
"toggleAriaLabel": "تبديل الموافقة التلقائية",
204203
"disabledAriaLabel": "الموافقة التلقائية معطلة - اختر الخيارات أولاً",
205204
"apiCostLimit": {
206205
"title": "Cost màxim de l'API",
207-
"description": "Gasta automàticament fins a aquesta quantitat en costos d'API abans de demanar aprovació per continuar amb la tasca.",
208206
"unlimited": "Il·limitat"
209207
},
210-
"selectOptionsFirst": "اختر خيار واحد على الأقل أدناه لتفعيل الموافقة التلقائية"
208+
"selectOptionsFirst": "اختر خيار واحد على الأقل أدناه لتفعيل الموافقة التلقائية",
209+
"maxLimits": {
210+
"description": "قم تلقائياً بإجراء الطلبات حتى هذه الحدود قبل طلب الموافقة للاستمرار."
211+
}
211212
},
212213
"providers": {
213214
"providerDocumentation": "توثيق {{provider}}",

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,16 @@
195195
},
196196
"apiRequestLimit": {
197197
"title": "Màximes Sol·licituds",
198-
"description": "Fes aquesta quantitat de sol·licituds API automàticament abans de demanar aprovació per continuar amb la tasca.",
199198
"unlimited": "Il·limitat"
200199
},
201200
"apiCostLimit": {
202201
"title": "Cost màxim de l'API",
203-
"description": "Gasta automàticament fins a aquesta quantitat en costos d'API abans de demanar aprovació per continuar amb la tasca.",
204202
"unlimited": "Il·limitat"
205203
},
206-
"selectOptionsFirst": "Seleccioneu almenys una opció a continuació per activar l'aprovació automàtica"
204+
"selectOptionsFirst": "Seleccioneu almenys una opció a continuació per activar l'aprovació automàtica",
205+
"maxLimits": {
206+
"description": "Realitza sol·licituds automàticament fins a aquests límits abans de demanar aprovació per continuar."
207+
}
207208
},
208209
"providers": {
209210
"providerDocumentation": "Documentació de {{provider}}",

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@
197197
},
198198
"apiRequestLimit": {
199199
"title": "Maximální počet žádostí",
200-
"description": "Automaticky provést tento počet žádostí API předtím, než požádá o schválení k pokračování v úkolu.",
201200
"unlimited": "Neomezeně"
202201
},
203202
"apiCostLimit": {
204-
"description": "Automaticky utratit až tuto částku za náklady na API před vyžádáním souhlasu s pokračováním úkolu.",
205203
"unlimited": "Neomezený",
206204
"title": "Maximální náklady na API"
207205
},
208206
"toggleAriaLabel": "Přepnout automatické schválení",
209207
"disabledAriaLabel": "Automatické schválení zakázáno - nejprve vyberte možnosti",
210-
"selectOptionsFirst": "Vyberte alespoň jednu možnost níže pro povolení automatického schválení"
208+
"selectOptionsFirst": "Vyberte alespoň jednu možnost níže pro povolení automatického schválení",
209+
"maxLimits": {
210+
"description": "Automatické odesílání požadavků až do těchto limitů, než bude vyžadováno schválení k pokračování."
211+
}
211212
},
212213
"providers": {
213214
"providerDocumentation": "Dokumentace {{provider}}",

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,16 @@
195195
},
196196
"apiRequestLimit": {
197197
"title": "Maximale Anfragen",
198-
"description": "Automatisch so viele API-Anfragen stellen, bevor du um die Erlaubnis gebeten wirst, mit der Aufgabe fortzufahren.",
199198
"unlimited": "Unbegrenzt"
200199
},
201200
"apiCostLimit": {
202201
"title": "Max API-Kosten",
203-
"description": "Automatisch bis zu diesem Betrag für API-Kosten ausgeben, bevor um Genehmigung zur Fortsetzung der Aufgabe gebeten wird.",
204202
"unlimited": "Unbegrenzt"
205203
},
206-
"selectOptionsFirst": "Wähle mindestens eine Option unten aus, um die automatische Genehmigung zu aktivieren"
204+
"selectOptionsFirst": "Wähle mindestens eine Option unten aus, um die automatische Genehmigung zu aktivieren",
205+
"maxLimits": {
206+
"description": "Stellt automatisch Anfragen bis zu diesen Limits, bevor um Genehmigung zur Fortsetzung gebeten wird."
207+
}
207208
},
208209
"providers": {
209210
"providerDocumentation": "{{provider}}-Dokumentation",

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,16 @@
192192
"description": "Automatically update the to-do list without requiring approval"
193193
},
194194
"apiRequestLimit": {
195-
"title": "Max Requests",
196-
"description": "Automatically make this many API requests before asking for approval to continue with the task.",
195+
"title": "Max Count",
197196
"unlimited": "Unlimited"
198197
},
199198
"apiCostLimit": {
200199
"title": "Max Cost",
201-
"description": "Automatically spend up to this amount on API costs before asking for approval to continue with the task.",
202200
"unlimited": "Unlimited"
203201
},
202+
"maxLimits": {
203+
"description": "Automatically make requests up to these limits before asking for approval to continue."
204+
},
204205
"toggleAriaLabel": "Toggle auto-approval",
205206
"disabledAriaLabel": "Auto-approval disabled - select options first",
206207
"selectOptionsFirst": "Select at least one option below to enable auto-approval"

0 commit comments

Comments
 (0)