Handle '+' in pin/port selectors and fix misleading not-connected error#2564
Draft
posthog[bot] wants to merge 2 commits into
Draft
Handle '+' in pin/port selectors and fix misleading not-connected error#2564posthog[bot] wants to merge 2 commits into
posthog[bot] wants to merge 2 commits into
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A trace selector pointing at a pin whose label contains
+(e.g. a stepper driver'sPUL+, orVIN+/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:preprocessSelectornow escapes a+that follows identifier characters (.PUL+→.PUL\+).css-selectotherwise reads+as an adjacent-sibling combinator, so.PUL+parsed as.PULplus a dangling combinator and never matched a port literally namedPUL+. This aligns the rawcss-selectpath with the selector cache, which already treatsPUL+as an atomic token (a leading+like.+INAalready parses fine and is left untouched;-is a valid CSS identifier char and needs no escaping).Trace__findConnectedPortsstrips a trailing combinator when slicing the parent selector, so.U2 > .VIN+now reportsComponent "U2" found ... It has [VINp, pin1, 1, GND, ...]instead of the misleadingComponent ".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
pinLabelscontaining+/-are intentionally excluded upstream by the@tscircuit/propsschema (enforced in core byfilterPinLabels, which emits asource_property_ignored_warning— "Pin labels can only contain letters, numbers and underscores"). So a<chip pinLabels={{ pin1: "VIN+" }} />port never carries theVIN+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
+/-inpinLabels(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.