"use client"; import { useCallback, useEffect, useState } from "react"; import { FolderSync, RefreshCw, FileText, CheckCircle2, AlertTriangle } from "lucide-react"; import { watchStatus, watchSync, type WatchStatus, type WatchSyncResult } from "@/lib/api"; /** * Watch Folder inspector: shows the auto-reindexed local directories, their file * counts, and a "Sync now" trigger. Adds/edits/deletes in a watched folder are * reflected in the index automatically by the worker; this surfaces + forces it. */ export function WatchPanel({ onSynced }: { onSynced?: () => void }) { const [status, setStatus] = useState(null); const [loading, setLoading] = useState(true); const [syncing, setSyncing] = useState(false); const [last, setLast] = useState(null); const load = useCallback(() => { setLoading(true); watchStatus() .then(setStatus) .catch(() => {}) .finally(() => setLoading(false)); }, []); useEffect(() => { load(); }, [load]); const sync = () => { setSyncing(true); watchSync() .then((r) => { setLast(r); if (r.added || r.updated || r.removed) onSynced?.(); }) .catch(() => {}) .finally(() => { setSyncing(false); load(); }); }; return (

Watch Folder {status?.enabled && status.tracked > 0 && ( {status.tracked} )}

{!status?.enabled ? (
Auto-reindex is off. Enable it with{" "} AURALYNQ_WATCH__ENABLED=true{" "} — then drop files into a watched folder and Auralynq keeps the index in sync automatically (adds, edits and deletes).
) : ( <>
    {status.directories.map((d) => (
  • {d.path} {d.exists ? ( {d.files} file{d.files === 1 ? "" : "s"} ) : ( missing )}
  • ))}
every {status.poll_seconds}s {status.recursive && recursive} {status.delete_missing && prunes deletes}
{last && (
{last.errors.length > 0 ? ( {last.errors[0]} ) : ( {last.added + last.updated + last.removed === 0 ? "Already up to date" : `+${last.added} added · ${last.updated} updated · ${last.removed} removed`} )}
)} )}
); }