import { useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { AlertTriangle, ArrowRight, Library, Plus } from "lucide-react"; import { api, type Pair } from "../api"; import { Badge, Button, Card, Empty, Spinner, formatAgo, formatBytes, statusTone } from "../ui"; import { PairForm } from "./PairForm"; import { JobBar, ScanButton } from "./PairPage"; export function Dashboard() { const [creating, setCreating] = useState(false); const pairs = useQuery({ queryKey: ["pairs"], queryFn: () => api.get("/pairs"), refetchInterval: (q) => (q.state.data?.some((p) => p.job?.state === "running") ? 1000 : 15000), }); return (

Libraries

Each pair links matching songs from a slave library to the host library's copy.

{pairs.isLoading && } {pairs.data?.length === 0 && ( } title="No library pairs yet"> Create a pair with a host library (e.g. Albums) and a slave library (e.g. your curated Singles). playlink finds songs in both and replaces the slave copy with a hardlink to the host copy, so each song is stored only once.
)}
{pairs.data?.map((p) => )}
setCreating(false)} />
); } function PairCard({ pair }: { pair: Pair }) { const c = pair.summary.counts; const stats: [string, number][] = [ ["linked", c.linked ?? 0], ["identical", c.identical ?? 0], ["review", pair.summary.review], ["unmatched", c.unmatched ?? 0], ]; return (
{pair.name}
host {pair.host_root}
slave {pair.slave_root}
{stats.map(([k, v]) => (
{v}
{k}
))}
Reclaimable: {formatBytes(pair.summary.reclaimable_bytes)} Deduplicated: {formatBytes(pair.summary.linked_bytes)} Last scan: {formatAgo(pair.last_scan_at)} {pair.auto_link_identical && auto-link} {pair.scan_interval_minutes > 0 && every {pair.scan_interval_minutes}m}
{pair.job?.state === "running" && } {pair.last_scan_error && (
{pair.last_scan_error}
)} {pair.last_scan_warnings.length > 0 && (
{pair.last_scan_warnings.length} layout warning{pair.last_scan_warnings.length > 1 && "s"}
)} Open
); }