Skip to content

Commit 3b2eaea

Browse files
committed
Refactor the UI of the Auto-Approve Menu
1 parent 61e122d commit 3b2eaea

File tree

1 file changed

+19
-58
lines changed

1 file changed

+19
-58
lines changed

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

Lines changed: 19 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,29 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
129129
overflowY: "auto",
130130
...style,
131131
}}>
132+
{isExpanded && (
133+
<div className="flex flex-col gap-2">
134+
<AutoApproveToggle {...toggles} onToggle={onAutoApproveToggle} />
135+
<div
136+
style={{
137+
color: "var(--vscode-descriptionForeground)",
138+
fontSize: "12px",
139+
}}>
140+
<Trans
141+
i18nKey="chat:autoApprove.description"
142+
components={{
143+
settingsLink: <VSCodeLink href="#" onClick={handleOpenSettings} />,
144+
}}
145+
/>
146+
</div>
147+
</div>
148+
)}
132149
<div
133150
style={{
134151
display: "flex",
135152
alignItems: "center",
136153
gap: "8px",
137-
padding: isExpanded ? "8px 0" : "8px 0 0 0",
154+
padding: "8px 0",
138155
cursor: "pointer",
139156
}}
140157
onClick={toggleExpanded}>
@@ -175,70 +192,14 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
175192
{enabledActionsList || t("chat:autoApprove.none")}
176193
</span>
177194
<span
178-
className={`codicon codicon-chevron-${isExpanded ? "down" : "right"}`}
195+
className={`codicon codicon-chevron-${isExpanded ? "up" : "right"}`}
179196
style={{
180197
flexShrink: 0,
181198
marginLeft: isExpanded ? "2px" : "-2px",
182199
}}
183200
/>
184201
</div>
185202
</div>
186-
187-
{isExpanded && (
188-
<div className="flex flex-col gap-2">
189-
<div
190-
style={{
191-
color: "var(--vscode-descriptionForeground)",
192-
fontSize: "12px",
193-
}}>
194-
<Trans
195-
i18nKey="chat:autoApprove.description"
196-
components={{
197-
settingsLink: <VSCodeLink href="#" onClick={handleOpenSettings} />,
198-
}}
199-
/>
200-
</div>
201-
202-
<AutoApproveToggle {...toggles} onToggle={onAutoApproveToggle} />
203-
204-
{/* Auto-approve API request count limit input row inspired by Cline */}
205-
<div
206-
style={{
207-
display: "flex",
208-
alignItems: "center",
209-
gap: "8px",
210-
marginTop: "10px",
211-
marginBottom: "8px",
212-
color: "var(--vscode-descriptionForeground)",
213-
}}>
214-
<span style={{ flexShrink: 1, minWidth: 0 }}>
215-
<Trans i18nKey="settings:autoApprove.apiRequestLimit.title" />:
216-
</span>
217-
<VSCodeTextField
218-
placeholder={t("settings:autoApprove.apiRequestLimit.unlimited")}
219-
value={(allowedMaxRequests ?? Infinity) === Infinity ? "" : allowedMaxRequests?.toString()}
220-
onInput={(e) => {
221-
const input = e.target as HTMLInputElement
222-
// Remove any non-numeric characters
223-
input.value = input.value.replace(/[^0-9]/g, "")
224-
const value = parseInt(input.value)
225-
const parsedValue = !isNaN(value) && value > 0 ? value : undefined
226-
setAllowedMaxRequests(parsedValue)
227-
vscode.postMessage({ type: "allowedMaxRequests", value: parsedValue })
228-
}}
229-
style={{ flex: 1 }}
230-
/>
231-
</div>
232-
<div
233-
style={{
234-
color: "var(--vscode-descriptionForeground)",
235-
fontSize: "12px",
236-
marginBottom: "10px",
237-
}}>
238-
<Trans i18nKey="settings:autoApprove.apiRequestLimit.description" />
239-
</div>
240-
</div>
241-
)}
242203
</div>
243204
)
244205
}

0 commit comments

Comments
 (0)