Skip to content

Commit 6c3287d

Browse files
committed
Makes trigger label simpler and dynamic
1 parent a60be40 commit 6c3287d

File tree

20 files changed

+198
-111
lines changed

20 files changed

+198
-111
lines changed

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

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react"
2-
import { Stamp, ListChecks, LayoutList, Settings } from "lucide-react"
2+
import { ListChecks, LayoutList, Settings, CheckCheck } from "lucide-react"
33

44
import { vscode } from "@/utils/vscode"
55
import { cn } from "@/lib/utils"
@@ -9,15 +9,13 @@ import { useRooPortal } from "@/components/ui/hooks/useRooPortal"
99
import { Popover, PopoverContent, PopoverTrigger, StandardTooltip } from "@/components/ui"
1010
import { AutoApproveSetting, autoApproveSettingsConfig } from "../settings/AutoApproveToggle"
1111
import { useAutoApprovalToggles } from "@/hooks/useAutoApprovalToggles"
12-
import { useAutoApprovalState } from "@/hooks/useAutoApprovalState"
1312

1413
interface AutoApproveDropdownProps {
1514
disabled?: boolean
16-
title?: string
1715
triggerClassName?: string
1816
}
1917

20-
export const AutoApproveDropdown = ({ disabled = false, title, triggerClassName = "" }: AutoApproveDropdownProps) => {
18+
export const AutoApproveDropdown = ({ disabled = false, triggerClassName = "" }: AutoApproveDropdownProps) => {
2119
const [open, setOpen] = React.useState(false)
2220
const portalContainer = useRooPortal("roo-portal")
2321
const { t } = useAppTranslation()
@@ -49,8 +47,6 @@ export const AutoApproveDropdown = ({ disabled = false, title, triggerClassName
4947
[baseToggles, alwaysApproveResubmit],
5048
)
5149

52-
const { hasEnabledOptions, effectiveAutoApprovalEnabled } = useAutoApprovalState(toggles, autoApprovalEnabled)
53-
5450
const onAutoApproveToggle = React.useCallback(
5551
(key: AutoApproveSetting, value: boolean) => {
5652
vscode.postMessage({ type: key, bool: value })
@@ -141,18 +137,14 @@ export const AutoApproveDropdown = ({ disabled = false, title, triggerClassName
141137
[],
142138
)
143139

144-
// Create display text for enabled actions
145-
const displayText = React.useMemo(() => {
146-
if (!effectiveAutoApprovalEnabled || !hasEnabledOptions) {
147-
return t("chat:autoApprove.none")
148-
}
149-
const enabledActionsList = Object.entries(toggles)
150-
.filter(([_key, value]) => !!value)
151-
.map(([key]) => t(autoApproveSettingsConfig[key as AutoApproveSetting].labelKey))
152-
.join(", ")
140+
// Calculate enabled and total counts as separate properties
141+
const enabledCount = React.useMemo(() => {
142+
return Object.values(toggles).filter((value) => !!value).length
143+
}, [toggles])
153144

154-
return enabledActionsList || t("chat:autoApprove.none")
155-
}, [effectiveAutoApprovalEnabled, hasEnabledOptions, toggles, t])
145+
const totalCount = React.useMemo(() => {
146+
return Object.keys(toggles).length
147+
}, [toggles])
156148

157149
// Split settings into two columns
158150
const settingsArray = Object.values(autoApproveSettingsConfig)
@@ -162,23 +154,25 @@ export const AutoApproveDropdown = ({ disabled = false, title, triggerClassName
162154

163155
return (
164156
<Popover open={open} onOpenChange={setOpen} data-testid="auto-approve-dropdown-root">
165-
<StandardTooltip content={title || t("chat:autoApprove.title")}>
166-
<PopoverTrigger
167-
disabled={disabled}
168-
data-testid="auto-approve-dropdown-trigger"
169-
className={cn(
170-
"inline-flex items-center gap-1.5 relative whitespace-nowrap px-1.5 py-1 text-xs",
171-
"bg-transparent border border-[rgba(255,255,255,0.08)] rounded-md text-vscode-foreground",
172-
"transition-all duration-150 focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder focus-visible:ring-inset",
173-
disabled
174-
? "opacity-50 cursor-not-allowed"
175-
: "opacity-90 hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)] cursor-pointer",
176-
triggerClassName,
177-
)}>
178-
<Stamp className="pointer-events-none opacity-80 flex-shrink-0 size-3" />
179-
<span className="truncate">{displayText}</span>
180-
</PopoverTrigger>
181-
</StandardTooltip>
157+
<PopoverTrigger
158+
disabled={disabled}
159+
data-testid="auto-approve-dropdown-trigger"
160+
className={cn(
161+
"inline-flex items-center gap-1.5 relative whitespace-nowrap px-1.5 py-1 text-xs",
162+
"bg-transparent border border-[rgba(255,255,255,0.08)] rounded-md text-vscode-foreground",
163+
"transition-all duration-150 focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder focus-visible:ring-inset",
164+
disabled
165+
? "opacity-50 cursor-not-allowed"
166+
: "opacity-90 hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)] cursor-pointer",
167+
triggerClassName,
168+
)}>
169+
<CheckCheck className="size-3" />
170+
<span className="truncate">
171+
{enabledCount === totalCount
172+
? t("chat:autoApprove.triggerLabelAll")
173+
: t("chat:autoApprove.triggerLabel", { count: enabledCount })}
174+
</span>
175+
</PopoverTrigger>
182176
<PopoverContent
183177
align="start"
184178
sideOffset={4}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
12011201
/>
12021202
</div>
12031203
<div className="max-w-48">
1204-
<AutoApproveDropdown title={t("chat:autoApprove.title")} triggerClassName="w-full" />
1204+
<AutoApproveDropdown triggerClassName="w-full" />
12051205
</div>
12061206
</div>
12071207
<div className="flex items-center gap-0.5">

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

Lines changed: 9 additions & 4 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/chat.json

Lines changed: 9 additions & 4 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/chat.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@
275275
"description": "Run these actions without asking for permission. Only enable for actions you fully trust.",
276276
"selectOptionsFirst": "Select at least one option below to enable auto-approval",
277277
"toggleAriaLabel": "Toggle auto-approval",
278-
"disabledAriaLabel": "Auto-approval disabled - select options first"
278+
"disabledAriaLabel": "Auto-approval disabled - select options first",
279+
"triggerLabel_zero": "No auto-approve",
280+
"triggerLabel_one": "1 auto-approved",
281+
"triggerLabel_other": "{{count}} auto-approved",
282+
"triggerLabelAll": "YOLO"
279283
},
280284
"announcement": {
281285
"title": "🎉 Roo Code {{version}} Released",

webview-ui/src/i18n/locales/es/chat.json

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

webview-ui/src/i18n/locales/fr/chat.json

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

webview-ui/src/i18n/locales/hi/chat.json

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

webview-ui/src/i18n/locales/id/chat.json

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

webview-ui/src/i18n/locales/it/chat.json

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

0 commit comments

Comments
 (0)