Repository navigation
fix(cli): a component's name in another case never resolves through a module that shares its spelling - #8350
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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]
| topTied.length === 1 && | ||
| topTied[0].name !== dirName && | ||
| topTied[0].name.toLowerCase() === dirName.toLowerCase(); | ||
| if (!caseOnly && topScore >= 90 && topTied.length === 1 && gap >= 20) { |
There was a problem hiding this comment.
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.
| '@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. |
There was a problem hiding this comment.
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.
PR Analysis Report🔎 Preview ·
|
9b36cb8 to
d1adb5c
Compare
There was a problem hiding this comment.
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]
|
@josephfarina, a question on |
d1adb5c to
b5fc408
Compare
|
/approve-spec b5fc408 |
There was a problem hiding this comment.
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
caseSpelledComponentSourcerecognises only components with their own top-levelsrc/folder, so a later module such asmotion/uikit/tab.tswould still answerastryx component taband--source tabfor Tab (inTabList/) 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) { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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."
b5fc408 to
c0c24b2
Compare
There was a problem hiding this comment.
Changes requested: one performance fix before this lands.
component()never opens a listing operation, so the new case index (caseStemIndex, built throughoncePerListing) is rebuilt on everyfindComponentSourcecall and a 60-componentastryx componentbatch goes from about 370 ms to about 1,000 ms; wrappingcomponent()'s read inwithListingCache, assearchandbuilddo, 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}`, () => { |
There was a problem hiding this comment.
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).
c0c24b2 to
d6ee0fc
Compare
There was a problem hiding this comment.
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 --sourceandprogressBar --sourcealso change from printing themotion/uikit/tables toERR_NO_SOURCE, so please name those three besidetokenizer.
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. |
There was a problem hiding this comment.
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."
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]>
d6ee0fc to
9ae73b4
Compare
There was a problem hiding this comment.
Changes requested: one performance fix before this lands.
- Outside a listing operation
oncePerListingrebuilds the new case index on everyfindComponentSourcecall, and theastryx component --listtext views resolve each row's import aftercomponent()returns (importCellandformatBriefAll), so resolving the list's imports goes from about 140 ms to about 480 ms andastryx component --listtakes about 0.3 s longer with the same output; running those lookups (andbuildRegistry) insidewithListingCache, ascomponent()now is, brings it to about 80 ms, and a test counting one index build for--listwould 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}`, () => { |
There was a problem hiding this comment.
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.
9ae73b4 to
0417833
Compare
There was a problem hiding this comment.
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]
|
/approve-spec 0417833 |
User impact
Anyone, or any agent, asking the CLI for a component by name in another case.
astryx component tokenizeropens CodeBlock's doc today, andastryx component slider --sourceprints a motion table: a confident, wrong file instead of the component the name spells.Problem and solution fit
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:tokenizerthroughCodeBlock/tokenizer.ts, andslider,switchandprogressBarthrough themotion/uikit/tables.src/exports the exact name (Tokenizer/Tokenizer.tsxexportsTokenizer,TabList/Tab.tsxexportsTab), no module that only shares the spelling stands for it. The doc lookup then goes to the component matcher, as for any case spelling (tokenizeropens Tokenizer,badgeopens Badge,buttonstays unknown with Button first).--sourcehas no case matching:--source buttonand--source badgeare already ERR_NO_SOURCE on main, so a case spelling's--sourcenow answers the same way.Expected behavior and authority
spec:AST-083FR7: "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.mdis 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--sourceboth read it.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):
tokenizeropenedCodeBlock/CodeBlock.doc.mjsand now opensTokenizer/Tokenizer.doc.mjs.--sourcelookups that change: 4.slider,switchandprogressBarprintedmotion/uikit/<name>.ts, andtokenizerprintedCodeBlock/tokenizer.ts. All four are now ERR_NO_SOURCE.Scope
Testing
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--sourcefile recorded in__fixtures__/resolutions/. The records differ from main only ontokenizer(now Tokenizer) andprogressBar's--source. A recorded name moves when Core renames or moves its module;vitest -uis the expected update path.motion/uikit/button.tsbelow a hook's doc, andCodeBlock/tokenizer.tsbeside CodeBlock's doc.buttonandtokenizerresolve 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.motion/uikit/tab.tsbelow a hook's doc never answerstabfor Tab inTabList/, andTabstill findsTabList/Tab.tsx. This case fails with a guard that only reads top-level folders.component('tokenizer')opens Tokenizer, and--sourceforslider,switch,progressBarandtokenizeris ERR_NO_SOURCE.tokenizer, the four--sourcecases and the recorded resolutions).oncePerListingin the listing cache), andcomponent()now runs inside one listing operation, assearchandbuilddo. Soastryx component(a batch too) and the catalog's discovery walksrc/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-namecomponent()batch (eight before), at most two forastryx component --list(74 before), one for the registry (160 before), and none for a miss. PerdiscoverOwnedComponentson Core, the case walk visits 1,887 entries, and warm CPU is 138–155 ms against main's 133–137 ms. A unit test pinsoncePerListing.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:knowledgeandreview:prepass.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.