11import React from "react"
2- import { Stamp , ListChecks , LayoutList , Settings } from "lucide-react"
2+ import { ListChecks , LayoutList , Settings , CheckCheck } from "lucide-react"
33
44import { vscode } from "@/utils/vscode"
55import { cn } from "@/lib/utils"
@@ -9,15 +9,13 @@ import { useRooPortal } from "@/components/ui/hooks/useRooPortal"
99import { Popover , PopoverContent , PopoverTrigger , StandardTooltip } from "@/components/ui"
1010import { AutoApproveSetting , autoApproveSettingsConfig } from "../settings/AutoApproveToggle"
1111import { useAutoApprovalToggles } from "@/hooks/useAutoApprovalToggles"
12- import { useAutoApprovalState } from "@/hooks/useAutoApprovalState"
1312
1413interface 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 }
0 commit comments