-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Move max requests setting from auto-approve menu to settings tab #6489
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
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 |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| import { HTMLAttributes, useState } from "react" | ||
| import { X } from "lucide-react" | ||
| import { Trans } from "react-i18next" | ||
|
|
||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||
| import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" | ||
| import { VSCodeCheckbox, VSCodeTextField } from "@vscode/webview-ui-toolkit/react" | ||
| import { vscode } from "@/utils/vscode" | ||
| import { Button, Input, Slider, StandardTooltip } from "@/components/ui" | ||
|
|
||
|
|
@@ -32,6 +33,7 @@ type AutoApproveSettingsProps = HTMLAttributes<HTMLDivElement> & { | |
| followupAutoApproveTimeoutMs?: number | ||
| allowedCommands?: string[] | ||
| deniedCommands?: string[] | ||
| allowedMaxRequests?: number | null | ||
| setCachedStateField: SetCachedStateField< | ||
| | "alwaysAllowReadOnly" | ||
| | "alwaysAllowReadOnlyOutsideWorkspace" | ||
|
|
@@ -50,6 +52,7 @@ type AutoApproveSettingsProps = HTMLAttributes<HTMLDivElement> & { | |
| | "allowedCommands" | ||
| | "deniedCommands" | ||
| | "alwaysAllowUpdateTodoList" | ||
| | "allowedMaxRequests" | ||
| > | ||
| } | ||
|
|
||
|
|
@@ -71,6 +74,7 @@ export const AutoApproveSettings = ({ | |
| alwaysAllowUpdateTodoList, | ||
| allowedCommands, | ||
| deniedCommands, | ||
| allowedMaxRequests, | ||
| setCachedStateField, | ||
| ...props | ||
| }: AutoApproveSettingsProps) => { | ||
|
|
@@ -374,6 +378,32 @@ export const AutoApproveSettings = ({ | |
| </div> | ||
| </div> | ||
| )} | ||
|
|
||
| {/* Max Requests Setting */} | ||
| <div className="flex flex-col gap-3 mt-6"> | ||
| <div className="flex items-center gap-4 font-bold"> | ||
| <span className="codicon codicon-number" /> | ||
| <div>{t("settings:autoApprove.apiRequestLimit.title")}</div> | ||
| </div> | ||
| <div className="flex items-center gap-2"> | ||
| <VSCodeTextField | ||
|
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. Consider adding a data-testid attribute for testing consistency with other form elements in the component. |
||
| placeholder={t("settings:autoApprove.apiRequestLimit.unlimited")} | ||
| value={(allowedMaxRequests ?? Infinity) === Infinity ? "" : allowedMaxRequests?.toString()} | ||
| onInput={(e) => { | ||
| const input = e.target as HTMLInputElement | ||
| // Remove any non-numeric characters | ||
| input.value = input.value.replace(/[^0-9]/g, "") | ||
| const value = parseInt(input.value) | ||
| const parsedValue = !isNaN(value) && value > 0 ? value : undefined | ||
| setCachedStateField("allowedMaxRequests", parsedValue) | ||
|
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. Critical: Missing immediate persistence behavior. The original implementation in AutoApproveMenu.tsx immediately persisted changes via vscode.postMessage. This new implementation only updates the cached state via setCachedStateField, which means the setting won't be saved until the user clicks the Save button. This creates inconsistent behavior compared to how this setting worked before. Should we maintain the immediate persistence behavior for consistency? |
||
| }} | ||
| style={{ flex: 1, maxWidth: "200px" }} | ||
|
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. Inconsistent styling approach: This section mixes Tailwind classes with inline styles. For consistency with the rest of the component, consider using Tailwind classes throughout or following the existing pattern used by other settings sections. |
||
| /> | ||
| </div> | ||
| <div className="text-vscode-descriptionForeground text-sm"> | ||
| <Trans i18nKey="settings:autoApprove.apiRequestLimit.description" /> | ||
| </div> | ||
| </div> | ||
| </Section> | ||
| </div> | ||
| ) | ||
|
|
||
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.
Missing visual grouping: Unlike other conditional settings sections (read-only, write, execute), this max requests setting doesn't have the visual grouping with left border that indicates it's part of the auto-approve feature set. This makes it appear disconnected from the other settings. Should this be grouped visually with the other auto-approve settings?