Skip to content

feat: highlight all same-net traces on hover#165

Open
makaiachildress-web wants to merge 1 commit intotscircuit:mainfrom
makaiachildress-web:feat/trace-hover-highlight-same-net
Open

feat: highlight all same-net traces on hover#165
makaiachildress-web wants to merge 1 commit intotscircuit:mainfrom
makaiachildress-web:feat/trace-hover-highlight-same-net

Conversation

@makaiachildress-web
Copy link

Summary

  • Adds useTraceHoverHighlight hook that highlights all traces in the same net when hovering over any trace
  • Net grouping uses subcircuit_connectivity_map_key (primary) with BFS over shared connected_source_port_ids as fallback
  • Disables the default per-trace :hover CSS from circuit-to-svg to prevent double highlighting
  • Uses precomputed group keys to eliminate flicker when moving between traces in the same net

Fixes tscircuit/tscircuit#1130
/claim #1130

How it works

  1. On mount, buildNetGroups() precomputes net membership for every schematic trace:
    • Strategy 1: Groups traces sharing the same subcircuit_connectivity_map_key
    • Strategy 2: For traces without the key, BFS walks source_trace -> connected_source_port_ids to find all source traces on the same net, then maps back to schematic trace IDs
  2. Each trace gets a stable group key for O(1) pointer-move comparisons
  3. On pointermove, finds the hovered trace via Element.closest(), looks up its net group, and sets stroke to #1e90ff on all paths in that group
  4. On pointerleave, restores original stroke colors
  5. Injected CSS override disables the default .trace:hover { filter: invert(1) } and the :has()-based net hover rules from circuit-to-svg

Test plan

  • Hover over a trace -> it turns blue (#1e90ff)
  • Other traces on the same net also highlight
  • Moving pointer off the trace restores original colors
  • Moving between traces on the same net does not flicker
  • No interference with existing component drag/dash animation
  • Works with the MrPicklePinosaur/tscircuit_demo circuit

Files changed

  • lib/hooks/useTraceHoverHighlight.ts - New hook with net grouping and hover logic
  • lib/components/SchematicViewer.tsx - Import and call the hook

🤖 Generated with Claude Code

Add useTraceHoverHighlight hook that highlights every trace in the same
net when hovering over any trace in the schematic viewer.

Net grouping uses two strategies:
1. subcircuit_connectivity_map_key when present on schematic traces
2. BFS over shared source ports as fallback for traces without the key

The hook disables the default per-trace :hover CSS from circuit-to-svg
to prevent double highlighting, and uses precomputed group keys to
avoid flicker when moving between traces in the same net.

Fixes tscircuit/tscircuit#1130

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-viewer Ready Ready Preview, Comment Feb 17, 2026 7:40pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change of color on hover for traces are missing

1 participant