import * as Dialog from '@radix-ui/react-dialog' import { useQuery } from '@tanstack/react-query' import { apiFetch } from '@/lib/http' import { LoadingSkeleton } from '@/components/common/LoadingSkeleton' import { NODE_COLOURS } from './KnowledgeGraph' import type { GraphNode, GraphTraverseResponse } from '@/types/api' interface Props { node: GraphNode | null teamId: string onClose: () => void onAskAbout: (query: string) => void } async function fetchTraverse(node: GraphNode, teamId: string): Promise { const params = new URLSearchParams({ type: node.label.toLowerCase(), name: node.name, team_id: teamId, }) const res = await apiFetch(`/graph/traverse?${params}`) return res.json() } export function GraphNodeDetailPanel({ node, teamId, onClose, onAskAbout }: Props) { const { data, isLoading, isError } = useQuery({ queryKey: ['graph-traverse', node?.label, node?.name, teamId], queryFn: () => fetchTraverse(node!, teamId), enabled: !!node, staleTime: 60_000, retry: 1, }) const colour = node ? (NODE_COLOURS[node.label] ?? '#94a3b8') : '#94a3b8' return ( { if (!open) onClose() }}> {node && ( <> {/* Header */}
{node.name} {node.label}
{/* Body */}

Related documents

{isLoading && } {isError && (

Could not load related documents.

)} {data && data.chunks.length === 0 && (

No related documents found.

)} {data && data.chunks.length > 0 && (
{data.chunks.slice(0, 6).map((chunk, i) => (
{chunk.length > 200 ? chunk.slice(0, 200) + '…' : chunk}
))}
)}
{/* Footer */}
)}
) }