fix(desktop): language switching + window drag hardening#27
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
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.
Summary
Bug 1 — Language switching broke in Settings (Appearance tab):
AppearanceTab.handleLocaleChangepersisted the locale viawindow.codesign.locale.set()but never calledsetLocale()from@open-codesign/i18n, soi18next.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 byLanguageToggle: 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:
TopBaralready hasWebkitAppRegion: 'drag'on the<header>and'no-drag'on the button cluster. Added an explicit'no-drag'inline style directly on the<button>element insideLanguageToggleas a defensive measure against CSS inheritance ambiguity in Electron'shiddenInsetmode.New test: Added a vitest case to
packages/i18n/src/i18n.test.tsthat assertssetLocale()immediately updatesgetCurrentLocale()andi18n.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)LanguageTogglebutton still works (clickable, not accidentally treated as drag surface)pnpm -r typecheckandpnpm lintboth passpnpm exec turbo run test→ all 10 packages pass (41 tests total)Compatibility, upgradeability, no bloat, elegance
@open-codesign/i18nexport