@@ -2499,6 +2499,7 @@ def render_html(
24992499const allBucketIds = new Set(rawNodes.map(node => node.bucket).filter(Boolean));
25002500const allGroupIds = new Set(rawNodes.map(node => node.group).filter(Boolean));
25012501let filterFromNodeSelection = false;
2502+ let manualFilter = "";
25022503function normalized(text) {{
25032504 return (text || "").trim().toLowerCase();
25042505}}
@@ -2963,7 +2964,19 @@ def render_html(
29632964 selectedNode = nodeId;
29642965 selectedEdge = null;
29652966 setDetails(nodeId);
2966- searchInput.value = "./" + nodeId;
2967+
2968+ const nodeFilter = "./" + nodeId;
2969+ const query = normalized(searchInput.value);
2970+ const depth = Math.max(0, parseInt(document.getElementById("filterDepth").value || "1", 10) || 0);
2971+ const visibleSet = query
2972+ ? computeFilterExpansion(matchingNodeIds(query), depth)
2973+ : new Set(activeViewNodeIds);
2974+
2975+ if (!filterFromNodeSelection && query) {{
2976+ manualFilter = searchInput.value;
2977+ }}
2978+
2979+ searchInput.value = nodeFilter;
29672980 filterFromNodeSelection = true;
29682981 syncFilterDepthVisibility();
29692982 updateStyles();
@@ -3361,6 +3374,7 @@ def render_html(
33613374 hoveredNode = null;
33623375 searchInput.value = "";
33633376 filterFromNodeSelection = false;
3377+ manualFilter = "";
33643378 syncFilterDepthVisibility();
33653379 hideTooltip();
33663380 updateStyles();
@@ -3384,6 +3398,8 @@ def render_html(
33843398network.on("click", params => {{
33853399 if (params.nodes.length) {{
33863400 const clicked = params.nodes[0];
3401+ const _viewActive = (viewSelect.value || "all") !== "all";
3402+ if (_viewActive && !activeViewNodeIds.has(clicked)) return;
33873403 if (selectedNode === clicked) {{
33883404 clearHighlight();
33893405 }} else {{
@@ -3394,6 +3410,11 @@ def render_html(
33943410 drawMiniMap();
33953411 }} else if (params.edges.length) {{
33963412 const clickedEdgeId = params.edges[0];
3413+ const _clickedEdgeState = edges.get(clickedEdgeId);
3414+ if (_clickedEdgeState && _clickedEdgeState.color && _clickedEdgeState.color.opacity != null && _clickedEdgeState.color.opacity < 1) {{
3415+ clearHighlight();
3416+ return;
3417+ }}
33973418 const isCptEdge = typeof clickedEdgeId === "string" && clickedEdgeId.startsWith("cpt-");
33983419 if (isCptEdge) {{
33993420 const cptEdge = cptEdgeById.get(clickedEdgeId);
@@ -3402,8 +3423,6 @@ def render_html(
34023423 const fileEdge = edgeById.get(clickedEdgeId);
34033424 if (fileEdge) showEdgeDetailToast(fileEdge.from, fileEdge.to, "file");
34043425 }}
3405- }} else {{
3406- clearHighlight();
34073426 }}
34083427}});
34093428
@@ -3427,7 +3446,9 @@ def render_html(
34273446
34283447searchInput.addEventListener("input", () => {{
34293448 filterFromNodeSelection = false;
3430- if (!normalized(searchInput.value)) {{
3449+ const _val = normalized(searchInput.value);
3450+ manualFilter = _val ? searchInput.value : "";
3451+ if (!_val) {{
34313452 clearHighlight();
34323453 }} else {{
34333454 syncFilterDepthVisibility();
@@ -3759,12 +3780,32 @@ def render_html(
37593780 hideTooltip();
37603781 }} else if (document.getElementById("searchResultsToast").style.display === "flex") {{
37613782 document.getElementById("searchResultsToast").style.display = "none";
3762- }} else if (selectedNode) {{
3783+ }} else if (filterFromNodeSelection && manualFilter) {{
3784+ searchInput.value = manualFilter;
3785+ filterFromNodeSelection = false;
3786+ selectedNode = null;
3787+ selectedEdge = null;
3788+ network.unselectAll();
3789+ details.classList.add("hidden");
3790+ syncFilterDepthVisibility();
3791+ updateStyles();
3792+ }} else if (selectedNode || filterFromNodeSelection) {{
37633793 clearHighlight();
37643794 }} else if (searchInput.value) {{
37653795 searchInput.value = "";
3796+ manualFilter = "";
37663797 updateStyles();
37673798 searchInput.focus();
3799+ }} else if ((viewSelect.value || "all") !== "all") {{
3800+ const curDepth = Math.max(0, parseInt(viewDepth.value || "0", 10) || 0);
3801+ if (curDepth > 0) {{
3802+ viewDepth.value = String(curDepth - 1);
3803+ applyViewState();
3804+ }} else {{
3805+ viewSelect.value = "all";
3806+ syncViewDepthVisibility();
3807+ applyViewState({{ fit: true }});
3808+ }}
37683809 }}
37693810}});
37703811
0 commit comments