Skip to content

Commit d996c38

Browse files
perf(i18n, app-shell)!: the marketplace pages' strings leave the eager language packs for a lazy marketplace namespace (#30640)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuUBtTWuZmgP7aDAfaaeufU6)_ Fixes #30588 Clause-②: yes (narrowing) Metadata-protocol: none Skills-docs: none — no `skills/`, `.claude/` or `docs/` text names the moved keys or teaches the pack shape (the 17 `marketplace.` hits there are `marketplace.zod.ts` and marketplace prose) ## 维护者速读 - 改了什么:应用市场两张页面(目录页、应用详情页)用到的文案从十个语言包里搬出,放进一个按需加载的 `marketplace` 文案包;打开市场页时才下载当前语言那一份(外加英文兜底),下载完成前页面显示原有的加载骨架,下载失败显示控制台自己的「出错了 / 重试」。Studio 软件包页也会用到的那部分文案(卸载、未加载徽标、依赖缺失与协议提示)留在语言包里不动。文字本身一个字没改。 - 为什么改:#30588。控制台首屏必载的英文语言包 `i18n-locale-en` 已到 59,951 / 60,000 gz,只剩 49 字节,挡住了 #30545、#30552 两个要加市场文案的 PR;上限不许抬。现在读数 57,003,余量 2,997(合入 main 之后的 head `54db079b`)。 - 风险与回滚:只改前端与构建分组;首屏总量 2,204,342 → 2,201,442 gz,没有新增首屏块,十份市场文案、加载器和加载框架都不在首屏。直接读语言包对象的代码(包入口的 `en`、`@object-ui/i18n/locales/CODE`)不再含被搬走的键,属 TypeScript 层面的收窄,changeset 写明了迁移。回滚即还原本 PR。 - 先看:`ui/packages/i18n/src/namespaces/marketplace/index.ts`(加载与就绪判断)、`ui/packages/app-shell/src/console/marketplace/MarketplaceNamespaceGate.tsx`(页面框架)、`ui/apps/console/vite.config.ts` 的 `i18n-ns-marketplace*` 与 `marketplace-namespace-gate` 分组(为什么两组都要 `includeDependenciesRecursively: false`)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/app-shell/src/console/marketplace/__tests__/MarketplacePage.namespaceGate-30588.test.tsx packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts packages/i18n/src/__tests__/marketplace-namespace-lazy.test.tsx`,预期 14 个用例全绿(中文页先骨架后中文、从不出现英文或原始键;切换语言时不误弹示例数据横幅)。 - 需要你做的:改动约 6,600 行(41 个文件,+4,338 / −2,294)(多为十个语言文件里整段搬移),超过 3,000 行人工合并线,请在席位复核通过后批准合并。 ## What changes - **A lazy `marketplace` namespace.** `ui/packages/i18n/src/namespaces/marketplace/CODE.ts` (ten files) are partial packs: the same shape as `src/locales/CODE.ts`, holding the `marketplace` group cut out of that pack, text unchanged (each language's pack merged with its catalogue is deep-equal to its pack at `bdbaf80c`). `index.ts` loads them through ten literal `import()`s and exports `useMarketplaceNamespace()`, `loadMarketplaceCatalogue()`, `isMarketplaceCatalogueLoaded()`, `resolveMarketplaceLanguage()` and the namespace constants. New published subpath `@object-ui/i18n/namespaces/marketplace`. - **How a page waits.** `useMarketplaceNamespace()` reads the i18next instance react-i18next serves, works out the two catalogues the language needs (its own, `zh-CN` served by `zh`, plus `en`, the packs' `fallbackLng`), merges the resident ones into the instance deep and without overwriting (a host's own `resources` win, as they do over the packs), and answers `loading` / `ready` / `failed` with a `retry()`. It records per instance which catalogues it installed, so a host resource that spells one `marketplace.*` key does not stop the rest of that language's catalogue. A catalogue the all-ten door registered (`registerBuiltInLocales()`) is used without a fetch. A failed fetch stays failed until `retry()` (or a later mount) asks again: no loop. - **The page frame.** App-shell's `MarketplaceNamespaceGate` wraps the bodies of `MarketplacePage` and `MarketplacePackagePage`: the existing copy-free skeleton (`MarketplaceResolving`) while loading and after a language switch, the console's resident `console.errors.somethingWentWrong` with `console.errors.tryAgain` when a catalogue cannot be fetched, the page once ready. The skeleton after a language switch unmounts the page body while the visitor stays on the page, so the frame also says when it is holding the page back (`marketplaceFrameHolding.ts`), and `SampleDataLeaveBanner`'s unmount cleanup asks it before raising the banner that follows an installer off the package page. - **What stays in the packs.** Studio's packages page (`views/metadata-admin/PackagesPage.tsx`), outside the marketplace route, renders `MarketplaceRowActions`, `MarketplaceNotLoaded` and the `dependencyMissing` / `protocolCheckSkipped` readers. Their keys stay resident in all ten packs: `marketplace.installedAdditiveNote`, `marketplace.notLoaded.*`, `marketplace.action.uninstall|uninstalling|details`, `marketplace.uninstall.confirm|confirmNotLoaded|successInList|successNotLoaded`, `marketplace.install.dependencyMissing.*`, `marketplace.install.protocolCheckSkipped.*` (19 leaves in `en`). The new `marketplaceNamespaceBoundary.test.ts` holds that set to what those files read. - **The all-ten door stays complete.** `@object-ui/i18n/locales` now hands out each language as its pack deep-merged with its namespace catalogue and refuses a key defined in both, so `all-locales-key-parity` and every suite walking `builtInLocales` still walk the moved keys, and `registerBuiltInLocales()` still makes every string resident. The package entry's `en` is the resident pack alone. - **The i18n gates learn the namespace.** `check-i18n-call-site-keys.mjs` (`collectEnKeys`, hence `check-i18n-dead-keys.mjs` too) and `check-i18n-en-drift.mjs` read `namespaces/marketplace/CODE.ts` beside each pack, refuse a key defined in both places, and keep the namespace file optional for fixture roots. No other gate rule changed. - **Chunking.** `ui/apps/console/vite.config.ts` gains `i18n-ns-marketplace` (the loader) and ten `i18n-ns-marketplace-CODE` groups, plus `marketplace-namespace-gate` (the frame). The loader's and the frame's groups take `includeDependenciesRecursively: false`; the comment there gives the two measured reasons (the default stole `locales/registry.ts` and the preload helper into an eager loader chunk; the frame otherwise lands in the chunk the two pages share with the eager packages page). - **Ceiling untouched.** `PER_CHUNK_GZIP_CEILINGS` and `PER_CHUNK_BASELINE` are unchanged; the new reading is recorded in prose beside `'i18n-locale-en': 60_000`. `locales/registry.ts` and the pack file names are unchanged. - **Changeset.** `.changeset/30588-marketplace-lazy-namespace.md`, `@object-ui/i18n` and `@object-ui/app-shell` patch, BREAKING with its migration, ADR-0087 `not-required (runtime-interface-only ui/packages/i18n/src/locales/en.ts#TranslationKeys)`. Branch: the harness-assigned `claude/project-thread-9mg01c`, not `claude/issue-30588-*`; the card is #30588. ## Tests - New `packages/i18n/src/__tests__/marketplace-namespace.test.ts` (56 cases): ten literal `import()` loaders and no static catalogue import (read by the TypeScript parser); every catalogue holds only the `marketplace` group and the probe key, no pack holds the probe key, no leaf is in both a pack and its catalogue; the all-ten door's languages are exactly pack plus catalogue; the entry's `en` lacks the moved keys; language resolution; the loader refuses an unknown code and memoises. - New `packages/i18n/src/__tests__/marketplace-namespace-lazy.test.tsx` (5 cases, registry re-registered as packs alone): `zh-CN` answers loading first, then every render of the probe is Chinese (no English, no raw key) and only `zh` and `en` were fetched; a switch to `ja` waits again; `sv` is served by `en`; a host resource for `marketplace.title` wins and `marketplace.refresh` still arrives in Chinese; a failing `ko` chunk answers failed once, makes no second request on its own, and `retry()` loads it. - New `packages/app-shell/src/console/marketplace/__tests__/MarketplacePage.namespaceGate-30588.test.tsx` (4 cases, a MutationObserver records every text node the page adds): the catalogue page in `zh-CN` and the package page in `de` show the skeleton, then their language, and never the English text or a raw key; an `ar` chunk that fails shows the Arabic resident error words, and Try again fetches it and renders Arabic; on a package page with a sample-data record from this session, a switch from `zh-CN` to `ja` raises no banner in any language, and leaving the page raises it in Japanese. Before the frame said it was holding, that case failed: the switch raised the banner in Chinese while the installer was still on the page (`expected … not to contain '"Service Desk" 中有示例数据。'`). - New `packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts` (5 cases): finds every module outside `console/marketplace/` that imports into it, holds that both pages render under the frame, and that every `marketplace.*` key spelled by a file reachable from an ungated door is a resident pack key. - Gate tests: `scripts/__tests__/check-i18n-call-site-keys.test.ts` and `check-i18n-en-drift.test.ts` gain the namespace cases (a group moved into the namespace is no drift; a change inside it is; a key in both is refused). - **Ablation (the dispatch's).** With the commit in place, `scripts/ablation-replace.mjs` replaced `MarketplacePage`'s `MarketplaceNamespaceGate` wrapper with a bare fragment (the page no longer loads the namespace): the frame test went red, 2 failed / 3, the first frame reading `expected 'marketplace.titlemarketplace.subtitle…' not to match /\bmarketplace\.[A-Za-z]/`. The same on `MarketplacePackagePage`: 1 failed / 3. Both restored by the tool's trap: blob equals HEAD, `git diff HEAD` empty. - **The boundary test catches the gap it was written for.** At the packs of `69ab56e1` (before the Studio keys went back), it failed 2 / 5, naming the eleven `MarketplaceRowActions.tsx` keys. ## Acceptance notes - **Bundle readings** (console `CI=true vite build`, `apps/console/dist/eager-closure.json`): `i18n-locale-en` 59,951 at `bdbaf80c` → 57,010 at `17e15c7f` (ceiling 60,000, headroom 49 → 2,990). Eager closure 2,204,342 → 2,201,442 gz, 103 → 103 eager chunks with the same names on both sides; no other chunk moved by more than 40 bytes. No `i18n-ns-marketplace*` chunk and no `marketplace-namespace-gate` chunk is eager. The ten catalogue chunks read 3,724 (`en`) to 5,048 (`ru`) gz each, the loader 1,315 gz, the frame 704 gz, all lazy. The prose beside the ceiling records 2,201,440, read at `5986ae70`; the 2 bytes are chunk-hash noise. - **Screenshots** (live stack, console via vite): catalogue page in `zh-CN` ([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-catalog-zh-CN-1440.png?raw=true)) and `de` ([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-catalog-de-1440.png?raw=true)); package page in `zh-CN` ([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-package-zh-CN-1440.png?raw=true)) and `de` ([shot](https://github.com/objectstack-ai/objectstack/blob/af733e30a3e6bc0e2e172de3e35638f32b21b844/evidence/30588/marketplace-package-de-1440.png?raw=true)), 1440 wide. A Playwright run recorded every text node each page added on the way: no raw `marketplace.` key and no English title or subtitle in any of them, no page error. The language files (`zh` and `en`, `de` and `en`) were requested only once the marketplace page opened; the dev server serves the loader module itself at boot, since dev has no chunks (the production readings above are the lazy ones). Shots committed at `af733e30` and removed from the tree by the next commit; they predate `17e15c7f`, which changes only when the sample-data banner is raised. - **Language switch while a page is open** shows the skeleton until the new language's catalogue lands, which unmounts the page body: a half-filled install dialog is lost on a switch, and the page reads its package again. Chosen over keeping the body mounted, which would show English for a moment. The one unmount cleanup in these pages that means the visitor left, the sample-data banner, checks the frame first (fixed in this PR, see Tests). - **For #30511 / PR #30595:** that card renames packs to `zh-Hans` / `zh-Hant` / `pt-BR`; after this lands it adds the matching `namespaces/marketplace/CODE.ts` files and loader entries (the shape test pins one loader per `BUILT_IN_LANGUAGE_CODES` entry, so it will say so). - **For PR #30545 / PR #30552:** their new `marketplace.install.preview.*` and related keys belong in the namespace catalogues, unless Studio's packages page reads them. ## Verification All on head `17e15c7f` unless noted. Lock readings are the lock's own VERDICT lines. **Re-run on `54db079b`** (origin/main merged at `64857f64`; PR #30653's new `purgeConfirmAtMost` wording carried into `namespaces/marketplace/<lang>.ts` in all ten languages, one test stub for its `countLocalSampleData` read; os-dev-report 6671129796): every pack deep-merged with its catalogue deep-equals main's pack at `47c457b23`; console/marketplace + i18n vitest 150 files, 1980 tests passed; ui `scripts/` 170 files, 4979 tests; `check:i18n-keys`, `check:i18n-dead-keys`, `check-i18n-en-drift.mjs --base origin/main` exit 0; `i18n-locale-en` 57,003 gz (headroom 2,997); 57/57 derived gates exit 0; full dogfood 421 files, 3513 tests passed. The readings below are the `17e15c7f` ones. - `pnpm --dir ui exec vitest run packages/app-shell/src/console/marketplace packages/i18n`: 150 files passed, 1960 tests passed, 13 skipped. - `pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin` (Studio's packages page and the rest of that view): run with the marketplace directory at `ae5aac72`, 780 files, 8133 passed, 1 skipped. Later commits touch only the frame, the namespace hook, the banner and tests; the boundary test holds that nothing outside the marketplace pages reaches them. - `pnpm --filter @object-ui/app-shell run type-check` (source and tests): exit 0. `pnpm --filter @object-ui/console run type-check` then `build:plugin`: exit 0. `pnpm --filter @object-ui/i18n run type-check`: exit 0 (no i18n source change after `f10a7fdf`). - **Reverse check on the narrowed type** (one-off file in app-shell, against the rebuilt `@object-ui/i18n` dist, removed after): `en.marketplace.action.uninstall` compiled and `en.marketplace.title` gave exactly one error, `TS2339: Property 'title' does not exist`; `git status` clean after. - `pnpm --dir ui run check:i18n-keys` (4,210 keys), `check:i18n-dead-keys` (report identical to base: same 94 entries), `node scripts/check-i18n-en-drift.mjs --base bdbaf80` (0 en values changed): exit 0 each. - `pnpm --dir ui check:eager-closure`, `pnpm --dir ui check:eager-locale-catalogues`: exit 0; `scripts/__tests__/check-eager-closure-budget.test.ts` (174): exit 0. - `node scripts/check-adr-0087-registration.mjs --base origin/main`: verified `runtime-interface-only` on `TranslationKeys`. - eslint `--no-inline-config` on every changed source, test and script: 0 errors; the only warnings are pre-existing ones in the two page files. - `node scripts/pm/dispatch-gates.mjs --commands`: 57 derived families, the same list at `9cf51c22` and at `17e15c7f`. All 57 exit 0; `--ran` reconciles 57 run, 0 NOT-MEASURED, 0 UNRUN. `check:dual-build-cjs-loads` first answered PREREQUISITE NOT MET (seven root dists absent) and passed once they were built; `pnpm --dir ui exec vitest run scripts/` passed on `17e15c7f` (170 files, 4979 tests, 2 skipped). Re-run on `17e15c7f` after the last commits: `check:type-check-debt`, `check:type-check-coverage`, `check:nul-bytes`, `check:test-source-alias`, `check:cross-package-test-inputs`, `check:published-files`, `check:undeclared-dep-imports`, `check:sourcemap-no-sources-content`, `check-empty-changeset`, `check-changeset-no-major`, `check-adr-0087-registration`, all exit 0. Outside the derived list, `pnpm --dir ui run check:new-line-citations`: 0 new citations. - **Full dogfood** (the narrowing arm): `pnpm exec turbo run build --filter='@objectstack/dogfood^...'` (69 tasks), then `pnpm --filter @objectstack/dogfood test` under the lock on `17e15c7f`: exit 0, Test Files 420 passed, 3 skipped (423); Tests 3496 passed, 36 skipped (3532). No failure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgXDwFw71MwSG9FKYDQ <!-- signed: domain:ui#1 · os-sales · session_01L6bhgWn6zhNa4LL7VB1rtL --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c17719d commit d996c38

41 files changed

Lines changed: 4339 additions & 2294 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/i18n': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
perf(i18n, app-shell)!: the marketplace pages' strings leave the eager language packs for a lazy `marketplace` namespace
7+
8+
Clause-②: yes (narrowing)
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (runtime-interface-only ui/packages/i18n/src/locales/en.ts#TranslationKeys) the key type of the console's own translation catalogue: no Zod schema, no spec declaration and no stored metadata reads it, so the compiler is the channel that reaches every caller -->
12+
13+
The console loads one language pack eagerly, `en`, and its chunk had grown to 59,951 of the 60,000 gzipped bytes its ceiling allows. About 3 KB of it was the `marketplace.*` group, read only by the two marketplace pages, which are lazy routes. That group now lives in `@object-ui/i18n/namespaces/marketplace`: ten catalogues, one per built-in language, each its own chunk, fetched when a marketplace page opens. The console's `en` chunk reads 57,010 bytes.
14+
15+
- **The pages wait for their text.** App-shell's marketplace catalogue and package pages render their load skeleton until the catalogue for the console's language (and `en`, the fallback) has arrived, and again after a language switch, so a visitor never sees English in a translated console or a raw key. A catalogue that cannot be fetched shows the console's own "Something went wrong" with Try again, which fetches it again.
16+
- **`useMarketplaceNamespace()`** (from the new subpath) is the hook behind that frame: it answers `loading`, `ready` or `failed` with a `retry()`, merges the catalogues into the page's i18next instance without overwriting a host's own `resources`, and uses a catalogue already made resident by `registerBuiltInLocales()` without fetching it.
17+
- **What stays in the packs.** Studio's packages page, outside the marketplace route, draws marketplace installs with the same components: their keys (`marketplace.installedAdditiveNote`, `marketplace.notLoaded.*`, `marketplace.action.uninstall`, `marketplace.action.uninstalling`, `marketplace.action.details`, `marketplace.uninstall.confirm`, `marketplace.uninstall.confirmNotLoaded`, `marketplace.uninstall.successInList`, `marketplace.uninstall.successNotLoaded`, `marketplace.install.dependencyMissing.*` and `marketplace.install.protocolCheckSkipped.*`) stay in every pack.
18+
- **Every string still in every language.** No text changed. `@object-ui/i18n/locales` (the all-ten door) hands out each language complete, its pack merged with its namespace catalogue, so key parity and `registerBuiltInLocales()` still cover the moved keys.
19+
20+
**BREAKING** (`@object-ui/i18n`, TypeScript and the pack modules): the package entry's `en`, the exported `TranslationKeys` (`typeof en`) and the pack modules `@object-ui/i18n/locales/<code>` no longer hold the moved `marketplace.*` keys. A `t()` call that names one still compiles, since its key is a `string`. A component outside app-shell's marketplace pages that reads one of those keys calls `useMarketplaceNamespace()` and renders it once the answer is `ready`; code that reads the catalogue objects directly reads them from `@object-ui/i18n/locales`, whose ten languages are complete.

‎ui/apps/console/vite.config.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,46 @@ export default defineConfig({
12351235
{ name: 'i18n-ns-studio-en', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]studio[\\/]en\.ts$/, priority: 84 },
12361236
{ name: 'i18n-ns-studio-zh', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]studio[\\/]zh\.ts$/, priority: 84 },
12371237
//
1238+
// The `marketplace` namespace (objectstack#30588): the pack group the
1239+
// two marketplace pages read, moved out of the ten packs so the
1240+
// eager `i18n-locale-en` chunk stops carrying it. All ten catalogues
1241+
// are `import()`ed by `packages/i18n/src/namespaces/marketplace/index.ts`
1242+
// when a marketplace page mounts, none is resident, so one group per
1243+
// catalogue for the rule above. The loader module gets a group too:
1244+
// without one it would fall to `i18n-runtime` below and be eager,
1245+
// while its only reader is the marketplace pages' frame.
1246+
//
1247+
// ⛔ Both the loader's group and the frame's (`marketplace-namespace-gate`,
1248+
// app-shell's `MarketplaceNamespaceGate.tsx`, the one module that
1249+
// imports the loader) take `includeDependenciesRecursively: false`,
1250+
// and the frame needs its group at all, for two measured reasons
1251+
// (console build of objectstack#30588, eager closure read from
1252+
// `eager-closure.json`):
1253+
// - with rolldown's default the loader's group followed its imports
1254+
// and took `locales/registry.ts` out of `i18n-runtime` and the
1255+
// dynamic-import preload helper out of `framework`; both are
1256+
// eager, so the group became an eager 2,374 B gz chunk;
1257+
// - without a group of its own the frame, shared by the two lazy
1258+
// marketplace pages, landed in the chunk those pages share with
1259+
// the eager Studio packages page (`MarketplaceRowActions.tsx` and
1260+
// the refusal readers), which is EAGER by that co-tenancy, and
1261+
// pulled the loader into the eager closure with it (+1,281 B gz).
1262+
// With both, the loader, the frame and the ten catalogues are lazy,
1263+
// the shared chunk is the one the base build emits, and the only
1264+
// change to the eager closure is `i18n-locale-en`'s.
1265+
{ name: 'i18n-ns-marketplace', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]index\.ts$/, priority: 84, includeDependenciesRecursively: false },
1266+
{ name: 'i18n-ns-marketplace-en', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]en\.ts$/, priority: 84 },
1267+
{ name: 'i18n-ns-marketplace-zh', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]zh\.ts$/, priority: 84 },
1268+
{ name: 'i18n-ns-marketplace-ja', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]ja\.ts$/, priority: 84 },
1269+
{ name: 'i18n-ns-marketplace-ko', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]ko\.ts$/, priority: 84 },
1270+
{ name: 'i18n-ns-marketplace-de', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]de\.ts$/, priority: 84 },
1271+
{ name: 'i18n-ns-marketplace-fr', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]fr\.ts$/, priority: 84 },
1272+
{ name: 'i18n-ns-marketplace-es', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]es\.ts$/, priority: 84 },
1273+
{ name: 'i18n-ns-marketplace-pt', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]pt\.ts$/, priority: 84 },
1274+
{ name: 'i18n-ns-marketplace-ru', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]ru\.ts$/, priority: 84 },
1275+
{ name: 'i18n-ns-marketplace-ar', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]marketplace[\\/]ar\.ts$/, priority: 84 },
1276+
{ name: 'marketplace-namespace-gate', test: /[\\/]packages[\\/]app-shell[\\/]src[\\/]console[\\/]marketplace[\\/](?:MarketplaceNamespaceGate\.tsx|marketplaceFrameHolding\.ts)$/, priority: 84, includeDependenciesRecursively: false },
1277+
//
12381278
// ⛔ `i18n-runtime` takes `includeDependenciesRecursively: false`
12391279
// for the reason `data-adapter` below does (objectui#9345, read out
12401280
// there in full): it outranks `framework` (83 over 80), and since
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The marketplace pages' frame for their own strings (objectstack#30588).
5+
*
6+
* The `marketplace.*` keys these pages read are not in the console's eager
7+
* language pack: they are `@object-ui/i18n`'s lazy `marketplace` namespace,
8+
* fetched when a page here mounts (the namespace module's header says why).
9+
* This frame renders the page only once the namespace answers `ready` for the
10+
* instance's language, so a visitor sees the copy-free load skeleton the pages
11+
* already use (`MarketplaceResolving`), never an English sentence in a
12+
* translated console nor a raw key. A language switch while a page is open
13+
* shows the skeleton again until that language's catalogue has arrived.
14+
*
15+
* That swap unmounts the page body while the visitor stays on the page, so an
16+
* unmount cleanup that means "the visitor left" (`SampleDataLeaveBanner`)
17+
* asks `useMarketplaceFrameHolding()` (`marketplaceFrameHolding.ts`) first.
18+
*
19+
* A catalogue that cannot be fetched is said once, in the console's own error
20+
* words (resident pack keys, which need no fetch), with a Try again that asks
21+
* for it again — never a skeleton that waits forever, and never a retry loop.
22+
*
23+
* ⛔ Every component in this directory that reads a `marketplace.*` key renders
24+
* under this frame (the two pages wrap their bodies in it), or is one of the
25+
* files Studio's packages page also renders — `MarketplaceRowActions.tsx`,
26+
* `dependencyMissing.ts`, `protocolCheckSkipped.ts` — whose keys stayed in
27+
* the packs for that reason and need no frame.
28+
* `__tests__/marketplaceNamespaceBoundary.test.ts` holds both halves.
29+
*/
30+
31+
import { useCallback, useLayoutEffect, useRef, type ReactNode } from 'react';
32+
import { RotateCcw } from 'lucide-react';
33+
import { Button, Empty, EmptyTitle } from '@object-ui/components';
34+
import { useObjectTranslation } from '@object-ui/i18n';
35+
import { useMarketplaceNamespace } from '@object-ui/i18n/namespaces/marketplace';
36+
import { MarketplaceResolving } from './MarketplaceResolving.js';
37+
import { MarketplaceFrameHolding } from './marketplaceFrameHolding.js';
38+
39+
export function MarketplaceNamespaceGate({ children }: { children: ReactNode }) {
40+
const namespace = useMarketplaceNamespace();
41+
const holding = useRef(false);
42+
useLayoutEffect(() => {
43+
holding.current = namespace.status !== 'ready';
44+
});
45+
const isHolding = useCallback(() => holding.current, []);
46+
return (
47+
<MarketplaceFrameHolding.Provider value={isHolding}>
48+
{namespace.status === 'ready' ? (
49+
children
50+
) : namespace.status === 'failed' ? (
51+
<MarketplaceNamespaceFailed onRetry={namespace.retry} />
52+
) : (
53+
<MarketplaceResolving />
54+
)}
55+
</MarketplaceFrameHolding.Provider>
56+
);
57+
}
58+
59+
function MarketplaceNamespaceFailed({ onRetry }: { onRetry: () => void }) {
60+
const { t } = useObjectTranslation();
61+
return (
62+
<div
63+
className="mx-auto flex w-full max-w-6xl items-center justify-center p-8"
64+
data-testid="marketplace-namespace-failed"
65+
>
66+
<Empty>
67+
<EmptyTitle>{t('console.errors.somethingWentWrong')}</EmptyTitle>
68+
<Button variant="outline" size="sm" onClick={onRetry} className="mt-4 gap-2">
69+
<RotateCcw className="h-4 w-4" />
70+
{t('console.errors.tryAgain')}
71+
</Button>
72+
</Empty>
73+
</div>
74+
);
75+
}

‎ui/packages/app-shell/src/console/marketplace/MarketplacePackagePage.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ import { SuggestedBindingsPanel, type SuggestedBindingsStrings } from '../../com
112112
import { ConnectorCredentialsStep } from './ConnectorCredentialsStep.js';
113113
import type { SuggestedBinding } from '../../services/suggestedBindingsApi.js';
114114
import { errorCodeIs } from '@object-ui/types';
115+
import { MarketplaceNamespaceGate } from './MarketplaceNamespaceGate.js';
115116

116117
/**
117118
* Whether a cloud install lands in the environment this console renders, read
@@ -163,7 +164,19 @@ function versionEntryId(version: string): string {
163164
return `marketplace-version-${version}`;
164165
}
165166

167+
/**
168+
* The page under the frame that fetches its strings first — the
169+
* `marketplace` namespace (`MarketplaceNamespaceGate.tsx` says why).
170+
*/
166171
export function MarketplacePackagePage() {
172+
return (
173+
<MarketplaceNamespaceGate>
174+
<MarketplacePackagePageBody />
175+
</MarketplaceNamespaceGate>
176+
);
177+
}
178+
179+
function MarketplacePackagePageBody() {
167180
const navigate = useNavigate();
168181
const { packageId, appName } = useParams<{ packageId?: string; appName?: string }>();
169182
const { isAdmin, isResolved } = useWorkspaceAdminStatus();

‎ui/packages/app-shell/src/console/marketplace/MarketplacePage.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { useProtocolCheckSkippedText } from './protocolCheckSkipped.js';
5656
import { ProtocolCheckSkippedNote } from './ProtocolCheckSkippedNote.js';
5757
import { ConnectorCredentialsStep } from './ConnectorCredentialsStep.js';
5858
import { packagesHref } from '../../views/metadata-admin/packageSource.js';
59+
import { MarketplaceNamespaceGate } from './MarketplaceNamespaceGate.js';
5960

6061
/**
6162
* The card grid's track (objectui#12616): a card is never narrower than 240px,
@@ -306,7 +307,19 @@ type OrgDeployState =
306307
| { phase: 'served'; manifestId: string; version: string | undefined; name: string; app: ServedApp | null }
307308
| { phase: 'timeout'; manifestId: string; version: string | undefined; name: string };
308309

310+
/**
311+
* The page under the frame that fetches its strings first — the
312+
* `marketplace` namespace (`MarketplaceNamespaceGate.tsx` says why).
313+
*/
309314
export function MarketplacePage() {
315+
return (
316+
<MarketplaceNamespaceGate>
317+
<MarketplacePageBody />
318+
</MarketplaceNamespaceGate>
319+
);
320+
}
321+
322+
function MarketplacePageBody() {
310323
const navigate = useNavigate();
311324
const { appName } = useParams();
312325
const { isAdmin, isResolved } = useWorkspaceAdminStatus();

‎ui/packages/app-shell/src/console/marketplace/SampleDataLeaveBanner.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@
1616
* It is raised only for a package this session recorded loading sample data
1717
* into (`sampleDataNotice.ts`), and only while a notification provider is
1818
* mounted: the page renders this component under that guard, since
19-
* `useNotifications()` throws outside one.
19+
* `useNotifications()` throws outside one. A language switch that sends the
20+
* page's frame back to its load skeleton unmounts this component too, with
21+
* the installer still on the page: that is not a leave, so no banner is
22+
* raised (`useMarketplaceFrameHolding`).
2023
*/
2124

2225
import { useEffect, useRef } from 'react';
2326
import { useNavigate } from 'react-router-dom';
2427
import { useNotifications } from '@object-ui/react';
2528
import { useObjectTranslation } from '@object-ui/i18n';
2629
import { attachBanner, requestClearConfirm, sampleDataNotice, withdrawBanner } from './sampleDataNotice.js';
30+
import { useMarketplaceFrameHolding } from './marketplaceFrameHolding.js';
2731

2832
export function SampleDataLeaveBanner({ manifestId }: { manifestId: string | null }) {
2933
const { notify, dismiss } = useNotifications();
3034
const { t } = useObjectTranslation();
3135
const navigate = useNavigate();
36+
const isFrameHolding = useMarketplaceFrameHolding();
3237
// The cleanup below runs once the page is gone, so it reads the functions
3338
// of the last render rather than those of the render that set it up.
3439
const latest = useRef({ notify, dismiss, t, navigate });
@@ -41,6 +46,8 @@ export function SampleDataLeaveBanner({ manifestId }: { manifestId: string | nul
4146
// Back on the package page: its install note speaks for the sample data.
4247
withdrawBanner(manifestId);
4348
return () => {
49+
// The frame took the page back for a language's strings: still here.
50+
if (isFrameHolding?.()) return;
4451
const notice = sampleDataNotice(manifestId);
4552
if (!notice) return;
4653
const { notify: raise, dismiss: drop, t: tr, navigate: go } = latest.current;
@@ -60,7 +67,7 @@ export function SampleDataLeaveBanner({ manifestId }: { manifestId: string | nul
6067
});
6168
attachBanner(notice.manifestId, () => drop(id));
6269
};
63-
}, [manifestId]);
70+
}, [manifestId, isFrameHolding]);
6471

6572
return null;
6673
}

0 commit comments

Comments
 (0)