Fix per-layer PCB trace rendering for via routes and add minimal plated-hole/via repro fixture#699
Conversation
…ed-hole/via repro fixture
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Updates PCB trace rendering to better handle per-layer drawing/highlighting, and adds a new 2026 fixture intended to reproduce/validate Sparkfun-style board routing (including via transitions).
Changes:
- Strengthen
isPcbTracetyping and introduce route filtering for traces by target copper layers during rendering. - Refactor highlighted vs non-highlighted trace partitioning to a single-pass loop.
- Add
SparkfunBoardsexample fixture with a small trace + via scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/lib/draw-pcb-trace.ts |
Adds per-layer trace route filtering and minor highlight partition refactor for trace drawing. |
src/examples/2026/sparkfun-boards.fixture.tsx |
New fixture to render a small Sparkfun-like route including a via and top/bottom segments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const filteredRoute = trace.route.filter( | ||
| (segment) => | ||
| segment.route_type === "wire" && | ||
| "layer" in segment && | ||
| targetLayers.has(segment.layer), | ||
| ) | ||
|
|
||
| if (filteredRoute.length === 0) return null | ||
|
|
||
| return { | ||
| ...trace, | ||
| route: filteredRoute, | ||
| } |
| return ( | ||
| <div style={{ backgroundColor: "black", width: "100%", height: "700px" }}> | ||
| <PCBViewer circuitJson={[ | ||
| { | ||
| "type": "pcb_plated_hole", |
Abse2001
left a comment
There was a problem hiding this comment.
wait for Seve's review , and after this we need to make vias and plated holes color blue like bottom traces when switching to bottom layer on the viewere
I am working on that too |
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
|
This broke so much stuff @rushabhcodes.... |
|
/sabotage |


This pull request introduces a new
SparkfunBoardsfixture for PCB visualization and refactors the PCB trace drawing logic to improve type safety and layer filtering. The main focus is on enhancing how PCB traces are filtered and rendered per layer, leading to more maintainable and robust code.Before
https://tscircuit--sparkfun-boards-v0-0-8-pr272-15835086.tscircuit.app/
PCB Trace Drawing Improvements:
isPcbTracetype guard to use a TypeScript type predicate, improving type safety when distinguishingPcbTraceelements.filterTraceByLayersfunction to filter trace segments by the target copper layers, ensuring only relevant wire segments are drawn for the selected layers.drawPcbTraceElementsForLayerfunction to usefilterTraceByLayersand improved the logic for separating highlighted and non-highlighted traces, enhancing clarity and correctness. [1] [2]Fixture Addition:
SparkfunBoardsReact component insparkfun-boards.fixture.tsxto showcase PCB visualization with plated holes, traces, and vias, using thePCBViewercomponent.Type Imports:
draw-pcb-trace.tsto includePcbTracefor stronger typing throughout the file.