Repository navigation
Commit 33c3b5e
perf(i18n, console)!: the Developer pages' and Connect an AI assistant strings load on demand, off the eager English pack (#32255)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBQpNH669Kx1m7Ee7gTKTkq7)_
Fixes #32225
Clause-②: yes (narrowing)
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台「开发者」四个页面(API 控制台、流程运行、公开表单、集成与 API)、「连接 AI 助手」页面和用户记录的「AI
助手」页签所用的 `console.developer.*`、`connectAgent.*` 两组文案,从 11
种语言的语言包里整块剪出,放进新的懒加载命名空间
`@object-ui/i18n/namespaces/developer`,打开这些界面时才下载;marketplace
命名空间与它共用一个新的加载器 `createPackNamespace`。
- 为什么改:每次首屏都要下载的 `i18n-locale-en` 已顶到 60.5 KB 上限(61,881 / 62,000
B),新增英文键的 PR(#32050、#32172、#32124、#32184、#32195)在合并队列里因
`check:eager-closure` 被弹出;现在是 57,330 B,留出 4,670 B 余量,上限一个字节没动。
- 风险与回滚:文案一个字没改,每种语言仍然完整(`@object-ui/i18n/locales` 合并了所有命名空间);读这些键的组件都包在
`DeveloperNamespaceGate` 里,未加载时显示骨架屏,加载失败显示「出错了 / 重试」,绝不显示英文或原始键名。导出的
`en` / `TranslationKeys` 少了这两组键(BREAKING,见 changeset),回滚即 revert 本 PR。
- 先看:`ui/packages/i18n/src/namespaces/packNamespace.ts`(从 marketplace
抽出的通用加载器)、`ui/packages/i18n/src/namespaces/developer/index.ts`(新命名空间)、`ui/packages/app-shell/src/console/connect/DeveloperNamespaceGate.tsx`(加载框)、`ui/apps/console/vite.config.ts`(11
个 `i18n-ns-developer-*` 分块)。
- 两分钟验证:`cd ui && pnpm exec vitest run
packages/i18n/src/__tests__/developer-namespace.test.ts
packages/app-shell/src/console/connect/DeveloperNamespaceGate-32225.test.tsx
apps/console/src/pages/developer/IntegrationsPage.developerNamespace-32225.test.tsx`,预期全绿;`pnpm
--dir ui run check:eager-closure` 显示 `i18n-locale-en 56.0 KB / 60.5 KB`。
- 需要你做的:本 PR 共 8,041 行,超过 3,000 行人工合并线(不涉及受管路径),请 os-zhuang 或 hotlong
任一人 Approve;批准后席位转 ready 入合并队列,或由维护者直接合并。
## What changes
- **A second pack-shaped lazy namespace, `developer`.**
`console.developer.*` (the four Developer pages) and `connectAgent.*`
(the Connect an AI Assistant widget and the AI Assistants tab of a
`sys_user` record) are cut whole from all eleven language packs into
`ui/packages/i18n/src/namespaces/developer/<tag>.ts`, one literal `() =>
import()` per platform locale tag, exactly the shape of `marketplace`
(#30588 / #30640). `zh-Hant.ts` is generated from `zh-Hans.ts`
(`gen:zh-hant`, registered in `scripts/regen-artifacts.mjs`). Call sites
are unchanged: they still call `t('console.developer.…')` /
`t('connectAgent.…')` on the default namespace, and the catalogues
deep-merge into the page's instance.
- **One loader for both namespaces.** The marketplace index's runtime
(language resolution, the two-catalogue wait, the resident short-circuit
under `registerBuiltInLocales()`, the silent `addResourceBundle`, retry)
moved verbatim into `namespaces/packNamespace.ts` as
`createPackNamespace({ name, groups, probeKey, loaders })`. The resident
check now reads any dotted group path, not only a top-level key.
`@object-ui/i18n/namespaces/marketplace` exports the same names as
before.
- **A frame on every reader.** `DeveloperNamespaceGate` (app-shell,
exported) renders children once the namespace answers `ready`, a
copy-free skeleton while it loads, and the console's resident "Something
went wrong / Try again" when a catalogue cannot be fetched. The four
Developer pages, `ConnectAgent` and `ManagedPersonAssistants` render
their bodies inside it. `PACK_NAMESPACE_FRAMES` in
`ui/scripts/check-i18n-call-site-keys.mjs` now lists the developer
namespace's two frame directories, so a namespace-only key read anywhere
else is refused (class 9).
- **Chunks.** Eleven `i18n-ns-developer-<tag>` groups (priority 84) in
`ui/apps/console/vite.config.ts`. The loader module stays in
`i18n-runtime` on purpose: app-shell registers the connect widgets
eagerly.
- **The complete door.** `@object-ui/i18n/locales` merges each pack with
its marketplace and developer catalogues, so key parity,
`registerBuiltInLocales()` and every test that reads a complete language
still see every key.
- **Budget note, ceiling unchanged.** A dated reading above
`'i18n-locale-en': 62_000` in
`ui/scripts/check-eager-closure-budget.mjs`. ⛔ The ceiling and its
baseline are not moved.
- **Changeset** `.changeset/32225-developer-lazy-namespace.md`:
`@object-ui/i18n` patch and `@object-ui/console` patch, with the
declaration lines and an ADR-0087 not-required marker
(runtime-interface-only `TranslationKeys`, the #30640 precedent).
`@object-ui/app-shell` is private and gets no row.
`Clause-②: yes (narrowing)`, measured: the package entry's `en`, the
exported `TranslationKeys` and the pack modules
`@object-ui/i18n/locales/<code>` lose the two groups. The claim line
said `no`; this is the same narrowing #30640 declared for marketplace.
### Readings (`ui/apps/console/dist/eager-closure.json`, `CI=true vite
build`)
| | `main` dee2e92 | this branch | change |
|---|---:|---:|---:|
| `i18n-locale-en` gzip | 61,881 B | 57,330 B | −4,551 B |
| headroom under the 62,000 B ceiling | 119 B | 4,670 B | |
| eager closure gzip | 2,267,784 B | 2,264,606 B | −3,178 B |
| `i18n-runtime` gzip | 7,913 B | 8,997 B | +1,084 B |
| `src` gzip | 66,844 B | 67,111 B | +267 B |
| eager chunks | 105 | 105 | |
The branch reading of `i18n-locale-en` is unchanged after merging `main`
e1146e8 (57,330 B, closure 2,264,584 B). `i18n-runtime` grows by the
shared loader plus the developer loader; `src` by the frame.
## Tests
- `developer-namespace.test.ts` (new): lazy by construction (one literal
`import()` per catalogue, one catalogue per built-in language, no static
catalogue import, built on `packNamespace.js`), cut and not copied (each
catalogue holds the two groups only, no pack holds either, the packs'
other `console` groups stay), the complete door (every language carries
pack and namespace keys; the entry's `en` is the resident pack alone),
and the loader (refuses an unshipped code; loads a catalogue once and
answers the same object after). Key parity across languages stays
`all-locales-key-parity`'s.
- `DeveloperNamespaceGate-32225.test.tsx` (new): zh-CN `ConnectAgent`
shows the skeleton, then Chinese, never English or a raw key; ja
`ManagedPersonAssistants` the same; a page that does not read the
namespace fetches no developer chunk; ar fetch failure shows the
resident error and Try again recovers.
- `IntegrationsPage.developerNamespace-32225.test.tsx` (new): zh-CN cold
mount, skeleton, then Chinese.
- Existing suites held to two namespaces:
`marketplace-namespace.test.ts`, `zh-hant-generated.test.ts`,
`ui/scripts/__tests__/check-i18n-en-drift.test.ts`.
- Ablations (`scripts/ablation-replace.mjs`): drop the namespace
registration (`addResourceBundle` in `packNamespace.ts`) → red; let the
gate render children while loading → red. Both restored, blob == HEAD,
`git diff HEAD` empty.
<details><summary>Test and gate log</summary>
- vitest (`cd ui`): `packages/i18n/`, app-shell `console/connect/` and
`marketplace/`, console `pages/developer/`, three `ui/scripts` suites:
188 files, 3028 passed, 16 failed on the first run; the 4 files holding
them fixed and re-run 143/143 green.
- type-check: `@object-ui/i18n` (both tsconfigs),
`@object-ui/app-shell`, `@object-ui/console`: exit 0. eslint on touched
files: 0 errors.
- `pnpm --dir ui run check:eager-closure`: exit 0 (`i18n-locale-en 56.0
KB / 60.5 KB ceiling, headroom 4.6 KB`).
- `check-i18n-call-site-keys`: exit 0, the developer namespace read 255
times, all inside its frames. `check-i18n-en-drift`: exit 0, 0 keys
removed. `check-i18n-dead-keys`: report identical to `main` dee2e92
apart from walked-file counts (the three
`connectAgent.capabilities.example*` needs-review rows are on `main`
too).
- `dispatch-gates.mjs --commands` at 7b1de06: 76 derived, 76 run, all
exit 0 (`check:dts-closure` and `check:dual-build-cjs-loads` first
exited 1 / 3 for missing dists, re-run 0 after a full `pnpm build`,
119/119 tasks); `--ran`: 76 accounted, 0 NOT-MEASURED, 0 UNRUN.
- dogfood (title carries `!`): `pnpm --filter @objectstack/dogfood test`
under the lock at 7b1de06 after the full build: 446 files passed, 3
skipped; 3712 tests passed, 42 skipped; VERDICT command-exit 0.
- Head 04e5c1e merges `main` bb67b98 (no `ui/` change beyond
`ui/packages/auth`, no `en` key change): the four namespace and frame
test files re-run 109/109, `check-i18n-call-site-keys` exit 0.
</details>
## Acceptance notes
- Five merge-queue ejections at `i18n-locale-en`: the chunk is now
57,330 B against 62,000 B, 4,670 B of headroom, without moving the
ceiling or the baseline.
- Every locale moved with the subtree; no string text changed.
- No first-load surface reads the moved keys: a cold load of `/home`
fetches no `i18n-ns-developer-*` chunk.
## Verification
Production preview build of this branch (`vite preview`) over a showcase
dev boot, admin sign-in, en-US and zh-CN, each surface opened from a
cold load in a fresh context:
| surface | en | zh-CN |
|---|---|---|
| `/home` | no developer chunk | no developer chunk |
| Developer › Integrations, API console, Flow runs, Public forms |
`i18n-ns-developer-en` | `i18n-ns-developer-zh-Hans` + `-en` |
| Account › Connect an AI Assistant | `i18n-ns-developer-en` |
`i18n-ns-developer-zh-Hans` + `-en` |
| Setup › Users › a user › AI Assistants tab | `i18n-ns-developer-en` |
`i18n-ns-developer-zh-Hans` + `-en` |
No raw `console.developer.*` / `connectAgent.*` key text on any page, no
failed frame, no skeleton left after load; the zh-CN pages read in
Chinese (for example 「集成与 API」, 「连接 AI 智能体(MCP)」, 「已授权的 AI 助手」). Shots:
project folder `ui-orders/32225-shots/` (14 files).
<details><summary>Browser harness notes</summary>
The console builds with a relative `base` (`./`), which the preview
server does not rewrite for deep links, so the harness mapped
`/apps/…/assets/*` requests to `/assets/*`; the chunk names in the table
are the requested file names. The "Agent key" default in the API-key
name box is a hard-coded initial value in `AgentConnectSection.tsx` on
`main`, not a key of this namespace.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzhSZ8Aow2HhBCMAYta
<!-- signed: domain:ui#2 · os-support-ai ·
session_01WGufzge87Pae2h7uSQzX8H -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent a923d47 commit 33c3b5e
48 files changed
Lines changed: 4670 additions & 3371 deletions
File tree
- .changeset
- scripts
- ui
- apps/console
- src/pages/developer
- packages
- app-shell/src
- console/connect
- i18n
- scripts
- src
- __tests__
- locales
- namespaces
- developer
- marketplace
- scripts
- __tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
940 | 940 | | |
941 | 941 | | |
942 | 942 | | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
943 | 955 | | |
944 | 956 | | |
945 | 957 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
152 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
209 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
210 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1280 | 1280 | | |
1281 | 1281 | | |
1282 | 1282 | | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1283 | 1304 | | |
1284 | 1305 | | |
1285 | 1306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
260 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
261 | 274 | | |
262 | 275 | | |
263 | 276 | | |
| |||
0 commit comments