diff --git a/src/LibraryManager.jsx b/src/LibraryManager.jsx index 5073920..3a6d51a 100644 --- a/src/LibraryManager.jsx +++ b/src/LibraryManager.jsx @@ -8,6 +8,48 @@ function statusLabel(job) { return `${type} · ${job.status}${progress ? ` · ${progress}` : ''}${detail}` } +function fileSyncMeta(file) { + const sync = file?.sync || {} + const status = String(sync.status || 'pending') + const progress = Math.max(0, Math.min(100, Number(sync.progress) || 0)) + const detail = String(sync.detail || '').trim() + const error = String(sync.error || '').trim() + + if (status === 'ready') { + return { + status, + progress: 100, + label: 'Available', + detail: detail || 'Ready in chat.' + } + } + + if (status === 'failed') { + return { + status, + progress: 100, + label: 'Sync failed', + detail: error || detail || 'Heimgeist could not finish syncing this file.' + } + } + + if (status === 'syncing') { + return { + status, + progress, + label: progress > 0 ? `Syncing ${Math.round(progress)}%` : 'Syncing', + detail: detail || 'Building corpus, enrichment, embeddings, and indexes.' + } + } + + return { + status: 'pending', + progress: 6, + label: 'Queued', + detail: 'Waiting to start the full sync pipeline.' + } +} + export default function LibraryManager({ apiBase, library, @@ -96,6 +138,7 @@ export default function LibraryManager({ const activeJobs = (jobs || []).filter(job => job.slug === library.slug && (job.status === 'queued' || job.status === 'running')) const isSyncing = activeJobs.length > 0 const isReadyForChat = !!library.states?.is_indexed + const hasFailedFiles = (library.files || []).some(file => file?.sync?.status === 'failed') return (
No files registered yet.