Skip to content

Commit 00dd9b8

Browse files
committed
fix(scheduled-tasks): edit/duplicate use the task's own timezone, not the account one
A task created in one zone but edited after the account zone changed (or duplicated) seeded its launch in the task's stored zone while validating and submitting in the current account zone, drifting unchanged run times. TaskPrefill now carries the task's timezone; the modal seeds AND submits in it for edit/duplicate, and only blank creates use the account zone.
1 parent 01943e8 commit 00dd9b8

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

apps/sim/app/workspace/[workspaceId]/scheduled-tasks/components/task-modal/task-modal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export interface TaskPrefill {
7373
contexts?: ChatContext[]
7474
launchDate: string
7575
launchTime: string
76+
/** The task's own zone; the modal seeds AND submits in it so unchanged times never drift. */
77+
timezone: string
7678
recurrence: Recurrence
7779
}
7880

@@ -145,8 +147,9 @@ function TaskModalContent({
145147
onRequestDelete,
146148
}: Omit<TaskModalProps, 'open'>) {
147149
const { workspaceId } = useParams<{ workspaceId: string }>()
148-
const timezone = useTimezone()
149150
const source = edit ?? prefill
151+
const accountTimezone = useTimezone()
152+
const timezone = source?.timezone ?? accountTimezone
150153
const editor = usePromptEditor({ workspaceId, initialValue: source?.prompt })
151154
const setContexts = editor.setContexts
152155

apps/sim/app/workspace/[workspaceId]/scheduled-tasks/hooks/use-scheduled-tasks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export function useScheduledTasks({
149149
contexts: task.contexts,
150150
launchDate: zonedWallClock(task.runAt, schedule.timezone).slice(0, 10),
151151
launchTime,
152+
timezone: schedule.timezone,
152153
recurrence,
153154
}
154155
},

0 commit comments

Comments
 (0)