From 5d969d6fdbbbe9f7e82a00a35c5106a4acc4a40c Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Mon, 22 Jun 2026 16:53:54 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20PatternExplorer=20tree=20=E2=80=94=20ext?= =?UTF-8?q?ract=20.tree=20from=20API=20response=20and=20compute=20node=20p?= =?UTF-8?q?aths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The taxonomy endpoint returns {tree, patterns} but the component was casting the whole response as the root node. Also added enrichTree() to attach computed path arrays to each node (backend PATTERN_TAXONOMY has no path field). Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/PatternExplorer.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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('')