Skip to content

Normalize through_obstacle autorouter segments before persisting pcb_trace.route#2316

Merged
rushabhcodes merged 10 commits into
tscircuit:mainfrom
rushabhcodes:fix/normalize-through-obstacle-public-route
May 21, 2026
Merged

Normalize through_obstacle autorouter segments before persisting pcb_trace.route#2316
rushabhcodes merged 10 commits into
tscircuit:mainfrom
rushabhcodes:fix/normalize-through-obstacle-public-route

Conversation

@rushabhcodes
Copy link
Copy Markdown
Contributor

Summary

This PR fixes a core autorouting bug where local autorouter output could write through_obstacle segments directly into
pcb_trace.route, even though the public route format should expose those segments as through_pad.

What changed

  • Normalize through_obstacle route points to through_pad before inserting pcb_trace records from autorouter output
  • Apply the same normalization in the reroute/jumper trace-splitting flow so downstream route handling sees the public route shape
    consistently
  • Add a regression test that reproduces the bug with a custom autorouter returning a through_obstacle segment and verifies the
    persisted route no longer contains it

Why this matters

This is a tscircuit/core behavior fix, not just a test update. It improves the public route data model exposed by autorouting and
prevents internal autorouter-specific segment types from leaking into persisted PCB trace data.

Copilot AI review requested due to automatic review settings May 21, 2026 17:29
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 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 21, 2026 10:28pm

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an autorouting persistence bug by ensuring internal autorouter-only through_obstacle segments are converted into the public through_pad route shape before pcb_trace.route is stored, keeping downstream route handling consistent with the public data model.

Changes:

  • Normalize through_obstacle route points to through_pad before inserting autorouter-produced traces into db.pcb_trace.
  • Apply the same normalization in the reroute/jumper trace-splitting path.
  • Add a regression test to verify persisted routes no longer contain through_obstacle.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/features/autorouting-through-obstacle-public-route.test.tsx Adds regression coverage to ensure persisted pcb_trace.route does not contain through_obstacle and includes through_pad.
lib/components/primitive-components/Group/Group.ts Normalizes autorouter output routes to the public route format before persistence and before jumper splitting.
Comments suppressed due to low confidence (1)

lib/components/primitive-components/Group/Group.ts:1265

  • This normalization block duplicates the same through_obstaclethrough_pad mapping introduced earlier in _updatePcbTraceRenderFromSimpleRouteJson. It would be more maintainable to centralize this conversion in a single utility (and avoid any in the mapper) so both flows always produce identical public routes.
      const publicRoute = pcb_trace.route.map((point: any) => {
        if (point.route_type !== "through_obstacle") return point
        return {
          route_type: "through_pad",
          start: point.start,
          end: point.end,
          start_layer: point.from_layer,
          end_layer: point.to_layer,
          width: point.width,
        }
      })

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/components/primitive-components/Group/Group.ts Outdated
Comment thread lib/components/primitive-components/Group/Group.ts Outdated
Comment thread lib/components/primitive-components/Group/Group.ts Outdated
Comment thread lib/components/primitive-components/Group/Group.ts Outdated
Comment thread tests/features/autorouting-through-obstacle-public-route.test.tsx Outdated
rushabhcodes and others added 6 commits May 22, 2026 03:44
Co-authored-by: Severin Ibarluzea <seve700@gmail.com>
Co-authored-by: Severin Ibarluzea <seve700@gmail.com>
Co-authored-by: Severin Ibarluzea <seve700@gmail.com>
Co-authored-by: Severin Ibarluzea <seve700@gmail.com>
@rushabhcodes rushabhcodes force-pushed the fix/normalize-through-obstacle-public-route branch from 7ecb4c0 to 34bc696 Compare May 21, 2026 22:14
@rushabhcodes rushabhcodes merged commit b353829 into tscircuit:main May 21, 2026
11 checks passed
@rushabhcodes rushabhcodes deleted the fix/normalize-through-obstacle-public-route branch May 21, 2026 22:39
@tscircuitbot
Copy link
Copy Markdown
Contributor


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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants