@@ -21,7 +21,6 @@ import type {
2121 ProjectId ,
2222 ScheduledTask ,
2323 ScheduledTaskId ,
24- ScheduledTaskSchedule ,
2524 ScheduledTaskThreadMode ,
2625 ScheduledTaskUpsertInput ,
2726 ScheduledTaskWebhookDeliverySummary ,
@@ -35,6 +34,7 @@ import {
3534 WEBHOOK_FILTER_OPS ,
3635 type WebhookFilterDraft ,
3736} from "@t3tools/client-runtime/scheduled-task-webhook" ;
37+ import { scheduleTimeZoneLabel } from "@t3tools/client-runtime/scheduled-task-time-zone" ;
3838import {
3939 MAX_WEBHOOK_DELIVERY_AGE_MINUTES ,
4040 MAX_WEBHOOK_FILTERS ,
@@ -104,7 +104,9 @@ import {
104104 defaultScheduledTaskProjectId ,
105105 matchesScheduledTaskScope ,
106106 scheduleFromDraft ,
107+ scheduleLabel ,
107108 scheduledTaskDefaultModel ,
109+ WEEKDAY_LABELS ,
108110 taskToDraft ,
109111 unbindDraftFromThread ,
110112 type DraftState ,
@@ -151,7 +153,6 @@ import {
151153} from "./settingsLayout" ;
152154
153155const WEEKDAY_ORDER = [ 1 , 2 , 3 , 4 , 5 , 6 , 0 ] as const ;
154- const WEEKDAY_LABELS = [ "Sun" , "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" ] as const ;
155156const WEEKDAY_SHORT = [ "Su" , "Mo" , "Tu" , "We" , "Th" , "Fr" , "Sa" ] as const ;
156157
157158// Thread ids are trimmed, so the leading space keeps this from matching one.
@@ -322,30 +323,6 @@ function splitModelKey(value: string): ModelSelection | null {
322323 } ;
323324}
324325
325- const ONCE_FORMATTER = new Intl . DateTimeFormat ( undefined , {
326- dateStyle : "medium" ,
327- timeStyle : "short" ,
328- } ) ;
329-
330- export function scheduleLabel ( schedule : ScheduledTaskSchedule ) : string {
331- if ( schedule . type === "webhook" ) return "On webhook" ;
332- if ( schedule . type === "once" ) return `Once, ${ ONCE_FORMATTER . format ( new Date ( schedule . runAt ) ) } ` ;
333- if ( schedule . type === "interval" ) {
334- const minutes = schedule . everyMs / 60_000 ;
335- return Number . isInteger ( minutes )
336- ? `Every ${ minutes } min`
337- : `Every ${ Math . round ( schedule . everyMs / 1000 ) } sec` ;
338- }
339- const weekdays = schedule . weekdays ?? [ ] ;
340- const days =
341- weekdays . length === 0
342- ? "Daily"
343- : weekdays . length === 5 && weekdays . every ( ( day ) => day >= 1 && day <= 5 )
344- ? "Weekdays"
345- : weekdays . map ( ( day ) => WEEKDAY_LABELS [ day ] ) . join ( ", " ) ;
346- return `${ days } at ${ schedule . timeOfDay } ` ;
347- }
348-
349326/** formatRelativeTime handles only the past; upcoming runs need future labels. */
350327function relativeLabel ( value : string | null , nowMs : number ) : string {
351328 if ( ! value ) return "Not scheduled" ;
@@ -552,6 +529,7 @@ function ScheduledTaskEnvironmentList({
552529 return {
553530 environment,
554531 connected : index >= 0 ,
532+ timeZone : data ?. timeZone ,
555533 tasks : data ?. tasks . filter ( ( task ) =>
556534 matchesScheduledTaskScope ( scope , environment . environmentId , task . projectId ) ,
557535 ) ,
@@ -586,7 +564,7 @@ function ScheduledTaskEnvironmentList({
586564
587565 return (
588566 < SettingsGroup >
589- { populated . map ( ( { environment, tasks } ) => {
567+ { populated . map ( ( { environment, tasks, timeZone } ) => {
590568 const { primary, secondary } = settingsScopeEnvironmentLabels ( environment , environments ) ;
591569 return (
592570 < div key = { environment . environmentId } className = "divide-y divide-border/50" >
@@ -610,6 +588,7 @@ function ScheduledTaskEnvironmentList({
610588 key = { task . id }
611589 environmentId = { environment . environmentId }
612590 task = { task }
591+ timeZone = { timeZone }
613592 onEdit = { ( ) => onEdit ( environment . environmentId , task ) }
614593 />
615594 ) ) }
@@ -734,6 +713,7 @@ function ScheduledTaskEnvironmentSection({
734713 key = { task . id }
735714 environmentId = { environment . environmentId }
736715 task = { task }
716+ timeZone = { tasksQuery . data ?. timeZone }
737717 onEdit = { ( ) => onEdit ( environment . environmentId , task ) }
738718 />
739719 ) )
@@ -747,10 +727,12 @@ function ScheduledTaskEnvironmentSection({
747727function ScheduledTaskRow ( {
748728 environmentId,
749729 task,
730+ timeZone,
750731 onEdit,
751732} : {
752733 readonly environmentId : EnvironmentId ;
753734 readonly task : ScheduledTask ;
735+ readonly timeZone : string | undefined ;
754736 readonly onEdit : ( ) => void ;
755737} ) {
756738 const canOperate = useAtomValue (
@@ -795,7 +777,7 @@ function ScheduledTaskRow({
795777 status = {
796778 < div className = "flex flex-wrap items-center gap-2" >
797779 < span >
798- { scheduleLabel ( task . schedule ) } ·{ " " }
780+ { scheduleLabel ( task . schedule , timeZone , task . nextRunAt ) } ·{ " " }
799781 { task . blockedByPolicy !== undefined ? (
800782 task . blockedByPolicy
801783 ) : ! task . enabled ? (
@@ -1416,6 +1398,7 @@ function ScheduledTaskEditorForm({
14161398 draft . editingId !== null &&
14171399 tasksQuery . data !== null &&
14181400 ! tasksQuery . data . tasks . some ( ( entry ) => entry . id === draft . editingId ) ;
1401+ const runAtZone = scheduleTimeZoneLabel ( tasksQuery . data ?. timeZone ) ;
14191402 const liveTask = tasksQuery . data
14201403 ? ( tasksQuery . data . tasks . find ( ( entry ) => entry . id === draft . editingId ) ?? null )
14211404 : task ;
@@ -2063,13 +2046,21 @@ function ScheduledTaskEditorForm({
20632046 < Input
20642047 type = "time"
20652048 id = "scheduled-task-time"
2049+ aria-describedby = {
2050+ runAtZone === undefined ? undefined : "scheduled-task-time-zone"
2051+ }
20662052 nativeInput
20672053 className = "w-32"
20682054 value = { draft . timeOfDay }
20692055 onChange = { ( event ) =>
20702056 setDraft ( ( current ) => ( { ...current , timeOfDay : event . target . value } ) )
20712057 }
20722058 />
2059+ { runAtZone === undefined ? null : (
2060+ < span id = "scheduled-task-time-zone" className = "text-xs text-muted-foreground" >
2061+ { runAtZone }
2062+ </ span >
2063+ ) }
20732064 < span className = "text-xs text-muted-foreground" > on</ span >
20742065 </ div >
20752066 < ToggleGroup
0 commit comments