Skip to content

fix(cli): search no longer lets a page claim every component it renders - #5340

Draft
AKnassa wants to merge 1 commit into
facebook:mainfrom
AKnassa:rocky/issue-5300-template-search-hygiene
Draft

fix(cli): search no longer lets a page claim every component it renders#5340
AKnassa wants to merge 1 commit into
facebook:mainfrom
AKnassa:rocky/issue-5300-template-search-hygiene

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

What this does

astryx search indexes 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 template returns 36 of 43 pages, 14 of them tied at score 98. The tie falls through to name.localeCompare, so dashboard-portfolio ranks first on the letter d and table-page comes back 35th of 36.

theme-showcase renders 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 for list 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's componentsUsed, a page's category.

Derived keywords, the component names read back out of a page's own source by extractComponents, are scaled by PIVOT / (PIVOT + count) with PIVOT = 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_SCORE is 50, so past 14 rendered components a single derived match no longer counts as a matched concept.

Result reason strings now read renders "List" where they read keyword "List", so a ranking can be explained.

Also corrects a stale comment in theme-showcase/template.doc.mjs stating the overview gallery is the only consumer of category. search() indexes it as well.

How to see it

astryx search "customer list" --type template

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, ide now sits below shell-nav, whose description reads "resizable file-tree SideNav". ide only renders a TreeList. Top hit file-explorer is unchanged.

pnpm -F @astryxdesign/cli test passes 2777, with the same 9 failures present on the base commit (ENOENT scandir 'packages/core/src'). pnpm lint:strict reports 0 errors, pnpm check:repo is 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.

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.
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Error Error Aug 22, 2026 5:33pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 22, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

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

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant