Skip to content

emrg: gui — persist theme/language selection in settings (fix rant 2026-08-27T22:22:50) - #1050

Merged
argszero merged 1 commit into
masterfrom
feature/gui-settings-persistence
Aug 27, 2026
Merged

emrg: gui — persist theme/language selection in settings (fix rant 2026-08-27T22:22:50)#1050
argszero merged 1 commit into
masterfrom
feature/gui-settings-persistence

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Fixes the GUI bug where theme (light/dark/system) and language (system/zh/en) selections are not persisted: every time the settings panel is reopened (or the GUI restarts), appearance resets to "Follow system".

Root cause

  1. config.toml had no [gui] themeemrg:getSettings (main.js) always returned theme: "system".
  2. SettingsPanel theme/language buttons only called setTheme/setLocale (DOM/localStorage) and never called saveSettings, so nothing was written to config.toml.
  3. emrg:saveSettings already supported writing toml.gui.theme — persistence was just one IPC call away.

Changes

  • main.js: lang added to validateConfig whitelist; saveSettings writes toml.gui.lang; getSettings returns lang ("" = follow system).
  • i18n.tsx: I18nProvider converted from stateless to stateful + LOCALE_CHANGED_EVENT broadcast so switching locale re-renders the UI immediately (localStorage write alone no longer triggers React re-render).
  • SettingsPanel.tsx: theme/lang clicks now persist via saveSettings (silent success, error message on failure); persisted lang applied when panel opens.
  • App.tsx: boot effect restores persisted theme + lang from getSettings (degrades gracefully when window.emrg is absent, e.g. jsdom/preview).
  • SettingsPanel.test.tsx: theme/lang tests now assert saveSettings payloads; added reopen-persistence test (persisted values applied, no reset to system).

Verification

  • tsc --noEmit: clean
  • renderer vitest: 446/446 passed
  • GUI node tests: 85 passed, 8 skipped
  • vite build: OK
  • pytest tests/: 1126 passed, 1 skipped
  • import + CLI: green

Refs: rant 2026-08-27T22:22:50

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260827-232221 (1/3). Head 4cf9ba2, CI test + test-windows green (33086890790), MERGEABLE/CLEAN. Local re-verification: tsc clean, vitest 446/446, GUI 85 pass + 8 skip, vite build OK, pytest 1126+1, import + CLI green.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260827-233730 (2/3). Head 4cf9ba2 unchanged since cyc20260827-232221 LGTM (1/3), CI test + test-windows green (33086890790), MERGEABLE/CLEAN. Local verification (from author cycle): tsc clean, vitest 446/446, GUI 85 pass + 8 skip, pytest 1126+1, import + CLI green.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260827-234739 (3/3). Head 4cf9ba2 unchanged since cyc20260827-233730 LGTM (2/3), CI test + test-windows green (33086890790), MERGEABLE/CLEAN. No ❌ in review history — 3 consecutive ✅ from distinct cycles (232221, 233730, 234739). Merging.

@argszero
argszero merged commit 64c3568 into masterAug 27, 2026
2 checks passed
argszero added a commit that referenced this pull request Aug 27, 2026
…derer count against reality (#1052)
* emrg: test — fix Agent.md renderer count drift (445->448) + guard renderer count against reality
R2254: #1049/#1050 added renderer tests (daemonBridge/Shell/SettingsPanel/
WorkspaceView) without bumping Agent.md — the renderer count drifted
445 -> 448 silently. The doc-count guard only validates each "(N: ...)"
line's internal sum (parts == headline), not reality, and the pytest CI
job has no node_modules to run vitest.
FIX: Agent.md renderer line corrected to 448 with per-file counts aligned
to vitest's executed numbers (workspaceView 29->27, WorkspaceView 8->10,
daemonBridge 14->15, Shell 24->25, SettingsPanel 19->20).
GUARD: test_doc_counts.py::test_renderer_count_matches_docs — a static
count of test-case definitions (^\s*(it|test)\( per file under
renderer/src) equals vitest's executed total exactly (verified for all 44
files), so it runs in plain pytest and turns any future renderer-count
drift red immediately.
Python tests 1127 -> 1128 (new guard), Agent.md synced.
* test: escape regex in docstring (fix SyntaxWarning in renderer count guard)
---------
Co-authored-by: argszero <argszero@gmail.com>
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
Sign up for freeto 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

@argszero