Skip to content

Edit cron jobs in a modal with live schedule validation#244

Merged
ramonski merged 3 commits into
masterfrom
feat/cron-edit-modal
Jul 9, 2026
Merged

Edit cron jobs in a modal with live schedule validation#244
ramonski merged 3 commits into
masterfrom
feat/cron-edit-modal

Conversation

@ramonski

@ramonski ramonski commented Jul 9, 2026

Copy link
Copy Markdown
Member

Context

Two problems with cron editing, in one feature:

  1. The pencil opened an inline per-card form, inconsistent with how task and clock time entries are edited (a modal). Follow-up to Edit every time entry through the shared modal, with notes preview/edit tabs #236/Unify the notes indicator across tasks and clock entries #239/Edit a clock entry's description from its popup #240.
  2. Cron schedules had no validation. A typo like 06 45 * * * (hour 45) was silently accepted, never ran, and — combined with Skip cron jobs with invalid schedules instead of 500-ing every cron mutation #243 — bricked every cron mutation.

What changed

Modal editor. The pencil now opens a CronJobDialog (mirrors TimeEntryDialog) holding schedule, model, output, timeout, cloud flag, and the prompt, saved together. The expanded card becomes a read-only prompt preview with an Edit button. Inline field/prompt editing is removed.

Live schedule validation. The schedule field validates as you type against the same APScheduler CronTrigger that actually schedules jobs, so the verdict never drifts from runtime behaviour:

  • valid → previews the next 3 fire times under the field
  • invalid → shows the error, marks the field red, and disables Save

New POST /api/cron/validate-schedule powers the live feedback; POST/PATCH also reject an invalid schedule (400) as a backstop. Both the modal and the add-job form use the shared ScheduleField.

Shared cron field bits (MODEL_DATALIST, fieldCls, OutputSelect, ScheduleField) moved to cronFields.tsx so the dialog and CronView reuse them without an import cycle.

Verified

Drove the real app (source backend + Vite): modal opens with correct values (the stale-timeout symptom is gone), invalid schedule shows the error and blocks Save, valid edit previews next runs, saves persist, and reopening shows fresh values. Backend suite: 841 passing (4 new schedule-validation tests).

Notes

The pencil now opens a dialog (like task/clock time entries)
holding the schedule, model, output, timeout, cloud flag, and the
prompt, saved together; the expanded card shows a read-only prompt
preview. Inline per-card field/prompt editing is gone.

The schedule field validates as you type against the same
APScheduler CronTrigger that actually runs jobs: a valid
expression previews its next fire times, an invalid one (like
hour 45) shows the error and blocks Save. The backend gains a
/cron/validate-schedule endpoint and rejects invalid schedules on
create/update as a backstop. Shared cron field bits move to
cronFields.tsx so the dialog and the add-job form reuse them
without importing CronView.
@ramonski ramonski self-assigned this Jul 9, 2026
@ramonski ramonski added the Enhancement ✨ Improvement to existing functionality label Jul 9, 2026
@ramonski ramonski merged commit 97953a3 into master Jul 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement ✨ Improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant