fix(webviews): markdown page loads only its own language's strings (eager JS budget base red)
Summary
Base red on every feat-cmux-next PR: web / react-apps-check fails check-webviews-diff-budget.mjs with markdown page evaluates 1407890 bytes on open, budget is 1400000 bytes.
Commit that pushed it over: bb58f0fa800 ("cmux-next markdown: Reading Settings popover, Settings rows and cmux.json keys"). Measured on Huge Blue across first-parent history: cc3cd98185e 1,386,749 bytes, bb58f0fa800 1,407,894. The popover itself was already lazy; the growth is markdown-page.mjs (+21 KB): ~25 new keys in every one of the 21 languages, because the page imported its whole generated/strings.json.
Fix (no budget raise): split the markdown table by locale, the mechanism the diff page already uses (gen-strings.mjs splitLocales). English stays the eager fallback; the one translation the app's language picks is fetched before the page mounts (an English app mounts synchronously, as before). The gallery adds its pseudo-locales to the same table.
gen-strings.mjs:markdown.splitLocales: true; the loaders' export name is per page (diffkeepsdiffLocaleLoaders, defaultlocaleLoaders).pages/markdown/stringTable.ts(new) +main.tsx: load English + the picked locale; a failed translation load falls back to English rather than a blank page..gitignore,scripts/ci/next_batch.py: generatedlocales/andlocaleLoaders.tspatterns cover every page, not just diff.
Testing
- Budget (Huge Blue,
vp build+node scripts/check-webviews-diff-budget.mjs): base 4bc289e7890 1,407,890 (red) -> this branch 1,348,792 (-59 KB, under 1.4 MB). Same number CI reported on #21807 for the base, so the measurement matches CI. bun run typecheck: no type errors.bun teston the markdown, strings-build-output, gallery-adjacent and ui suites: all pass exceptui-rules"migrated page code has no raw roles…" and twosubtle-elevationtests, which fail identically at the base tip (separate base reds, not touched here).- The failing test for this change is the existing budget check, red on the base.
Changelog: none
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Brings the markdown page's eager JS back under its 1.4 MB budget by loading only the one translation the app's language picks instead of all 21 languages' strings, which had pushed first-load to 1,407,890 bytes.
Bug Fixes
gen-strings.mjssplits the markdown table by locale like the diff page's; English stays the eager fallback, and a failed translation load falls back to English rather than blanking the page.- Loader exports are now per page (
diffkeepsdiffLocaleLoaders, defaultlocaleLoaders), and.gitignore/next_batch.pypatterns cover generatedlocales/andlocaleLoaders.tsunder every page. - The gallery adds its pseudo-locales to the same table, locale chunks are named (
markdown-labels-*) and counted as lazy-only in the budget check, and the picked translation loads before the page mounts; first-load drops to 1,348,792 bytes.