Skip to content

fix: missing board labels (A0, SCL, DIGITAL-PWM~) after subcircuit inflation from imported KiCad PCB#2452

Open
rushabhcodes wants to merge 3 commits into
tscircuit:mainfrom
rushabhcodes:fix/inflate-standalone-pcb-text-empty-component-id
Open

fix: missing board labels (A0, SCL, DIGITAL-PWM~) after subcircuit inflation from imported KiCad PCB#2452
rushabhcodes wants to merge 3 commits into
tscircuit:mainfrom
rushabhcodes:fix/inflate-standalone-pcb-text-empty-component-id

Conversation

@rushabhcodes

Copy link
Copy Markdown
Contributor

Problem

When importing a KiCad PCB (e.g. Arduino Uno) as a <subcircuit circuitJson={...} />, board labels like A0, A1, SCL, SDA, and DIGITAL - PWM~ were silently dropped from the output. The silkscreen and copper text elements simply never appeared in the inflated circuit.

Root Cause (two bugs in inflateStandalonePcbPrimitives.ts)

Bug 1 — Empty-string pcb_component_id was not recognized as standalone:
The filter that identifies standalone primitives (board-level elements not attached to any component) only accepted null or undefined as "no component":

// before — misses elements where pcb_component_id === ""
elm.pcb_component_id === null || elm.pcb_component_id === undefined

The KiCad converter emits pcb_component_id: "" for board-level labels, so every one of those elements was filtered out. Fixed by treating any falsy value as "no component":

// after
!elm.pcb_component_id

Bug 2 — pcb_copper_text was absent from standalonePrimitiveTypes:
pcb_copper_text was never included in the list of types eligible for standalone inflation, so copper-layer board labels (e.g. "UNO TH RevC") were unconditionally skipped regardless of their pcb_component_id.

Fix

  • Added "pcb_copper_text" to standalonePrimitiveTypes
  • Changed the component-id check from strict null/undefined to a falsy guard

Reproduction & Tests

  • New test repro131-arduino-uno-labels-missing inflates the full Arduino Uno circuit JSON and asserts that A0, A1, SCL, SDA, DIGITAL - PWM~, and the copper-text label are all present in the inflated output
  • Updated snapshots for repro116 and subcircuit-circuit-json08 which now correctly render the previously-missing labels

…flation from imported KiCad PCB

Two bugs in inflateStandalonePcbPrimitives prevented standalone pcb_silkscreen_text
and pcb_copper_text elements from being inflated when their pcb_component_id was an
empty string (as emitted by the KiCad converter) rather than null/undefined.
Also adds pcb_copper_text to the standalonePrimitiveTypes list, which was missing entirely.

Reproduces and fixes with repro131 test against the Arduino Uno KiCad source.

Co-Authored-By: Rushabh Patil <rushabhpatil.dev@gmail.com>
@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 12:22pm

Request Review

Snapshots now correctly render A0/A1/SCL/SDA/DIGITAL-PWM~ labels after the
pcb_silkscreen_text/pcb_copper_text standalone inflation fix.

Co-Authored-By: Rushabh Patil <rushabhpatil.dev@gmail.com>

@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 approval from rishabh as well before merging

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.

Can you add an actual kicad snapshot of this kicad_pcb file? The text is just cluttering.

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