Skip to content

Support implicit single-pin component selectors for traces (localized fallback)#2010

Merged
seveibar merged 1 commit intomainfrom
codex/refactor-single-pin-component-connection
Mar 4, 2026
Merged

Support implicit single-pin component selectors for traces (localized fallback)#2010
seveibar merged 1 commit intomainfrom
codex/refactor-single-pin-component-connection

Conversation

@seveibar
Copy link
Contributor

@seveibar seveibar commented Mar 4, 2026

Motivation

  • Users should be able to refer to single-pin components by name (e.g. TP1) when connecting traces without changing global selector semantics.
  • Prior attempt modified selectOne/caching broadly and was fragile; a minimal, localized approach is safer.

Description

  • Add a localized fallback in Trace__findConnectedPorts that, when a trace endpoint selector fails to resolve as a port and does not explicitly contain a port token, resolves the selector as a component and returns its sole Port if the component has exactly one port.
  • The fallback is implemented as resolveImplicitSinglePort(selector) and is only used when selectOne(selector, { type: 'port' }) returns null.
  • Add tests to cover the intended behavior: single-pin-component-implies-pin1.test.tsx (accept single-pin implicit selector) and multi-pin-component-no-implied-pin1-trace-error.test.tsx (ensure multi-pin components do not imply pin1).
  • Add updated PCB/schematic snapshot artifacts for the single-pin test.

Testing

  • Ran BUN_UPDATE_SNAPSHOTS=1 bun test tests/components/base-components/single-pin-component-implies-pin1.test.tsx and the test passed with snapshots created.
  • Ran bun test tests/components/base-components/multi-pin-component-no-implied-pin1-trace-error.test.tsx tests/components/base-components/trace-port-selector-errors.test.tsx tests/components/base-components/shorthand-selector.test.tsx and all tests passed.
  • Ran bunx tsc --noEmit for type-checking and bun run format; both completed successfully.

Codex Task

@vercel
Copy link

vercel bot commented Mar 4, 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 Mar 4, 2026 11:42pm

Request Review

@seveibar seveibar requested a review from AnasSarkiz March 4, 2026 23:45
@seveibar seveibar merged commit d466bfd into main Mar 4, 2026
11 checks passed
@tscircuitbot
Copy link
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

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.

2 participants