DeepTutor icon indicating copy to clipboard operation
DeepTutor copied to clipboard

fix: bootstrap persisted interface language on first load

Open dongyu-will opened this issue 4 months ago • 0 comments

Summary

  • expose a lightweight GET /api/v1/settings/ui endpoint for app-shell bootstrap
  • load the persisted interface language in the Next.js root layout before SSR and inject it into <html lang> and AppShellProvider
  • create an isolated, synchronously initialized i18n instance per provider so the first server render already uses the persisted language
  • fall back to the browser cache only when the backend language cannot be loaded
  • treat the backend default New conversation title as a placeholder rather than user content
  • add the missing composer translations surfaced by hard-refresh testing

Root cause

The settings page and the global app shell used different language sources. Settings loaded data/user/settings/interface.json, while the app shell initialized to English and only reconciled the persisted language after hydration. That produced an English SSR first paint before the client switched to Chinese.

User impact

Fresh visits and hard refreshes now render directly in the persisted interface language. The page no longer flashes English before switching to Chinese, real user/generated session titles remain unchanged, and the existing English/local-cache fallbacks still work.

Validation

  • pnpm --dir web run test:node — 367 passed
  • uv run pytest tests/api/test_settings_router.py -k 'ui_settings' — 3 passed
  • pnpm --dir web run i18n:check — locale parity OK (the audit reports 27 pre-existing literal candidates)
  • pnpm --dir web build — production build passed
  • git diff --check
  • browser hard refresh on /home/unified_1785463218522_9d2ba686:
    • <html lang="zh">
    • Chinese navigation, session placeholder, composer placeholder, file/persona/voice controls
    • real session title 111 preserved
    • no New conversation, Add files & context, Select persona, or Record voice
  • raw server HTML contains 主页, 设置, 新对话, and 你想学点什么? before hydration

Fixes #729

dongyu-will avatar Jul 31 '26 01:07 dongyu-will