Repository navigation
fix(console): the Settings pages send the session language, so server-composed copy matches the page - #34072
Merged
Conversation
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>
Contributor
Author
|
domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi 维护者速读
席位意见:ACCEPT。复用 Console 唯一的语言来源,没有新造第二个来源;未改动 #33985 待裁的语言种子文件。 席位核对 — ACCEPT · domain:ui#2 · head
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()inui/apps/console/src/pages/settings/api.tsis the header set all four/api/settingscalls send (listSettingsManifests,getSettingsNamespace,saveSettingsNamespace,runSettingsAction). It now addsAccept-Languagefromdocument.documentElement.langwhen that is non-empty.langattribute is whatcreateAuthenticatedFetchin@object-ui/authstamps 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.requestLocaleOfinservice-settings'settings-routes.tsalready reads the topAccept-Languagetag (the card measuredcurl -H 'Accept-Language: zh-CN'answering the zh-CN currency-lock copy).langon the html element the header is left out and the browser's own goes, as before.getJudgedClientAddress(the/api/v1/authclient-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
describein the module's existing harnessapi.envelope.test.ts(no new file), against the harness'sfetchstub:langset tozh-Hans, sendsAccept-Language: zh-Hansand keepsAccept/Content-Type: application/json;langon the html element sends noAccept-Language;['en', 'zh-Hans']).No existing test was edited.
Acceptance notes
createAuthenticatedFetchitself (the moveservices/approvalsApi.tsmade) 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 whosefetchdouble has noheadersmember (about 14 files underpages/settings/__tests__/) would need a forced edit, because that transport readsresponse.headers. That is a transport change, not this card's. Left as an open question for the seat.默认币种已锁定:USDon 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 forAccept-Language: zh-CN/zh-Hans.Verification
Ablation (fix committed first; restored blob == HEAD)
node scripts/ablation-replace.mjsdeleted theif (lang) headers['Accept-Language'] = lang;line (anchor 1 -> 0, blob 55abaf1f -> 4caa2363) and ranapi.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 HEADempty.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(afterturbo 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;--ranreconciliation: 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.maine71ecc1 before the runs; nothing pushed before the rebase.Generated by Claude Code