mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
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
This commit is contained in:
parent
82350297a4
commit
20f99a2523
1 changed files with 29 additions and 8 deletions
|
|
@ -23,6 +23,7 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
|
|||
const { t } = useTranslation()
|
||||
const [isExpanded, setIsExpanded] = useState(false)
|
||||
const [editedCommand, setEditedCommand] = useState(command)
|
||||
const [isEditing, setIsEditing] = useState(false)
|
||||
|
||||
const getCommandStatus = (cmd: string): "allowed" | "denied" | "none" => {
|
||||
if (allowedCommands.includes(cmd)) return "allowed"
|
||||
|
|
@ -78,16 +79,36 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
|
|||
</button>
|
||||
|
||||
{isExpanded && (
|
||||
<div className="px-3 pb-3">
|
||||
<div className="px-3 pb-3 pt-2">
|
||||
<div className="ml-5 flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<input
|
||||
type="text"
|
||||
value={editedCommand}
|
||||
onChange={(e) => setEditedCommand(e.target.value)}
|
||||
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"
|
||||
placeholder={command}
|
||||
/>
|
||||
{isEditing ? (
|
||||
<input
|
||||
type="text"
|
||||
value={editedCommand}
|
||||
onChange={(e) => setEditedCommand(e.target.value)}
|
||||
onBlur={() => setIsEditing(false)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
setIsEditing(false)
|
||||
}
|
||||
if (e.key === "Escape") {
|
||||
setEditedCommand(command)
|
||||
setIsEditing(false)
|
||||
}
|
||||
}}
|
||||
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"
|
||||
placeholder={command}
|
||||
autoFocus
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
onClick={() => setIsEditing(true)}
|
||||
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"
|
||||
title="Click to edit command">
|
||||
{editedCommand}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<button
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue