diff --git a/frontend/src/pages/PatternExplorer.tsx b/frontend/src/pages/PatternExplorer.tsx index 40ab66d..475e196 100644 --- a/frontend/src/pages/PatternExplorer.tsx +++ b/frontend/src/pages/PatternExplorer.tsx @@ -293,11 +293,26 @@ function TreeNodeRow({ ) } +// ── Helper: add computed path arrays to each node ──────────────────────────── +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function enrichTree(node: any, parentPath: string[] = []): TaxonomyNode { + const path = [...parentPath, node.id] + return { + ...node, + path, + children: (node.children ?? []).map((c: any) => enrichTree(c, path)), + } +} + // ── Tree View ───────────────────────────────────────────────────────────────── function TreeView({ patterns }: { patterns: Pattern[] }) { const { data: taxonomyData } = usePatternTaxonomy() - const taxonomy = taxonomyData as TaxonomyNode | undefined + // API returns { tree: {...}, patterns: [...] } — extract the tree and enrich nodes with path arrays + const taxonomy: TaxonomyNode | undefined = useMemo(() => { + const raw = (taxonomyData as any)?.tree + return raw ? enrichTree(raw) : undefined + }, [taxonomyData]) const [selectedPath, setSelectedPath] = useState([]) const [nameFilter, setNameFilter] = useState('')