feat(pcb): update placed footprints from libraries - #232
Open
TWT233 wants to merge 5 commits into
Open
Conversation
Co-authored-by: TRAE CLI <noreply@bytedance.com>
Co-authored-by: TRAE CLI <noreply@bytedance.com>
Co-authored-by: TRAE CLI <noreply@bytedance.com>
Co-authored-by: TRAE CLI <noreply@bytedance.com>
15 tasks
mixelpixx
added a commit
that referenced
this pull request
Aug 17, 2026
`builders::layer_from_name` mapped anything it did not recognise to `BL_UNDEFINED`, and its table stopped at `In2.Cu` — no `Dwgs.User`, `Cmts.User`, `Eco1/2.User`, `F/B.Adhes`, `Margin`, `Rescue`, no inner copper past the second, and none of `User.1`–`User.45`. `Dwgs.User` is the one that mattered. It is ordinary content in the official libraries, and KiCAD 10.0.5 does not validate a scalar layer field on an incoming item: it indexes its layer bitset with whatever arrives. So placing `Connector_USB:USB_C_Receptacle_GCT_USB4105-xx-A_16P_TopMnt_Horizontal` (two `Dwgs.User` children) or `Connector:BJB_Pico_46.110.1001_Receptacle_Horizontal` (eight) faulted KiCAD at `0xc0000005` in `kicommon.dll`, discarding the session's unsaved board. Konnect saw only an NNG receive timeout. Two halves, because widening the table alone would leave the next layer KiCAD adds able to do this again: * `layer_from_name` now covers every layer a KiCAD 10 footprint can legally draw on. Inner copper and user layers are computed rather than listed — the enum is contiguous for both runs except that `BL_Rescue = 62` sits between `BL_User_9 = 61` and `BL_User_10 = 63`. * `try_layer_from_name` refuses a name with no representation, and `build_footprint_item` now validates the root layer, every pad layer and every graphic layer before it builds a single child. An unrepresentable layer has to stop where it can still be reported; downstream there is no error to catch, only a dead editor. The pad path already dropped `BL_UNDEFINED` from its layer list; the graphic and text paths passed it straight through. That asymmetry was the bug. Reported with a full root-cause analysis by @neusse. The widened table follows the arithmetic in @TWT233's #232, which arrived at the same mapping while building `update_footprints_from_library`. Refs #237
mixelpixx
added a commit
that referenced
this pull request
Aug 17, 2026
Two defects in v0.6.0, both of which could cost a user work. **#237 — KiCAD could be terminated while placing a footprint.** An ordinary `Dwgs.User` graphic serialised as `BL_UNDEFINED`, and KiCAD 10.0.5 indexes its layer bitset with whatever arrives rather than validating it. Two official library footprints reproduce it; the process exits and takes any unsaved board with it. The layer table now covers every layer a KiCAD 10 footprint can draw on, and an unrepresentable layer is refused before anything is sent. Reported with a full root-cause analysis by @neusse; the widened mapping follows the arithmetic in @TWT233's #232. **#238 — `konnect init --help` ran the installer.** Subcommands were matched before the `--help` arm and the client parser skipped every argument that was not `--client`, so a command that reads as documentation overwrote `~/.claude`. `--help` is now answered wherever it appears, and an unrecognised argument is an error rather than being ignored. Reported by @neusse. Known limitation, filed as #240: after KiCAD dies for any reason, the next closed-board call still cannot tell "KiCAD was never running" from "KiCAD died a second ago holding this board", and edits the file. No tool added, removed or renamed; no response shape changed. 19 toolsets, 202 tools.
Rebase-equivalent merge onto post-v0.6.1 main, including mixelpixx#229 and mixelpixx#230. The combined catalogue is pcb_components 17, 204 registered + 6 meta = 210 total; README, DEV.md, tool-directory.md and package metadata move together and doc_tool_counts verifies the arithmetic. mixelpixx#237 independently landed the layer mapping this PR introduced. Keep main's fallible try_layer_from_name boundary and aliases, discard the duplicate map, and route footprint refresh through build_footprint_item so root, pad and graphic layers are refused before an unrepresentable value reaches KiCad. A refresh-specific In99.Cu regression test pins that composition. Preserves main's closed-board move, rotate and flip tools while adding update_footprints_from_library to the same toolset and Skill catalogue. Gate: fmt; clippy --workspace --locked --all-targets -D warnings; all 21 footprint-refresh tests; workspace lib/tests excluding three update_symbols_from_library tests that fail identically on clean upstream/main@3827cdd on this host; doctests. Co-authored-by: TRAE CLI <noreply@bytedance.com>
Owner
|
Status at Round 12: your main-merge resolved the layer_from_name reconciliation cleanly — thank you for taking that on before I got to it. The branch is conflict-free against main as of v0.7.0. What remains on my side before merge: the three review nits (the module-wide |
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
Add
update_footprints_from_libraryto thepcb_componentstoolset so an agent can refresh already placed footprints after their linked KiCad library definitions change.The tool supports exact reference and library-ID filters, defaults to a non-mutating dry run, and reports changed domains before applying. It refreshes losslessly supported library-owned pads, graphics, fields, attributes, metadata, and 3D models while preserving board-owned instance state and pad nets.
Closes #231
Approach
KiCad 10's IPC API does not expose a native "Update Footprints from Library" command, so this implements the operation as a typed planner and merge:
.kicad_modcontent into IPC footprint definitions and fail closed on unsupported/lossy clauses;UpdateItemsbatch inside one KiCad undo commit.A reviewed dry run returns
plan_revision; apply requires that exact revision. Any selected conflict or stale revision prevents the batch from being sent.Compatibility and safety
dry_rundefaults totrue;dry_run=falserequiresexpected_plan_revisionfrom a current plan.build_footprint_item, so root, pad, and graphic layers usetry_layer_from_nameand an unrepresentable layer is refused before anything reaches KiCad.Current branch status
Rebased-equivalent merge commit
5f330febrings the branch onto post-v0.6.1main, including #229, #230, and #237. The PR isCLEAN/MERGEABLEat head5f330fe90e6ec513c76dc38044b679bdb8b6ee38.Validation
Local validation on this branch:
cargo fmt --all -- --checkcargo clippy --workspace --locked --all-targets -- -D warningscargo test -p konnect-core --locked pcb_footprint_update::tests(21 passed)cargo test --workspace --locked --lib --tests -- --skip update_symbols_from_library_refreshes_a_stale_embedded_copy --skip update_symbols_from_library_refuses_a_moved_pin_unless_allowed --skip update_symbols_from_library_refuses_a_removed_pincargo test --workspace --locked --docgit diff --checkThe three skipped
update_symbols_from_library_*tests fail identically on cleanupstream/main@3827cddon this host, so they are not introduced by this PR.GitHub CI for head
5f330feis green:Live/board acceptance from the original feature work:
cargo test -p konnect --test live_kicad_tools footprint_library_update_apply_then_dry_run_is_noop --locked -- --ignored --nocapture(1 passed). It created and placed a fixture, changed its library pads/graphics/metadata/model, completed dry-run -> apply -> noop, then ran DRC.Review checklist
docs/NAMING_CONVENTIONS.md; no existing public name changes require migration handling.tool-directory.md, DEV.md, README, plugin, and packaging counts are synchronized.