fix(tree): align node-alias precedence with the graph build (#5030 follow-up)
tree_html.build_tree folded aliases in a different order (src first) than build._fold_node_aliases (src last), so a node carrying two conflicting file aliases could key on different paths in the viewer vs the built graph. Use the same order and pop the consumed alias, as the build-side fold does. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
778c906a08
commit
6ee8e2258e
1 file changed
+5
-2
@@ -216,10 +216,13 @@ def build_tree(
|
||||
nodes: List[Dict[str, Any]] = list(graph.get("nodes", []))
|
||||
for n in nodes:
|
||||
if not n.get("source_file"):
|
||||
for alias in ("src", "file", "path", "filepath"):
|
||||
# Same alias order as build._fold_node_aliases (`src` last), so a node
|
||||
# carrying two conflicting aliases resolves to the identical
|
||||
# source_file in the built graph and in this viewer.
|
||||
for alias in ("file", "path", "filepath", "src"):
|
||||
val = n.get(alias)
|
||||
if isinstance(val, str) and val.strip():
|
||||
n["source_file"] = val.strip()
|
||||
n["source_file"] = n.pop(alias).strip()
|
||||
break
|
||||
file_nodes = [n for n in nodes if n.get("source_file")]
|
||||
if not file_nodes:
|
||||
|
||||
Reference in new issue
Block a user