Skip to content

fix: support updated KiCad imports and preserve imported trace topology during inflation#2450

Open
rushabhcodes wants to merge 12 commits into
tscircuit:mainfrom
rushabhcodes:update-kicad-to-circuit-json-and-kicadts
Open

fix: support updated KiCad imports and preserve imported trace topology during inflation#2450
rushabhcodes wants to merge 12 commits into
tscircuit:mainfrom
rushabhcodes:update-kicad-to-circuit-json-and-kicadts

Conversation

@rushabhcodes

@rushabhcodes rushabhcodes commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This branch updates the KiCad import dependencies in core and adapts subcircuit inflation to the new circuit JSON shape they produce.

What changed

  • bumped kicad-to-circuit-json from ^0.0.60 to ^0.0.96
  • bumped kicadts from ^0.0.35 to ^0.0.45
  • added inflators for simple_led and simple_fiducial
  • wired those new source component types into inflate-circuit-json.ts
  • fixed imported trace inflation to handle 1 source_trace -> many pcb_trace instead of assuming a 1:1 mapping
  • updated affected repro expectations and PCB snapshots

Why this branch was needed

The dependency update changed the imported KiCad circuit JSON in two important ways:

  1. Imported boards can now contain simple_led and simple_fiducial source components, which previously crashed inflation because core had no inflators for those ftype values.
  2. Imported routed copper is no longer guaranteed to be represented as one pcb_trace per source_trace. On the Arduino Uno repro, the new import output contains 109 source_trace records but 188 pcb_trace records. The old inflation logic used getWhere({ source_trace_id }), so it kept only one routed segment for each source_trace_id and silently dropped the rest.

Fix details

LED and fiducial inflation

  • inflateSourceLed rehydrates imported LEDs with PCB placement and footprint data.
  • inflateSourceFiducial rehydrates imported fiducials with placement and pad diameter derived from the imported SMT pad.

Trace inflation

inflateSourceTrace now inflates one Trace per matching imported pcb_trace, while still preserving the straight-line fallback when an injected trace has no routed PCB geometry.

That restores the missing imported traces instead of collapsing them during subcircuit inflation.

Tests and snapshots

Updated coverage and snapshots for the affected repros:

  • repro116-arduino-uno.test.tsx
  • repro116-arduino-uno-reroute.test.tsx
  • repro116-arduino-uno-reroute-center.test.tsx
  • repro116-arduino-uno-reroute-lower-mid.test.tsx
  • repro117-schematic-disabled-inflation.test.tsx

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Jun 16, 2026 5:39pm

Request Review

@MustafaMulla29 MustafaMulla29 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, lets fix the failing tests first.

Inflating circuit JSON that contained LED or fiducial components threw
"No inflator implemented for source component ftype" because the switch
in inflate-circuit-json.ts was missing those cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rushabhcodes rushabhcodes changed the title chore(deps): update KiCad dependencies fix: prevent crash when importing circuit JSON boards containing LED or fiducial components and update KiCad dependencies Jun 16, 2026
@rushabhcodes rushabhcodes requested review from a team, MustafaMulla29 and seveibar June 16, 2026 07:25

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the traces are missing in this!
Screenshot 2026-06-16 at 1 33 44 PM

@MustafaMulla29 MustafaMulla29 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a review from rishabh as well!

@rushabhcodes rushabhcodes requested a review from imrishabh18 June 16, 2026 08:23

@imrishabh18 imrishabh18 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the traces missing for those circuits?

@rushabhcodes rushabhcodes changed the title fix: prevent crash when importing circuit JSON boards containing LED or fiducial components and update KiCad dependencies fix: support updated KiCad imports and preserve imported trace topology during inflation Jun 16, 2026
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.

3 participants