Skip to content

fix(cli): translated component docs must not drop props - #3892

Merged
cixzhang merged 1 commit into
meta:mainfrom
AKnassa:fix/component-doc-overlay-prop-drop
Jul 19, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
AKnassa:fix/component-doc-overlay-prop-drop

Conversation

@AKnassa

@AKnassa AKnassa commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Found while fixing #2182 — same bug class, different surface. No issue filed for this one; happy to open one if you'd prefer it tracked.

The bug

A docsZh / docsDense block that carries its own props array was returned wholesale by the loader instead of being overlaid onto the English doc. That makes the translation a replacement, not an overlay — so any prop the translation hasn't caught up with simply ceases to exist.

$ astryx component Button --zh
# isInterruptible — absent.  isIconOnly — absent.
# Both exist in the English doc.

Ten components are affected. Seven show up as a plain props-length mismatch (Button, Card, Center, DateInput, FileInput, StatusDot, Tokenizer); three more — MobileNav, Popover, Stack — hide inside the multi-component components[] shape, which a length check doesn't see. The test found those three; I hadn't.

Why it matters beyond i18n: CLAUDE.md instructs every AI agent to run astryx component <Name> before touching a component. A prop that isn't in the docs is a prop that never gets used.

The fix

Translations are overlaid, matched by prop name rather than position. A prop the translation doesn't cover falls back to its English entry instead of vanishing.

The prop's contract (type, default, required) also stays authoritative from the English doc while the translation supplies only the prose — so a stale translation can no longer misstate a type, which is the same failure mode one step further along.

Existing Chinese descriptions are untouched: variant still reads 视觉样式变体。

Same principle as #2182 — an overlay that covers a subset must not destroy what it doesn't cover.

Test plan

  • 11 tests red before the fix, naming each dropped prop.
  • After: EN and ZH prop counts match for every component (Button 17/17, FileInput 19/19, Tokenizer 29/29, Center 8/8), the dropped props are back, and the existing Chinese prose survives — a fix that quietly reverted everything to English would also have gone green, so I checked that explicitly.
  • pnpm exec vitest run — 337 files, 6487 tests, all passing.
  • pnpm check:repo — all five gates pass.

One thing to flag honestly: on my first full-suite run, packages/cli/src/commands/template.path-safety.test.mjs > treats targetPath with .tsx extension as a file failed. It is not caused by this change — it passes in isolation on this branch and on clean main, and a second unmodified full-suite run went green (337/337). It looks order-dependent under parallel execution. Mentioning it in case it's worth its own flake issue.

A docsZh/docsDense block that carries its own `props` array was returned
wholesale by the loader instead of being overlaid onto the English doc. That
made the translation a REPLACEMENT, not an overlay: any prop the translation
had not caught up with simply ceased to exist.

  $ astryx component Button --zh
  # isInterruptible and isIconOnly: absent. They exist in English.

Ten components were affected — including MobileNav, Popover and Stack through
the multi-component `components[]` shape, which a props-length check alone
does not see.

A reader of the translated docs cannot discover a prop that is not there, and
CLAUDE.md instructs every AI agent to run `astryx component <Name>` before
touching a component. A prop missing from the docs is a prop that never gets
used.

Translations are now overlaid, matched by prop NAME rather than position: a
prop the translation does not cover falls back to its English entry instead of
vanishing. The prop's contract (type, default, required) stays authoritative
from the English doc while the translation supplies the prose, so a stale
translation can no longer misstate a type either. Existing Chinese
descriptions are untouched.

Same principle as the reference-doc overlay fix (meta#2182): an overlay that
covers a subset must not destroy what it does not cover.

Claude-Session: https://claude.ai/code/session_01VYm8FsvUjk3xwDmonZRYeE
@vercel

vercel Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 12, 2026 11:16pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 12, 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 Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | View full report

@AKnassa
AKnassa marked this pull request as ready for review July 13, 2026 01:16
@cixzhang

Copy link
Copy Markdown
Contributor

cc: @josephfarina for CLI docs.

It looks like translation docs can override prop definitions from the canonical docs. I wonder if we should strip down the translation docs to just the description and enforce that via type or lint? Aside from the description, the rest of the doc properties seem like they would need to be consistent with the canonical English docs to be correct.

@cixzhang cixzhang 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 for this fix!

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Jul 19, 2026
@cixzhang
cixzhang merged commit 02f2602 into meta:main Jul 19, 2026
23 checks passed
@github-actions
github-actions Bot deleted the fix/component-doc-overlay-prop-drop branch July 20, 2026 08:54
josephfarina added a commit that referenced this pull request Jul 20, 2026
… + CI gate

- backfill stable block ids into theme (50) and layout (13) canonical docs
- regenerate theme/tokens/layout dense+zh overlays as prose-only id-keyed blocks
- extend docOverlays.test: every overlay block id resolves to a real base block,
  overrides are prose-only (id + text/items only), base block ids are unique;
  legacy positional `content` shape is now rejected
- component-doc surface already safe via #3892 (overlayComponentDoc, name-matched)

Refs #2182

Co-authored-by: Cursor <[email protected]>
josephfarina added a commit that referenced this pull request Jul 20, 2026
Make reference-doc dense/zh overlays structurally unable to drop, misalign, or
override canonical content (the #2182 / #3891 bug class).

- ContentBlock gains an optional stable id; ReferenceTranslationDoc is prose-only,
  id-keyed blocks and cannot express type/code/table/structure
- api/docs.mjs merge is id-anchored and fail-safe: unmatched or unexpressible
  overrides fall back to canonical English; no array positions anywhere
- all reference docs migrated: principles, theme, layout (per-block ids), tokens
  (ids emitted from scripts/generate-token-docs.mjs); overlays rewritten to blocks
- docOverlays.test.mjs gate: every overlay block id resolves, prose-only, unique
  base ids, and the legacy positional content shape is rejected
- component/hook overlays already safe on main via #3892 (overlayComponentDoc)

Refs #2182

Co-authored-by: Cursor <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 16c7fa26 Deployed Jul 12, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants