import { FileX, PlusCircle, Search, SearchX, Trash } from 'lucide-react'; import { useState } from 'react'; import type { Skill } from '@/api'; import { AddSkillDialog } from '@/components/dialog/AddSkillDialog.tsx'; import { DeleteDialog } from '@/components/dialog/DeleteDialog.tsx'; import { PanelEmpty } from '@/components/panel/PanelEmpty'; import { Button } from '@/components/ui/button'; import { InputGroup, InputGroupAddon, InputGroupInput } from '@/components/ui/input-group'; import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from '@/components/ui/item'; import { useTranslation } from '@/i18n/useI18n.ts'; interface SkillPanelProps { /** The skills equipped in the workspace. */ skills: Skill[]; /** Whether the skill list is still loading. */ loading?: boolean; /** * Add a skill to the workspace. * * @param skillPath - Path of the skill to add. */ onAdd: (skillPath: string) => Promise; /** * Remove a skill by name. * * @param name - The skill name to remove. */ onRemove: (name: string) => Promise; } /** * Pure content body for the Skill dock panel: a search box, the list * of equipped skills, and an "Add Skill" action. Holds only local UI * state (search text, delete confirmation target); all data arrives * via props so it owns no data fetching. * * Renders without its own header/border — the surrounding `Panel` * chrome (from `PanelDock`) provides those. * * @param skills - The skills to list. * @param loading - Whether the list is loading. * @param onAdd - Add-skill callback. * @param onRemove - Remove-skill callback. * @returns The skill panel body. */ export function SkillPanel({ skills, loading = false, onAdd, onRemove }: SkillPanelProps) { const { t } = useTranslation(); const [search, setSearch] = useState(''); const [deleteOpen, setDeleteOpen] = useState(false); const [deleteTarget, setDeleteTarget] = useState(null); const filtered = search ? skills.filter((s) => s.name.toLowerCase().includes(search.toLowerCase())) : skills; return (
{t('panel.skill.description')} setSearch(e.target.value)} /> {loading ? (

{t('panel.loading')}

) : filtered.length === 0 ? ( ) : (
{filtered.map((skill) => ( {skill.name} {skill.description} ))}
)} { if (deleteTarget) await onRemove(deleteTarget); }} />
); }