import { useState } from 'react'; // 'agents-md', 'browser-sessions', 'mcp', 'skills', 'pets', 'ssh-connections' are virtual subdirs (not raw file editor directories) // ('scripts' / 'templates' were retired 2026-06 β€” superseded by Skills + the Bash tool) export type SubdirId = 'agents-md' | 'browser-macros' | 'recordings' | 'trash' | 'memory' | 'browser-sessions' | 'mcp' | 'skills' | 'pets' | 'ssh-connections' | 'notes' | 'subscribed-notes'; /** True for subdirs that have actual files on disk */ export const FILE_SUBDIRS: SubdirId[] = ['browser-macros', 'recordings', 'trash', 'memory', 'notes']; export interface FileEntry { name: string; size: number; mtime: string; } export interface SubdirFiles { subdir: SubdirId; files: FileEntry[]; loading: boolean; } interface FileTreeProps { subdirData: SubdirFiles[]; selectedSubdir: SubdirId | null; selectedFile: string | null; onSelectSubdir: (subdir: SubdirId) => void; onSelectFile: (subdir: SubdirId, file: string) => void; onDeleteFile: (subdir: SubdirId, file: string) => void; } const SUBDIR_LABELS: Record = { 'agents-md': 'AGENTS.md', 'browser-macros': 'browser-macros', recordings: 'recordings', trash: 'trash', memory: 'memory', 'browser-sessions': 'browser-sessions', mcp: 'MCP', skills: 'Skills', pets: 'pets', 'ssh-connections': 'ssh-connections', notes: 'Notes (ε…±ζœ‰)', 'subscribed-notes': 'Subscribed Notes', }; const SUBDIR_ICONS: Record = { 'agents-md': 'πŸ“–', 'browser-macros': 'πŸ€–', recordings: '🎬', trash: 'πŸ—‘', memory: '🧠', 'browser-sessions': '🌐', mcp: 'πŸ”Œ', skills: 'πŸ“š', pets: 'β—‰', 'ssh-connections': 'πŸ”', notes: 'πŸ“', 'subscribed-notes': 'πŸ””', }; /** Virtual subdirs that don't show a file list (they render custom panel content instead). */ const VIRTUAL_SUBDIRS = new Set(['agents-md', 'browser-sessions', 'mcp', 'skills', 'pets', 'ssh-connections', 'subscribed-notes']); export function FileTree({ subdirData, selectedSubdir, selectedFile, onSelectSubdir, onSelectFile, onDeleteFile, }: FileTreeProps) { const [hoveredFile, setHoveredFile] = useState(null); return (
{subdirData.map(({ subdir, files, loading }) => { const isOpen = selectedSubdir === subdir; const isVirtual = VIRTUAL_SUBDIRS.has(subdir); return (
{/* Subdir header */} {/* File list β€” only for non-virtual subdirs */} {isOpen && !isVirtual && (
{loading && (
Loading…
)} {!loading && files.length === 0 && (
Empty
)} {!loading && files.map(file => { const fileKey = `${subdir}/${file.name}`; const isSelected = selectedSubdir === subdir && selectedFile === file.name; return (
setHoveredFile(fileKey)} onMouseLeave={() => setHoveredFile(null)} onClick={() => onSelectFile(subdir, file.name)} > {file.name} {(hoveredFile === fileKey || isSelected) && ( )}
); })}
)}
); })}
); }