You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(FR-2754): per-version metadata propagation in docs site (#7103)
Resolves#7101 (FR-2754)
Stacked on top of #7099 (FR-2753).
## Why
Two per-version-metadata bugs surface on the multi-version docs deploy (FR-2729). Both predate FR-2753; they are observable now that the version selector reaches a real archive on the deployed site.
### Bug 1 — Spurious version-mismatch banner
From a page on the latest minor (e.g. `/26.4/ko/`), clicking "next" in the sidebar version selector lands on `/next/ko/index.html` with the banner *"이 페이지는 버전 next에 존재하지 않습니다. 해당 버전의 인덱스 페이지로 이동했습니다."*. The page exists in `next` — the message is wrong. Refreshing clears it. The reverse direction (`next → 26.4`) is fine.
**Cause:** `availability` is computed from `pageRegistry.hasSlug(version, slug)` and the registry is filled incrementally as pages render. With `versions: [26.4 (latest), next]`, `next`'s slugs are not yet in the registry when 26.4 pages render, so `availability["next"] = false` is baked into 26.4 pages. The inline switcher script reads that and arms a sessionStorage notice on click.
### Bug 2 — Brand pill always shows the workspace version
The pill in the topbar (`<span class="bai-brand-version">`) reads `v26.5.0-alpha.0 (sha)` on every page including pages under `/26.4/`. It should reflect the version the user is viewing.
**Cause:** `metadata.version` is set once from `getDocVersion()` at build start and reused for every per-version render.
## What
- **`VersionPageRegistry.declareSlug(version, slug)`** — records slug presence without adding a sitemap row. `record()` reuses it so callers cannot accidentally diverge the two paths.
- **Pre-pass in `generateWebsite`** (versioned mode only) iterates every declared version, loads its `book.config.yaml`, and `declareSlug()`'s every (lang × nav-item) slug plus the synthetic home slug. Runs BEFORE any page is rendered, so per-page `availability` is correct regardless of build order. No markdown files are loaded — only `book.config.yaml` navigation entries.
- **`pickDisplayVersion()` helper** in `versions.ts` chooses the brand pill text per render: workspace version in flat mode and on workspace-source entries (`next`); `pdfTag` (e.g. `v26.4.7`) for an archive-branch version when set; the version label itself as final fallback. `buildLanguage` calls it via metadata.
- **`packages/backend.ai-webui-docs/.docs-archive/` gitignored** — that directory is the local materialization point for `docs-archive/<minor>` worktrees and must not be tracked back into the workspace.
## Tests
7 new unit tests in `versions.test.ts`:
- `VersionPageRegistry.declareSlug` records slug presence without adding sitemap rows.
- `record()` after `declareSlug()` is idempotent on the slug set but still emits one row per `record()` call.
- `pickDisplayVersion`:
- flat mode → workspace version
- workspace-source `next` → workspace version
- archive-branch with `pdfTag` → `pdfTag`
- archive-branch without `pdfTag` → version label
- missing `versionEntry` → workspace version (defensive)
## Verification
- `pnpm --filter backend.ai-docs-toolkit test` → **146 pass / 0 fail** (was 139 before this PR).
- `bash scripts/verify.sh` → ALL PASS.
- `pnpm run build:web --lang all` against the live config with `docs-archive/26.4` worktree materialized:
- `/26.4/ko/index.html` `data-availability` is `{"26.4":true,"next":true}` (was `{"26.4":true,"next":false}`).
- `/26.4/ko/index.html` brand pill renders `v26.4.7` (was `v26.5.0-alpha.0 (sha)`).
- `/next/ko/index.html` brand pill renders `v26.5.0-alpha.0 (sha)` (workspace) — preserved.
- Browser-driven Playwright check (5/5 pass): 26.4→next click leaves sessionStorage clean (no banner); next→26.4 likewise; brand pill text matches the version on each page; both pages share the corrected `data-availability` map.
## Files changed
- `packages/backend.ai-docs-toolkit/src/versions.ts` — `declareSlug` + `pickDisplayVersion`.
- `packages/backend.ai-docs-toolkit/src/website-generator.ts` — pre-pass loop + `pickDisplayVersion` call site.
- `packages/backend.ai-docs-toolkit/src/versions.test.ts` — 7 tests.
- `packages/backend.ai-webui-docs/.gitignore` — `.docs-archive/` entry.
## Checklist
- [x] Documentation — N/A (toolkit-internal change; user-facing doc pages unaffected)
- [x] Minimum required manager version — N/A (no backend change)
- [x] Test case(s) to demonstrate the difference of before/after — 7 unit tests + end-to-end build inspection + Playwright browser verification
0 commit comments