Skip to content

fix(desktop): language switching + window drag hardening#27

Merged
hqhq1025 merged 1 commit intomainfrom
wt/dev-bugs
Apr 18, 2026
Merged

fix(desktop): language switching + window drag hardening#27
hqhq1025 merged 1 commit intomainfrom
wt/dev-bugs

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

  • Bug 1 — Language switching broke in Settings (Appearance tab): AppearanceTab.handleLocaleChange persisted the locale via window.codesign.locale.set() but never called setLocale() from @open-codesign/i18n, so i18next.changeLanguage() was never invoked. The UI only reflected the new language after a full app restart. Fixed by mirroring the correct two-step flow already used by LanguageToggle: persist → applyLocale(persisted) → update component state. Also updated the in-UI hint from "Restart the app after changing the language." to "Language changes take effect immediately."

  • Bug 2 — Window drag hardening: TopBar already has WebkitAppRegion: 'drag' on the <header> and 'no-drag' on the button cluster. Added an explicit 'no-drag' inline style directly on the <button> element inside LanguageToggle as a defensive measure against CSS inheritance ambiguity in Electron's hiddenInset mode.

  • New test: Added a vitest case to packages/i18n/src/i18n.test.ts that asserts setLocale() immediately updates getCurrentLocale() and i18n.t() without requiring a page reload. Runs clean with the 8 pre-existing tests (9 total now).

Test plan

  • pnpm dev → Settings → Appearance → switch zh-CN / en → UI updates immediately (no restart)
  • Restart the app → language choice is persisted from previous session
  • TopBar LanguageToggle button still works (clickable, not accidentally treated as drag surface)
  • macOS: drag the empty space in the TopBar between the wordmark and the button cluster → window moves
  • pnpm -r typecheck and pnpm lint both pass
  • pnpm exec turbo run test → all 10 packages pass (41 tests total)

Compatibility, upgradeability, no bloat, elegance

  • Compatibility ✅ — no schema or IPC changes
  • Upgradeability ✅ — no new migration paths
  • No bloat ✅ — zero new dependencies; re-uses existing @open-codesign/i18n export
  • Elegance ✅ — Settings now follows the same pattern as LanguageToggle

Bug 1 — Settings language change took effect only after restart:
- AppearanceTab.handleLocaleChange called window.codesign.locale.set()
  to persist but never invoked setLocale() from @open-codesign/i18n,
  so i18next.changeLanguage() was never called.
- Now: persist → applyLocale(persisted) → setLocale(applied), matching
  the same pattern LanguageToggle already used.
- Update the "Restart the app" hint to "Language changes take effect immediately."

Bug 2 — Window drag: add explicit WebkitAppRegion:'no-drag' directly on
the LanguageToggle <button> element so interactive controls are
unambiguously non-draggable regardless of CSS inheritance quirks in
Electron's hiddenInset mode.

Test: add vitest that asserts setLocale() updates getCurrentLocale() and
i18n.t() without a page reload (9 tests now, up from 8).

Signed-off-by: hqhq1025 <1506751656@qq.com>
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence issues found on added/modified lines.

Summary

  • Review mode: initial
  • No issues to report in the current diff.
  • Not found in repo/docs: docs/VISION.md, docs/PRINCIPLES.md.
  • Residual risk: no UI/E2E coverage in this PR for the language toggle drag-region behavior or locale-persist failure path in renderer interactions.

Testing

  • Not run (automation)

open-codesign Bot

@hqhq1025 hqhq1025 merged commit b1cf20c into main Apr 18, 2026
6 checks passed
@hqhq1025 hqhq1025 deleted the wt/dev-bugs branch April 18, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant