Skip to content

Commit e1b7c89

Browse files
fix(ui): show schedule names in task nav
Use schedule metadata for scheduled-run task labels and add a calendar indicator so recurring runs are easier to recognize. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 03866d5 commit e1b7c89

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

agentex-ui/components/task-sidebar/task-button.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { memo, useCallback, useMemo } from 'react';
22

33
import { formatDistanceToNow } from 'date-fns';
4+
import { CalendarClock } from 'lucide-react';
45

56
import { ResizableSidebar } from '@/components/ui/resizable-sidebar';
67
import {
78
SearchParamKey,
89
useSafeSearchParams,
910
} from '@/hooks/use-safe-search-params';
10-
import { createTaskName } from '@/lib/task-utils';
11+
import { createTaskName, isScheduledTask } from '@/lib/task-utils';
1112
import { cn } from '@/lib/utils';
1213

1314
import type { TaskListResponse } from 'agentex/resources';
@@ -19,6 +20,7 @@ type TaskButtonProps = {
1920
function TaskButtonImpl({ task }: TaskButtonProps) {
2021
const { taskID, updateParams } = useSafeSearchParams();
2122
const taskName = createTaskName(task);
23+
const scheduledTask = isScheduledTask(task);
2224

2325
const firstAgentName = useMemo(
2426
() => task.agents?.[0]?.name ?? null,
@@ -64,7 +66,12 @@ function TaskButtonImpl({ task }: TaskButtonProps) {
6466
isSelected={taskID === task.id}
6567
className={cn('flex flex-col gap-1 text-left')}
6668
>
67-
<span className="w-full truncate text-sm">{taskName}</span>
69+
<span className="flex w-full items-center gap-1.5 truncate text-sm">
70+
{scheduledTask && (
71+
<CalendarClock className="text-muted-foreground size-3.5 shrink-0" />
72+
)}
73+
<span className="truncate">{taskName}</span>
74+
</span>
6875
<div
6976
className={cn(
7077
'text-muted-foreground w-full truncate text-xs',

agentex-ui/lib/task-utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import type { TaskListResponse } from 'agentex/resources';
22

3+
const LEGACY_SCHEDULED_MESSAGE_PREFIX = 'Scheduled Message: ';
4+
5+
export function isScheduledTask(
6+
task: TaskListResponse.TaskListResponseItem
7+
): boolean {
8+
const scheduleId = task?.task_metadata?.schedule_id;
9+
return typeof scheduleId === 'string' && scheduleId.length > 0;
10+
}
11+
312
export function createTaskName(
413
task: TaskListResponse.TaskListResponseItem
514
): string {
615
const displayName = task?.task_metadata?.display_name;
716
if (typeof displayName === 'string' && displayName) {
17+
if (isScheduledTask(task)) {
18+
return displayName.replace(LEGACY_SCHEDULED_MESSAGE_PREFIX, '');
19+
}
820
return displayName;
921
}
1022

agentex/src/temporal/activities/scheduled_agent_run_activities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ async def launch_scheduled_agent_run(
249249
# caller-supplied display_name in schedule.task_metadata overrides it.
250250
display_fire_time = _format_fire_time(fire_id)
251251
task_metadata = {
252-
"display_name": f"Scheduled Message: {schedule.name} · {display_fire_time}",
252+
"display_name": f"{schedule.name} · {display_fire_time}",
253253
**(schedule.task_metadata or {}),
254254
"schedule_id": schedule_id,
255255
"scheduled_fire_id": fire_id,

0 commit comments

Comments
 (0)