Repository navigation
feat: switch between light and dark themes on a daily schedule - #34653
Conversation
e62411d to
0d4b68c
Compare
|
Rebased: main moved in [operator: bolichen97] |
|
[operator: bolichen97] One red in the local related-test run on this head is main's, not this change's: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: Scheduled is a fourth mode value with two optional keys, and the existing readers (the resolved Notes
[DESIGN-REVIEWED] 669bb4b Description read[DESCRIPTION-READ] 9f84fd349776fe9681615bc524fdc54dc9957f532be35631983bc40d10df6c7a 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This adds a fourth Mode, Scheduled, alongside Auto, Light and Dark. No default changes, so it is not product shape. The one change that reaches everyone, the desktop focus rule, is declared and is needed because a background window now pushes its appearance every minute. Notes
What this change shipsInventory (8 items) — 7 justifiedIntent: let the dashboard switch between light and dark at two times of day the user picks. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 669bb4b Description read[DESCRIPTION-READ] 8538db98caede9545bc7a47c4e680948d3155afd01701a5a47e66084471909a7 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 blind reader read the Scheduled mode button and the "Light from" / "Dark from" time fields correctly and said they would use them. The save-failure notice is confusing, but it only appears when a save is refused. Notes
[UX-REVIEWED] 669bb4b Description read[DESCRIPTION-READ] feb6c8273178db8ec772b8c69cacb18966830d54a5d9f226b995e4e90c6ead1f That sha256 names everything this verdict read: the PR description, plus the 7 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 — ✅ no blocking findingsReviewed 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 — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
|
buluoray
left a comment
There was a problem hiding this comment.
Approve on 0d4b68c. Adds a fourth theme mode, Scheduled (light from / dark from, 07:00 / 19:00 defaults), stored as two validated workspace keys. The PUT only gains values, the default path is unchanged, and every mc-theme reader (useTheme, crew companion, Mochi, Electron native-theme) handles schedule. No defect found; the one upheld GPT finding belongs to a class that already exists on main. Decisive lines: src/kiro_crew/dashboard/handlers/core.py:515 (_CLOCK_TIME_RE, fullmatch), src/kiro_crew/dashboard/handlers/core.py:607-612 (schedule_light/dark validation), website/src/utils/themeSchedule.ts:45-51 (scheduledMode, wraps past midnight), website/src/hooks/useThemeSchedule.ts:28-35 (minute tick only while Scheduled), website/src/hooks/useTheme.tsx:1319-1323 (Electron gets the resolved mode under Scheduled), website/src/hooks/useTheme.tsx:1396-1401 (Toggle from Scheduled)
0d4b68c to
7d70104
Compare
|
Rebased: main moved in [operator: bolichen97] |
|
self-added: no
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. Adds a fourth theme mode, Scheduled, with two times stored in the workspace config. The backend checks each time against a 24-hour HH:MM pattern (fullmatch) and refuses anything else with 400. The boot and theme-config payloads, the loader, the schema and the specs are all consistent. On the frontend, the dashboard, crew companion and Mochi all use the same resolver. A one-minute clock runs only while Scheduled is on. The times are saved by their own request and a refused save is reported. Settings saves on blur, and the workspace's times are adopted at boot only if it has saved some. In the desktop app, the shell is sent the resolved light or dark, and the focus re-sync falls back correctly through resolveThemeSource. The new focus check drops only pushes from background dashboard windows, as the spec says. Each behaviour has a deterministic test, and every test, lint and build job passed; the only red checks are GitHub API rate-limit failures. I found no regression, data-loss or trust problem. 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 |
7f20a03 to
50216d6
Compare
|
Rebased: main moved in [operator: bolichen97] |
50216d6 to
6bf3e5d
Compare
|
Rebased: main moved in [operator: bolichen97] |
Add a Scheduled choice to Settings > Display > Mode. The dashboard is light from one local time and dark from another (07:00 and 19:00 until the user sets them), read on the device's own clock and time zone, and it switches while the dashboard stays open. Picking Auto, Light or Dark replaces the schedule, and Toggle Theme from Scheduled picks the appearance not on screen. The mode and both times are stored in the workspace like the existing mode, so a second browser or the desktop app switches at the same times. The desktop shell follows the resolved mode, and the crew companion and Mochi windows resolve the same schedule and repaint when the shell's appearance changes. Part of #21097 (sunrise and sunset need a location source and are not in this change).
6bf3e5d to
669bb4b
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Reviewed head 669bb4b. The theme PUT accepts only an empty value or a strict 24-hour HH:MM for the two new keys. The schedule resolver wraps past midnight correctly, and the minute clock runs only while Scheduled is selected. Times save on blur through their own request, so a refused save is shown and retried. The desktop shell gets the resolved light or dark, and the new focus check stops a background dashboard window from overriding the focused one. I ran the backend theme config tests, the four schedule and display panel frontend suites, and the window chrome and IPC desktop tests on this head, and all passed with all CI checks green, so nothing here blocks.
Problem / Motivation
Goal: Let the dashboard switch itself between light and dark at two times of day the user picks, read on the device's own clock.
Settings > Display > Mode offers Auto, Light and Dark. Someone who wants light beside a bright window by day and dark at night has to flip it by hand twice a day, or use Auto, which only follows the operating system's setting.
Why it matters
Light is easier to read in daylight and dark is easier at night. A schedule does that switch without the user thinking about it, in every browser and desktop window that shows the dashboard.
Not a goal
What changed (motivation → approach → change)
Mode gets a fourth choice, Scheduled, so the dashboard is light by day and dark at night without anyone flipping it. It shows two time fields, Light from and Dark from (07:00 and 19:00 until the user sets them). The dashboard is light from the first time until the second, wraps past midnight, and switches while it stays open. Picking Auto, Light or Dark replaces the schedule and keeps its times.
A fourth mode rather than a separate on/off schedule, so there is one answer to "what mode am I in" and a manual pick needs no rule about when the schedule takes over again.
utils/themeSchedule.tsuseTheme.tsx+useThemeSchedule.tspages/settings/DisplayPanel.tsx,components/settings.tsxconfig/sections_dashboard.py,config/loader_builders.py,dashboard/handlers/core.py,api/client/themes.ts,config-baseline.jsondashboard.theme_modeacceptsschedule;theme_schedule_light/theme_schedule_darkhold the times, so a second browser or the desktop app switches at the same times./api/config/themeaccepts""or a 24-hourHH:MMand refuses anything else with 400native-theme.js,preload.js,ipc-registrar.js,runtime/window/chrome.js,apps/crew-companion/dashboardTheme.ts,apps/mochi/src/shared/themes.tsuseTheme.tsx,providers/actionsProvider.tscomponents/OnboardingFlow.tsx,settingsRegistry.gen.ts,docs/settings-registry.generated.json,docs/ui-index.generated.json,i18n/en.context.json,i18n/locales/*.jsonThe themes, config and dashboard-handler specs describe the new mode and its two fields.
Backwards compatibility
Compatible: the theme PUT and the config schema only gain a mode value and two optional keys; every value accepted today is still accepted, and a workspace that never saves a schedule behaves as before. A build from before this change does not know
schedule, so after a downgrade the user picks a mode again. In the desktop app, a dashboard window in the background no longer sets the shared appearance while another dashboard window has focus; it sets it when it next gains focus, as it already did.Removes nothing: no key, mode, route or reader is taken away.
Tests
test/test_api_theme_config.pypassed 20 times at-n0, 10 times at-n 4besidetest_config_patch.pyandtest_config_schema.py, and in a shuffled order (seed 10821).useTheme.schedule.test.tsx,dashboardTheme.test.ts,DisplayPanel.test.tsxandDisplayPanel.pseudolocale.test.tsxpassed 5 times with--sequence.shuffle.website/electron/test/window-chrome-theme-mode.test.js,window-lifecycle.test.jsandipc-registrar.test.jspassed in order and 3 times in random order (--test-randomize, seeds 11, 222 and 3333). Thewindow-chrome-theme-mode.test.jscase fails with the shell's focus check removed. TheDisplayPanel.test.tsxtime-field case fails with the save-on-blur reverted, and the refused-save case inuseTheme.schedule.test.tsxfails with the save'sonErrorremoved or with the times sent through the shared theme request.website/src/test/useTheme.schedule.test.tsx: with light 07:00 / dark 19:00 and a fake clock at 18:59:30, Scheduled is light and turns dark within a minute without a reload; a manual Light pick then holds; Toggle Theme from Scheduled picks the other appearance; saving times persists both and applies them at once; a refused save is reported, even with a mode write right after it, until a later save succeeds; a second browser adopts the workspace's times at boot.website/electron/test/window-chrome-theme-mode.test.js: a push from a background dashboard window while another dashboard window has focus leaves the shared appearance alone; the focused window's own push applies, and so does a push while a companion window or no window has focus.ipc-registrar.test.js: the appearance message hands its sender to the shell.website/src/test/dashboardTheme.test.ts: the crew companion window resolves Scheduled from the stored times, repaints on the shell's appearance change and stops listening on cleanup.website/src/test/DisplayPanel.pseudolocale.test.tsx: the Scheduled option is translated and still writesschedule.website/src/test/DisplayPanel.test.tsx: typing a time saves nothing until the field loses focus, then saves once; a cleared field keeps the saved time; a refused save shows its notice under the times, and leaving a field saves the same pair again.test/test_api_theme_config.py: the PUT storesscheduleand both times, returns them from every theme payload, and refuses7:00,24:00,19:00:00, a trailing newline and a number.Manual verification
Ran the change in an isolated gateway (seeded
minimaldata home, never the real one), opened Settings > Display > Theme in Chromium with the clock fixed in UTC, and picked Scheduled: at 12:00 the dashboard was light and at 20:30 dark, with the 07:00 / 19:00 defaults showing. With Dark picked, the two time fields are hidden. With the theme PUT answered 500 in the browser, changing Light from to 06:30 and leaving the field kept 06:30 on screen and showed the notice under the times. The desktop shell's focus rule is covered by the Electron unit tests above; no desktop build was run.Screenshots / video
Scheduled at 12:00, light, with the two time fields:
Scheduled at 20:30, dark:
A schedule save the workspace refuses: the notice under the two times, with the new time still shown:
Dark picked: four mode choices, no time fields:
Related Issues
Part of #21097
#31196 takes the same issue another way (an on/off schedule kept per browser, plus sunrise and sunset); this PR does not build on it.
Sibling sweep
N/A: a feature, not a fix.
Pattern harvest
N/A: a feature, not a fix.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)