feat(web): system theme option — follow the OS prefers-color-scheme (stretch of #67) - #90
Open
dchaudhari7177 wants to merge 2 commits into
Open
feat(web): system theme option — follow the OS prefers-color-scheme (stretch of #67)#90dchaudhari7177 wants to merge 2 commits into
dchaudhari7177 wants to merge 2 commits into
Conversation
dchaudhari7177
force-pushed
the
feat/system-theme
branch
from
July 26, 2026 15:33
dfb8b3f to
7692570
Compare
Three-way theme choice in Settings (Dark / True black / Light), replacing the OLED checkbox: - theme.ts: ThemeName gains "light"; stored-value validation keeps unknown values falling back to dark; applyTheme sets data-theme for any non-default theme. - tokens.css: a [data-theme=light] block — paper surfaces, ink text, darkened hairlines; the coral accent shifts to its deep value for contrast on paper; warn/err darkened for AA. The code card stays a dark panel deliberately. - TerminalView: light mode swaps the FULL xterm palette (One Light-derived), not just the background — the dark ANSI ramp would be unreadable on paper. Live switch keeps working via rc-theme-change. - theme.test.ts extended for the new value, fallback, and meta mirror. Closes burakgon#67
- theme.ts: ThemePreference = ThemeName | "system"; resolveTheme() maps "system" to light/dark via (prefers-color-scheme: light) with the AppLayout matchMedia guard idiom (jsdom/SSR falls back to dark); watchSystemTheme() re-applies + re-announces rc-theme-change on OS flips only while the preference is "system". - main.tsx: start the watcher right after the boot applyTheme. - SettingsPanel: fourth "System" option in the Theme select. - TerminalView: terminalTheme() resolves the preference, so an open terminal follows an OS scheme flip live via the re-fired rc-theme-change. - Tests: system round-trip + no-matchMedia fallback, OS-flip announce gating (vi.stubGlobal matchMedia stub with a change-listener registry). Stretch item from burakgon#67
dchaudhari7177
force-pushed
the
feat/system-theme
branch
from
July 27, 2026 14:11
7692570 to
102a7df
Compare
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.
The stretch item from #67 ("a fourth system option that follows
prefers-color-scheme"), as the separate PR the issue invited.pwa/theme.ts— the stored preference and the rendered palette are now distinct types:ThemeName(dark | oled | light, what tokens.css/xterm can render) vsThemePreference(ThemeName | "system").resolveTheme()maps"system"to light/dark via(prefers-color-scheme: light), using the same defensivematchMediaguard asAppLayout.useIsDesktop(jsdom/SSR → dark).watchSystemTheme()re-applies and re-announcesrc-theme-changewhen the OS scheme flips — but only while the preference is"system", so a concrete choice never gets overridden.main.tsx— starts the watcher immediately after the bootapplyTheme, so a daylight/night OS switch restyles the app (and an open terminal, which re-reads its palette onrc-theme-change) live, no reload.SettingsPanel.tsx— a fourth System option in the Theme select; still applies instantly.Tests — extends
theme.test.ts(8 passing):"system"round-trips and resolves per a stubbedprefers-color-scheme; withoutmatchMediait falls back to dark instead of crashing; the OS-flip watcher announces only while the preference is system (vi.stubGlobalmatchMedia stub with a change-listener registry, the repo's existing idiom).Verification —
pnpm typecheckclean; theme tests 8/8. End-to-end in a real browser: with the stored preference"system", booting under an OS light scheme paints paper (data-theme="light",--bg #f6f6f7) and under an OS dark scheme paints near-black with thetheme-colormeta mirrored (#0a0a0b, attribute removed).