({
projectPath,
className,
scopeFilter = 'all',
})
| 88 | * Provides a no-code interface for creating, editing, and deleting commands |
| 89 | */ |
| 90 | export const SlashCommandsManager: React.FC<SlashCommandsManagerProps> = ({ |
| 91 | projectPath, |
| 92 | className, |
| 93 | scopeFilter = 'all', |
| 94 | }) => { |
| 95 | const [commands, setCommands] = useState<SlashCommand[]>([]); |
| 96 | const [loading, setLoading] = useState(true); |
| 97 | const [saving, setSaving] = useState(false); |
| 98 | const [error, setError] = useState<string | null>(null); |
| 99 | const [searchQuery, setSearchQuery] = useState(""); |
| 100 | const [selectedScope, setSelectedScope] = useState<'all' | 'project' | 'user'>(scopeFilter === 'all' ? 'all' : scopeFilter as 'project' | 'user'); |
| 101 | const [expandedCommands, setExpandedCommands] = useState<Set<string>>(new Set()); |
| 102 | |
| 103 | // Edit dialog state |
| 104 | const [editDialogOpen, setEditDialogOpen] = useState(false); |
| 105 | const [editingCommand, setEditingCommand] = useState<SlashCommand | null>(null); |
| 106 | const [commandForm, setCommandForm] = useState<CommandForm>({ |
| 107 | name: "", |
| 108 | namespace: "", |
| 109 | content: "", |
| 110 | description: "", |
| 111 | allowedTools: [], |
| 112 | scope: 'user' |
| 113 | }); |
| 114 | |
| 115 | // Delete confirmation dialog state |
| 116 | const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); |
| 117 | const [commandToDelete, setCommandToDelete] = useState<SlashCommand | null>(null); |
| 118 | const [deleting, setDeleting] = useState(false); |
| 119 | |
| 120 | // Analytics tracking |
| 121 | const trackEvent = useTrackEvent(); |
| 122 | |
| 123 | // Load commands on mount |
| 124 | useEffect(() => { |
| 125 | loadCommands(); |
| 126 | }, [projectPath]); |
| 127 | |
| 128 | const loadCommands = async () => { |
| 129 | try { |
| 130 | setLoading(true); |
| 131 | setError(null); |
| 132 | const loadedCommands = await api.slashCommandsList(projectPath); |
| 133 | setCommands(loadedCommands); |
| 134 | } catch (err) { |
| 135 | console.error("Failed to load slash commands:", err); |
| 136 | setError("Failed to load commands"); |
| 137 | } finally { |
| 138 | setLoading(false); |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | const handleCreateNew = () => { |
| 143 | setEditingCommand(null); |
| 144 | setCommandForm({ |
| 145 | name: "", |
| 146 | namespace: "", |
| 147 | content: "", |
nothing calls this directly
no test coverage detected