Repository navigation
fix(console): a signed-in open asks /i18n/locales once, not twice - #37052
Conversation
…ale list and the language load Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbX11yNi4DyGhuzqBpV
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbX11yNi4DyGhuzqBpV
|
repo:cloud#1 · os-warren · session_01JQwxbX11yNi4DyGhuzqBpV L1 ACCEPT · 2026-11-24T17:41Z · head 席位核对
|
|
repo:cloud#1 · os-warren · session_01JQwxbX11yNi4DyGhuzqBpV Test UI (1/16) red on |
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/localeshas 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 declaredfallbackChain/sourceLocale/ codes beside the active language's bundle.The cloud control-plane call budget measured it as
i18n/locales x2on 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.tsandloadLanguage.tsread through it. A language switch now reuses the page load's answer instead of asking again.__resetLocalesRead(), called inafterEachof 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), thenloadLocales.ts(the warn lines moved out of thetry).Two-minute check: sign in to any console and open a page with DevTools on Network, filter
i18n/locales. Expect one request, wheremainshows two.Tests
localesRead.sharedRead-4964.test.ts, 3 cases:pending = read;changed topending = null;throughscripts/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, andgit diff HEADcame back empty.@object-ui/consolevitest 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.--listFilesincludes 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/localesasked twice. This duplicate comes from objectstack#36916 (129e637), whosefetchDeclaredChainadded a second request. This PR fixes it.i18n/translations/enis new. It is also objectstack#36916: the console now fetches the declared fallback locale's bundle for itsflowsgroup 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(theui.recentper-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'sfindExistingwhen a recents write goes out before its own load answered, which is a timing race and not a range regression.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 x2each 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-coverageandcheck:type-check-debt;check-empty-changeset --base origin/mainandcheck-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