Skip to content

Commit e494b22

Browse files
committed
fix(chat): distinct error state and stable history keys in scheduled-task viewer
- Render a 'couldn't load' state when the schedules query errors, instead of falsely claiming the task was deleted (uses React Query isError) - Use a stable composite key for jobHistory rows so same-second timestamps don't collide
1 parent 52649ff commit e494b22

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ interface EmbeddedScheduledTaskProps {
694694
}
695695

696696
function EmbeddedScheduledTask({ workspaceId, scheduleId }: EmbeddedScheduledTaskProps) {
697-
const { data: schedules = [], isLoading } = useWorkspaceSchedules(workspaceId)
697+
const { data: schedules = [], isLoading, isError } = useWorkspaceSchedules(workspaceId)
698698
const schedule = useMemo(
699699
() => schedules.find((s) => s.id === scheduleId),
700700
[schedules, scheduleId]
@@ -703,16 +703,18 @@ function EmbeddedScheduledTask({ workspaceId, scheduleId }: EmbeddedScheduledTas
703703
if (isLoading && !schedule) return LOADING_SKELETON
704704

705705
if (!schedule) {
706+
// A failed list query also yields no schedule; keep that distinct from a
707+
// genuinely missing task so we don't tell the user it was deleted.
708+
const heading = isError ? "Couldn't load scheduled task" : 'Scheduled task not found'
709+
const detail = isError
710+
? 'Something went wrong loading this scheduled task. Try again.'
711+
: 'This scheduled task may have been deleted'
706712
return (
707713
<div className='flex h-full flex-col items-center justify-center gap-3'>
708714
<Calendar className='size-[32px] text-[var(--text-icon)]' />
709715
<div className='flex flex-col items-center gap-1'>
710-
<h2 className='font-medium text-[20px] text-[var(--text-primary)]'>
711-
Scheduled task not found
712-
</h2>
713-
<p className='text-[var(--text-body)] text-small'>
714-
This scheduled task may have been deleted
715-
</p>
716+
<h2 className='font-medium text-[20px] text-[var(--text-primary)]'>{heading}</h2>
717+
<p className='text-[var(--text-body)] text-small'>{detail}</p>
716718
</div>
717719
</div>
718720
)
@@ -749,9 +751,9 @@ function EmbeddedScheduledTask({ workspaceId, scheduleId }: EmbeddedScheduledTas
749751
<div className='flex flex-col gap-2'>
750752
<span className='text-[var(--text-muted)] text-caption'>Recent runs</span>
751753
<div className='flex flex-col gap-2'>
752-
{schedule.jobHistory.slice(0, 5).map((run) => (
754+
{schedule.jobHistory.slice(0, 5).map((run, index) => (
753755
<div
754-
key={run.timestamp}
756+
key={`${run.timestamp}-${index}`}
755757
className='flex flex-col gap-1 rounded-[6px] bg-[var(--surface-4)] px-3 py-2'
756758
>
757759
<span className='text-[var(--text-tertiary)] text-caption'>

0 commit comments

Comments
 (0)