Repository navigation
Conversation
The theme had two states, `light` and `dark`, and every toggle stored an explicit choice. `hasStoredTheme()` then reports true for the rest of the install, so after a person touched the control once the board stopped following the device appearance and no control could put it back: a two-state toggle cannot express "follow the system". That costs more than a preference. On Android an installed app paints its status bar from the manifest `theme_color` while the status-bar icon colour comes from the operating system scheme. A board showing dark while the phone is light therefore renders dark icons on a dark bar, which reads as an unreadable status bar rather than as a theme mismatch. Add `system` as a third preference. It is stored as the absence of the key, which is what "follow the OS" already meant to the bootstrap script in `index.html`, so a reload keeps following the system and the inline script and this provider cannot disagree. The single canonical control walks light -> dark -> system, and its label names the state it moves to, so the third state is reachable without adding a widget to the two surfaces that render it.
Contributor
|
Contributor
Author
|
Addressed all three findings in ee8a71c8.
Also re-verified: |
Three findings from review of the system-theme change: - `ThemeToggle` indexes the state table with `themePreference`, so the mocks in `Auth.test.tsx` and `SidebarAccountMenu.test.tsx` crashed the suites that render it. Both mocks now supply the field. - `systemTheme` stops tracking the OS while an explicit theme is selected, so switching to `system` rendered one frame of a stale theme. The switch now reads the OS itself and applies both updates in one render. - `index.html` forced dark when `localStorage` threw, while the provider read the same failure as "follow the system". Both sides now follow the OS, so the initial class cannot disagree with the first render.
conreo
force-pushed
the
feat/system-theme-preference
branch
from
September 15, 2026 10:35
ee8a71c to
f6bf6f1
Compare
Contributor
This branch has not been deployed
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.
Thinking Path
Linked Issues or Issue Description
No public issue tracks this. Described here following the issue template.
Subsystem affected
The UI theme model:
ui/src/context/ThemeContext.tsx,ui/src/components/ThemeToggle.tsx, and their tests. No server, schema, API, or contract change.Problem or motivation
Themeis"light" | "dark"andtoggleTheme()always behaves as an explicit choice, sohasStoredTheme()is true from then on and theprefers-color-schemeeffect never attaches again. A person who prefers dark at night and light by day cannot get both, and a person who wants the board to match the device has no way back to that after one click. The initial, OS-following behaviour is the one the app advertises by default, so losing it permanently is surprising.The user-visible consequence on Android is the status bar. Chrome paints it from the manifest
theme_color, which cannot vary by scheme (color_scheme_darkis still only a W3C proposal), while the icon colour comes from the OS scheme. When the board and the OS disagree, the icons can be the same colour as the bar (Chromium 559396686 covers the dynamictheme-colorpath for installed apps). Keeping board and OS in agreement is the fix available today.Proposed solution
"system"to the preference union.themestays the resolved"light" | "dark"so existing consumers (MarkdownBody,applyTheme) are unchanged, and a newthemePreferenceexposes the choice for a control that needs to show it.systemas the absence of the key, which is exactly what "follow the OS" already means to the bootstrap script inindex.html, so the two cannot disagree and no storage format change is needed.ThemeToggleto walklight → dark → system. Its label already names the destination ("Switch to dark mode"), so it becomes "Switch to system theme" on the extra step: the third state is reachable without a second control on the two surfaces that render it.Alternatives considered
"system". Rejected: the bootstrap script would have to learn a third stored value, and two places would then decide what "system" means.theme_colorto a mid-tone so it reads acceptably under both schemes. Rejected: it degrades both schemes to hide a mismatch that this change removes at the source.Roadmap alignment
ROADMAP.mddoes not plan this work.Additional context
ThemeToggleis documented as the "canonical theme-toggle widget" whose "label, icon, and toggle behaviour stay in sync as the theme model evolves", so the model change lands in the one component by design. The two-state label contract is preserved for the first two steps; only the step afterdarkis new.What Changed
ui/src/context/ThemeContext.tsx:ThemePreferenceis"light" | "dark" | "system";themeis resolved for the document whilethemePreferencerecords the choice;systemstores no key; the OS listener attaches exactly while the preference issystem;toggleTheme()walks light → dark → system.ui/src/components/ThemeToggle.tsx: the label and icon come from a single table of the three states, naming the state the control moves to (Moon, then Monitor, then Sun).ui/src/context/ThemeContext.test.tsx: adds coverage for returning from an explicit choice to the system preference, and for the three-stop toggle; the existing tests for OS-following and for the stored-choice case are unchanged.ui/src/components/ThemeToggle.test.tsx: the mock supplies the new field, and each of the three states asserts its label.Verification
vitest run src/context/ThemeContext.test.tsx src/components/ThemeToggle.test.tsx src/lib/pwa-install-mode.test.ts src/lib/pwa-display-mode.test.tsinui: 4 files, 18 tests passed.pnpm check:token-gates: all four gates clean (colour literals, arbitrary bracket values, raw font-size, legacyhsl(var())).pnpm --filter @paperclipai/ui typecheck(tsc -b): no errors.localStorageholds nopaperclip.themekey while the preference is system.Risks
"light"or"dark"string, and absence still means "follow the OS".themegets the same resolved"light" | "dark"as before, so no rendering path changes.Model Used
deepseek-v4-flash. The model ran as a tool-using coding agent (shell, file edits, test runs) inside a coding harness. The harness did not report a context-window size or a reasoning mode.Checklist
Fixes:/Closes/Refs #OR (b) described the issue in-PR following the relevant issue template — no public issue exists, so this is described in-PR#NNN/github.com/paperclipai/paperclipURLs)