diff --git a/CHANGELOG.md b/CHANGELOG.md index 833f214a9e..37fb723179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4203,6 +4203,13 @@ This release closes that milestone with **439 merged pull requests**. name existed. Values are now passed through as loaded, as BoxLite and the local provider already did. ([#6673]) +- **frontend:** A one-time scheduled task whose `run_at` is a bare date + (`"2026-12-07"`, which a chat-created task can carry) now shows midnight of + that day in the task's timezone, which is when the server runs it. The UI read + the trailing `-07` as a UTC offset and displayed UTC midnight instead: 08:00 in + `Asia/Shanghai`, and the previous evening west of UTC, in the task list, + detail, chat card and the edit form's prefilled time. ([#6692]) + ### Security - **authz:** Enforce permission checks on routes that only had authentication, and @@ -9616,3 +9623,4 @@ with **180 merged pull requests** since the first 2.0 milestone tag. [#6666]: https://github.com/bytedance/deer-flow/pull/6666 [#6673]: https://github.com/bytedance/deer-flow/pull/6673 [#6681]: https://github.com/bytedance/deer-flow/pull/6681 +[#6692]: https://github.com/bytedance/deer-flow/pull/6692 diff --git a/CHANGELOG_zh.md b/CHANGELOG_zh.md index cbf1d07b39..c0bb428b25 100644 --- a/CHANGELOG_zh.md +++ b/CHANGELOG_zh.md @@ -3226,6 +3226,11 @@ 或 agent 时变成空字符串;若同名主机变量存在,则变成该变量的值。现在这些值按 加载结果原样传递,与 BoxLite 和本地提供者一致。([#6673]) +- **前端:** `run_at` 只有日期(如 `"2026-12-07"`,对话中创建的任务可能如此)的单次定时 + 任务,现在显示为任务时区当天的零点,与服务端实际执行时间一致。此前界面把末尾的 + `-07` 误认为 UTC 偏移量,显示成 UTC 零点:在 `Asia/Shanghai` 显示为 08:00,在 UTC + 以西的时区则显示为前一天晚上;任务列表、详情、对话卡片和编辑表单的预填时间都受影响。([#6692]) + ### 安全 - **鉴权:** 仅有认证而无权限校验的路由现在会强制执行权限检查,且 @@ -7727,3 +7732,4 @@ DeerFlow 2.0 是围绕"超级智能体"框架的彻底重写,核心包含子 [#6666]: https://github.com/bytedance/deer-flow/pull/6666 [#6673]: https://github.com/bytedance/deer-flow/pull/6673 [#6681]: https://github.com/bytedance/deer-flow/pull/6681 +[#6692]: https://github.com/bytedance/deer-flow/pull/6692 diff --git a/frontend/src/core/scheduled-tasks/cron.ts b/frontend/src/core/scheduled-tasks/cron.ts index 7df2e1d0e0..bc47e83158 100644 --- a/frontend/src/core/scheduled-tasks/cron.ts +++ b/frontend/src/core/scheduled-tasks/cron.ts @@ -596,9 +596,19 @@ export function utcToZonedLocalInput(iso: string, timezone: string): string { * ("2026-10-07T09:00:00") meant in the task's zone, the same way the server * reads it; reading it with `new Date()` would use the viewer's zone instead. * A value with an offset is already an instant and is returned unchanged. + * A bare date ("2026-10-07") is midnight in the task's zone, as the server's + * `datetime.fromisoformat` reads it; it is matched first because its trailing + * "-07" would otherwise pass for a UTC offset. */ export function onceRunAtInstant(runAt: string, timezone: string): string { const value = runAt.trim(); + if (/^\d{4}-\d{2}-\d{2}$/.test(value)) { + try { + return zonedLocalToUtcIso(`${value}T00:00`, timezone || "UTC"); + } catch { + return value; + } + } if (!value || /(?:Z|[+-]\d{2}(?::?\d{2})?)$/i.test(value)) { return value; } diff --git a/frontend/tests/e2e/scheduled-task-date-only.spec.ts b/frontend/tests/e2e/scheduled-task-date-only.spec.ts new file mode 100644 index 0000000000..1c1c42ac1c --- /dev/null +++ b/frontend/tests/e2e/scheduled-task-date-only.spec.ts @@ -0,0 +1,68 @@ +import { expect, test } from "@playwright/test"; + +import { mockLangGraphAPI } from "./utils/mock-api"; + +// The viewer's zone differs from the task's, so a result that leans on either +// UTC or the browser zone shows up as a wrong time. +test.use({ timezoneId: "Asia/Shanghai" }); + +test("a date-only run_at shows and edits as midnight in the task's zone", async ({ + page, +}) => { + const patches: Record[] = []; + page.on("request", (request) => { + if ( + request.method() === "PATCH" && + new URL(request.url()).pathname.includes("/api/scheduled-tasks") + ) { + patches.push(request.postDataJSON() as Record); + } + }); + mockLangGraphAPI(page, { + threads: [], + scheduledTasks: [ + { + id: "date-only-task", + thread_id: null, + title: "Date-only task", + prompt: "Summarize", + schedule_type: "once", + // As a chat-created task can store it; the server runs it at + // 2027-12-07 00:00 America/New_York. + schedule_spec: { run_at: "2027-12-07" }, + timezone: "America/New_York", + status: "enabled", + next_run_at: "2027-12-07T05:00:00Z", + last_run_at: null, + last_run_id: null, + last_error: null, + run_count: 0, + created_at: "2026-09-01T00:00:00Z", + updated_at: "2026-09-01T00:00:00Z", + }, + ], + }); + + // The schedule line drops the year inside the current year and turns + // relative ("Tomorrow") in the final week, so pin "now" well before the run. + await page.clock.setFixedTime(new Date("2026-10-01T00:00:00Z")); + await page.goto("/workspace/scheduled-tasks"); + const detail = page.getByTestId("scheduled-task-detail"); + // The schedule line itself, read from run_at. The separate next-run line + // comes from the server's next_run_at and was right even before. + await expect( + detail.getByText("Once, Dec 7, 2027 00:00 (America/New_York)", { + exact: true, + }), + ).toBeVisible(); + + await detail.getByRole("button", { name: "Edit", exact: true }).click(); + const form = page.getByTestId("scheduled-task-form"); + await expect(form.getByLabel("Run at")).toHaveValue("2027-12-07T00:00"); + + await form.getByLabel("Title", { exact: true }).fill("Renamed task"); + await form.getByRole("button", { name: "Save changes", exact: true }).click(); + await expect.poll(() => patches.length).toBe(1); + // Only the title changed, so the stored run_at is not rewritten. + expect(patches[0]).not.toHaveProperty("schedule_spec"); +}); diff --git a/frontend/tests/unit/components/workspace/schedule-edit-instant.dom.test.tsx b/frontend/tests/unit/components/workspace/schedule-edit-instant.dom.test.tsx index 37c90015fc..d51a76ed04 100644 --- a/frontend/tests/unit/components/workspace/schedule-edit-instant.dom.test.tsx +++ b/frontend/tests/unit/components/workspace/schedule-edit-instant.dom.test.tsx @@ -62,6 +62,24 @@ test.each([ expect(onChange).toHaveBeenLastCalledWith(initial); }); +test("a date-only run_at opens at midnight in the task's zone and is kept as sent", () => { + // The server runs a bare date at midnight in the task's zone; reading it as + // UTC midnight put the New York field on the previous evening. + const initial = once("2026-12-07"); + const onChange = rs.fn(); + const ui = render( + , + ); + expect((ui.getByLabelText("Run at") as HTMLInputElement).value).toBe( + "2026-12-07T00:00", + ); + expect(onChange).toHaveBeenLastCalledWith(initial); +}); + test("parent feedback and title-only rerenders retain the original instant", () => { const original = once("2026-11-01T06:30:00Z"); function Editor() { diff --git a/frontend/tests/unit/core/scheduled-tasks/cron.test.ts b/frontend/tests/unit/core/scheduled-tasks/cron.test.ts index 6ce8e1b112..092c4d792f 100644 --- a/frontend/tests/unit/core/scheduled-tasks/cron.test.ts +++ b/frontend/tests/unit/core/scheduled-tasks/cron.test.ts @@ -538,6 +538,17 @@ describe("onceRunAtInstant", () => { ); }); + test("a date-only run_at is midnight in the task's zone, as the server runs it", () => { + // `-07` at the end of a bare date is a day, not a UTC offset. + expect(onceRunAtInstant("2026-12-07", "Asia/Shanghai")).toBe( + "2026-12-06T16:00:00+00:00", + ); + // West of UTC the old reading (UTC midnight) also fell on the previous day. + expect(onceRunAtInstant("2026-12-07", "America/New_York")).toBe( + "2026-12-07T05:00:00+00:00", + ); + }); + test("a run_at with an offset is already an instant", () => { for (const value of [ "2026-10-07T01:00:00Z", @@ -655,4 +666,22 @@ describe("describeTaskSchedule for a chat-created one-time task", () => { }).text, ).toBe("Once, Oct 7 09:00 (America/New_York)"); }); + + test("reads a date-only run_at as midnight on that day in the task's zone", () => { + for (const [timezone, expected] of [ + ["Asia/Shanghai", "Once, Dec 7 00:00 (Asia/Shanghai)"], + ["America/New_York", "Once, Dec 7 00:00 (America/New_York)"], + ] as const) { + const task = { + schedule_type: "once" as const, + schedule_spec: { run_at: "2026-12-07" }, + timezone, + }; + expect( + describeTaskSchedule(task, "en-US", { + now: new Date("2026-10-01T00:00:00Z"), + }).text, + ).toBe(expected); + } + }); });