fix(desktop,shared): stop calling an already-run schedule invalid

Merged
SA
3mo ago
+57-27

Summary

A run-once schedule (FREQ=DAILY;COUNT=1;DTSTART=…, typically authored by an agent via CLI/MCP) fires once, then the evaluator disables the trigger and leaves next_run_at at that fire time — correct. The editor then rendered it as "Invalid recurrence rule — changes aren't saved" and "Next run 2 days ago", both wrong.

  • rruleProblem() in shared: distinguishes unparseable from exhausted; isValidRrule delegates to it.
  • ScheduleSentence: only complains about an edited draft (the saved rule being exhausted is history, not an error); wording is "No upcoming runs" vs "Invalid recurrence rule".
  • TriggersCard: a disabled (exhausted) trigger's row reads "Ran 2 days ago" with the exact time in the tooltip.

Not changed: run-once still shows as Custom with the raw rule, since it isn't one of the five preset shapes.

Test plan

  • typecheck desktop + shared, biome, shared rrule tests
  • Open the automation from the screenshot: row says "Ran 2 days ago", no red text
  • Type garbage into Custom → "Invalid recurrence rule…"; type FREQ=DAILY;COUNT=1;DTSTART=20200101T000000Z → "No upcoming runs…"

Summary by cubic

Stops marking already-run schedules as invalid and fixes misleading “next run” text. Previously, a run-once rule that already fired showed “Invalid recurrence rule — changes aren't saved” and “Next run 2 days ago”; now it’s treated as exhausted, shows “No upcoming runs” when editing, and trigger rows read “Ran … ago”.

  • @superset/shared/rrule: adds rruleProblem to distinguish unparseable vs exhausted; isValidRrule delegates to it.
  • Schedule editor: only warns on an edited custom rule; shows “No upcoming runs — changes aren't saved” for exhausted drafts, otherwise “Invalid…”.
  • Triggers card: treats disabled schedules with a final nextRunAt as last run; label reads “Ran … ago” (tooltip shows exact time); still previews “Would run …” for paused automations.
  • Not changed: run-once rules remain “Custom” with the raw RRULE.

Summary by CodeRabbit

  • Improvements
    • Automation schedules now clearly indicate whether they have already run, are scheduled to run next, or would run if re-enabled.
    • Paused automations continue showing their upcoming occurrence accurately.
    • Exhausted recurring schedules are distinguished from invalid schedule rules.
    • Saved, exhausted schedules no longer show an error unless their recurrence settings are changed.
    • Custom recurrence changes are accepted only when valid and different from the saved schedule.