The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 23:15 UTC
fix(scheduler): label fixed-time tasks with the server timezone (#18653)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Scott Norteman committed
Oct 20, 2026 at 00:55 UTC
f0dac29574acd616523c5ff74a1baa427a8c9114
7 files changed
+121
-11
apps/server/src/scheduledTasks/ScheduledTaskService.schedule.test.ts
+47
@@ -6,6 +6,7 @@ import * as DateTime from "effect/DateTime";
6
import * as Effect from "effect/Effect";
7
import * as Layer from "effect/Layer";
8
import * as Schema from "effect/Schema";
9
+import * as Stream from "effect/Stream";
10
import * as TestClock from "effect/testing/TestClock";
11
12
import * as ThreadLaunchService from "../orchestration-v2/ThreadLaunchService.ts";
@@ -58,6 +59,52 @@ it.effect("rejects a stale form save after deletion while preserving explicit-id
59
}).pipe(Effect.provide(SqlitePersistence.layerMemory)),
60
);
61
62
+it.effect("includes the scheduler zone in empty lists and subscription updates", () =>
63
+ Effect.gen(function* () {
64
+ const layerDependencies = Layer.mergeAll(
65
+ NodeCrypto.layer,
66
+ Scheduler.layer,
67
+ Layer.mock(ThreadLaunchService.ThreadLaunchService)({}),
68
+ Layer.mock(ManagedProjectFolders.ManagedProjectFolders)({
69
+ namedProjectsRoot: "/projects",
70
+ isScratchProject: () => Effect.succeed(false),
71
+ }),
72
+ Layer.mock(ThreadManagementService.ThreadManagementService)({}),
73
+ Layer.mock(SecretRequests.SecretRequests)({}),
74
+ );
75
+ yield* Effect.gen(function* () {
76
+ const service = yield* ScheduledTaskService.ScheduledTaskService;
77
+ const timeZone = DateTime.zoneToString(DateTime.zoneMakeLocal());
78
+ expect(yield* service.list()).toEqual({ tasks: [], timeZone });
79
+
80
+ const input = yield* decodeUpsertInput({
81
+ title: "Morning review",
82
+ prompt: "Review the open pull requests.",
83
+ enabled: false,
84
+ schedule: { type: "fixed_time", timeOfDay: "09:00" },
85
+ projectId: "project-schedule-zone",
86
+ workspaceStrategy: { type: "root" },
87
+ modelSelection: { instanceId: "codex", model: "gpt-5.4" },
88
+ runtimeMode: "full-access",
89
+ interactionMode: "default",
90
+ });
91
+ const snapshots = yield* service.subscribeList().pipe(
92
+ Stream.tap((snapshot) =>
93
+ snapshot.tasks.length === 0 ? service.upsert(input) : Effect.void,
94
+ ),
95
+ Stream.take(2),
96
+ Stream.runCollect,
97
+ );
98
+ const populated = yield* service.list();
99
+ expect(populated).toMatchObject({
100
+ timeZone,
101
+ tasks: [{ title: "Morning review", schedule: input.schedule }],
102
+ });
103
+ expect(snapshots).toEqual([{ tasks: [], timeZone }, populated]);
104
+ }).pipe(Effect.provide(ScheduledTaskService.layer.pipe(Layer.provide(layerDependencies))));
105
+ }).pipe(Effect.provide(SqlitePersistence.layerMemory)),
106
+);
107
+
108
it.effect("preserves a due run when a save only pads the scheduled hour", () =>
109
Effect.gen(function* () {
110
const dueAt = DateTime.makeZonedUnsafe(
apps/server/src/scheduledTasks/ScheduledTaskService.ts
+4
-1
@@ -927,7 +927,10 @@ export const layer = Layer.effect(
927
928
const list: ScheduledTaskService["Service"]["list"] = () =>
929
listRows().pipe(
930
- Effect.map((tasks) => ({ tasks })),
930
+ Effect.map((tasks) => ({
931
+ tasks,
932
+ timeZone: DateTime.zoneToString(DateTime.zoneMakeLocal()),
933
+ })),
934
Effect.mapError((cause) => taskError("Could not list schedule tasks.", { cause })),
935
);
936
apps/server/src/ws.ts
+1
@@ -1294,6 +1294,7 @@ export const layerWsRpc = (
1294
currentSession.scopes.includes(AuthOrchestrationOperateScope)
1295
? result
1296
: {
1297
+ ...result,
1298
tasks: result.tasks.map(({ webhook: _webhook, ...task }) => task),
1299
};
1300
const authorizeEffect = <A, E, R>(
apps/web/src/components/chat/ThreadAutomationsPanel.permissions.browser.test.tsx
+41
-2
@@ -1,4 +1,10 @@
1
-import { EnvironmentId, ThreadId, ScheduledTaskId, type ScheduledTask } from "@t3tools/contracts";
1
+import {
2
+ EnvironmentId,
3
+ ThreadId,
4
+ ScheduledTaskId,
5
+ type ScheduledTask,
6
+ type ScheduledTaskListResult,
7
+} from "@t3tools/contracts";
8
import { act } from "react";
9
import { createRoot, type Root } from "react-dom/client";
10
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
@@ -28,7 +34,7 @@ vi.mock(import("../../state/use-atom-command"), async (importOriginal) => {
34
});
35
vi.mock(import("../../state/query"), async (importOriginal) => ({
36
...(await importOriginal()),
31
- useEnvironmentQuery: (() => ({ data: { tasks: [task] }, error: null })) as never,
37
+ useEnvironmentQuery: (() => ({ data: listResult, error: null })) as never,
38
}));
39
40
import { ThreadAutomationsPanel } from "./ThreadAutomationsPanel";
@@ -41,12 +47,15 @@ const task = {
47
enabled: true,
48
schedule: { type: "interval", everyMs: 60000 },
49
lastRunStatus: "never",
50
+ nextRunAt: null,
51
} as ScheduledTask;
52
+let listResult: ScheduledTaskListResult & { timeZone?: string };
53
let root: Root;
54
let container: HTMLDivElement;
55
beforeEach(() => {
56
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
57
state.allowed = true;
58
+ listResult = { tasks: [task] };
59
state.toggle.mockReset().mockResolvedValue({ _tag: "Success" });
60
state.run.mockReset().mockResolvedValue({ _tag: "Success" });
61
container = document.createElement("div");
@@ -84,3 +93,33 @@ it("rejects a retained toggle after task permission is revoked", async () => {
93
await act(async () => byLabel("Pause Daily review").click());
94
expect(state.toggle).toHaveBeenCalledOnce();
95
});
96
+
97
+it("labels fixed times with the server zone and preserves labels from older servers", async () => {
98
+ const tasks: ScheduledTask[] = [
99
+ { ...task, schedule: { type: "fixed_time", timeOfDay: "09:00" } },
100
+ { ...task, id: ScheduledTaskId.make("interval"), title: "Interval review" },
101
+ {
102
+ ...task,
103
+ id: ScheduledTaskId.make("webhook"),
104
+ title: "Webhook review",
105
+ schedule: { type: "webhook", signature: null },
106
+ },
107
+ ];
108
+ const labels = () => Array.from(container.querySelectorAll("li p"), (row) => row.textContent);
109
+
110
+ listResult = { tasks, timeZone: "Asia/Kolkata" };
111
+ await renderPanel();
112
+ expect(labels()).toEqual(["Daily at 09:00 Asia/Kolkata", "Every 1 min", "On webhook"]);
113
+
114
+ listResult = { tasks, timeZone: "Etc/UTC" };
115
+ await renderPanel();
116
+ expect(labels()).toEqual(["Daily at 09:00 UTC", "Every 1 min", "On webhook"]);
117
+
118
+ listResult = { tasks, timeZone: "UTC" };
119
+ await renderPanel();
120
+ expect(labels()).toEqual(["Daily at 09:00 UTC", "Every 1 min", "On webhook"]);
121
+
122
+ listResult = { tasks };
123
+ await renderPanel();
124
+ expect(labels()).toEqual(["Daily at 09:00", "Every 1 min", "On webhook"]);
125
+});
apps/web/src/components/chat/ThreadAutomationsPanel.tsx
+8
-4
@@ -37,10 +37,10 @@ const STATUS_DOT_CLASS: Record<ScheduledTask["lastRunStatus"], string> = {
37
failed: "bg-destructive",
38
};
39
40
-function taskScheduleLine(task: ScheduledTask) {
40
+function taskScheduleLine(task: ScheduledTask, timeZone: string | undefined) {
41
return (
42
<>
43
- {scheduleLabel(task.schedule)}
43
+ {scheduleLabel(task.schedule, timeZone)}
44
{task.enabled && task.nextRunAt !== null ? (
45
<>
46
{" · next "}
@@ -185,11 +185,15 @@ export function ThreadAutomationsPanel(props: {
185
<span className="block truncate text-sm font-medium text-foreground/80">
186
{task.title}
187
</span>
188
- <p className="truncate text-2xs text-muted-foreground">{taskScheduleLine(task)}</p>
188
+ <p className="truncate text-2xs text-muted-foreground">
189
+ {taskScheduleLine(task, tasksQuery.data?.timeZone)}
190
+ </p>
191
</TooltipTrigger>
192
<TooltipPopup side="left">
193
<p className="font-medium">{task.title}</p>
192
- <p className="text-muted-foreground">{taskScheduleLine(task)}</p>
194
+ <p className="text-muted-foreground">
195
+ {taskScheduleLine(task, tasksQuery.data?.timeZone)}
196
+ </p>
197
</TooltipPopup>
198
</Tooltip>
199
<Tooltip>
apps/web/src/components/settings/ScheduledTasksSettings.tsx
+18
-4
@@ -179,7 +179,11 @@ function splitModelKey(value: string): ModelSelection | null {
179
};
180
}
181
182
-export function scheduleLabel(schedule: ScheduledTaskSchedule): string {
182
+function scheduleTimeZoneLabel(timeZone: string | undefined) {
183
+ return timeZone === "Etc/UTC" ? "UTC" : timeZone;
184
+}
185
+
186
+export function scheduleLabel(schedule: ScheduledTaskSchedule, timeZone?: string): string {
187
if (schedule.type === "webhook") return "On webhook";
188
if (schedule.type === "interval") {
189
const minutes = schedule.everyMs / 60_000;
@@ -194,7 +198,8 @@ export function scheduleLabel(schedule: ScheduledTaskSchedule): string {
198
: weekdays.length === 5 && weekdays.every((day) => day >= 1 && day <= 5)
199
? "Weekdays"
200
: weekdays.map((day) => WEEKDAY_LABELS[day]).join(", ");
197
- return `${days} at ${schedule.timeOfDay}`;
201
+ const zone = scheduleTimeZoneLabel(timeZone);
202
+ return `${days} at ${schedule.timeOfDay}${zone === undefined ? "" : ` ${zone}`}`;
203
}
204
205
/**
@@ -364,6 +369,7 @@ function ScheduledTaskEnvironmentList({
369
return {
370
environment,
371
connected: index >= 0,
372
+ timeZone: data?.timeZone,
373
tasks: data?.tasks.filter((task) =>
374
matchesScheduledTaskScope(scope, environment.environmentId, task.projectId),
375
),
@@ -405,7 +411,7 @@ function ScheduledTaskEnvironmentList({
411
412
return (
413
<SettingsGroup>
408
- {populated.map(({ environment, tasks }) => {
414
+ {populated.map(({ environment, tasks, timeZone }) => {
415
const { primary, secondary } = settingsScopeEnvironmentLabels(environment, environments);
416
const transport = environmentTransportLabel(environment);
417
return (
@@ -435,6 +441,7 @@ function ScheduledTaskEnvironmentList({
441
key={task.id}
442
environmentId={environment.environmentId}
443
task={task}
444
+ timeZone={timeZone}
445
onEdit={() => onEdit(environment.environmentId, task)}
446
/>
447
))}
@@ -550,6 +557,7 @@ function ScheduledTaskEnvironmentSection({
557
key={task.id}
558
environmentId={environment.environmentId}
559
task={task}
560
+ timeZone={tasksQuery.data?.timeZone}
561
onEdit={() => onEdit(environment.environmentId, task)}
562
/>
563
))
@@ -563,10 +571,12 @@ function ScheduledTaskEnvironmentSection({
571
function ScheduledTaskRow({
572
environmentId,
573
task,
574
+ timeZone,
575
onEdit,
576
}: {
577
readonly environmentId: EnvironmentId;
578
readonly task: ScheduledTask;
579
+ readonly timeZone: string | undefined;
580
readonly onEdit: () => void;
581
}) {
582
const canOperate = useAtomValue(
@@ -611,7 +621,7 @@ function ScheduledTaskRow({
621
status={
622
<div className="flex flex-wrap items-center gap-2">
623
<span>
614
- {scheduleLabel(task.schedule)} ·{" "}
624
+ {scheduleLabel(task.schedule, timeZone)} ·{" "}
625
{!task.enabled ? (
626
"Paused"
627
) : isWebhook ? (
@@ -998,6 +1008,7 @@ function ScheduledTaskEditorForm({
1008
draft.editingId !== null &&
1009
tasksQuery.data !== null &&
1010
!tasksQuery.data.tasks.some((entry) => entry.id === draft.editingId);
1011
+ const runAtZone = scheduleTimeZoneLabel(tasksQuery.data?.timeZone);
1012
const liveTask = tasksQuery.data
1013
? (tasksQuery.data.tasks.find((entry) => entry.id === draft.editingId) ?? null)
1014
: task;
@@ -1501,6 +1512,9 @@ function ScheduledTaskEditorForm({
1512
setDraft((current) => ({ ...current, timeOfDay: event.target.value }))
1513
}
1514
/>
1515
+ {runAtZone === undefined ? null : (
1516
+ <span className="text-xs text-muted-foreground">{runAtZone}</span>
1517
+ )}
1518
<span className="text-xs text-muted-foreground">on</span>
1519
</div>
1520
<ToggleGroup
packages/contracts/src/scheduledTask.ts
+2
@@ -196,6 +196,8 @@ export const ScheduledTaskListResult = Schema.Struct({
196
// Trigger types grow over time; a client must not lose the whole list over
197
// one task it cannot decode.
198
tasks: ForwardCompatibleArray(ScheduledTask),
199
+ /** The server's IANA zone for fixed-time schedules. Absent from older servers. */
200
+ timeZone: Schema.optional(TrimmedNonEmptyString),
201
});
202
export type ScheduledTaskListResult = typeof ScheduledTaskListResult.Type;
203