feat: highlight traces and same-net traces on hover#164
feat: highlight traces and same-net traces on hover#164aifunmobi wants to merge 3 commits intotscircuit:mainfrom
Conversation
When hovering over a schematic trace, the trace and all other traces connected to the same net change color to indicate interactivity. Net groups are precomputed from circuit-json relationships for efficient pointer event handling. Closes tscircuit/tscircuit#1130
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The previous approach using BFS over circuit-json source_trace relationships missed connections. The SVG already encodes correct net grouping via data-subcircuit-connectivity-map-key attributes set by circuit-to-svg. This is simpler and handles all edge cases including traces without net keys.
Demo — Trace Hover Highlighting (example9)How to test
Same-net grouping verificationIn example9, traces are grouped by net using the
Verified via browser console: // Hovering trace_0 → both net2 traces turn blue
trace_0: stroke="#60a5fa" // ✅ highlighted
trace_1: stroke="#60a5fa" // ✅ same-net highlighted
trace_2: stroke="rgb(0, 150, 0)" // unchanged (different net)
trace_3: stroke="rgb(0, 150, 0)" // unchanged (no net)This is the exact issue that caused PRs #142, #149, and #157 to be rejected — incomplete net grouping where only the directly hovered trace highlighted but not all same-net traces. |
Demo VideoExample 9 (RC charging voltage divider): Hovering over a trace highlights it and all same-net traces in blue ( |
rushabhcodes
left a comment
There was a problem hiding this comment.
Use the repro give https://tscircuit.com/MrPicklePinosaur/tscircuit_demo#schematic to demonstrate your fix
Loads MrPicklePinosaur/tscircuit_demo circuit from tscircuit registry to demonstrate trace hover highlighting on a complex real-world schematic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Demo on MrPicklePinosaur/tscircuit_demoAdded a new fixture ( How to test
This is the exact repro from https://tscircuit.com/MrPicklePinosaur/tscircuit_demo#schematic rendered with our PR's hover highlight hook. |
|
@rushabhcodes Here's the interactive demo using the exact repro you requested: Preview (MrPicklePinosaur/tscircuit_demo circuit): The fixture loads circuit JSON directly from the tscircuit registry API ( Verification (98 traces, 11 nets)You can verify same-net highlighting in the browser console: // After hovering over any net1 trace:
document.querySelector('[data-schematic-trace-id="schematic_trace_0"] path:not(.trace-invisible-hover-outline)').getAttribute('stroke')
// → "#60a5fa" (highlighted)
document.querySelector('[data-schematic-trace-id="schematic_trace_1"] path:not(.trace-invisible-hover-outline)').getAttribute('stroke')
// → "#60a5fa" (same net — also highlighted)
document.querySelector('[data-schematic-trace-id="schematic_trace_3"] path:not(.trace-invisible-hover-outline)').getAttribute('stroke')
// → "rgb(0, 150, 0)" (different net — unchanged)How to test
The net grouping uses the |
|
@rushabhcodes Hey! Just checking in — I posted the demo using the MrPicklePinosaur/tscircuit_demo repro circuit 9 days ago. Does that address your feedback? Happy to make any other changes if needed. Thanks! |

Summary
#60a5fa)useTraceHoverHighlighthook follows the same pattern as existinguseChangeSchematicTracesForMovedComponentsCloses tscircuit/tscircuit#1130
/claim #1130
How it works
circuitJson: schematic traces → source traces → connected portspointermove, detects which trace group the pointer is over viaElement.closest("[data-schematic-trace-id]")Test plan
#60a5fa)