diff --git a/frontend/src/pages/PatternExplorer.tsx b/frontend/src/pages/PatternExplorer.tsx index 475e196..6e438f8 100644 --- a/frontend/src/pages/PatternExplorer.tsx +++ b/frontend/src/pages/PatternExplorer.tsx @@ -308,10 +308,12 @@ function enrichTree(node: any, parentPath: string[] = []): TaxonomyNode { function TreeView({ patterns }: { patterns: Pattern[] }) { const { data: taxonomyData } = usePatternTaxonomy() - // API returns { tree: {...}, patterns: [...] } — extract the tree and enrich nodes with path arrays + // API returns { tree: {...}, patterns: [...] } — extract the tree and enrich nodes with path arrays. + // Start enriching from root's children with [] so paths match pattern taxonomy_path (no "root" prefix). const taxonomy: TaxonomyNode | undefined = useMemo(() => { const raw = (taxonomyData as any)?.tree - return raw ? enrichTree(raw) : undefined + if (!raw) return undefined + return { ...raw, path: [], children: (raw.children ?? []).map((c: any) => enrichTree(c, [])) } }, [taxonomyData]) const [selectedPath, setSelectedPath] = useState([])