import { useEffect } from "react"; import { downloadFile, type FileNode } from "../api/client"; import { DownloadIcon } from "../components/Icon"; import { useStore } from "../store/useStore"; export function HistoryView({ onOpen }: { onOpen: () => void }) { const { sessions, refreshSessions, openSession, removeSession } = useStore(); useEffect(() => { refreshSessions(); }, [refreshSessions]); return (
{sessions.map((session) => (
{session.title}
{session.message_count ?? 0} message(s) · {new Date(session.updated_at * 1000).toLocaleString("fr-FR")}
))} {sessions.length === 0 && }
); } export function FilesView() { const { fileTree, refreshFiles } = useStore(); useEffect(() => { refreshFiles(); }, [refreshFiles]); return (
{fileTree.length ? : }
); } function WorkspaceTree({ nodes, depth }: { nodes: FileNode[]; depth: number }) { const { openPreview, previewPath } = useStore(); return ( <> {nodes.map((node) => (
{node.type === "file" && ( )}
{node.children && }
))} ); } export function ToolsView({ onSettings }: { onSettings: () => void }) { const { config, availableTools, refreshConfig, selectedModel } = useStore(); useEffect(() => { refreshConfig(); }, [refreshConfig, selectedModel]); return (
{availableTools.map((name) => { const enabled = config?.tools[name] ?? false; return (
{name} {enabled ? "ACTIF" : "INACTIF"}
); })}
); } function Page({ title, subtitle, children }: { title: string; subtitle: string; children: React.ReactNode }) { return (

{title}

{subtitle}

{children}
); } function Empty({ text }: { text: string }) { return
{text}
; } function formatSize(bytes: number): string { if (bytes < 1024) return `${bytes} o`; if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} Ko`; return `${(bytes / 1024 / 1024).toFixed(1)} Mo`; }