Repository navigation
fix(automations): resume a paused automation at its next future occurrence - #53266
Conversation
…rence
While an automation is paused the scheduler skips it, so nextRunAt
never advances. A bare { enabled: true } kept that stale value, the
next tick found it due, and runScheduledOccurrence ran (or recorded as
missed) the latest slot that fell while it was paused. Recompute
nextRunAt when a recurring automation is re-enabled, as the WSL-move
undo already does; one-off automations keep their own timing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
ELI5
If you pause a scheduled automation and turn it back on later, Orca used to immediately run the time slot that passed while it was paused. Now turning it back on just waits for the next scheduled time.
What Changed
Before: pausing stops the scheduler from advancing
nextRunAt. Resuming sent{ enabled: true }, andupdatedAutomationSchedulekept the stalenextRunAtbecause the rrule, dtstart and zone were unchanged. The next tick found the automation due and ran, or recorded as missed, the latest slot that fell during the pause.After:
updatedAutomationScheduletreatsenabled: trueon a currently disabled automation as a schedule change, and recomputesnextRunAt = nextAutomationOccurrenceAfter(rrule, dtstart, now, zone), the next future slot. One-off (once) automations are excluded and keep their existing timing.Why
This puts the reseed where the schedule is already recomputed for every other "when it runs" change, and matches what the WSL-move undo does when it turns automations back on. The alternative, changing
runScheduledOccurrenceto ignore slots from before a resume, would need a resume timestamp stored on every automation.Linked Issue
Fixes #53265
Visual Proof
N/A: no visual change. After a resume, the automation's next run shows the next future slot instead of a past one, and no surprise run starts.
Testing
Added
automation-schedule-operations.test.ts. A paused daily automation whosenextRunAtlies in the past is resumed two days later, andnextRunAtmust be the next future occurrence.It fails without this change: the stale past slot is returned.
The existing
wsl-move-local-automations-rewrite.test.ts(9 tests) andwsl-host-automation-disable.test.tsstill pass.On Linux,
oxfmtandoxlintpass. Atscrun scoped to the changed files and their import graph also passes, using the repo'stsconfig.node.jsonsettings. The fullpnpm check:changedtypecheck doesn't finish on a 4-vCPU, 8 GB machine, so CI covers the rest.Performance
None, because one occurrence calculation runs only when an automation is re-enabled.
Risk
Level: Low
Someone who relied on a resume catching up a slot that passed during the pause will now wait for the next slot instead. That matches what pausing means, and the WSL undo path already behaves this way. One-off automations are unchanged. Back out with a plain revert.
AI Disclosure
Found and written with Claude Code (Claude Opus 5.5), then reviewed by me.
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code