Skip to content

fix(cli): a component's name in another case never resolves through a module that shares its spelling - #8350

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c01-cli-component-lookup
Nov 4, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c01-cli-component-lookup

Conversation

@vjeux

@vjeux vjeux commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Anyone, or any agent, asking the CLI for a component by name in another case. astryx component tokenizer opens CodeBlock's doc today, and astryx component slider --source prints a motion table: a confident, wrong file instead of the component the name spells.

Problem and solution fit

  1. Why it occurs: a name with no doc of its own falls back to any source file of that spelling anywhere in src/, then to the nearest doc above that file. A component's name in another case can therefore resolve through a module that only shares the spelling: tokenizer through CodeBlock/tokenizer.ts, and slider, switch and progressBar through the motion/uikit/ tables.
  2. Why it harms: the answer is a confident, wrong doc or source file. Agents act on it.
  3. The fix: a component's or hook's exact name in another case is that component's. When a file named for it anywhere in src/ exports the exact name (Tokenizer/Tokenizer.tsx exports Tokenizer, TabList/Tab.tsx exports Tab), no module that only shares the spelling stands for it. The doc lookup then goes to the component matcher, as for any case spelling (tokenizer opens Tokenizer, badge opens Badge, button stays unknown with Button first). --source has no case matching: --source button and --source badge are already ERR_NO_SOURCE on main, so a case spelling's --source now answers the same way.

Expected behavior and authority

spec:AST-083 FR7: "a name that resolves keeps resolving to the same entry". The spec owner's ruling for this defect: when a file that exports the exact name exists it wins, so a collision like the motion table cannot open the wrong file, and every other name that resolves keeps resolving to the same entry. This PR adds that as one FR7 sentence: "A component's exact name in another case is that component's: a module that only shares its spelling never resolves for it." docs/specs/AST-083-result-order/spec.md is owner-gated, so the change needs an engineering owner's /approve-spec <head sha>.

Smallest restoration

  • findComponentSource (foundation/discovery/component-discovery.mjs) returns no module for a component's name in another case. Its doc fallback and --source both read it.
  • Unchanged: exact names, hooks, sub-components, family members, module names (StepStatus, defineTheme), typo suggestions and the component list.

Evidence

On real core, compared with main 58c5b8a over every catalog name (174), every case spelling (469: lowercase, uppercase and camelCase) and every module name (477):

  • Doc lookups that change: 1. tokenizer opened CodeBlock/CodeBlock.doc.mjs and now opens Tokenizer/Tokenizer.doc.mjs.
  • --source lookups that change: 4. slider, switch and progressBar printed motion/uikit/<name>.ts, and tokenizer printed CodeBlock/tokenizer.ts. All four are now ERR_NO_SOURCE.
  • Everything else resolves as on main: the 174 exact names, the other 384 case spellings that resolve and the 370 module names that resolve.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Recorded resolutions (api/component/resolution-compat.test.mjs): every name that resolves through a fallback on main (385 case spellings and 309 module names whose doc is another file's) keeps opening the entry, doc and --source file recorded in __fixtures__/resolutions/. The records differ from main only on tokenizer (now Tokenizer) and progressBar's --source. A recorded name moves when Core renames or moves its module; vitest -u is the expected update path.
    • Timing: each case spelling goes through the component matcher, which reads the catalog again for each name (about 70 ms), so the names are split into 14 range files, one test each. With 8 busy loops sharing the test's 4 CPUs at equal niceness, each case range takes 10.8–14.0 s and the module range 6.9 s, under the default 30 s timeout.
  • The collision, in a fixture: a motion table motion/uikit/button.ts below a hook's doc, and CodeBlock/tokenizer.ts beside CodeBlock's doc. button and tokenizer resolve through neither, while a module name in the same folder still resolves through the nearest doc. A lowercase folder whose file does not export the folder's name is not a component.
  • A sub-component, in a fixture: motion/uikit/tab.ts below a hook's doc never answers tab for Tab in TabList/, and Tab still finds TabList/Tab.tsx. This case fails with a guard that only reads top-level folders.
  • On real core: component('tokenizer') opens Tokenizer, and --source for slider, switch, progressBar and tokenizer is ERR_NO_SOURCE.
  • Red first: with main's lookup, 7 of these fail (the fixture case, tokenizer, the four --source cases and the recorded resolutions).
  • Discovery cost: the case index is built once per operation (oncePerListing in the listing cache), and component() now runs inside one listing operation, as search and build do. So astryx component (a batch too) and the catalog's discovery walk src/ once, not once per name or component. The CLI's list views and the XLE registry read inside one listing operation too, and a lookup that finds no file builds no index. Tests count the builds: one for a three-name component() batch (eight before), at most two for astryx component --list (74 before), one for the registry (160 before), and none for a miss. Per discoverOwnedComponents on Core, the case walk visits 1,887 entries, and warm CPU is 138–155 ms against main's 133–137 ms. A unit test pins oncePerListing.
  • Local gates at this head: the CLI discovery, component, search and command suites pass 1,298 of 1,299. The one failure, hook-discovery's barrel case, imports a built Core this worktree lacks and fails the same way on main. Strict ESLint, Prettier on the changed files, check:knowledge and review:pre pass.

Writing rubric results

spec:AST-083: FR7 gains one present-tense sentence; its verification row already names the component command tests, which hold the new test. R1–R6 pass: no history, research, references, rejected alternatives or open questions.

@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 7:53pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 8:10 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 25, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approval waits on an engineering-owner decision: this change stops astryx component resolving 245 names that resolve today (136 lowercase spellings such as badge and textinput, and 109 module names such as StepStatus and defineTheme), while spec:AST-083 FR7 says "a name that resolves keeps resolving to the same entry" and no current record makes component lookup case-sensitive or export-gated. Any engineering owner, you included, can settle it by stating on this pull request whether these non-exact spellings may stop resolving in a patch [fix], or whether FR7 must be amended first, in which case the change ships as [breaking] in a minor. If it stays a [fix], please make the changeset describe what this release changes (for example textinput and defineTheme) rather than a button.ts table Core does not have yet. The code itself holds up: exact names, hooks, exporting sub-components, family members and every Core doc resolve as before.

[Automated review]

Comment thread packages/cli/api/component/_adapter.mjs Outdated
topTied.length === 1 &&
topTied[0].name !== dirName &&
topTied[0].name.toLowerCase() === dirName.toLowerCase();
if (!caseOnly && topScore >= 90 && topTied.length === 1 && gap >= 20) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This guard stops 136 lowercase spellings that open their component today (badge, textinput, dropdownmenu, ...) from resolving. spec:AST-083 FR7 says "a name that resolves keeps resolving to the same entry", so this needs an engineering owner's call before it lands.

Comment thread .changeset/cli-component-name-case.md Outdated
'@astryxdesign/cli': patch
---

[fix] `astryx component` matches component and hook names case for case, and only in the file that exports the name. A lowercased name such as `list` or `badge` is now unknown, with the component it matches by case suggested, instead of opening List's or Badge's doc. A module that only shares a name's spelling, such as a lowercase `button.ts` table elsewhere in Core, no longer opens the nearest doc either, and `--source` no longer reads it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Core has no lowercase button.ts table in this release, so the example describes a case users never met. If this stays a [fix], consider naming the released effect instead: lowercase spellings such as textinput and module names such as defineTheme stop resolving.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 0417833

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 3.33 MB packed (+9.8 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: core 50 rows; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@vjeux
vjeux marked this pull request as draft October 29, 2026 22:35
@vjeux
vjeux force-pushed the uikit/c01-cli-component-lookup branch from 9b36cb8 to d1adb5c Compare October 30, 2026 22:11

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approval waits on an engineering-owner decision: this change stops astryx component resolving names that resolve today (386 case spellings such as badge, BADGE and textInput, and 131 module names such as StepStatus and defineTheme), while spec:AST-083 FR7 says "a name that resolves keeps resolving to the same entry" and no current record makes component lookup case-sensitive or export-gated. Any engineering owner, you included, can record that decision on this pull request: comment /approve-spec followed by its full head SHA if these spellings may stop resolving in a patch [fix], or say that FR7 must be amended first, in which case the change ships as [breaking] in a minor. The code itself holds up: exact names, hooks, exporting sub-components, family members and every Core doc resolve as before, and each failing case spelling suggests its component first. If it stays a [fix], please have the changeset name what this release changes (for example BADGE, textInput, defineTheme, and url now opening Link's doc) rather than a button.ts table Core does not have yet.

[Automated review]

@vjeux

vjeux commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@josephfarina, a question on spec:AST-083 FR7, which you own: this change stops 265 names that resolve today from resolving (136 lowercase spellings of components, such as badge and textinput, and 129 module names, such as defineTheme and StepStatus), and FR7 says "a name that resolves keeps resolving to the same entry". Should FR7 be amended so that only exact component and hook names resolve (a), or should these names keep resolving, in which case this change is dropped (b)? Since it's breaking, it won't ship in a patch either way: with (a) it lands as [breaking] in the next minor.

@vjeux
vjeux force-pushed the uikit/c01-cli-component-lookup branch from d1adb5c to b5fc408 Compare November 3, 2026 16:05
@vjeux vjeux changed the title fix(cli): component lookup opens only a file that exports that exact name fix(cli): a component's name in another case never resolves through a module that shares its spelling Nov 3, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec b5fc408

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the case-spelling guard is narrower than the FR7 sentence it ships with.

  • The FR7 sentence approved at this head and the title say a module that only shares a component's spelling never resolves for it, but caseSpelledComponentSource recognises only components with their own top-level src/ folder, so a later module such as motion/uikit/tab.ts would still answer astryx component tab and --source tab for Tab (in TabList/) with no test failing; match a case spelling against the catalog's component names rather than top-level folders and add a sub-component case to the fixture test, or narrow the sentence and title to components with their own folder.

The rest holds up: across every catalog name in four spellings and every module stem in Core, only tokenizer and the three motion-table --source answers change, exactly as described, and the new tests fail on main and pass here. Two optional tidy-ups are inline: the changeset's motion-table wording, which 0.7.6 users never met, and a stale reason in the ownFileNames comment.

[Automated review]

* @param {string} name
* @returns {string | null}
*/
function caseSpelledComponentSource(srcDir, name) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This recognises a component only by a top-level src/ folder of its name. The FR7 sentence approved here covers every component, so a sub-component such as Tab (in TabList/) is not protected: with a module motion/uikit/tab.ts, astryx component tab and --source tab would resolve through it, and tab is not in the recorded resolutions. Matching a case spelling against the catalog's names (discoverComponents) instead of top-level folders, and adding a tab-style case to the fixture test, would close it; otherwise narrow the FR7 sentence and the title to components with their own folder.


/**
* The file names a component's own source can have. The prefixed forms
* (`XDSButton.tsx`) come first, since that is the current on-disk convention,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional (comment style): Core's src/ holds no XDS*.tsx file, so the prefixed form is no longer the on-disk convention. Suggested: "The XDS forms come first, so an older prefixed file wins over a bare one. .tsx comes before .ts, so a component wins over a same-named helper. .ts covers hooks and functions."

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: one performance fix before this lands.

  • component() never opens a listing operation, so the new case index (caseStemIndex, built through oncePerListing) is rebuilt on every findComponentSource call and a 60-component astryx component batch goes from about 370 ms to about 1,000 ms; wrapping component()'s read in withListingCache, as search and build do, brings it back to one walk, and a test that counts one index build would keep it there.

The rest holds up: the FR7 sentence is owner-approved for this head, only tokenizer and the three motion-table --source answers change across every catalog name and Core module stem checked, the sub-component gap from the last round is closed, and the new tests fail on main and pass here.

[Automated review]

* @returns {Map<string, Array<{stem: string, file: string}>>}
*/
function caseStemIndex(srcDir) {
return oncePerListing(`case-stems\0${srcDir}`, () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

component() runs outside withListingCache, so oncePerListing recomputes this index on every findComponentSource call: two or three walks of src/ per name. A 60-name component() batch goes from about 370 ms to about 1,000 ms (189 index builds). Wrapping component()'s read in withListingCache, as search and build do, gives one build per call (273 ms for the same batch).

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: one wording fix in the changeset before this lands.

  • The changeset ends with "Every other name resolves as before", but against 0.7.7, the latest stable release, astryx component slider --source, switch --source and progressBar --source also change from printing the motion/uikit/ tables to ERR_NO_SOURCE, so please name those three beside tokenizer.

The rest holds up: the FR7 sentence is owner-approved for this head, only these four lookups change across every catalog name and Core module spelling checked, and component() now builds the case index once per call, which fixes the earlier slowdown.

[Automated review]

'@astryxdesign/cli': patch
---

[fix] `astryx component` takes a component's exact name in another case as that component's, never a module's that only shares the spelling. `tokenizer` opens Tokenizer's doc instead of CodeBlock's, which it reached through `CodeBlock/tokenizer.ts`, and `--source tokenizer` no longer prints that module. Every other name resolves as before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Against 0.7.7, the latest stable release, --source slider, --source switch and --source progressBar print motion/uikit/<name>.ts; on this head they answer ERR_NO_SOURCE, so "Every other name resolves as before" is not true for 0.7.7 users. Suggested: "--source with tokenizer, slider, switch or progressBar no longer prints CodeBlock/tokenizer.ts or the motion tables in motion/uikit/, and answers ERR_NO_SOURCE, as --source badge does."

cixzhang added a commit that referenced this pull request Nov 3, 2026
Under a coarse primary pointer, Button (and IconButton and ToggleButton)
paints its touch press on its own ::before layer, present only while a
press is on or fading, with isolation only then. ClickableCard,
SelectableCard and Thumbnail fade their ::after. Each release is an
opacity animation, which engines run on the compositor, so it keeps
fading while the page's script runs. Any other pointer is unchanged.

Rebased onto main and #9765 (which supersedes #8117), on Specs'
direction: the layers play the strength's own press clock and curve
(main's tempo clock) for now, and a pen follows the touch presentation.
Button FR15's release length waits on an owner decision. So this drops
#8118's UIButton table, its mouse and key input marker, its #8350 CLI
files and #8338's reduced-motion arms. The press layer styles live in
the press attribute's owner module.

Co-authored-by: Cindy Zhang <[email protected]>

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: one performance fix before this lands.

  • Outside a listing operation oncePerListing rebuilds the new case index on every findComponentSource call, and the astryx component --list text views resolve each row's import after component() returns (importCell and formatBriefAll), so resolving the list's imports goes from about 140 ms to about 480 ms and astryx component --list takes about 0.3 s longer with the same output; running those lookups (and buildRegistry) inside withListingCache, as component() now is, brings it to about 80 ms, and a test counting one index build for --list would keep it there.

The rest holds up: the FR7 sentence is owner-approved for this head, only tokenizer and the three motion-table --source answers change across every catalog name and Core module spelling checked, and the changeset now names all four.

[Automated review]

* @returns {Map<string, Array<{stem: string, file: string}>>}
*/
function caseStemIndex(srcDir) {
return oncePerListing(`case-stems\0${srcDir}`, () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Outside a listing operation oncePerListing computes on every call, so each findComponentSource call walks all of src/ here. component() is wrapped now, but the astryx component --list text views call resolveImportPath per row after component() returns (clients/cli/commands/component.mjs:370, and formatBriefAll at :312): the 174 rows' imports go from about 140 ms to about 480 ms on the same Core (about 80 ms inside one listing operation), and buildRegistry from about 0.6 s to 1.3 s. Wrapping those callers in withListingCache fixes it.

A name with no doc of its own fell back to any source file of that
spelling, then to the nearest doc above it. So `tokenizer` opened
CodeBlock's doc through CodeBlock/tokenizer.ts.

A component's or hook's exact name in another case is now that
component's: when a file named for it anywhere in src/ exports it, as
TabList/Tab.tsx exports Tab, no module that only shares the spelling
stands for it.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Recommended for approval.

The FR7 sentence is owner-approved for this head, and across every catalog name and every Core file and folder name in four case forms, only the four lookups the changeset names change: tokenizer now opens Tokenizer's doc, and --source for tokenizer, slider, switch and progressBar answers ERR_NO_SOURCE. The list views and the XLE registry now build the case index once per operation, so astryx component --list prints the same output as on main without the earlier slowdown. Nothing else is needed from this review.

[Automated review]

@vjeux
vjeux marked this pull request as ready for review November 3, 2026 20:21
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 0417833

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 3, 2026
@cixzhang
cixzhang marked this pull request as draft November 3, 2026 21:13
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 21:13
@cixzhang
cixzhang merged commit 15a98a1 into meta:main Nov 4, 2026
179 of 186 checks passed
@vjeux
vjeux deleted the uikit/c01-cli-component-lookup branch November 4, 2026 00:11

This branch was successfully deployed

1 active deployment
Preview — 04178334 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants