Skip to content

fix: highlight all traces on same net on hover#201

Open
rimi11e wants to merge 1 commit into
tscircuit:mainfrom
rimi11e:fix/1130-hover-connected-traces
Open

fix: highlight all traces on same net on hover#201
rimi11e wants to merge 1 commit into
tscircuit:mainfrom
rimi11e:fix/1130-hover-connected-traces

Conversation

@rimi11e
Copy link
Copy Markdown

@rimi11e rimi11e commented May 17, 2026

   Fixes tscircuit/tscircuit#1130

   ## Summary
   On hovering a schematic trace, every other trace electrically
   connected to the same net is now highlighted (orange, with a
   subtle drop-shadow). The grouping uses
   `getFullConnectivityMapFromCircuitJson`, the same connectivity
   utility tscircuit/circuit-json-to-readable-netlist relies on,
   so disjoint trace segments that share a port or a `source_net`
   are correctly grouped together.

   This addresses the review feedback on #149: "trace going to the
   right should also get highlighted as it is part of same net."

   ## What changed
   - `lib/hooks/useConnectedTracesHoverHighlighting.ts` (new): hook
     that memoizes a `schematic_trace_id → net group key` map per
     circuit-json change, and applies/removes a highlight CSS class
     on mouseover/mouseout.
   - `lib/components/SchematicViewer.tsx`: wires the hook in. Disabled
     while edit mode is active to avoid interfering with drag handles.
   - `package.json`: adds `circuit-json-to-connectivity-map` and
     `@tscircuit/soup-util` as dependencies.

   ## Notes
   - Listener is attached to the SVG container with `mouseover`/`mouseout`
     (event delegation), so it works regardless of how many traces are
     rendered.
   - Cleanup removes listeners and clears any active highlight on unmount
     or when `circuitJsonKey` changes.

   ## Testing
   - Verified visually with the existing cosmos examples (example1,
     example2, example4 multi-net circuits).
   - No existing snapshot/unit tests changed — purely additive.

Closes tscircuit/tscircuit#1130

Adds useConnectedTracesHoverHighlighting hook that uses
getFullConnectivityMapFromCircuitJson to compute the full
equivalence class of source-level connectivity, then highlights
every schematic_trace whose source_trace_id maps to the same
net as the hovered trace.

This fixes the issue raised on PR tscircuit#149 where traces extending to
the right (or otherwise disjoint trace segments on the same net)
were not being highlighted.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 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 May 17, 2026 10:15am

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.

2 participants