Skip to content

feat: add Light/Dark/System theme support with title-bar synchronization (#513) - #563

Merged
carvalab merged 1 commit into
mainfrom
feat/513-dark-theme-e2e
Aug 31, 2026
Merged

carvalab merged 1 commit into
mainfrom
feat/513-dark-theme-e2e

Conversation

@carvalab

Copy link
Copy Markdown
Contributor

Same change as #547, reopened from an in-repo branch so CI runs without the fork-approval gate.

Summary

Implements #513 — end-to-end Light/Dark/System theme support across the renderer and Electron main process, with no new dependencies.

  • Settings & persistence: theme_mode (light | dark | system, default system) registered in both settings allowlists and value-validated in both write paths. No migration, no seeding; absent/invalid resolves to system.
  • Renderer theme engine: useThemeMode store + ThemeSync component — resolves system via matchMedia, toggles .dark on <html>, ownership-gated localStorage mirror, token-gated DB seed for follower windows (DB > param > mirror > OS), fire-and-forget push of the effective theme to main.
  • FOUC guard: blocking pre-paint script (param → mirror → prefers-color-scheme), precedence matrix covered by a vm-based test suite.
  • Native chrome sync: narrow set-theme-effective IPC (sender-validated) → live overlay re-color on Windows/macOS; correct initial colors everywhere (Linux: next launch, documented); ?theme= on the KDS window; effectiveTheme on get-status.
  • Settings UI: Appearance tab (ownerManager-gated, optimistic update with rollback) — labels in all 5 locales.
  • Full dark-mode coverage: Settings + panels, products, customers, tables, staff, POS modals, KDS components, dashboard — light mode pixel-stable (visually verified on every route in both themes).
  • Docs: title-bar phase-1 + platform-matrix updates.

Test Plan

  • npm run lint (0 errors), npm run build, npm run i18n:check
  • test:titlebar-window-options — theme-mode helpers
  • test:electron-api-contract — setThemeEffective typed on both sides
  • test:theme-mode-settings (new) — write-path validation, negative + persistence
  • test:theme-fouc-script (new) — FOUC precedence matrix vs the production script
  • test:reports-insights — fixtures made date-independent (they aged out of the 90-day window on Aug 31; this was breaking everyone's CI, not just this PR)
  • test:e2e:electron (new) — dark toggle, nativeTheme.themeSource system sync, relaunch persistence
  • Browser visual sweep on every route, both themes
  • Windows/macOS live overlay re-color (unit-verified; manual matrix rows added to the docs)

…ion (#513)

- theme_mode setting (light|dark|system, default system) validated in both
  write paths (IPC set-setting + HTTP wildcard PUT); no migration, no seeding
- useThemeMode store + ThemeSync component: matchMedia resolution, .dark
  toggle, ownership-gated localStorage mirror, token-gated DB seed for
  follower windows (DB > param > mirror > OS, bounded retry with real delay
  + one-shot 60s re-check after transient failure), in-window user-choice
  guard, server-truth rollback with needsServerTruth hydration delivery,
  post-login re-hydration via flo:auth-changed, set-theme-effective push
- FOUC pre-paint guard (param > mirror > prefers-color-scheme) with vm-based
  precedence matrix test
- main-process wiring: direct getDatabase() initial isDark at window
  creation, sender-validated set-theme-effective handler (overlay +
  background color, main window only), effectiveTheme on get-status,
  ?theme= on the KDS window URL
- Appearance settings tab (ownerManager-gated, optimistic + rollback, 5 locales
  incl. French from #549)
- native Electron e2e: dark toggle, nativeTheme.themeSource system sync,
  relaunch persistence; theme-mode-settings + theme-fouc-script suites;
  KDS-hardening and renderer-API expectations aligned
- full dark-mode coverage: Settings page and panels, products, customers,
  tables, staff, addon-groups, POS modals, KDS components, dashboard,
  loyalty ledger modal — light mode pixel-stable
- docs amended (title-bar-phase1, platform matrix); allowScripts field for
  local npm install scripts

Review fixes (greptile): in-window user-choice guard; DB fetch before
mirror; bounded retry with no stale mirror write-back; server-truth
rollback; one-shot follower re-check after transient outage; hydration
delivers server truth when a failed save armed it.

Ponytail cleanup: shared fetchThemeMode helper (boot + recheck dedup),
stdlib asserts in theme-mode-settings, trimmed VM stubs, optional relaunch
on relaunched harness, dead refs/conditions/comments removed (-144 lines).

Rebase follow-ups (#537/#549/#546/#562): tokenize weighted-products/refund/
period-toggle/loyalty-ledger surfaces; fr.json theme-key parity; auth
dispatch guarded for non-browser envs (auth-ui-deterministic); themed
order-card selector in quick-customer-creation e2e; dashboard KPI values
kept dark on pastel tiles; reports-insights fixtures date-independent
(upstream #562 fix adopted); test:refunds restored to the test chain;
comment hygiene (~200 lines of review-narration stripped); allowScripts
field for local npm install scripts.
@carvalab
carvalab force-pushed the feat/513-dark-theme-e2e branch from 5e09db1 to f2adf5d Compare August 31, 2026 13:09
@carvalab
carvalab merged commit 48970c2 into main Aug 31, 2026
14 checks passed
@carvalab
carvalab deleted the feat/513-dark-theme-e2e branch August 31, 2026 13:18
itsbkm added a commit that referenced this pull request Aug 31, 2026
Both this branch and the just-merged theme-support PR (#563) appended new
entries to the same npm test script chain; combined both sets.
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