Skip to content

Handle '+' in pin/port selectors and fix misleading not-connected error#2564

Draft
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-code/plus-pin-selector-handling
Draft

Handle '+' in pin/port selectors and fix misleading not-connected error#2564
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-code/plus-pin-selector-handling

Conversation

@posthog

@posthog posthog Bot commented Jul 2, 2026

Copy link
Copy Markdown

Summary

A trace selector pointing at a pin whose label contains + (e.g. a stepper driver's PUL+, or VIN+/IN+/D+ on analog/USB parts) failed with a confusing "Could not find port" error that named the wrong component.

Two fixes in @tscircuit/core:

  • preprocessSelector now escapes a + that follows identifier characters (.PUL+.PUL\+). css-select otherwise reads + as an adjacent-sibling combinator, so .PUL+ parsed as .PUL plus a dangling combinator and never matched a port literally named PUL+. This aligns the raw css-select path with the selector cache, which already treats PUL+ as an atomic token (a leading + like .+INA already parses fine and is left untouched; - is a valid CSS identifier char and needs no escaping).
  • Trace__findConnectedPorts strips a trailing combinator when slicing the parent selector, so .U2 > .VIN+ now reports Component "U2" found ... It has [VINp, pin1, 1, GND, ...] instead of the misleading Component ".U2 > " found ... It has no ports.

Why

Reported via an inbox report: the error fired repeatedly for users wiring up common parts with + pin labels, and the message pointed at an unrelated component, making it hard to diagnose.

Scope / important caveat

pinLabels containing +/- are intentionally excluded upstream by the @tscircuit/props schema (enforced in core by filterPinLabels, which emits a source_property_ignored_warning — "Pin labels can only contain letters, numbers and underscores"). So a <chip pinLabels={{ pin1: "VIN+" }} /> port never carries the VIN+ name, and a trace to it still cannot connect — it now just produces an accurate diagnostic instead of a misleading one. Ports that legitimately carry a + name/alias (e.g. an explicit <port name="PUL+" />) now resolve through the selector engine in cache-miss paths as well.

Fully supporting +/- in pinLabels (so the common <chip pinLabels> form connects) would require relaxing the pin-label regex in @tscircuit/props — that's a separate, deliberate product decision and is out of scope for this change.

Tests

  • tests/components/base-components/preprocess-selector-plus-pin.test.tsx — unit coverage of the escaping.
  • tests/repros/repro-plus-pin-selector.test.tsx — the not-connected error now names the real component and lists its pins.

Both fail without the corresponding fix.


Created with PostHog Code from an inbox report.

preprocessSelector now escapes a "+" that follows identifier characters (e.g. ".PUL+") so css-select treats it as part of the class token instead of an adjacent-sibling combinator. Trace__findConnectedPorts strips a trailing combinator when slicing the parent selector so the error names the real component and lists its pins.

Generated-By: PostHog Code
Task-Id: 9a93b68c-7f7c-49db-9c6a-256f5325ebc4
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Jul 2, 2026 10:46pm

Request Review

The parent-selector slicing fix now reports Component ".unnamed_chip1" instead of the dangling ".unnamed_chip1 > ", so this existing inline snapshot is updated to match the corrected (accurate) message.

Generated-By: PostHog Code
Task-Id: 9a93b68c-7f7c-49db-9c6a-256f5325ebc4
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants