Skip to content

fix(console): save a language picked on the sign-in page as the person's own when they have none - #30539

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-3ct8gd
Nov 5, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-3ct8gd

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread
domain:ui#4 · os-sales · session_01L6bhgVfPeFZkN1FP93imKU

维护者速读

  • 改了什么:在登录页选了语言、本人还没设过语言偏好的,登录时这个选择会存成本人的语言偏好(sys_user.locale),换设备、发邮件都跟着走。
  • 为什么改:A language picked on the sign-in page is dropped when someone else last used that browser, and the sign-in list differs from the signed-in one #30338 只做到「选的语言在这台浏览器上留住」,没有存进个人偏好;登录页靠整页跳转离开,跳转前没人写库。
  • 风险与回滚:只有登录页选过语言才多发两次请求(读一次本人记录、写一次),已有偏好不改,写失败照常登录。回滚即撤本 PR。
  • 先看:LoginPage.tsx Post-login effect 新增的第 0 步;useUserLocale.ts 的 saveSignInLanguagePick。
  • 两分钟验证:退出登录,在登录页底部的地球图标里选 Français,用一个没设过语言的账号登录,进个人资料页,语言应为 Français;刷新仍是法语。
  • 需要你做的:无,席位落地。

Fixes #30399

Clause-②: yes (widening)
Metadata-protocol: none

What changes

  • @object-ui/app-shell useUserLocale.ts: a language picked while signed out is now also held for one save (signInPickToSave, page-load memory, no storage key). New saveSignInLanguagePick(userId, writer?) reads the person's sys_user row and, only when locale is unset, writes the pick through the column's one write door, update('sys_user', id, { locale }), the call useLanguageSelection makes. It spends the pick on the first call, sends no request when nothing was picked, and never rejects: a failed read or write logs once at error (the pick stays in the device slot, so this browser still renders it). hasSignInLanguagePick() answers whether there is anything to save.
  • Barrel: hasSignInLanguagePick, saveSignInLanguagePick and the SignInLanguagePickWriter type are exported from @object-ui/app-shell (hence Clause-②: yes (widening); the claim's line says no and names this case for the seat to correct).
  • LoginPage.tsx, the Post-login orchestration effect only: a new step 0 starts the save once (ref latch) when there is a pick, holds the spinner, and re-runs the effect when the save settles (state). Steps 1 to 3 are unchanged, so all five exits wait on it:
Exit Applies Why
OAuth provider hand-off (followOauthAuthorize) yes a full navigation to the relying party; same person, same page-load
Mobile sign-in hand-off (assign(handoff.target)) yes full navigation; a session the hand-off refuses for its age is held to the form and saves nothing (it is not a sign-in yet)
No organization (assign(root or redirect)) yes full navigation
Several organizations (assign('/organizations')) yes full navigation
Final redirect (assign(redirect or root), after the single-org auto-select) yes full navigation; the auto-select itself is not an exit

The "Read public auth config" effect and the DevAdminRow render are untouched (#30420 is changing them in parallel).

Why

Measured on origin/main f6faf751 and in a live sign-in (Verification below): the pick ends in the objectui-locale slot, sys_user.locale stays empty. Two findings the order's suggested route needed adjusting for:

  • No adapter on the sign-in page. The order suggested awaiting adapter.update('sys_user', id, { locale }). useAdapter() answers null on /login: the console mounts AdapterProvider inside ConnectedShell, and the public auth routes render outside it. So saveSignInLanguagePick builds the same ObjectStackAdapter AdapterProvider builds (same base URL, createAuthenticatedFetch) for the one save. Live, that is one GET /api/v1/discovery, one GET and one PATCH on /api/v1/data/sys_user/ID, all before the next page-load's discovery.
  • The owner-change keeper spends its copy first. A language picked on the sign-in page is dropped when someone else last used that browser, and the sign-in list differs from the signed-in one #30338's signedOutPick is consumed by the owner-change event, which fires (inside AuthProvider) before the post-login effect runs, and never fires when the browser's last owner signs in again. So the save reads a second page-load copy, cleared by the same signed-in-switch path.

Route B as ruled: awaited before the navigation, no fire-and-forget, no new storage marker.

Acceptance notes

  • Bound, unchanged from A language picked on the sign-in page is dropped when someone else last used that browser, and the sign-in list differs from the signed-in one #30338: memory lasts one page-load. A pick followed by a reload of the sign-in page, or by an identity provider round-trip, is not saved.
  • No timeout on the save. A request that hangs keeps the spinner up as long as the adapter's own fetch does; a refused or failed request lets the sign-in proceed. Noted, not added: a bound would be a choice of number nobody has ruled on.
  • Same shape, reported, not fixed (order): RegisterPage.tsx renders the same footer language menu and leaves by the same four window.location.assign exits after a sign-up that signs the person in, so a pick made there is kept in the slot but not saved. SetupPage.tsx has no language menu of its own; a pick made on another signed-out page earlier in the same page-load would reach its two exits unsaved.
  • Observed, not this card's: with no pick, the existing post-login effect can navigate twice in the test harness (once before the organizations answer, once after). The new pins assert only that the page leaves and saves nothing in that case.
  • An existing language is kept even when the deployment does not offer it (live row 2: a stored de stays de); what renders then is the existing reader's business, unchanged here.

Tests

  • ui/packages/app-shell/src/hooks/__tests__/userLocaleSignInPick-30338.test.tsx, new top-level describe (8 cases): saved for a new owner; saved when the last owner signs in again (no owner change); an existing language is read and kept; CONTROL no pick, no request; spent once; a signed-in switch replaces it; a failed write resolves, logs at error, slot kept; a failed read writes nothing.
  • ui/apps/console/src/pages/auth/__tests__/signInLanguagePick-30399.test.tsx (new, 11 cases): for each of the five exits, nothing leaves while the save is in flight and the expected exit is taken once it settles; CONTROL for each exit with no pick; a session the mobile hand-off refuses saves nothing.
vitest: locale hook files, the app-shell layout suite and every console auth page test (merged head 3e162ec)
pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/hooks/__tests__/userLocaleSignInPick-30338.test.tsx packages/app-shell/src/hooks/__tests__/userLocaleOwnerChange-10193.test.tsx packages/app-shell/src/hooks/__tests__/userLocale-10059.test.tsx packages/app-shell/src/layout/ apps/console/src/pages/auth/
 Test Files  172 passed (172)
      Tests  1180 passed (1180)
os-verify-lock: VERDICT command-exit 0
Ablations (each through scripts/ablation-replace.mjs, mutation proven on disk, restored: blob == HEAD, git diff HEAD empty)
A1 LoginPage: drop the step-0 return (the save starts, the exit runs beside it = route C)
   signInLanguagePick-30399: 5 failed | 6 passed (11) — every exit case red, every CONTROL green
A2 useUserLocale: drop the "column already set" check
   userLocaleSignInPick-30338: 1 failed | 12 passed (13) — "a language of their own already saved is kept"
A3 useUserLocale: do not hold the pick for the save
   userLocaleSignInPick-30338: 4 failed | 9 passed (13) — the four cases that need a pick
Type check
pnpm --filter @object-ui/app-shell type-check   (tsc --noEmit && tsc -p tsconfig.test.json)
os-verify-lock: VERDICT command-exit 0
pnpm build (turbo, includes @object-ui/console tsc + vite build) on 3e162ec6
os-verify-lock: VERDICT command-exit 0

Verification

Live: showcase pnpm dev -- --fresh plus the console on vite, Playwright en-US, 1440 wide. Users created by the seeded admin. Row 1 before = this head with step 0 disabled in place (ablation-replace --hold, restored after).

Row Who Picked sys_user.locale after sign-in Slot Language after reload
1 before no language of their own Français empty fr fr
1 after no language of their own (0 orgs, root exit) Français fr fr fr
2 after has de Français de (unchanged) fr fr
3 after no language of their own nothing empty, no PATCH sent empty en-US
4 after seeded admin (1 org, final exit) Français fr fr fr

Requests in row 1 after, in order: POST sign-in/email, GET discovery, GET sys_user/ID, PATCH sys_user/ID, then the next page-load's GET discovery.

Gates (merged head 3e162ec)

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 35; all 35 exit 0, codes captured before any pipe. pnpm --dir ui exec vitest run scripts/ was killed once by the container's memory limit while other gates ran (exit 1, SIGKILL) and re-run alone: 170 passed, 2 skipped files, exit 0. Extra, outside the derivation: pnpm --dir ui run check:spec-symbols exit 0; node scripts/check-sdui-manifest.mjs exit 0 (also derived). dispatch-gates --ran: 35 derived, 35 run, 0 NOT-MEASURED (a derived zero).

Branch claude/project-thread-3ct8gd is the card thread's platform-assigned branch (not claude/issue-30399-*).

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgUkfsVq9sKkVSugapT


Generated by Claude Code

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

Copy link
Copy Markdown
Contributor Author

domain:ui#4 · os-sales · session_01L6bhgVfPeFZkN1FP93imKU

维护者速读

席位核对 — ACCEPT · head e29693a

  • 形态:7 文件 +497/−2(源码 LoginPage.tsx +29、useUserLocale.ts +97/−2、index.ts +6;两份测试 +352;写入普查 affordanceGrantMap-12082.test.tsx +2;changeset @object-ui/app-shell 与 @object-ui/console 各 patch)。check-governed-merges --pr 30539:NOT governed,499 行 ≤ 3000。Fixes #30399,draft,目标 main,标题无 !。
  • 复核面:TIER_DEFAULT(声明面:Clause-②: yes (widening),@object-ui/app-shell 入口新增 hasSignInLanguagePick、saveSignInLanguagePick 与类型 SignInLanguagePickWriter;没有 packages/spec 路径、没有受管路径、没有收窄),由本席在此写出。认领行已由补记 6661094583 改为 yes,并把 index.ts 补进文件面。
  • 席位逐行读:第 0 步在 if (!user) return 之后、五个出口之前:signInPickSaveRef 三态闩只起一次保存,saving 时整个 effect 返回,保存落定后 setSignInPickSaved(true) 让 effect 重跑,原来的 1–3 步一字未改,所以五个出口都等它。handoff.holdForSignIn 时跳过(会话还不算登录)。saveSignInLanguagePick 先把 pick 置空再 await,只花一次;读到 locale 已有值就不写;写只走 update('sys_user', id, { locale }),与 useLanguageSelection 同一道门;永不 reject,失败记一次 error。登录页在 ConnectedShell 外、useAdapter() 为 null,因此自建一个与 AdapterProvider 同 baseUrl、同 createAuthenticatedFetch 的 ObjectStackAdapter;@object-ui/data-objectstack 本来就是 app-shell 的依赖,import.meta.env.VITE_SERVER_URL 在 app-shell 已有先例。「Read public auth config」effect 与 DevAdminRow 都没动,与本席 PR fix(console): hide the dev admin chip when email and password sign-in is off #30531(Console sign-in page offers "Sign in as dev admin" when email and password sign-in is off, and the server refuses it #30420)不相交,后落地者合 main 即可。
  • 前提实测:dev 报告 6660977920。改前登录页选 fr 登录后 sys_user.locale 为空;改后真栈走查:无偏好者存为 fr、刷新仍 fr,已有 de 不变,没选不发 PATCH,单组织管理员走最终出口也存为 fr。消融三腿(去掉第 0 步的 return、去掉「已有值不写」、不留 pick)分别 5/1/4 红,还原后 blob 与 HEAD 相同。dev 在 3e162ec6 上:172 文件 1180 例绿;派生门禁 35 条全部 exit 0,0 NOT-MEASURED;check:spec-symbols、check-sdui-manifest exit 0;pnpm build exit 0。
  • 门禁 check-runs:3e162ec6 上 Test UI (5/16) 红:ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx 的写入普查发现新写入点 useUserLocale.ts :: saveSignInLanguagePick :: update 未登记,是本 PR 自己的缺口。卡线程在 e29693aa 补了一条 outOfFamily 登记(紧挨 useLanguageSelection 那条,理由:只在本人 sys_user.locale 为空时写本人自己的列,失败不拦登录),没有动 UNMAPPED_BACKLOG;本席逐字读过这两行。现 head 上 55 个,44 success,11 skipped(ui-only diff 的预期跳过),0 红,Test UI (5/16) 与各 Type Check 均绿。mergeable_state clean。
  • 接受的偏差:建议路线里的「await 上下文 adapter」改为一次性自建 adapter(登录页没有 adapter 上下文,实测成立);index.ts 在认领文件面外,是导出所必需,已补记;写入普查文件 ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx 也在文件面外,是新写入点的必登记项;保存没有超时,请求挂住时转圈跟随 adapter 自身 fetch,dev 没有自定数字,本席同意不加。
  • 范围外去向:RegisterPage.tsx 同形(同一语言菜单、注册即登录后同样四个整页出口,选择只留在浏览器):不另立卡,由仍开着的 A language picked on the sign-in page is dropped when someone else last used that browser, and the sign-in list differs from the signed-in one #30338 承载,本席在本 PR 与 First-run flow: small frictions a new deployment's first people meet #30125 第 2 项(同改 RegisterPage.tsx)都落地后,作为 A language picked on the sign-in page is dropped when someone else last used that browser, and the sign-in list differs from the signed-in one #30338 的余项派出。SetupPage.tsx 没有自己的语言菜单:记录,不立卡。测试中无 pick 时既有 effect 会导航两次:dev 已写进 Acceptance notes,本 PR 不改。
  • 落地条款:中继 pr_ready + automerge_enable。合并后由 Fixes 关卡,席位同一笔摘掉 pm:dispatched 并留落地评论。

Generated by Claude Code

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 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.

Sign-in page: a language picked before signing in is not saved as the person's own preference when they have none (save after #30157)

1 participant