fix(schematic): resolve netlabel net connections to the net's ports (floating power net label)#2559
Open
chayan-1906 wants to merge 1 commit into
Open
Conversation
A netlabel with a net selector connection (e.g. connection="net.C") treated the resolved Net instance as a Port. A Net has no schematic position, so the user's label anchored at (0,0) - on top of whatever component sat there. For power/ground nets the schematic trace solver then added its own rail at the real pin and marked the port connected, so the stranded user label was never rescued, producing a floating duplicate power rail (tscircuit/tscircuit.com#3759). Resolve net selectors to the net's connected ports instead. The user label now anchors at the real pin and the solver skips its duplicate placement and stub trace. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes tscircuit/tscircuit.com#3759
Problem
A power net label connected through a net renders a phantom rail on top of an unrelated component:
The V5 rail correctly appears at R3.pin1, but a second, floating V5 rail is drawn on top of R1 (whichever component sits at schematic origin).
Root cause
NetLabel._getConnectedPorts()resolves theconnectionselector withselectOne(connection)and casts the result toPort. For a net selector like"net.C"this returns the Net instance, which has no schematic position, so the user's label anchors at the fallback(0, 0).For power/ground nets the schematic trace solver then places its own rail at the real pin (
getSchematicPortIdsWithAssignedNetLabelscan't see that the pin already has a user-defined label, for the same reason), routes a stub trace to it, and marks the port connected — soinsertNetLabelsForPortsMissingTracenever rescues the stranded user label. Result: a correct rail at R3.pin1 plus a floating duplicate at(0, 0).Non-power labels were silently rescued by the missing-trace pass, which is why only power/ground rails visibly floated — though they still produced two identical labels stacked at the pin.
Fix
Resolve net selectors to the net's connected ports (
Net.getAllConnectedPorts()) in_getConnectedPorts(). The user label then anchors at the real pin, and the existing solver logic skips both the duplicate placement (applyNetLabelPlacements) and the stub trace (applyTracesFromSolverOutput).Before (issue repro): two
V5labels —(0.00, 0.00)on top of R1 +(-0.65, 4.36)near R3.After: one
V5label at(-0.55, 3.96)= R3.pin1,rail_upsymbol kept.Regular labels (e.g.
net="MYNET"): same position as before, no longer duplicated.Testing
tests/repros/repro142-floating-power-net-label.test.tsx— fails on main (phantom anchors 3.99 units away from R3.pin1), passes with the fixautorouter-preset-laser-prefab) also fails on unmodified main (pre-existing)bunx tsc --noEmitclean,biome formatclean,bun run buildsucceeds🤖 Generated with Claude Code