Skip to content

Conversation

@seveibar
Copy link
Contributor

Summary

  • update circuit-json to the latest version
  • render anchor offset indicators when components are positioned relative to a PCB board and honor display offset overrides for labels
  • add a PCB test covering board-relative offsets and display overrides

Testing

  • bun test tests/pcb/pcb-component-relative-to-board.test.ts
  • bunx tsc --noEmit
  • bun run format

Codex Task

@vercel
Copy link

vercel bot commented Dec 11, 2025

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

Project Deployment Preview Comments Updated (UTC)
circuit-to-svg Ready Ready Preview Comment Dec 11, 2025 4:59am

@tscircuitbot
Copy link

Size Report

Bundle Size

  • Base branch size: 1.2M
  • PR branch size: 1.2M
  • Difference: 0

Install Size

  • Base branch size: 10.37mb
  • PR branch size: 10.46mb
  • Difference: +.09

Full Howfat Output (PR Branch)

circuit-to-svg@0.0.286 (13 deps, 10.46mb, 1094 files, ©undefined)
╭──────────────────────────────┬──────────────┬──────────┬───────┬───────────┬─────────┬───────────╮
│ Name                         │ Dependencies │     Size │ Files │ Native    │ License │ Deprec    │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ @types/node@22.19.2          │            1 │   2.39mb │   124 │           │ MIT     │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ bun-types@1.3.4              │            2 │   4.72mb │   471 │           │ MIT     │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ calculate-elbow@0.0.12       │              │  67.05kb │    54 │           │         │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ svgson@5.3.1                 │            7 │ 123.63kb │    41 │           │ MIT     │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ transformation-matrix@2.16.1 │              │ 430.45kb │    56 │           │ MIT     │           │
╰──────────────────────────────┴──────────────┴──────────┴───────┴───────────┴─────────┴───────────╯

@tscircuitbot
Copy link

Size Report

Bundle Size

  • Base branch size: 1.2M
  • PR branch size: 1.2M
  • Difference: 0

Install Size

  • Base branch size: 10.37mb
  • PR branch size: 10.47mb
  • Difference: +.10

Full Howfat Output (PR Branch)

circuit-to-svg@0.0.286 (13 deps, 10.47mb, 1097 files, ©undefined)
╭──────────────────────────────┬──────────────┬──────────┬───────┬───────────┬─────────┬───────────╮
│ Name                         │ Dependencies │     Size │ Files │ Native    │ License │ Deprec    │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ @types/node@22.19.2          │            1 │   2.39mb │   124 │           │ MIT     │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ bun-types@1.3.4              │            2 │   4.72mb │   471 │           │ MIT     │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ calculate-elbow@0.0.12       │              │  67.05kb │    54 │           │         │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ svgson@5.3.1                 │            7 │ 123.63kb │    41 │           │ MIT     │           │
├──────────────────────────────┼──────────────┼──────────┼───────┼───────────┼─────────┼───────────┤
│ transformation-matrix@2.16.1 │              │ 430.45kb │    56 │           │ MIT     │           │
╰──────────────────────────────┴──────────────┴──────────┴───────┴───────────┴─────────┴───────────╯

Comment on lines +385 to +391
const baseValue = displayOffset ?? offsetMm.toFixed(2)
const valueStr =
typeof baseValue === "number" ? baseValue.toString() : baseValue
const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm")
const unitSuffix = hasUnit ? "" : "mm"

return `${axis}: ${valueStr}${unitSuffix}`
Copy link
Contributor

Choose a reason for hiding this comment

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

The function doesn't handle empty string displayOffset properly. If displayOffset is an empty string "", the nullish coalescing operator (??) will use it instead of falling back to the calculated value, resulting in labels like "X: mm" or "Y: mm".

Fix:

function formatOffsetLabel(
  axis: "X" | "Y",
  offsetMm: number,
  displayOffset?: number | string,
): string {
  const baseValue = displayOffset ?? offsetMm.toFixed(2)
  const valueStr =
    typeof baseValue === "number" ? baseValue.toString() : baseValue
  
  // Handle empty strings
  if (typeof valueStr === "string" && valueStr.trim() === "") {
    return `${axis}: ${offsetMm.toFixed(2)}mm`
  }
  
  const hasUnit = valueStr.trim().endsWith("mm")
  const unitSuffix = hasUnit ? "" : "mm"

  return `${axis}: ${valueStr}${unitSuffix}`
}
Suggested change
const baseValue = displayOffset ?? offsetMm.toFixed(2)
const valueStr =
typeof baseValue === "number" ? baseValue.toString() : baseValue
const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm")
const unitSuffix = hasUnit ? "" : "mm"
return `${axis}: ${valueStr}${unitSuffix}`
const baseValue = displayOffset ?? offsetMm.toFixed(2)
const valueStr =
typeof baseValue === "number" ? baseValue.toString() : baseValue
// Handle empty strings
if (typeof valueStr === "string" && valueStr.trim() === "") {
return `${axis}: ${offsetMm.toFixed(2)}mm`
}
const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm")
const unitSuffix = hasUnit ? "" : "mm"
return `${axis}: ${valueStr}${unitSuffix}`

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@seveibar seveibar merged commit 3206278 into main Dec 11, 2025
8 checks passed
@seveibar seveibar deleted the codex/update-circuit-json-anchor-display-logic branch December 11, 2025 05:05
@tscircuitbot
Copy link


Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


1 similar comment
@tscircuitbot
Copy link


Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants