fix(cli): search no longer lets a page claim every component it renders - #5340
Draft
AKnassa wants to merge 1 commit into
Draft
fix(cli): search no longer lets a page claim every component it renders#5340AKnassa wants to merge 1 commit into
AKnassa wants to merge 1 commit into
Conversation
A page template's search keywords are read back out of its own source, and each rendered component name scored as an exact keyword match — the same 90 an author's `category` earns. So every page rendering a <List> anywhere claimed "list" as loudly as the page that IS a list. On "customer list" 14 pages tied at 98, the tie fell through to the alphabetical tiebreak, and table-page came back 35th of 36. Breadth was unbounded too: theme-showcase renders 51 components — 4x the median page — so it matched more terms of almost any query than the page written for it, and took first place on "list of users". Keywords now come in two grades. Authored ones (a component's `keywords`, a block's `componentsUsed`, a page's `category`) keep scoring at face value. Ones derived by reading a page's source are length-normalized by how many were derived alongside them, so a focused page outranks a kitchen sink on the same component and a wide-surface page stops claiming concepts it only brushes against. Results now read `renders "List"` rather than `keyword "List"`, so a ranking can be explained. Addresses the retrieval-hygiene half of facebook#5300. The roster half — six proposed new page templates — is a curation call left to maintainers. Verified: `astryx search "customer list" --type template` returns the table pages instead of dashboard-portfolio. Full cli suite 2777 passed, with the same 9 pre-existing failures as the base commit; lint:strict, check:repo and all four cli typechecks green.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
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.
What this does
astryx searchindexes a page template by the components it renders, weighted the same as keywords a template author wrote by hand. A page rendering a<List>in a sidebar scored on "list" exactly as loudly as the page that is a list. Derived keywords now score lower, and lower still the more components a page renders.Why
The ranking carried almost no information for component-shaped queries. On
main,astryx search "customer list" --type templatereturns 36 of 43 pages, 14 of them tied at score 98. The tie falls through toname.localeCompare, sodashboard-portfolioranks first on the letter d andtable-pagecomes back 35th of 36.theme-showcaserenders 51 components against a median page's 13, so it matches more terms of almost any multi-word query than the page written for that query. It ranks first forlist of users.What changed
Keywords come in two grades in
packages/cli/api/search/search.mjs.Authored keywords keep their weight: a component's
keywords, a block'scomponentsUsed, a page'scategory.Derived keywords, the component names read back out of a page's own source by
extractComponents, are scaled byPIVOT / (PIVOT + count)withPIVOT = 18. Measured scores for an exact hit: 5 components gives 70, 14 gives 51, 15 gives 49, 51 gives 23. An authored keyword stays 90.MIN_TOKEN_SCOREis 50, so past 14 rendered components a single derived match no longer counts as a matched concept.Result
reasonstrings now readrenders "List"where they readkeyword "List", so a ranking can be explained.Also corrects a stale comment in
theme-showcase/template.doc.mjsstating the overview gallery is the only consumer ofcategory.search()indexes it as well.How to see it
Before:
dashboard-portfolio,dashboard-project-status,dashboard-service-monitoring,detail-page.After:
table(93),library(85),table-grouped(85),table-page(85).Checks
A 16 query before/after battery: 9 rankings changed, 7 identical. The unchanged ones (
kanban board,settings screen,login page,analytics dashboard,documentation site,photo gallery,notifications) answer off authored name and category signals, which this does not touch.One deliberate demotion: on
file tree,idenow sits belowshell-nav, whose description reads "resizable file-tree SideNav".ideonly renders aTreeList. Top hitfile-exploreris unchanged.pnpm -F @astryxdesign/cli testpasses 2777, with the same 9 failures present on the base commit (ENOENT scandir 'packages/core/src').pnpm lint:strictreports 0 errors,pnpm check:repois clean, and all four cli typechecks pass.Scope
Part of #5300, covering its "Related retrieval-hygiene bug" section. The six proposed page templates in that issue are a curation call and are not part of this PR.