Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const TaskDetailsDialogContent: React.FC<TaskDetailsDialogContentProps> = ({
/>
) : (
<TaskScheduleSection
schedule={task.schedule}
schedule={task.schedule || ""}
nextRun={task.next_run || ""}
isDeleted={isDeleted}
/>
Expand Down
4 changes: 2 additions & 2 deletions components/VercelChat/tools/tasks/TaskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ const TaskCard: React.FC<TaskCardProps> = ({ task, isDeleted, ownerEmail }) => {

<div className="flex items-center space-x-4">
<div className="flex items-center space-x-2">
{isRecurring(task.schedule) && (
{task.schedule && isRecurring(task.schedule) && (
<Repeat className="h-4 w-4 text-muted-foreground dark:text-muted-foreground flex-shrink-0" />
)}
<span className="text-base text-muted-foreground dark:text-muted-foreground">
{parseCronToHuman(task.schedule.trim())}
{task.schedule ? parseCronToHuman(task.schedule.trim()) : "No schedule"}
Comment on lines +81 to +85
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Normalize the schedule once before both checks.

The label uses task.schedule.trim(), but the Repeat icon still reads the raw value. If a saved cron has extra whitespace, the text and icon can disagree. Reuse one normalized value for both branches.

♻️ Proposed fix
 const TaskCard: React.FC<TaskCardProps> = ({ task, isDeleted, ownerEmail }) => {
   const [isDropdownOpen, setIsDropdownOpen] = useState(false);
   const { updateAction, isLoading: isUpdating } = useUpdateScheduledAction();
   const { deleteAction, isLoading: isDeleting } = useDeleteScheduledAction();
   const isActive = task.enabled && !isDeleted;
   const isPaused = !task.enabled && !isDeleted;
+  const normalizedSchedule = task.schedule?.trim() || "";
 
   const handlePause = async (e: React.MouseEvent) => {
@@
-          {task.schedule && isRecurring(task.schedule) && (
+          {normalizedSchedule && isRecurring(normalizedSchedule) && (
             <Repeat className="h-4 w-4 text-muted-foreground dark:text-muted-foreground flex-shrink-0" />
           )}
           <span className="text-base text-muted-foreground dark:text-muted-foreground">
-            {task.schedule ? parseCronToHuman(task.schedule.trim()) : "No schedule"}
+            {normalizedSchedule ? parseCronToHuman(normalizedSchedule) : "No schedule"}
           </span>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/VercelChat/tools/tasks/TaskCard.tsx` around lines 81 - 85,
Normalize task.schedule once into a single variable (e.g., const
normalizedSchedule = task.schedule?.trim()) and use that normalizedSchedule for
both the isRecurring check and the label rendering: call
isRecurring(normalizedSchedule) for the Repeat icon and pass normalizedSchedule
to parseCronToHuman (or show "No schedule" if falsy). Update references to
task.schedule in this block so both the icon and text operate on the same
trimmed value.

</span>
</div>
<div className="flex items-center space-x-2 w-20 justify-end relative">
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/isRecurring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Checks if a cron expression represents a recurring schedule (daily, weekly, or monthly)
*/
export const isRecurring = (cronExpression: string): boolean => {
if (!cronExpression) return false;
try {
const parts = cronExpression.split(" ");
if (parts.length >= 5) {
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/parseCronToHuman.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cronstrue from "cronstrue";

export const parseCronToHuman = (cronExpression: string): string => {
if (!cronExpression) return "No schedule";
try {
return cronstrue.toString(cronExpression);
} catch (e) {
Expand Down