@@ -65,6 +65,8 @@ export interface DraftState {
6565 readonly timeOfDay : string ;
6666 /** Local date and time as a `datetime-local` input value, such as 2026-11-02T15:00. */
6767 readonly runAt : string ;
68+ /** The stored ISO run time, sent back unchanged when the field was not edited. */
69+ readonly savedRunAt : string ;
6870 readonly weekdays : ReadonlySet < number > ;
6971 readonly projectId : string ;
7072 readonly threadId : string ;
@@ -158,8 +160,13 @@ export function webhookDeliveryLabel(delivery: {
158160export function scheduleFromDraft ( draft : DraftState ) : ScheduledTaskUpsertSchedule | null {
159161 if ( scheduleDraftErrors ( draft ) . length > 0 ) return null ;
160162 if ( draft . scheduleMode === "once" ) {
163+ const unchanged =
164+ draft . savedRunAt && toDateTimeLocalValue ( new Date ( draft . savedRunAt ) ) === draft . runAt ;
161165 // A `datetime-local` value has no offset, so Date reads it as local time.
162- return { type : "once" , runAt : new Date ( draft . runAt ) . toISOString ( ) } ;
166+ return {
167+ type : "once" ,
168+ runAt : unchanged ? draft . savedRunAt : new Date ( draft . runAt ) . toISOString ( ) ,
169+ } ;
163170 }
164171 if ( draft . scheduleMode === "webhook" ) {
165172 const maxDeliveryAgeMinutes = parseMaxDeliveryAge ( draft . maxDeliveryAgeMinutes ) ;
@@ -227,6 +234,7 @@ export function taskToDraft(task: ScheduledTask): DraftState {
227234 schedule . type === "interval" ? String ( Math . max ( 1 , schedule . everyMs / 60_000 ) ) : "15" ,
228235 timeOfDay : schedule . type === "fixed_time" ? schedule . timeOfDay : "09:00" ,
229236 runAt : schedule . type === "once" ? toDateTimeLocalValue ( new Date ( schedule . runAt ) ) : "" ,
237+ savedRunAt : schedule . type === "once" ? schedule . runAt : "" ,
230238 weekdays,
231239 projectId : task . projectId ,
232240 threadId : task . threadId ?? "" ,
0 commit comments