feat(web): sync per-user locale preference end-to-end (persist + session-load apply) #1181
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/i18n-locale-sync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Wires the per-user locale preference (spec 058 / ADR 0111, backend PR #1180, frontend infra PR #1178) end-to-end in the web app.
What changed
SessionUser(src/lib/session/session.ts) gainslocale: string | null, populated at both store-construction sites:POST /api/sessionreturnsUserAccountwithout locale, soGET /api/sessionis fetched in parallel withgetSetupStatus()(no extra sequential round-trip); non-fatal on failure (falls back tonull→ no sync).locale: null.CurrentSession(src/lib/api/upload.ts) exposeslocale?: string | null(optional so a not-yet-upgraded API build still type-checks;undefinedtreated as null).persistLocaleToAccount(locale):PUT /api/session/preferencesvia the existingapiClient, never rejects (console.warn on failure),keepalive: trueso the request survives the page reloadsetLocale()triggers right after — without it the account would stay out of sync and the choice would be reverted on the next session load.persistLocaleToAccount(value)alongsidesetLocale(value)(cookie remains the immediate transport).refreshHeaderSelfPerson+ setup login:syncLocaleFromAccount(session.locale)so a stored account locale beats a stale browser cookie. Match/unsupported/null no-op guards against reload loops.Verification (all green locally)
npm run check→ 0 errors (18 pre-existing warnings in untouched files, same as baseline)npm run build→ ✓ built in 33.77snpm run test:unit→ 200/200 (26 files), incl. newlocaleSync.spec.ts(8 tests: PUT method/url/body/keepalive, never-rejects on 400/401/network failure, sync apply/no-op/unsupported) andsession.spec.ts(3 tests). Specs pass even on a fresh checkout without compiledsrc/lib/paraglide/.Behavioral caveats
AppShelldoes not hydrate theSessionUserstore (pre-existing design, documented at line 181: only setup/register populate it); it only gained the sync call. Store construction sites updated as required.EXTRACTION.md: localeSync wiring marked done (wave-5 line updated).
714f9c6917c6946379d8