Skip to content

fix(console): the Settings pages send the session language, so server-composed copy matches the page - #34072

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-5plpus
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-5plpus

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #33857

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:控制台「设置」页的四个请求(读设置列表、读某个命名空间、保存、执行动作)现在带上会话界面语言作为 Accept-Language,取值来源是页面根元素的 lang 属性(document.documentElement.lang),和元数据、数据请求用的同一个来源。
  • 为什么改:服务端按请求语言拼文案(本地化页的「默认币种已锁定」横幅、保存被拒的提示、动作结果),之前这四个请求只带浏览器自己的语言,中文会话在英文浏览器上看到的这几处是英文,页面其余部分是中文。
  • 风险与回滚:只改 settings/api.ts 的请求头构造;没有界面语言时不发这个头,行为与之前完全相同;不碰服务端、不碰鉴权。回滚即还原这一个提交。
  • 先看:ui/apps/console/src/pages/settings/api.ts 的 jsonHeaders;再看 api.envelope.test.ts 末尾新增的一组测试。
  • 两分钟验证:pnpm --dir ui exec vitest run apps/console/src/pages/settings/api.envelope.test.ts,预期 28 条全绿。
  • 需要你做的:无,席位落地。

What changes

jsonHeaders() in ui/apps/console/src/pages/settings/api.ts is the header set all four /api/settings calls send (listSettingsManifests, getSettingsNamespace, saveSettingsNamespace, runSettingsAction). It now adds Accept-Language from document.documentElement.lang when that is non-empty.

  • Source: the html element's lang attribute is what createAuthenticatedFetch in @object-ui/auth stamps on the console's metadata and data calls, and the i18n provider keeps it in step with the language switcher. No second locale source is introduced; the docblock says the two stamps must agree.
  • The server side is unchanged: requestLocaleOf in service-settings' settings-routes.ts already reads the top Accept-Language tag (the card measured curl -H 'Accept-Language: zh-CN' answering the zh-CN currency-lock copy).
  • Unchanged: with no lang on the html element the header is left out and the browser's own goes, as before. getJudgedClientAddress (the /api/v1/auth client-address read in the same module) is not one of the four calls and returns no composed copy; it is untouched.

Tests

One new top-level describe in the module's existing harness api.envelope.test.ts (no new file), against the harness's fetch stub:

  • each of the four calls, with the html element's lang set to zh-Hans, sends Accept-Language: zh-Hans and keeps Accept / Content-Type: application/json;
  • CONTROL: each of the four calls with an empty lang on the html element sends no Accept-Language;
  • a language switch between two calls reaches the second (['en', 'zh-Hans']).

No existing test was edited.

Acceptance notes

  • Routing these four calls through createAuthenticatedFetch itself (the move services/approvalsApi.ts made) was weighed and not taken here: it also adds the bearer, X-Tenant-ID, session-rotation adoption and the 401/403 session events to the settings calls, and every settings test whose fetch double has no headers member (about 14 files under pages/settings/__tests__/) would need a forced edit, because that transport reads response.headers. That is a transport change, not this card's. Left as an open question for the seat.
  • The card's acceptance (the Localization banner reads 默认币种已锁定:USD on a zh-CN session) is pinned at the request layer here; it was not re-measured in a browser against a live server. The card's own curl control shows the server answers that copy for Accept-Language: zh-CN / zh-Hans.

Verification

Ablation (fix committed first; restored blob == HEAD)
  • node scripts/ablation-replace.mjs deleted the if (lang) headers['Accept-Language'] = lang; line (anchor 1 -> 0, blob 55abaf1f -> 4caa2363) and ran api.envelope.test.ts: 5 failed | 23 passed (28). Red: the four "sends the session language" cases and the language-switch case. The four CONTROL cases stay green. Restore: blob == HEAD 55abaf1f, git diff HEAD empty.
Local runs at d41fbf1
  • pnpm --dir ui exec vitest run apps/console/src/pages/settings/ (under the verify lock): Test Files 40 passed (40); Tests 387 passed (387).
  • pnpm --filter @object-ui/console run type-check (after turbo run build --filter='@object-ui/console^...', under the verify lock): exit 0.
  • node scripts/pm/dispatch-gates.mjs --commands: 36 derived families, each run, all exit 0; --ran reconciliation: 36 derived, 36 run, 0 NOT-MEASURED, 0 UNRUN. pnpm --dir ui exec vitest run scripts/: 171 files passed, 2 skipped; 5065 tests passed, 2 skipped.
  • Branch rebased onto main e71ecc1 before the runs; nothing pushed before the rebase.

Generated by Claude Code

The four /api/settings calls stamp Accept-Language from <html lang>, the
source the console's authenticated fetch reads, so server-composed copy
(currency-lock banner, save refusals, action results) arrives in the
session's language. No <html lang> leaves the header to the browser.

Claude-Session: https://claude.ai/code/session_01ADHkmTMJ1tS7fhvnNnQSxg
Co-authored-by: Claude <noreply@anthropic.com>
@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 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi

维护者速读

席位意见:ACCEPT。复用 Console 唯一的语言来源,没有新造第二个来源;未改动 #33985 待裁的语言种子文件。

席位核对 — ACCEPT · domain:ui#2 · head d41fbf12 · 2026-11-15T18:02Z

  • Shape: draft → main, first line Fixes #33857, no other closing keyword. Clause-②: no / Metadata-protocol: none match the claim (6898254288).
  • Diff read by the seat: api.ts +26/−4 (one helper), one test file +66, one changeset +10 (@object-ui/console patch). Inside the claimed surface; languageSeed.ts / LocalizationFetchProvider.tsx untouched.
  • Gates: check-runs on d41fbf12 = success 32, skipped 13, failure 0, read 2026-11-15T18:02Z. Dev: 36/36 derived gates run, 0 NOT-MEASURED; ablations red, controls green.
  • Accepted deviation: the card's browser acceptance was not measured on a live server; it is pinned at the request layer (the card measured the server's locale pick correct with curl).
  • Open question answered A: keep the header in this helper; moving the settings calls onto createAuthenticatedFetch is not this card.
  • Out of scope: none. Landing: mergeable_state clean; no governed path. Ready + auto-merge now.

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

2 participants