Repository navigation
fix(automations): show the saved schedule time on DST spring-forward days - #52107
Conversation
[Low impact] The PR appears safe to merge. SummaryKeeps schedule labels at their saved clock time on spring-forward days.
Reviews (2) · Last reviewed commit: "fix(automations): show the saved schedul..." · Reviewed by Greptile |
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
…days Schedule labels were formatted from today's date with setHours, so on a spring-forward day a time in the skipped hour (2:30 AM in New York) was shown an hour later. Format the saved hour and minute as a UTC instant with a UTC-zoned formatter, which has no DST gap, and cache the formatter instead of building one per label. Fixes stablyai#52100 Co-authored-by: Neil <[email protected]>
223e88e to
666a138
Compare
ELI5
If you save an automation for 2:30 AM, Orca now keeps showing "2:30 AM" even on the day the clocks jump forward and skip that hour. Before, it showed "3:30 AM" for that whole day, which made it look like the schedule had been saved wrong.
What Changed
30 2 * * *inAmerica/New_Yorkwas labeledDaily at 3:30 AM. Any saved time inside the skipped hour was shown shifted by the DST offset (for example Europe/Berlin 2:00 showed as 3:00, Lord Howe 2:15 showed as 2:45).Daily at 2:30 AM) every day of the year.formatTimeinsrc/shared/automations/scheduling/automation-schedules.tsused to callnew Date()andsetHours(hour, minute), which rolls a local time in the DST gap forward to the next valid time. It now formatsDate.UTC(2000, 0, 1, hour, minute)with a formatter whosetimeZoneisUTC. UTC has no DST gap, so the hour and minute come back as saved. The device locale and thehour/minuteoptions are unchanged, so 12h/24h display follows the user's locale as before. The formatter is built once and reused instead of once per label.The desktop renderer's schedule labels, the CLI's
orca automations list, and the mobile bot sheet all go through this shared formatter. The scheduler's own occurrence math is untouched.Why
The label is a display of the saved hour and minute, not of a real instant, so it should not depend on today's DST state. A fixed UTC instant removes that dependency in every zone, including zones whose DST rules change in the future, without needing a hand-picked "safe" local reference date.
Linked Issue
Fixes #52100
Visual Proof
Behavior change is the label text. Captured from the built
orca automations listcommand with the clock frozen at March 8, 2026, 12:00 local time inAmerica/New_Yorkwith anen-USlocale (from the original PR):Before
After
Cross-zone probe (saved time inside each zone's gap, formatted on that zone's gap day):
On a normal day, every minute of the day formats identically to main across those zones.
Testing
Added a regression test in
automation-schedules.test.tsthat setsTZ=America/New_York, freezesDateon March 8, 2026, asserts local 2:30 AM really rolls to 3:30 AM that day, and checksformatAutomationSchedule('30 2 * * *')returns the saved time. The expected string is built withIntlso the test is independent of the runner's locale. Skipped on Windows like the adjacent DST tests, since Windows Node may ignore runtimeTZchanges.On main the new test fails:
expected 'Daily at 3:30 AM' to be 'Daily at 2:30 AM'. On this branch:src/shared/automations/scheduling/41/41 pass, and the file passes under bothTZ=UTCandTZ=America/New_York.macOS (targeted vitest) and Linux (original PR: full test run, CLI build for before/after).
oxlint, oxfmt, anti-slop, code-quality native plugins, ast-grep, and the changed-code quality gate are clean on the touched files.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
Faster. The label formatter is a pure function called once per rendered schedule label; no polling, I/O, subprocess, or cache invalidation is involved, and work per label does not depend on how many automations are mounted. Caching the
Intl.DateTimeFormatinstead of constructing one per call measured 21.1 us/call on main vs 0.40 us/call on this branch; formatting 200 labels takes 4.22 ms on main vs 0.08 ms here.Risk
Level: Low
The riskiest part is the displayed hour or hour cycle being wrong. The formatter keeps the device locale and the same options, and a normal-day comparison against main matched for every minute. The cached formatter uses the process default locale, which is fixed for the life of the process, same as before. Plain revert restores the previous behavior; no saved data or settings are touched.
Review
Original fix by @SeungWoonSong in #52107. Maintainer follow-up switched the reference instant to a UTC-zoned formatter and cached it. Authorship is preserved on the squashed commit.
Agent skill upstream boundary
Notes
No SSH/remote, agent, persistence, or security paths are touched. Mobile and CLI pick up the fix through the shared formatter.
Checklist
N/Awith reason (before/after CLI output above)pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)