Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions webview-ui/src/components/chat/AutoApproveMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { vscode } from "@src/utils/vscode"
import { useExtensionState } from "@src/context/ExtensionStateContext"
import { useAppTranslation } from "@src/i18n/TranslationContext"
import { AutoApproveToggle, AutoApproveSetting, autoApproveSettingsConfig } from "../settings/AutoApproveToggle"
import { MaxLimitInputs } from "../settings/MaxLimitInputs"
import { StandardTooltip } from "@src/components/ui"
import { useAutoApprovalState } from "@src/hooks/useAutoApprovalState"
import { useAutoApprovalToggles } from "@src/hooks/useAutoApprovalToggles"
Expand All @@ -22,8 +21,6 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
autoApprovalEnabled,
setAutoApprovalEnabled,
alwaysApproveResubmit,
allowedMaxRequests,
allowedMaxCost,
setAlwaysAllowReadOnly,
setAlwaysAllowWrite,
setAlwaysAllowExecute,
Expand All @@ -34,8 +31,6 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
setAlwaysApproveResubmit,
setAlwaysAllowFollowupQuestions,
setAlwaysAllowUpdateTodoList,
setAllowedMaxRequests,
setAllowedMaxCost,
} = useExtensionState()

const { t } = useAppTranslation()
Expand Down Expand Up @@ -245,13 +240,6 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
</div>

<AutoApproveToggle {...toggles} onToggle={onAutoApproveToggle} />

<MaxLimitInputs
allowedMaxRequests={allowedMaxRequests ?? undefined}
allowedMaxCost={allowedMaxCost ?? undefined}
onMaxRequestsChange={(value) => setAllowedMaxRequests(value)}
onMaxCostChange={(value) => setAllowedMaxCost(value)}
/>
</div>
)}
</div>
Expand Down
103 changes: 57 additions & 46 deletions webview-ui/src/components/settings/AutoApproveSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLAttributes, useState } from "react"
import { X } from "lucide-react"
import { X, CheckCheck } from "lucide-react"

import { useAppTranslation } from "@/i18n/TranslationContext"
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
Expand Down Expand Up @@ -114,57 +114,68 @@ export const AutoApproveSettings = ({

return (
<div {...props}>
<SectionHeader description={t("settings:autoApprove.description")}>
<SectionHeader>
<div className="flex items-center gap-2">
{!hasEnabledOptions ? (
<StandardTooltip content={t("settings:autoApprove.selectOptionsFirst")}>
<VSCodeCheckbox
checked={effectiveAutoApprovalEnabled}
disabled={!hasEnabledOptions}
aria-label={t("settings:autoApprove.disabledAriaLabel")}
onChange={() => {
// Do nothing when no options are enabled
return
}}
/>
</StandardTooltip>
) : (
<VSCodeCheckbox
checked={effectiveAutoApprovalEnabled}
disabled={!hasEnabledOptions}
aria-label={t("settings:autoApprove.toggleAriaLabel")}
onChange={() => {
const newValue = !(autoApprovalEnabled ?? false)
setAutoApprovalEnabled(newValue)
vscode.postMessage({ type: "autoApprovalEnabled", bool: newValue })
}}
/>
)}
<span className="codicon codicon-check w-4" />
<CheckCheck className="w-4 h-4" />
<div>{t("settings:sections.autoApprove")}</div>
</div>
</SectionHeader>

<Section>
<AutoApproveToggle
alwaysAllowReadOnly={alwaysAllowReadOnly}
alwaysAllowWrite={alwaysAllowWrite}
alwaysAllowBrowser={alwaysAllowBrowser}
alwaysApproveResubmit={alwaysApproveResubmit}
alwaysAllowMcp={alwaysAllowMcp}
alwaysAllowModeSwitch={alwaysAllowModeSwitch}
alwaysAllowSubtasks={alwaysAllowSubtasks}
alwaysAllowExecute={alwaysAllowExecute}
alwaysAllowFollowupQuestions={alwaysAllowFollowupQuestions}
alwaysAllowUpdateTodoList={alwaysAllowUpdateTodoList}
onToggle={(key, value) => setCachedStateField(key, value)}
/>
<MaxLimitInputs
allowedMaxRequests={allowedMaxRequests}
allowedMaxCost={allowedMaxCost}
onMaxRequestsChange={(value) => setCachedStateField("allowedMaxRequests", value)}
onMaxCostChange={(value) => setCachedStateField("allowedMaxCost", value)}
/>
<div className="space-y-4">
<div>
{!hasEnabledOptions ? (
<StandardTooltip content={t("settings:autoApprove.selectOptionsFirst")}>
<VSCodeCheckbox
checked={effectiveAutoApprovalEnabled}
disabled={!hasEnabledOptions}
aria-label={t("settings:autoApprove.disabledAriaLabel")}
onChange={() => {
// Do nothing when no options are enabled
return
}}>
<span className="font-medium">Auto-Approve Enabled</span>
</VSCodeCheckbox>
</StandardTooltip>
) : (
<VSCodeCheckbox
checked={effectiveAutoApprovalEnabled}
disabled={!hasEnabledOptions}
aria-label={t("settings:autoApprove.toggleAriaLabel")}
onChange={() => {
const newValue = !(autoApprovalEnabled ?? false)
setAutoApprovalEnabled(newValue)
vscode.postMessage({ type: "autoApprovalEnabled", bool: newValue })
}}>
<span className="font-medium">{t("settings:autoApprove.enabled")}</span>
</VSCodeCheckbox>
)}
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:autoApprove.description")}
</div>
</div>

<AutoApproveToggle
alwaysAllowReadOnly={alwaysAllowReadOnly}
alwaysAllowWrite={alwaysAllowWrite}
alwaysAllowBrowser={alwaysAllowBrowser}
alwaysApproveResubmit={alwaysApproveResubmit}
alwaysAllowMcp={alwaysAllowMcp}
alwaysAllowModeSwitch={alwaysAllowModeSwitch}
alwaysAllowSubtasks={alwaysAllowSubtasks}
alwaysAllowExecute={alwaysAllowExecute}
alwaysAllowFollowupQuestions={alwaysAllowFollowupQuestions}
alwaysAllowUpdateTodoList={alwaysAllowUpdateTodoList}
onToggle={(key, value) => setCachedStateField(key, value)}
/>

<MaxLimitInputs
allowedMaxRequests={allowedMaxRequests}
allowedMaxCost={allowedMaxCost}
onMaxRequestsChange={(value) => setCachedStateField("allowedMaxRequests", value)}
onMaxCostChange={(value) => setCachedStateField("allowedMaxCost", value)}
/>
</div>

{/* ADDITIONAL SETTINGS */}

Expand Down
19 changes: 7 additions & 12 deletions webview-ui/src/components/settings/AutoApproveToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,7 @@ export const AutoApproveToggle = ({ onToggle, ...props }: AutoApproveToggleProps
const { t } = useAppTranslation()

return (
<div
className={cn(
"flex flex-row flex-wrap justify-center gap-2 max-w-[600px] mx-auto my-2 ",
"[@media(min-width:600px)]:gap-4",
"[@media(min-width:800px)]:max-w-[900px]",
"[@media(min-width:1200px)]:max-w-[1800px]",
)}>
<div className={cn("flex flex-row flex-wrap gap-2 py-2")}>
{Object.values(autoApproveSettingsConfig).map(({ key, descriptionKey, labelKey, icon, testId }) => (
<StandardTooltip key={key} content={t(descriptionKey || "")}>
<Button
Expand All @@ -124,11 +118,12 @@ export const AutoApproveToggle = ({ onToggle, ...props }: AutoApproveToggleProps
aria-label={t(labelKey)}
aria-pressed={!!props[key]}
data-testid={testId}
className={cn(" aspect-square h-[80px]", !props[key] && "opacity-50")}>
<span className={cn("flex flex-col items-center gap-1")}>
<span className={`codicon codicon-${icon}`} />
<span className="text-sm text-center">{t(labelKey)}</span>
</span>
className={cn(
"h-7 px-2 rounded-md flex items-center gap-1.5 text-xs whitespace-nowrap",
!props[key] && "opacity-50",
)}>
<span className={`codicon codicon-${icon} text-sm`} />
<span>{t(labelKey)}</span>
</Button>
</StandardTooltip>
))}
Expand Down
30 changes: 14 additions & 16 deletions webview-ui/src/components/settings/MaxCostInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@ export function MaxCostInput({ allowedMaxCost, onValueChange }: MaxCostInputProp
)

return (
<div className="flex flex-col gap-3 pl-3 flex-auto">
<div className="flex items-center gap-4 font-bold">
<>
<label className="flex items-center gap-2 text-sm font-medium whitespace-nowrap">
<span className="codicon codicon-credit-card" />
<div>{t("settings:autoApprove.apiCostLimit.title")}</div>
</div>
<div className="flex items-center">
<FormattedTextField
value={allowedMaxCost}
onValueChange={handleValueChange}
formatter={unlimitedDecimalFormatter}
placeholder={t("settings:autoApprove.apiCostLimit.unlimited")}
style={{ flex: 1, maxWidth: "200px" }}
data-testid="max-cost-input"
leftNodes={[<span key="dollar">$</span>]}
/>
</div>
</div>
{t("settings:autoApprove.apiCostLimit.title")}:
</label>
<FormattedTextField
value={allowedMaxCost}
onValueChange={handleValueChange}
formatter={unlimitedDecimalFormatter}
placeholder={t("settings:autoApprove.apiCostLimit.unlimited")}
style={{ maxWidth: "200px" }}
data-testid="max-cost-input"
leftNodes={[<span key="dollar">$</span>]}
/>
</>
)
}
2 changes: 1 addition & 1 deletion webview-ui/src/components/settings/MaxLimitInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const MaxLimitInputs: React.FC<MaxLimitInputsProps> = ({

return (
<div className="space-y-2">
<div className="flex justify-stretch">
<div className="grid grid-cols-[auto_1fr] gap-x-2 gap-y-2 items-center">
<MaxRequestsInput allowedMaxRequests={allowedMaxRequests} onValueChange={onMaxRequestsChange} />
<MaxCostInput allowedMaxCost={allowedMaxCost} onValueChange={onMaxCostChange} />
</div>
Expand Down
28 changes: 13 additions & 15 deletions webview-ui/src/components/settings/MaxRequestsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@ export function MaxRequestsInput({ allowedMaxRequests, onValueChange }: MaxReque
)

return (
<div className="flex flex-col gap-3 pl-3 flex-auto">
<div className="flex items-center gap-4 font-bold">
<>
<label className="flex items-center gap-2 text-sm font-medium whitespace-nowrap">
<span className="codicon codicon-pulse" />
<div>{t("settings:autoApprove.apiRequestLimit.title")}</div>
</div>
<div className="flex items-center gap-2">
<FormattedTextField
value={allowedMaxRequests}
onValueChange={handleValueChange}
formatter={unlimitedIntegerFormatter}
placeholder={t("settings:autoApprove.apiRequestLimit.unlimited")}
style={{ flex: 1, maxWidth: "200px" }}
data-testid="max-requests-input"
/>
</div>
</div>
{t("settings:autoApprove.apiRequestLimit.title")}:
</label>
<FormattedTextField
value={allowedMaxRequests}
onValueChange={handleValueChange}
formatter={unlimitedIntegerFormatter}
placeholder={t("settings:autoApprove.apiRequestLimit.unlimited")}
style={{ maxWidth: "200px" }}
data-testid="max-requests-input"
/>
</>
)
}
1 change: 1 addition & 0 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
},
"autoApprove": {
"description": "Allow Roo to automatically perform operations without requiring approval. Enable these settings only if you fully trust the AI and understand the associated security risks.",
"enabled": "Auto-Approve Enabled",
"readOnly": {
"label": "Read",
"description": "When enabled, Roo will automatically view directory contents and read files without requiring you to click the Approve button.",
Expand Down
Loading