"use client"; import Link from "next/link"; import { useMemo } from "react"; import { ArrowDownLeft, ArrowUpRight, ExternalLink, Sparkles, Crosshair, X, Paperclip, Tag } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Badge, Spinner } from "@/components/ui/primitives"; import { cn, timeAgo } from "@/lib/utils"; import type { GraphData, GraphEdge, GraphNode, NodeKind } from "@/lib/graph/types"; import { KIND_CLASS } from "./colors"; const KIND_LABEL: Record = { page: "Page", database: "Database", research: "Research", row: "Row", attachment: "Attachment", tag: "Tag" }; export function Inspector({ node, data, onClose, onFocus, onSuggest, suggesting, onNeighbourhood, className }: { node: GraphNode; data: GraphData; onClose: () => void; onFocus: (id: string) => void; onSuggest: (id: string) => void; suggesting?: boolean; onNeighbourhood: (id: string) => void; className?: string }) { const byId = useMemo(() => new Map(data.nodes.map((n) => [n.id, n])), [data]); const links = useMemo(() => { const out: { other: GraphNode; edge: GraphEdge; dir: "out" | "in" }[] = []; for (const e of data.edges) { if (e.source === node.id && byId.has(e.target)) out.push({ other: byId.get(e.target)!, edge: e, dir: "out" }); else if (e.target === node.id && byId.has(e.source)) out.push({ other: byId.get(e.source)!, edge: e, dir: "in" }); } return out.sort((a, b) => (a.edge.status === b.edge.status ? a.other.title.localeCompare(b.other.title) : a.edge.status === "accepted" ? -1 : 1)); }, [data, node.id, byId]); const isPage = node.kind !== "attachment" && node.kind !== "tag"; const href = isPage ? `/p/${node.id}` : node.kind === "attachment" ? `/api/files/${node.id.slice(4)}` : null; return (
{node.icon ? `${node.icon} ` : ""}{node.title}
{KIND_LABEL[node.kind]}{node.section && {node.section}}degree {node.degree}{isPage && · {node.in} in / {node.out} out}{node.updatedAt && · {timeAgo(node.updatedAt)}}
{href && } {isPage && }
{links.length} connection{links.length === 1 ? "" : "s"}
{!links.length &&

No links yet. Mention another page with @ or ask for AI suggestions.

}
    {links.map(({ other, edge, dir }) => (
  • {edge.status === "suggested" && edge.rationale &&

    {edge.rationale}

    }
  • ))}
); }