fix: persist a one-time schedule's run time so edit and disable keep its year (#1499)

PR #1497 pinned an enabled one-shot's next_run_at on creation, but the chosen
instant did not survive two paths: editing reconstructed the date from the
yearless cron (current year), and a disabled one-shot nulled next_run_at with no
other store, so enabling it later recomputed from the cron. Both moved a
future-year one-shot to a different annual occurrence than the date displayed.

Persist the one-shot's absolute fire time in a dedicated run_at column
(additive, nullable; recurring schedules leave it null). Create and update store
run_at independently of the enabled state; next_run_at is derived from it when
enabled and null while disabled, so a disabled one-shot keeps its run_at and the
enable toggle restores the exact instant from the column rather than the cron.
The editor reconstructs a one-shot's date from the persisted run_at, so opening
and re-saving without changes preserves the originally chosen year.

No behavior change for recurring schedules or fresh installs; the column is added
by an additive migration safe for upgrades from v0.92.0.
This commit is contained in:
Anso
2026-06-28 05:23:23 -04:00
committed by GitHub
parent 60536aa614
commit ba57c67048
6 changed files with 139 additions and 31 deletions
+5
View File
@@ -18,6 +18,11 @@ export interface ScheduledTask {
target_services: string | null;
prune_label_filter: string | null;
delete_after_run?: number;
// Absolute epoch-ms fire time for a one-time ('once') schedule; null/absent for
// recurring shapes. Persisted so the chosen instant (including year) survives
// disable/enable and edit, where the yearless cron would otherwise collapse to
// the next annual occurrence.
run_at?: number | null;
next_runs?: number[];
}