Skip to content

Commit 20f99a2

Browse files
committed
feat: improve command permissions UI with click-to-edit functionality
- Add click-to-edit behavior: command displays as text and becomes input on click - Add proper padding between collapsible trigger and input field - Fix layout shift between text and input states with transparent border - Update focus styling to match standard input components (focus:outline-0) - Add hover effect with background highlight for better UX - Support Enter to confirm and Escape to cancel edits
1 parent 8235029 commit 20f99a2

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
2323
const { t } = useTranslation()
2424
const [isExpanded, setIsExpanded] = useState(false)
2525
const [editedCommand, setEditedCommand] = useState(command)
26+
const [isEditing, setIsEditing] = useState(false)
2627

2728
const getCommandStatus = (cmd: string): "allowed" | "denied" | "none" => {
2829
if (allowedCommands.includes(cmd)) return "allowed"
@@ -78,16 +79,36 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
7879
</button>
7980

8081
{isExpanded && (
81-
<div className="px-3 pb-3">
82+
<div className="px-3 pb-3 pt-2">
8283
<div className="ml-5 flex items-center gap-2">
8384
<div className="flex-1">
84-
<input
85-
type="text"
86-
value={editedCommand}
87-
onChange={(e) => setEditedCommand(e.target.value)}
88-
className="font-mono text-xs bg-vscode-input-background text-vscode-input-foreground border border-vscode-input-border rounded px-2 py-1 w-full focus:outline-none focus:border-vscode-focusBorder"
89-
placeholder={command}
90-
/>
85+
{isEditing ? (
86+
<input
87+
type="text"
88+
value={editedCommand}
89+
onChange={(e) => setEditedCommand(e.target.value)}
90+
onBlur={() => setIsEditing(false)}
91+
onKeyDown={(e) => {
92+
if (e.key === "Enter") {
93+
setIsEditing(false)
94+
}
95+
if (e.key === "Escape") {
96+
setEditedCommand(command)
97+
setIsEditing(false)
98+
}
99+
}}
100+
className="font-mono text-xs bg-vscode-input-background text-vscode-input-foreground border border-vscode-input-border rounded px-2 py-1.5 w-full focus:outline-0"
101+
placeholder={command}
102+
autoFocus
103+
/>
104+
) : (
105+
<div
106+
onClick={() => setIsEditing(true)}
107+
className="font-mono text-xs text-vscode-foreground cursor-pointer hover:bg-vscode-list-hoverBackground px-2 py-1.5 rounded transition-colors border border-transparent"
108+
title="Click to edit command">
109+
{editedCommand}
110+
</div>
111+
)}
91112
</div>
92113
<div className="flex items-center gap-1">
93114
<button

0 commit comments

Comments
 (0)