diff --git a/visual-tree-search-app/components/SimpleSearchVisual.tsx b/visual-tree-search-app/components/SimpleSearchVisual.tsx index 9d7eabb..fb39821 100644 --- a/visual-tree-search-app/components/SimpleSearchVisual.tsx +++ b/visual-tree-search-app/components/SimpleSearchVisual.tsx @@ -103,7 +103,7 @@ const SimpleSearchVisual: React.FC = ({ messages }) => setTreeNodes(updatedTreeNodes); setSelectedNodeId(newSelectedNodeId); } - }, [messages, treeNodes, selectedNodeId]); + }, [messages]); // Render the tree visualization useEffect(() => { @@ -221,7 +221,7 @@ const SimpleSearchVisual: React.FC = ({ messages }) => : theme === 'dark' ? "#374151" : "#D1D5DB") .attr("stroke-width", d => d.data.id === selectedNodeId ? 3 : 2); - // Add node labels directly on the node circles + // Add node labels with tooltips nodes.append("text") .attr("dy", ".35em") .attr("x", d => d.children ? -18 : 18) @@ -230,19 +230,18 @@ const SimpleSearchVisual: React.FC = ({ messages }) => // For root node if (d.data.parent_id === null) return "ROOT"; - // Extract action name from action string + // Show full action string if (d.data.action) { - const actionMatch = d.data.action.match(/^([a-zA-Z_]+)\(/); - return actionMatch ? actionMatch[1] : "action"; + return d.data.action; } return d.data.id.toString().slice(-4); }) - .attr("font-size", "14px") + .attr("font-size", "15px") .attr("font-weight", "500") .attr("fill", d => { if (d.data.id === selectedNodeId) { - return theme === 'dark' ? "#93C5FD" : "#2563EB"; + return "#ff5722"; // Orange for selected node } return theme === 'dark' ? "#FFFFFF" : "#111827"; }); @@ -264,29 +263,21 @@ const SimpleSearchVisual: React.FC = ({ messages }) => // Add tooltip interactions nodes .on("mouseover", function(event, d) { - if (tooltipRef.current) { - let content = `
Node ID: ${d.data.id}
`; - if (d.data.action) content += `
Action: ${d.data.action}
`; - if (d.data.description) content += `
Description: ${d.data.description}
`; - if (typeof d.data.value === 'number') content += `
Value: ${d.data.value.toFixed(2)}
`; - if (typeof d.data.reward === 'number') content += `
Reward: ${d.data.reward.toFixed(2)}
`; - if (typeof d.data.visits === 'number') content += `
Visits: ${d.data.visits}
`; - if (d.data.feedback) content += `
Feedback: ${d.data.feedback}
`; - + if (tooltipRef.current && d.data.description) { const tooltip = d3.select(tooltipRef.current); tooltip.transition() .duration(200) .style("opacity", .9); - tooltip.html(content) + tooltip.html(d.data.description) .style("left", (event.pageX + 15) + "px") - .style("top", (event.pageY - 30) + "px"); + .style("top", (event.pageY - 60) + "px"); } }) .on("mousemove", function(event) { if (tooltipRef.current) { d3.select(tooltipRef.current) .style("left", (event.pageX + 15) + "px") - .style("top", (event.pageY - 30) + "px"); + .style("top", (event.pageY - 28) + "px"); } }) .on("mouseout", function() {