Skip to content

Fix jlcpcb CAD fallback for library footprints#2305

Open
techmannih wants to merge 5 commits into
tscircuit:mainfrom
techmannih:codex/fix-jlcpcb-cad-fallback
Open

Fix jlcpcb CAD fallback for library footprints#2305
techmannih wants to merge 5 commits into
tscircuit:mainfrom
techmannih:codex/fix-jlcpcb-cad-fallback

Conversation

@techmannih
Copy link
Copy Markdown
Member

What changed

This updates CAD fallback generation for library-style footprints so cad_component.footprinter_string is only emitted for direct footprinter strings such as 0402 or soic8.

For library references like jlcpcb:C51950748, KiCad library refs, URLs, and static asset paths, the fallback now emits a bounding-box CAD component instead of forwarding the library reference as a footprinter string.

Why this changed

The 3D viewer was trying to parse jlcpcb:... as a raw footprinter function when no CAD model was available. That produced runtime errors like:

Invalid footprint function, got "jlcpcb"

The underlying footprint could still load for PCB rendering, but the CAD fallback path was sending an invalid string into the 3D engine.

Impact

This fixes 3D rendering for library footprints that do not provide a CAD model by falling back cleanly to a bounding box instead of surfacing a parser error.

Root cause

NormalComponent.doInitialCadModelRender() treated any string footprint as a valid footprinter_string fallback. Library refs such as jlcpcb:... are valid footprint lookup keys, but they are not valid raw footprinter expressions.

Validation

  • bun test tests/footprint/footprint-library-map-jlcpcb-cadmodel.test.tsx
  • bun test tests/components/normal-components/cad-component-bounding-box.test.tsx

Notes

Repo-wide build/type generation still has unrelated pre-existing DTS failures in lib/components/primitive-components/PcbTrace.ts.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

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

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment May 17, 2026 7:47pm

Request Review

@techmannih techmannih changed the title [codex] Fix jlcpcb CAD fallback for library footprints Fix jlcpcb CAD fallback for library footprints May 16, 2026
@techmannih techmannih marked this pull request as ready for review May 16, 2026 20:25
Copy link
Copy Markdown
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

bad naming, the fix is valid but there are issues:

  1. canUseFootprintStringFallback is unclear. There is no fallback. Better naming is needed e.g. footprintIsFootprinterString is more clear
  2. Ternary usage is confusing
  3. !! is never allowed

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.

2 participants