import { Command, MessageSquare, Package } from 'lucide-react'; import React from 'react'; import type { AIQuickMessage, SlashCommandItem, SystemSlashCommand, UserSkillSlashOption, } from '../../infrastructure/ai/quickMessages'; import { getSlashCommandItemId } from '../../infrastructure/ai/quickMessages'; import { ScrollArea } from '../ui/scroll-area'; export interface SlashCommandPickerProps { listboxId: string; ariaLabel: string; quickMessages: AIQuickMessage[]; systemCommands: SystemSlashCommand[]; userSkills: UserSkillSlashOption[]; slashCommandItems: SlashCommandItem[]; activeMenuIndex: number; onActiveIndexChange: (index: number) => void; onSelectQuickMessage: (message: AIQuickMessage) => void; onSelectSystemCommand: (command: SystemSlashCommand) => void; systemCommandsSectionLabel: string; systemCommandDescription: (command: SystemSlashCommand) => string; onSelectSkill: (skill: UserSkillSlashOption) => void; quickMessagesSectionLabel: string; userSkillsSectionLabel: string; noResultsLabel: string; emptyHintLabel?: string; className?: string; style?: React.CSSProperties; listRef?: React.Ref; } export const SlashCommandPicker: React.FC = ({ listboxId, ariaLabel, quickMessages, systemCommands, userSkills, slashCommandItems, activeMenuIndex, onActiveIndexChange, onSelectQuickMessage, onSelectSystemCommand, systemCommandsSectionLabel, systemCommandDescription, onSelectSkill, quickMessagesSectionLabel, userSkillsSectionLabel, noResultsLabel, emptyHintLabel, className, style, listRef, }) => { const activeItem = slashCommandItems[activeMenuIndex]; const activeDescendantId = activeItem ? `${listboxId}-${getSlashCommandItemId(activeItem)}` : undefined; return (
{slashCommandItems.length === 0 ? (

{noResultsLabel}

{emptyHintLabel ? (

{emptyHintLabel}

) : null}
) : ( <> {systemCommands.length > 0 ? ( <>
{systemCommandsSectionLabel}
{systemCommands.map((command) => { const idx = slashCommandItems.findIndex( (item) => item.kind === 'system' && item.command.slug === command.slug, ); const isActive = idx === activeMenuIndex; return ( ); })} ) : null} {quickMessages.length > 0 ? ( <>
{quickMessagesSectionLabel}
{quickMessages.map((message) => { const idx = slashCommandItems.findIndex( (item) => item.kind === 'quickMessage' && item.message.id === message.id, ); const isActive = idx === activeMenuIndex; return ( ); })} ) : null} {userSkills.length > 0 ? ( <>
{userSkillsSectionLabel}
{userSkills.map((skill) => { const idx = slashCommandItems.findIndex( (item) => item.kind === 'skill' && item.skill.id === skill.id, ); const isActive = idx === activeMenuIndex; return ( ); })} ) : null} )}
); };