feat: add hour range mode for calendar schedule#2
Conversation
Extract calendar utilities into dedicated module and add support for hour range scheduling (e.g., run every hour from 7:00 to 23:00). Detects existing hour-range patterns when editing agents and displays them compactly in the detail view. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| const hour = ci.hour ?? 0 | ||
| const minute = ci.minute ?? 0 | ||
| parts.push(`at ${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`) |
There was a problem hiding this comment.
🟡 formatSingleCalendarInterval displays hour: null (every-hour) schedules as "00:XX" instead of indicating hourly recurrence
When the user creates a schedule with the new "Every hour" mode, calendarInterval.hour is set to null and saved as start_calendar_interval: [{ hour: null, minute: 0, ... }]. When this job is viewed in JobDetail, formatCalendarIntervals at src/lib/calendar-utils.ts:127 is called with a single interval. Since detectHourRange requires intervals.length >= 2 (src/lib/calendar-utils.ts:14), it returns null, falling through to formatSingleCalendarInterval. There, const hour = ci.hour ?? 0 at line 159 treats null (meaning "every hour" in launchd) as 0, producing output like "Every day at 00:00" when the job actually runs 24 times per day (at :00 of every hour). This is misleading — a user would believe their job runs once at midnight rather than every hour.
| const hour = ci.hour ?? 0 | |
| const minute = ci.minute ?? 0 | |
| parts.push(`at ${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`) | |
| if (ci.hour === null || ci.hour === undefined) { | |
| const minute = ci.minute ?? 0 | |
| parts.push(`every hour at :${String(minute).padStart(2, "0")}`) | |
| } else { | |
| const minute = ci.minute ?? 0 | |
| parts.push(`at ${String(ci.hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`) | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Adds an "hour range" scheduling mode to the calendar schedule configuration, allowing users to define a range of hours (e.g., 7:00–23:00) instead of specifying each hour individually. Calendar utility functions are extracted into a dedicated module with tests.
Changes
JobDetail.tsxandJobForm.tsxintosrc/lib/calendar-utils.tsCalendarIntervalentries for plist outputgetNextOccurrencesMultito compute next runs across multiple intervalsBreaking Changes
None
Test Plan
pnpm test— all 23 tests pass (14 new calendar-utils tests)pnpm lintandpnpm typecheck— no errors