Skip to content

fix(console): a signed-in open asks /i18n/locales once, not twice - #37052

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/cloud-4964-i18n-locales-once
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/cloud-4964-i18n-locales-once

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #37055

Part of objectstack-ai/cloud#4964 (the console-boots call budget, cloud#2914).
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用户无感;控制台每次打开页面少发一次「语言列表」请求,界面与行为不变。
  • 为什么做:云端控制台启动检查的请求预算超标,其中一次是框架新功能把同一个语言列表请求重复发了两遍,这里合并成一次。
  • 出错会怎样:最坏是语言菜单或流程标签的回退语言读不到,退回内置语言包,不影响使用;可直接撤回。
  • 要你做什么:无。

What changes

GET /api/v1/i18n/locales has two readers in the console, and since objectstack#36916 each sent its own request on every signed-in page open:

  • loadLocales (the globe menu's locale codes), read after the first paint;
  • loadLanguage, which since objectstack#36916 reads the declared fallbackChain / sourceLocale / codes beside the active language's bundle.

The cloud control-plane call budget measured it as i18n/locales x2 on both counted pages (cloud#4964, job 138590046931).

  • ui/apps/console/src/localesRead.ts (new): readLocales(), one shared request per page load. The parsed body is shared; each reader keeps its own parse and its own degrade-quietly rule. A failed read (non-2xx, network error, unparsable body) is handed to the readers that shared it and then forgotten, so the next reader asks again, as before.
  • loadLocales.ts and loadLanguage.ts read through it. A language switch now reuses the page load's answer instead of asking again.
  • Test seam __resetLocalesRead(), called in afterEach of the five test files that drive the real loaders (each case is its own page load).

Read first, by risk: localesRead.ts (the cache lifetime and the failure rule), then loadLocales.ts (the warn lines moved out of the try).

Two-minute check: sign in to any console and open a page with DevTools on Network, filter i18n/locales. Expect one request, where main shows two.

Tests

  • New: localesRead.sharedRead-4964.test.ts, 3 cases:
    • the boot's two loaders together ask once and each gets its answer;
    • a later reader and a language switch reuse the answer;
    • a failed read is not kept.
  • Ablation, run once: with pending = read; changed to pending = null; through scripts/ablation-replace.mjs, cases 1 and 2 go red (expected 2 to be 1, expected 3 to be 1) and case 3 stays green. The file was then restored, and git diff HEAD came back empty.
  • The @object-ui/console vitest project in full, at 419db28: Test Files 333 passed (333), Tests 3568 passed (3568). The commit after it adds only the changeset.
  • pnpm --filter @object-ui/console type-check: exit 0. --listFiles includes the new test file.

Acceptance notes

Root cause of the cloud#4964 console-boots red: pricing went from 24 to 27 calls. I measured with the same harness (verify-console-pin.mjs) on local stacks, old pin 0e83fe0 against new pin 4c4a677:

  • i18n/locales asked twice. This duplicate comes from objectstack#36916 (129e637), whose fetchDeclaredChain added a second request. This PR fixes it.
  • i18n/translations/en is new. It is also objectstack#36916: the console now fetches the declared fallback locale's bundle for its flows group on every open where the active language is not the authored one. That is the feature working as designed, not a duplicate; the budget question is the cloud seat's.
  • data/sys_user_preference?top=1 (the ui.recent per-key re-read) appeared in the CI run only. In 3 local new-pin runs and 2 old-pin runs it never showed. It is the write path's findExisting when a recents write goes out before its own load answered, which is a timing race and not a range regression.
  • Preference writes on open vary between 1 and 2 on both pins: old pin pricing measured 24 and then 23.

Measured with this branch's console, 3 runs: pricing 25 calls, 0 duplicates; welcome 25 and 26, 0 duplicates. Without it, on the new pin, 3 runs: pricing 26 with i18n/locales x2 each time.

Verification

Local gates (derived with dispatch-gates --commands, 37 families, all exit 0; reconciliation 37 derived, 37 run)

Every derived command exited 0. That covers:

  • check:nul-bytes, check:published-files, check:test-source-alias, check:type-check-coverage and check:type-check-debt;
  • check-empty-changeset --base origin/main and check-changeset-no-major --base origin/main;
  • pnpm --dir ui exec vitest run scripts/ (Test Files 172 passed, 2 skipped).

dispatch-gates --ran: "37 derived famil(ies) accounted for — 37 run, 0 NOT-MEASURED". The repo-wide lint and the rest of the farm are left to CI.


Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbX11yNi4DyGhuzqBpV

L1 ACCEPT · 2026-11-24T17:41Z · head a1e8b99 · #37055 (one i18n/locales read per page load; root cause of the cloud console-boots duplicate, objectstack-ai/cloud#4964).

席位核对

  • Shape (read by the seat): new localesRead.ts, which shares one in-flight/settled read of /api/v1/i18n/locales per page load. A failed read is not kept, so a later caller retries. loadLocales.ts and loadLanguage.ts's fetchDeclaredChain (added by feat(i18n): console flow labels follow the server's declared fallback chain #36916) both go through it and parse the same body as before. Test seam __resetLocalesRead is not exported publicly. No contract face, no governed path.
  • Root cause (measured, dev report on cloud#4964, comment 7139458310): pin 0e83fe03 vs 4c4a677 on local stacks with cloud's harness. Two reads of i18n/locales both come from feat(i18n): console flow labels follow the server's declared fallback chain #36916. With this PR on the 4c4a677 backend, pricing measures 25 and welcome 25–26, with 0 duplicates.
  • Gates (container, per report): the new test plus 5 loader files, 32/32; full @object-ui/console project 333 files / 3,568 tests; type-check 0; derived dispatch-gates 37/37; ablation red, then restored.
  • Accepted behaviour: the locales list is read once per SPA load. An environment's locale list does not change under a signed-in tab often enough to need a re-read, and a reload picks up changes.
  • Not in this PR: the remaining over-budget call on cloud page/pricing is i18n/translations/<fallback>, the feat(i18n): console flow labels follow the server's declared fallback chain #36916 feature as designed. That budget line is the cloud seat's decision on cloud#2914.
  • Landing: ready + arm. The objectstack queue requires its checks.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 24, 2026 17:42
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbX11yNi4DyGhuzqBpV

Test UI (1/16) red on a1e8b99 · 2026-11-24T17:53Z · job 138646970925. One test failed: studioAddress.guard.test.ts › "no ui source outside the builder spells one" hit the 15 s timeout. It is a whole-tree source scan of ui/, so it touches nothing this diff changes (three apps/console/src loader files). The other 502 files / 11,967 tests in the shard passed. The seat re-runs the failed job once when the run completes. If it fails again, the seat traces it rather than re-running.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit c8f44e8 Nov 24, 2026
71 of 73 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/cloud-4964-i18n-locales-once branch November 24, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

控制台每次打开只请求一次语言列表

2 participants