Repository navigation
feat: add scheduled light and dark theme switching - #31196
JLargent42 wants to merge 2 commits into
Conversation
dcae718 to
2bebec7
Compare
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The schedule is off by default, so nobody gets it without choosing it. It is not product shape, and nothing in the repository already does this. Notes
What this change shipsInventory (8 items) — 7 justifiedIntent: let the dashboard switch itself between light and dark at sunrise/sunset or at set times, while a pick by hand still works. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 30ccd0d Description read[DESCRIPTION-READ] bd427893364eccc0cf514ff2107bdf13907e4518720350757a401520be54c706 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the reader read the toggle and the method choice correctly, and the place is right. The screenshots show the older copy, though: the toggle reads "Switch on a schedule" and the time fields "Light from". Notes
[UX-REVIEWED] 30ccd0d Description read[DESCRIPTION-READ] 42af589f6310fd71903cb00d2a2190e2a2eb8615362f040c445c32eea57bd0c6 That sha256 names everything this verdict read: the PR description, plus the 8 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the schedule stays on the device, and switches go through the existing theme surface without a fourth mode value. Notes
[DESIGN-REVIEWED] 30ccd0d Description read[DESCRIPTION-READ] b32554db2c890d4c6a693b07e47950aacdaea3fbb835025ee044b0fd7bf1cdae That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — 🔴 changes requested (blocking)Reviewed Blocking: after a reload, the scheduled mode is shown but the BLOCKING — website/src/components/ThemeScheduleDriver.tsx:607 Trigger: The schedule is on and the period is dark. The workspace mode is light. [BLOCK-MERGE] 30ccd0d Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- website/src/components/ThemeScheduleDriver.tsx:62 -- Boot reconciliation overwrites the scheduled mode cache
BLOCKING -- website/src/components/ThemeScheduleDriver.tsx:58 -- Schedule edits retain a failed-write manual override
[BLOCK-MERGE] 30ccd0d Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — Rung: MEDIUM. Any reload where the scheduled mode differs from the workspace mode (the normal case while a schedule is on) sets F2 — Rung: LOW. It needs every one of these: the hand-pick write is refused even after every reclaim tier ( False positive or not applicable? A repository writer can comment: |
|
4db6c86 addresses the review blocks on 2bebec7: (Opus) a polar day/night boundary now starts after the previous day's last sun event and same-mode boundaries merge, so polar day stays light and doesn't re-switch at midnight; (GPT F1) a tab follows a boundary another tab records; (GPT F2) the driver waits for themeBootReady; (GPT F3) a refused storage write leaves the snapshot unchanged (no render loop) and the boundary is remembered in memory. Each has a test that fails on 2bebec7. Also adds the feature-map row for the Source Gates feature-map check. |
Code change approver recommendation: A person should decideWhy: the decider raised 2 possible problems and estimates a 72% chance that this change introduces a defect; a person should check them. The schedule logic, the store and the settings UI look well built and are tested, and the earlier-head polar-day and sibling-tab bugs appear fixed. But the driver switches modes through the Mode picker's Things to check (possible problems the decider raised; at this confidence many turn out to be fine):
An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
4db6c86 to
8c2f559
Compare
|
Review follow-up for 4db6c86 → 8c2f559:
|
8c2f559 to
412cc94
Compare
|
412cc94 addresses the blocks on 8c2f559:
|
412cc94 to
2420d11
Compare
Settings > Display > Theme gains a 'Switch on a schedule' toggle under the Mode picker. It switches light/dark at local sunrise and sunset, computed on the device from a typed coarse latitude/longitude (no network call, no geolocation), or at fixed light and dark times. Times follow the device time zone. The schedule applies once per boundary through the existing setTheme, so a mode picked by hand holds until the next switch. Closes #21097
2420d11 to
30ccd0d
Compare
Problem / Motivation
Goal: Let users switch the dashboard between light and dark automatically, at local sunrise and sunset or at fixed times, while still changing the theme by hand.
Today the Mode picker offers Auto (follow the OS), Light and Dark. There is no way to have the dashboard turn light during the day and dark at night on its own schedule.
Why it matters
Light theme is easier to read beside a bright window during the day; dark theme is easier at night. Without a schedule the user flips the mode by hand twice a day, or has to tie it to an OS setting they may not want changed.
Not a goal
theme_modevalues.What changed (motivation → approach → change)
Goal → reuse the existing theme surface and
setThemerather than add a fourth mode → a small device-local schedule plus a driver.website/src/utils/themeSchedule.ts(pure): the schedule type and parser, the sunrise equation (sunTimes, refraction-corrected, polar day/night handled), and the boundary logic (scheduledModeAt,dueScheduledMode). Days and clock times are built with the localDateconstructor, so everything follows the device time zone, DST included. With the sunrise/sunset method but no location, the fixed times apply.website/src/hooks/useThemeSchedule.ts: auseSyncExternalStorestore overlocalStorage["mc-theme-schedule"](cross-tab viastorage). Editing when the schedule switches clearsappliedAtso it applies at once.website/src/components/ThemeScheduleDriver.tsx(mounted besideThemeExperienceLayerinmain.tsx): applies the scheduled mode through the samesetThemethe Mode picker uses, once per boundary, recording it inappliedAt. A manual mode change therefore holds until the next scheduled switch. Re-checks at the next boundary (at least hourly) and on tab visibility.website/src/pages/settings/ThemeScheduleSettings.tsx, mounted under the Mode picker inDisplayPanel.tsx: the toggle (shows the device time zone), method (Sunrise and sunset / Custom times), latitude/longitude with range validation and today's computed times, or the two time fields.SettingsInputacceptstype="time".en-XA); settings registry and UI index regenerated (settingsExtract.tsmaps the new panel file);docs/system-specs/modules/themes.mddocuments it.Why not a fourth
schedulemode value: it would need a backend validator change, an ElectronthemeSourcemapping, and would leak a device-local schedule into the workspace-widetheme_mode.Backwards compatibility
Compatible: purely additive; with the schedule off (the default) nothing runs and the existing modes behave as before.
Removes nothing: no key, value, route or capability is removed or tightened.
Tests
website/src/utils/themeSchedule.test.ts: sunrise/sunset within minutes of published times (Seattle June solstice, London December solstice), polar day/night, fixed times, an inverted (night-shift) schedule, sun-method fallback without a location, once-per-boundary application with a manual change held until the next boundary, parser defaults.website/src/components/ThemeScheduleDriver.test.tsx: off does nothing; on applies at once and switches at the next boundary; a manual pick holds until the next boundary.website/src/pages/settings/ThemeScheduleSettings.test.tsx: toggling writes the schedule; fixed times are stored; a typed location computes sun times with nofetchand no geolocation call; an out-of-range latitude is not stored.Proof: not provable -- frontend test (prove.py runs Python only); all three files import modules this PR adds, so they fail without it.
Rebased on
4f7b1ee782; theui-index.generated.jsonconflict was resolved by taking main's file and regenerating it withnpm run gen:ui(settings registry re-run withnpm run gen:settings, no change). Local gate (scripts/local-gate.pyplan, run at 2 workers): frontend related 519 files / 14252 tests pass; typecheck, eslint on changed files andgen-ui-index --checkpass; backend related batch 1 passes and batch 2 passes apart from the host reds below; black/subprocess-encoding, comment-history, brand-name and file-line-cap pass. Host reds outside this diff, each reproduced with the same failures on the merge-base4f7b1ee782in a temporary worktree:file_explorer/tests/test_server.py,test_design_tweak_backend.py,test_design_tweak_devproc.py(/local/home403s),test_docker_entrypoint.py,test_crew_image_build_plan.py(libffi),test_auto_improvement_members.py,test_native_skill_projection.py(essential-source sandbox),test_dashboard_gallery_approvals.py(platform composition),test_kas_bundle.py(no network),test_mcp_slim_entry.py,test_living_ui_harness.py, and onetest_find_ui_auto.pycase (continue with github).Manual verification
Rendered the real
ThemeScheduleSettingsrows in light and dark through a throwaway capture entry (vitest pinsTZ=UTC, so times read in UTC): off, sunrise/sunset without a location, with a location (today's times shown), and custom times. Not yet exercised against a running gateway across a real boundary; the driver test covers the boundary with fake timers.Screenshots / video
Related Issues
Closes #21097
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.