fix(layout): respect manualEdits placements during auto-pack#2280
Open
gsdali wants to merge 1 commit intotscircuit:mainfrom
Open
fix(layout): respect manualEdits placements during auto-pack#2280gsdali wants to merge 1 commit intotscircuit:mainfrom
gsdali wants to merge 1 commit intotscircuit:mainfrom
Conversation
The board's manualEdits.pcb_placements positions a component via _computePcbGlobalTransformBeforeLayout, but the auto-packer in each group then re-positioned the same component, silently undoing the user's pin. Group_doInitialPcbLayoutPack marked a child as static (skip-repack) only if isRelativelyPositioned() returned true — and that helper checks pcbX/pcbY/pcbLeftEdgeX/etc., not manualEdits. Components placed via the IDE drag-and-pin flow weren't covered. Walk every descendant of the group being packed and ask the nearest subcircuit for a manual placement. If one exists, add the pcb_component_id to staticPcbComponentIds — the packer then leaves it where the manual edit pinned it. Repro test in tests/pcb-packing/ — chip + 4 caps inside an anchored region, manualEdits pinning each cap to a different corner. Without the fix every cap collapses to the chip's network-minimum (x=0); with the fix they land at the requested coordinates. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5 tasks
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.
Summary
The board's
manualEdits.pcb_placementspopulates a component'sposition via
_computePcbGlobalTransformBeforeLayout, but theauto-packer in each group then re-positions the same component,
silently undoing the user's pin. From the user's perspective, dragging
a component in the IDE writes to
manual-edits.jsonbut the rebuiltboard ignores almost everything they did.
The cause is in
Group_doInitialPcbLayoutPack: it marks a child as"static" (skip-repack) only if
isRelativelyPositioned()returns true,and that helper only checks
pcbX/pcbY/pcbLeftEdgeX/ etc. Itdoesn't consult
manualEdits, so any component placed via the IDEdrag-and-pin flow that has no explicit prop coordinates gets repacked
along with the auto-placed siblings.
Repro
tests/pcb-packing/manual-edits-respected-by-packer.test.tsxmirrorsthe failing case in a downstream board: a chip plus 4 caps inside an
anchored region, with
manualEditspinning each cap to a differentcorner.
Pre-fix on
main: every cap collapses to (0, 0) — the chip'snetwork-minimum point — and the test assertion
c1.center.x ≈ 5failswith
Received: 0.Post-fix: all four caps land at the requested coordinates and the test
passes.
Fix
Walk every descendant of the group being packed, ask the nearest
subcircuit if it resolves a manual placement for that descendant, and
add the
pcb_component_idtostaticPcbComponentIdsif so. The packerthen leaves it where the manual placement put it.
Two-line change in
lib/components/primitive-components/Group/Group_doInitialPcbLayoutPack/Group_doInitialPcbLayoutPack.ts,plus a focused recursion helper. No effect on components that already
have
pcbX/pcbY(those are already marked static via the existingisRelativelyPositioned()path).Related (out of scope here)
There is a separate, complementary bug in
_computePcbGlobalTransformBeforeLayoutwheremanualPlacement(whichis already in subcircuit-absolute coordinates) is composed with the
parent group's transform, double-counting the group anchor for any
component inside an anchored region. A non-zero-anchored group like
<group pcbX={16} pcbY={0}>containing a manually-placed cap at(11.4, 4.3) lands the cap at (27.4, 4.3) instead of (11.4, 4.3). Filed
separately as issue #TBD — that fix is needed for the IDE drag flow to
produce visually-correct positions, but is independent of this PR.
This PR makes the static-marking honest; the position-interpretation
fix lets it land where the user dragged.
Test plan
main(cap at x=0), passes with fix(cap at x=5)
tests/pcb-packing/(2 tests) — passtests/components/pcb tests/groups tests/features/pcb-pack-layout(51 tests) — pass
walks every child, which is consistent with
collectMarginsafew lines above; alternative would be to scan
db.toArray()oncefor
pcb_componentrows, but that's the same big-O for typicalboards and reads worse)
🤖 Generated with Claude Code