Skip to content

fix: merge nearby same-net trace segments#418

Open
MolhamHamwi wants to merge 2 commits into
tscircuit:mainfrom
MolhamHamwi:bounty-34-merge-close-same-net-segments
Open

fix: merge nearby same-net trace segments#418
MolhamHamwi wants to merge 2 commits into
tscircuit:mainfrom
MolhamHamwi:bounty-34-merge-close-same-net-segments

Conversation

@MolhamHamwi
Copy link
Copy Markdown

Summary

  • add a cleanup phase that aligns close overlapping same-net trace segments onto a shared X/Y coordinate
  • keeps endpoint/pin segments fixed and only adjusts interior trace segments
  • skips different-net segments so unrelated routes are not collapsed together

Closes #34
Related to #29

Test Plan

  • bun test tests/solvers/TraceCleanupSolver/mergeNearbySameNetSegments.test.ts tests/solvers/TraceCleanupSolver/TraceCleanupSolver.test.ts
  • bunx tsc --noEmit
  • bun run build

Copilot AI review requested due to automatic review settings May 23, 2026 07:55
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

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

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment May 23, 2026 8:19am

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

Adds a new TraceCleanupSolver pipeline phase that aligns nearby overlapping same-net trace segments onto a shared X/Y coordinate to reduce “almost-parallel” clutter (issue #34 / related #29).

Changes:

  • Introduces mergeNearbySameNetSegments to detect overlapping horizontal/vertical interior segments on the same net and align them to a shared coordinate.
  • Integrates this cleanup phase into TraceCleanupSolver after the L-shape balancing step.
  • Adds unit tests covering same-net alignment and different-net non-alignment.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/solvers/TraceCleanupSolver/mergeNearbySameNetSegments.ts Implements the new same-net segment alignment pass.
lib/solvers/TraceCleanupSolver/TraceCleanupSolver.ts Wires the new cleanup phase into the solver pipeline.
tests/solvers/TraceCleanupSolver/mergeNearbySameNetSegments.test.ts Adds unit tests for the new merge/alignment behavior.

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

Comment on lines 28 to 32
type PipelineStep =
| "minimizing_turns"
| "balancing_l_shapes"
| "merging_close_same_net_segments"
| "untangling_traces"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in dbcd4a3: updated the pipeline JSDoc with the new close same-net merge phase.

Comment on lines +142 to +146
changed = true
break
}

if (changed) break
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in dbcd4a3: replaced the two-pass single-pair merge with component-based grouping so all eligible close same-net segments are aligned, and added a 3-trace regression test.

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.

Merge same-net trace lines that are close together (make at the same Y or same X)

2 participants