11import React , { useState , useMemo } from "react"
2- import { Check , ChevronDown , Info , X } from "lucide-react"
2+ import { Check , CheckCheck , ChevronUp , X } from "lucide-react"
33import { cn } from "../../lib/utils"
4- import { useTranslation , Trans } from "react-i18next"
5- import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
4+ import { useTranslation } from "react-i18next"
65import { StandardTooltip } from "../ui/standard-tooltip"
76
87interface CommandPattern {
@@ -29,10 +28,6 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
2928 const [ isExpanded , setIsExpanded ] = useState ( false )
3029 const [ editingStates , setEditingStates ] = useState < Record < string , { isEditing : boolean ; value : string } > > ( { } )
3130
32- const handleOpenSettings = ( ) => {
33- window . postMessage ( { type : "action" , action : "settingsButtonClicked" , values : { section : "autoApprove" } } )
34- }
35-
3631 // Create a combined list with full command first, then patterns
3732 const allPatterns = useMemo ( ( ) => {
3833 // Create a set to track unique patterns we've already seen
@@ -68,50 +63,36 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
6863 }
6964
7065 return (
71- < div className = "border-t border-vscode-panel-border bg-vscode-sideBar-background/30" >
66+ < div className = "border-t border-vscode-panel-border/50 bg-vscode-sideBar-background/30" >
7267 < button
7368 onClick = { ( ) => setIsExpanded ( ! isExpanded ) }
7469 className = "w-full px-3 py-2 flex items-center justify-between hover:bg-vscode-list-hoverBackground transition-colors" >
75- < div className = "flex items-center gap-2" >
76- < ChevronDown
77- className = { cn ( "size-4 transition-transform" , {
78- "-rotate-90" : ! isExpanded ,
79- } ) }
70+ < div className = "group flex items-center gap-2 cursor-pointer w-full text-left" >
71+ < span
72+ className = { cn (
73+ "text-sm flex-1 group-hover:opacity-100" ,
74+ isExpanded ? "opacity-100" : "opacity-40" ,
75+ ) } >
76+ < CheckCheck className = "size-3 inline-block mr-2" />
77+ { t ( "chat:commandExecution.manageCommands" ) }
78+ </ span >
79+ < ChevronUp
80+ className = { cn (
81+ "group-hover:opacity-100 size-4 transition-transform" ,
82+ isExpanded ? "opacity-100" : "opacity-40 -rotate-180" ,
83+ ) }
8084 />
81- < span className = "text-sm font-medium" > { t ( "chat:commandExecution.manageCommands" ) } </ span >
82- < StandardTooltip
83- content = {
84- < div className = "max-w-xs" >
85- < Trans
86- i18nKey = "chat:commandExecution.commandManagementDescription"
87- components = { {
88- settingsLink : (
89- < VSCodeLink
90- href = "#"
91- onClick = { ( e ) => {
92- e . preventDefault ( )
93- handleOpenSettings ( )
94- } }
95- className = "text-vscode-textLink-foreground hover:text-vscode-textLink-activeForeground"
96- />
97- ) ,
98- } }
99- />
100- </ div >
101- } >
102- < Info className = "size-3.5 text-vscode-descriptionForeground" />
103- </ StandardTooltip >
10485 </ div >
10586 </ button >
10687
10788 { isExpanded && (
108- < div className = "px-3 pb-3 space-y-2" >
89+ < div className = "pl-6 pr-2 pt-1 pb-2 space-y-2" >
10990 { allPatterns . map ( ( item ) => {
11091 const editState = getEditState ( item . pattern )
11192 const status = getPatternStatus ( editState . value )
11293
11394 return (
114- < div key = { item . pattern } className = "ml-5 flex items-center gap-2" >
95+ < div key = { item . pattern } className = "flex items-center gap-2" >
11596 < div className = "flex-1" >
11697 { editState . isEditing ? (
11798 < input
@@ -146,35 +127,49 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
146127 ) }
147128 </ div >
148129 < div className = "flex items-center gap-1" >
149- < button
150- className = { cn ( "p-1 rounded transition-all" , {
151- "bg-green-500/20 text-green-500 hover:bg-green-500/30" :
152- status === "allowed" ,
153- "text-vscode-descriptionForeground hover:text-green-500 hover:bg-green-500/10" :
154- status !== "allowed" ,
155- } ) }
156- onClick = { ( ) => onAllowPatternChange ( editState . value ) }
157- aria-label = { t (
130+ < StandardTooltip
131+ content = { t (
158132 status === "allowed"
159133 ? "chat:commandExecution.removeFromAllowed"
160134 : "chat:commandExecution.addToAllowed" ,
161135 ) } >
162- < Check className = "size-3.5" />
163- </ button >
164- < button
165- className = { cn ( "p-1 rounded transition-all" , {
166- "bg-red-500/20 text-red-500 hover:bg-red-500/30" : status === "denied" ,
167- "text-vscode-descriptionForeground hover:text-red-500 hover:bg-red-500/10" :
168- status !== "denied" ,
169- } ) }
170- onClick = { ( ) => onDenyPatternChange ( editState . value ) }
171- aria-label = { t (
136+ < button
137+ className = { cn ( "p-1 rounded transition-all cursor-pointer" , {
138+ "bg-green-500/20 text-green-500 hover:bg-green-500/30" :
139+ status === "allowed" ,
140+ "text-vscode-descriptionForeground hover:text-green-500 hover:bg-green-500/10" :
141+ status !== "allowed" ,
142+ } ) }
143+ onClick = { ( ) => onAllowPatternChange ( editState . value ) }
144+ aria-label = { t (
145+ status === "allowed"
146+ ? "chat:commandExecution.removeFromAllowed"
147+ : "chat:commandExecution.addToAllowed" ,
148+ ) } >
149+ < Check className = "size-3.5" />
150+ </ button >
151+ </ StandardTooltip >
152+ < StandardTooltip
153+ content = { t (
172154 status === "denied"
173155 ? "chat:commandExecution.removeFromDenied"
174156 : "chat:commandExecution.addToDenied" ,
175157 ) } >
176- < X className = "size-3.5" />
177- </ button >
158+ < button
159+ className = { cn ( "p-1 rounded transition-all cursor-pointer" , {
160+ "bg-red-500/20 text-red-500 hover:bg-red-500/30" : status === "denied" ,
161+ "text-vscode-descriptionForeground hover:text-red-500 hover:bg-red-500/10" :
162+ status !== "denied" ,
163+ } ) }
164+ onClick = { ( ) => onDenyPatternChange ( editState . value ) }
165+ aria-label = { t (
166+ status === "denied"
167+ ? "chat:commandExecution.removeFromDenied"
168+ : "chat:commandExecution.addToDenied" ,
169+ ) } >
170+ < X className = "size-3.5" />
171+ </ button >
172+ </ StandardTooltip >
178173 </ div >
179174 </ div >
180175 )
0 commit comments