Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend/library): fix schedule display issues for recurring schedules (#11362)

Bently32bb6705d12e
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/CronScheduler.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/CronScheduler.tsx
index ed275d636d..1d56d79a80 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/CronScheduler.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/CronScheduler.tsx
@@ -259,9 +259,18 @@ export function CronScheduler({
<YearlyPicker values={selectedMonths} onChange={setSelectedMonths} />
)}
- {frequency !== "hourly" && (
- <TimeAt value={selectedTime} onChange={setSelectedTime} />
- )}
+ {frequency !== "hourly" &&
+ !(frequency === "custom" && customInterval.unit === "hours") && (
+ <TimeAt
+ value={selectedTime}
+ onChange={setSelectedTime}
+ label={
+ frequency === "custom" && customInterval.unit === "days"
+ ? "Starting at"
+ : "At"
+ }
+ />
+ )}
</div>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/TimeAt.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/TimeAt.tsx
index a3ee19f29e..9d26a46989 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/TimeAt.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/AgentRunsView/components/ScheduleAgentModal/components/CronScheduler/TimeAt.tsx
@@ -6,9 +6,11 @@ import { Select } from "@/components/atoms/Select/Select";
export function TimeAt({
value,
onChange,
+ label = "At",
}: {
value: string;
onChange: (v: string) => void;
+ label?: string;
}) {
const [hour12, setHour12] = useState<string>("9");
const [minute, setMinute] = useState<string>("00");
@@ -54,7 +56,7 @@ export function TimeAt({
<div className="flex items-end gap-1">
<div className="relative">
<label className="mb-0 block text-sm font-medium text-zinc-700">
- At
+ {label}
</label>
<div className="flex items-center gap-2">
<Select
diff --git a/autogpt_platform/frontend/src/lib/cron-expression-utils.ts b/autogpt_platform/frontend/src/lib/cron-expression-utils.ts
index c75dbd5e68..72d67b9817 100644
--- a/autogpt_platform/frontend/src/lib/cron-expression-utils.ts
+++ b/autogpt_platform/frontend/src/lib/cron-expression-utils.ts
@@ -150,31 +150,6 @@ export function humanizeCronExpression(cronExpression: string): string {
return `Every ${days} at ${formatTime(hour, minute)}`;
}
- // Handle monthly (e.g., 30 14 1,15 * *)
- if (
- dayOfMonth !== "*" &&
- month === "*" &&
- dayOfWeek === "*" &&
- !minute.includes("/") &&
- !hour.includes("/")
- ) {
- const days = dayOfMonth.split(",").map(Number);
- const dayList = days.join(", ");
- return `On day ${dayList} of every month at ${formatTime(hour, minute)}`;
- }
-
- // Handle yearly (e.g., 30 14 1 1,6,12 *)
- if (
- dayOfMonth !== "*" &&
- month !== "*" &&
- dayOfWeek === "*" &&
- !minute.includes("/") &&
- !hour.includes("/")
- ) {
- const months = getMonthNames(month);
- return `Every year on the 1st day of ${months} at ${formatTime(hour, minute)}`;
- }
-
// Handle custom minute intervals with other fields as * (e.g., every N minutes)
if (
minute.includes("/") &&
@@ -200,6 +175,7 @@ export function humanizeCronExpression(cronExpression: string): string {
}
// Handle specific days with custom intervals (e.g., every N days)
+ // This must come BEFORE the monthly check to avoid misinterpreting */N as monthly days
if (
dayOfMonth.startsWith("*/") &&
month === "*" &&
@@ -211,6 +187,35 @@ export function humanizeCronExpression(cronExpression: string): string {
return `Every ${interval} days at ${formatTime(hour, minute)}`;
}
+ // Handle monthly (e.g., 30 14 1,15 * *)
+ // Check that dayOfMonth doesn't start with */ to avoid matching day intervals
+ if (
+ dayOfMonth !== "*" &&
+ !dayOfMonth.startsWith("*/") &&
+ month === "*" &&
+ dayOfWeek === "*" &&
+ !minute.includes("/") &&
+ !hour.includes("/")
+ ) {
+ const days = dayOfMonth.split(",").map(Number);
+ const dayList = days.join(", ");
+ return `On day ${dayList} of every month at ${formatTime(hour, minute)}`;
+ }
+
+ // Handle yearly (e.g., 30 14 1 1,6,12 *)
+ // Check that dayOfMonth doesn't start with */ to avoid matching day intervals
+ if (
+ dayOfMonth !== "*" &&
+ !dayOfMonth.startsWith("*/") &&
+ month !== "*" &&
+ dayOfWeek === "*" &&
+ !minute.includes("/") &&
+ !hour.includes("/")
+ ) {
+ const months = getMonthNames(month);
+ return `Every year on the 1st day of ${months} at ${formatTime(hour, minute)}`;
+ }
+
return `Cron Expression: ${cronExpression}`;
}