Skip to content

fix(cli): read a section of a docs-tree namespace from the guide that has it - #7212

Merged
cixzhang merged 2 commits into
mainfrom
fix/namespace-section-reads
Oct 9, 2026
Merged

cixzhang merged 2 commits into
mainfrom
fix/namespace-section-reads

Conversation

@josephfarina

@josephfarina josephfarina commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Restored: astryx docs layout side-panels, and every other astryx docs layout <section> read, worked in 0.6.6 and have failed with ERR_UNKNOWN_SECTION since layout became a docs-tree namespace. With this change, a section read on a namespace returns the section when exactly one guide below the namespace has it, so those reads work again. The same holds for any later topic split.

New behavior, for a decision: when a section query matches sections in more than one guide (for example a title fragment two guides share), the read used to guess and now asks. A flat topic's section read returns its first title match; across guides, this read fails with ERR_UNKNOWN_SECTION and names each guide that matches, so the reader picks one. The choice lives in one function (oneGuide) with its own test, so returning the first match in tree order instead is a one-line change.

Problem and solution fit

  • A section argument on any namespace failed, because a namespace has no sections of its own.
  • Splitting a flat topic into guides therefore broke every section read readers and agents already used, including the reads printed by earlier docs and release notes.
  • Agents follow those printed commands literally, so a failing read costs a retry or a wrong answer.

The fix reads the section from the guide that holds it, so the command keeps its meaning without the reader knowing the topic was split.

Expected behavior and authority

The docs-tree spec amendment in review (the change to AST-046 FR6) states the contract. A section read on a namespace returns the section when exactly one guide below it, at any depth, has it, found by key (its id, else the key its title derives) or by title. The response is the guide's own section read (docs.detail.section). When no guide or several have it, the read fails with ERR_UNKNOWN_SECTION, naming the guides that have it, or every guide when none does. A section read on a typed doc still fails, naming the doc.

Smallest restoration

  • api/docs/docs.mjs: a section argument on a namespace goes to the new read; a typed doc still fails.
  • api/docs/detail/section/section.mjs: namespaceSection walks the guides below the namespace in tree order. Each guide answers with the section its own section read returns for the query, so the namespace read returns exactly what astryx docs <guide> <section> returns. When that section's key is the query in some guides, those guides answer first. A namespace with no guide below it (such as cli/api) names its children on a section read, as before. The response is built by the same code as a topic's section read, so the JSON shape, links, --dense and --zh all match.
  • The command and API docs describe the read. The layout split's pending release note no longer says astryx docs layout <section> stops resolving.

Evidence

  • Reproduction before the change: astryx docs layout side-panels fails with "layout" has no sections.
  • Result after the change: it prints the Side panels section. --json returns the same docs.detail.section as astryx docs layout/side-panels side-panels, by key and by title, in --dense and --zh too.
  • Representative unchanged path: flat topic section reads (astryx docs theme quick-start) and the section read on a typed doc.
  • Regression tests: api/docs/namespace-section.test.mjs covers layout reads by key and title, dense and zh, the guide's own answer when an earlier section's title contains the query and a later section's derived key equals it, a key match in one guide beating a title match in another, a miss naming every guide at any depth, a namespace with no guides naming its children, an ambiguous query naming each matching guide, and oneGuide on its own.

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. The one new behavior, asking when several guides match, is stated above.
  • Public text and artifacts contain no internal Meta context.

Testing

  • npx vitest run packages/cli/api/docs/namespace-section.test.mjs packages/cli/api/docs/docs.test.mjs packages/cli/clients/cli/commands/docs.test.mjs
  • Full CLI node suite (vitest run --project node packages/cli) against bare main on the same machine: no failure specific to this change. Tests that differed between the two concurrent runs (theme build watch, theme doctor and provenance, search CLI) pass when rerun alone.
  • node scripts/release/changeset-coverage.mjs pr: passes. The docs tree builds with 0 diagnostics.

… has it

`astryx docs layout side-panels` worked in 0.6.6 and has failed since the
layout split, because a section argument on a namespace always failed.
A section read on a namespace now finds the one guide below it, at any
depth, that has the section (by key, then by title, as a topic's section read
does) and returns that guide's own section read. When no guide or more than
one has it, the read fails with ERR_UNKNOWN_SECTION and names the guides.
The choice between several matching guides lives in one function, oneGuide.
@vercel

vercel Bot commented Oct 9, 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 Oct 9, 2026 3:27am UTC

Request Review

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

astracat-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 9, 2026, 5:00 AM UTC

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

23 of 442 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050
SideNav Resizable in AppShell probe light 3,208
TableGroupedRows Default neutral light 2,133
TableGroupedRows Default neutral dark 2,116
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882

and 3 more.


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

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

Thanks — this restores a read that the layout split broke, and the shape of
the fix looks right: astryx docs layout side-panels answers from the guide
that has the section again, in the same payload shape as reading the guide
directly, and the ambiguity and language cases are covered by tests.

Approval needs a maintainer spec decision first. On main, AST-046 is still a
draft and its FR6 says a section argument on a namespace must fail; the
contract this change implements — return the section when exactly one guide
below the namespace has it, and fail naming the guides when none or several
do — currently lives only in the in-review spec update (#7210). A maintainer
needs to land that governing claim on main (including whether an exact-key
match in one guide outranks a title match in another) before this can be
approved; nothing about the implementation needs to be removed or split for
that.

Two smaller fixes are worth taking along whenever that lands:

  • The namespace read can pick a different section than the guide's own read
    for the same query when a title-derived key matches a later section while
    an earlier section's title contains the query ("Shell contract" before
    "Shell" in one guide). That sits awkwardly with the changeset's "returns
    the same section the guide's own read returns", and the key-preference test
    doesn't currently pit a key against a competing title match. Aligning the
    per-guide candidate with the guide's own search result — or spelling out a
    namespace-only rule in the spec — plus a competing fixture would close it.
  • On namespaces with no guides below them (cli/api, cli/commands,
    unorganized), a section miss now returns no suggestions while saying
    "Open one of its guides instead"; restoring the previous children
    suggestions for that case keeps the error actionable.

[Automated review]

…n read

Each guide now answers with the section its own section read returns for the
query, so 'astryx docs <namespace> <section>' returns exactly what the guide
read does, even when a later section's title-derived key matches while an
earlier section's title contains the query. A namespace with no guide below
it (cli/api) names its children again on a section miss.

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

Approving. This stands on its own against current main, restores the 0.6.6 reads, and both Changesets pass the coverage gate.

  • Run from this head against the layout namespace that is already on main: astryx docs layout side-panels fails on main with "layout" has no sections and prints the Side panels section here; --json is byte-identical to astryx docs layout/side-panels side-panels; the title form, --dense and --zh return the same docs.detail.section. All 14 section keys of the v0.6.6 flat layout doc resolve. A miss names the guides, cli/api (no guides) still names its children, astryx docs theme quick-start is unchanged. Nothing here needs the pending topic split; it applies to any namespace.
  • Tests: the three named files pass 58/58; routing the namespace case back to the old failure fails 8 of the 10 new tests. The CLI README check passes.
  • Changesets: node scripts/release/changeset-coverage.mjs pr ✓ (@astryxdesign/cli named; released CLI JSON ids intact); rewording the unreleased #7125 note so it no longer says section reads stop resolving is the right correction. The ambiguity rule (several guides match → an error naming them rather than the first match) is the AST-046 owner's choice; AST-046 is still a draft record, so that choice is recorded for its amendment in #7210 and does not hold this restoration.

[Automated review]

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

Thanks — the two fixes from the last round look right: a namespace read now returns exactly what the chosen guide's own section read returns (the "Shell contract" before "Shell" case included), and namespaces with no guides below them name their children again on a section miss. With those in, the implementation matches the proposed contract end to end — exactly-one guide answers in the guide's own payload shape by key and by title, in --dense and --zh too, and a query that matches several guides asks instead of guessing.

Approval still needs the maintainer spec decision. On main, AST-046 is a draft whose FR6 says a section argument on a namespace must fail; the contract this implements lives in the in-review spec update (#7210). A maintainer needs to land that governing claim on main — including the rule that an exact-key match in one guide outranks a title match in another — before this can be approved. Nothing needs to be removed or split for that, and no code changes are being requested in the meantime.

[Automated review]

@cixzhang
cixzhang enabled auto-merge (squash) October 9, 2026 05:00
@cixzhang
cixzhang merged commit 4ec0d0e into main Oct 9, 2026
45 checks passed
@github-actions
github-actions Bot deleted the fix/namespace-section-reads branch October 9, 2026 06:25

This branch was successfully deployed

1 active deployment
Preview — c2f67d5c Deployed Oct 9, 2026 by vercel[bot]
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants