Skip to content

fix(schematic): update every placed component unit - #273

Open
nordic-style wants to merge 1 commit into
mixelpixx:mainfrom
nordic-style:codex/fix/multi-unit-component-mutations
Open

fix(schematic): update every placed component unit#273
nordic-style wants to merge 1 commit into
mixelpixx:mainfrom
nordic-style:codex/fix/multi-unit-component-mutations

Conversation

@nordic-style

Copy link
Copy Markdown
Contributor

Summary

  • delete every placed unit instead of leaving orphan units behind
  • translate and rotate all units by one shared delta, preserving their relative layout
  • update shared fields, reference paths, annotations, and groups across every unit in one revision-aware command
  • target move_region placements by UUID so selecting unit 2 never moves unit 1
  • replace every unit's library id atomically while preserving and validating unit numbers
  • aggregate component and pin-location reads across all placements

Refs #182

Approach

A reference designator identifies one logical component, but KiCad stores a multi-unit component as one top-level symbol block per placed unit. Every reference-based component operation now resolves the complete block/placement set. Component-wide moves use the lowest-numbered unit as the requested anchor and apply its snapped delta to the other units; rotation follows the same rule so relative orientation is preserved.

Shared properties are built as one edit set against the original document revision. Existing copies are updated everywhere, missing custom-field copies are repaired per unit, and all user text is escaped before insertion or replacement. Reference renames update both rendered properties and every netlist instances path.

Component replacement validates all preserved unit numbers against the new symbol, updates every lib_id, and writes once. Supplying a single unit for a reference with multiple placements is rejected before any write because the request is ambiguous.

This is the mutation half of #182. #272 covers analysis/export/validation/review call sites; #267 covers the additional intentional-NC and power-pin behavior in validate_component_connections.

Compatibility and safety

  • Single-unit behavior remains compatible; response objects gain additive unit counts and placement arrays.
  • move_schematic_component and rotate_schematic_component now operate on the logical component instead of silently changing only the first block.
  • get_schematic_component and pin-location tools now include every placement; the original top-level position remains the lowest-numbered unit's anchor.
  • replace_component.unit is intentionally rejected for multi-placement references; omit it to preserve every existing unit.
  • All text edits use one revision-aware command; typed move/delete paths still overwrite once after the complete in-memory mutation.
  • An ambiguous replacement regression verifies the schematic remains byte-identical on error.
  • Rollback is a single revert of commit 51c8f60.

Validation

  • 12 focused end-to-end Multi-Unit tests pass: delete, move, rotate, value/custom-field edit with escaping, reference rename, partial annotation repair, grouping, component summary, pin locations, full replacement, ambiguous replacement rollback, and unit-specific region move
  • cargo test --workspace --locked --lib --tests: all suites pass except the same three pre-existing local update_symbols_from_library_* failures caused by the installed KiCad Device:R library shadowing the test fixture; konnect-core reaches 554/557 passing tests
  • HTTP and stdio protocol suites pass
  • cargo test --workspace --locked --doc: pass
  • cargo clippy --workspace --locked --all-targets -- -D warnings: pass
  • cargo fmt --all -- --check: pass

Reference-only component mutations selected the first matching symbol block, so deleting left orphan units behind while moving, rotating, editing, annotating, grouping, and replacing tore one logical component into inconsistent placements.

Apply shared mutations to every placed unit, preserve relative placement and rotation, target region moves by UUID, aggregate component and pin-location reads, and reject ambiguous unit overrides before writing. Shared property edits now escape values and repair partially populated legacy units in one revision-aware command.

Refs mixelpixx#182
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.

1 participant