From 7b2e333a9de62333d69b2e7ab296a0b1f7acb937 Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Mon, 22 Jun 2026 16:56:57 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20PatternExplorer=20=E2=80=94=20exclude=20?= =?UTF-8?q?root=20id=20from=20node=20paths=20so=20they=20match=20taxonomy?= =?UTF-8?q?=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit enrichTree was building paths starting with 'root', but patterns store paths like ['geopolitical', 'armed_conflict', ...] — no root prefix. Fix: start enriching root children with parentPath=[] instead of ['root']. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/PatternExplorer.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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([])