Skip to content

[Bug] astryx search: Outline is unreachable by its own table of contents keyword #5239

Closed

Description

@nynexman4464

Description

astryx search "table of contents" does not return Outline at all — even though
'table of contents' is a literal entry in Outline's own keywords array, and the first
seven words of its description are "A table-of-contents sidebar for documentation pages".
Table ranks; Outline is absent.

In practice Outline is only findable if you already know the word "outline".

I hit this building an in-page table of contents with anchor links for a docs-style page. I
searched for an existing component first, found nothing, and hand-rolled a stack of links plus
a scroll-position helper. A colleague asked "is there really no component for this?" — there
is, and it is considerably better than what I wrote: scroll-spy, sliding indicator, single tab
stop with arrow-key navigation, a labelled nav landmark, and nested scroll container support.
Both of my hand-rolled components were deleted.

Expected: a query that exactly matches a declared keyword returns the component that
declares it, at or near the top.
Actual: it is absent from the results entirely.

The metadata is already correct — this is a ranking bug

Outline.doc.mjs already declares:

keywords: [
  'outline',
  'table of contents',   // exact phrase searched -> returns nothing
  'toc',                 // ranks 1st
  'heading navigation',  // exact phrase searched -> returns nothing
  'scroll spy',          // ranks 4th
  'documentation',
  'anchors',             // ranks 1st
  'sliding indicator',   // ranks 3rd
],

So this is not a request to add keywords. Three of the eight declared keywords fail to
retrieve their own component, and the two that fail hardest are the most natural things
someone would type.

It is not multi-word keywords in general — most work:

query (a multi-word keyword of another component) owner's rank
copy button → useClipboard 2nd
markdown renderer → Markdown 1st
mobile drawer → useAppShellMobile 4th
data visualization → useTheme 1st

The pattern is that a keyword phrase loses when one of its words is, or prefixes, another
component's name.
"table of contents" tokenizes to table + contents; Table is an exact
name hit and the documentation-* templates absorb the rest, so the component holding the
exact full phrase as a keyword is pushed off the list entirely. "heading navigation" loses the
same way to the *Nav family.

An exact whole-phrase match against keywords currently ranks below a single-token partial
match against a component name.

A second, narrower bug: function words are treated as required terms

on this page returns nothing at all. Probing it:

query results
page 20
this page 1
on page 5
on this 0
on this page 0
on this page please 0

Matching appears to be conjunctive across terms, and common function words ("on", "this",
"please") are required terms matching nothing, so a single one zeroes the result set.

I checked whether empty results are a widespread problem before reporting one, and they are
not: across 40 realistic queries (sticky sidebar, infinite scroll, skeleton loader,
command palette, drag and drop, …) exactly one returned zero — on this page. Empty is
also sometimes correct: zzzzqqqx returns nothing, which is right. So this is specifically
about function words being required, not about empty results in general.

Suggested fixes, cheapest first

  1. Rank exact whole-phrase keywords matches above partial name-token matches. This alone
    fixes table of contents and heading navigation, with no metadata changes anywhere.
  2. Drop or downweight common function words rather than requiring them — or relax to a
    ranked OR when the conjunctive match yields zero. Nonsense queries should still return
    nothing.
  3. Consider a category-scoped browse. Outline is category: 'Navigation', exactly the
    right shelf, but there is no obvious way to browse by category from the CLI;
    astryx component --category Navigation would have found it in one step.
  4. Optionally add 'on this page' and 'in-page navigation' as keywords — that is what docs
    sites actually label this control — though it is a band-aid if (1) lands.

Why it is worth fixing

The CLI's own guidance is "discover, don't guess", and I followed it: search first, then
build. Search said the component did not exist, so I wrote a worse version of one that did,
plus a second component for scroll behaviour Outline already owns. That is precisely the
failure mode good search metadata prevents — and here the metadata was already correct. Only
the ranking let it down.

Reproduction

pnpm exec astryx search "table of contents"
# expected: Outline (it declares 'table of contents' as a keyword)
# actual:   table, documentation-design, Table, detail-page, documentation — no Outline

Queries I ran before writing any code, in order:

query top results Outline?
table of contents navigation List, detail-page, useGridFocus, useListFocus, documentation, table absent
table of contents table, documentation-design, Table, detail-page, documentation absent
on this page (no results at all) absent
anchor links to page sections Link, Popover, useLayer, usePopover, useHoverCard, Section absent
in-page navigation jump to section Section, AppShell, Breadcrumbs, ClickableCard, CommandPalette, Link absent
sidebar heading navigation AppShell, MobileNav, SideNav, Breadcrumbs, ClickableCard absent
scroll to anchor position restore useLayer, useScrollLock, Carousel, Link, … Outline 8th
scroll element into view on hash change Carousel, useScrollLock, useScrollOverflow, AlertDialog, … Outline 10th

Six of eight natural phrasings return it nowhere. In the two where it does appear it ranks
below Carousel and AlertDialog.

Queries that do work — all of which require already knowing the name:

query top results
outline Outline, TreeList, …
document outline Outline, documentation-design, …
toc Outline, shell-nav, Tab
anchors Outline, Link, Popover

Astryx Version

@astryxdesign/[email protected], @astryxdesign/[email protected]

Environment

CLI (pnpm exec astryx search), Node 22, macOS and Linux — not browser-dependent.

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

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions