A local-first multi-agent app development platform, built on PenguinHarness
fix(web): 定时任务的启用开关被拒时,原因留在那一行下面
lmlihenge7d5369e7b3c
diff --git a/changelog/unreleased/2026-10-31-schedule-toggle-refusal.md b/changelog/unreleased/2026-10-31-schedule-toggle-refusal.mdnew file mode 100644index 00000000..eab6ac4c--- /dev/null+++ b/changelog/unreleased/2026-10-31-schedule-toggle-refusal.md@@ -0,0 +1,49 @@+# A scheduled task's enable switch keeps a refusal's reason under its row, not only in a toast++- **Date:** 2026-10-31+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[中文](2026-10-31-schedule-toggle-refusal.zh.md)++The enable switch on a scheduled task's row writes nothing optimistically either: it moves only+once the write lands, so a refused flip leaves the switch where it was and the list unchanged —+the attempt looks like nothing happened at all, and the only word about why was a toast that+dismissed itself after six seconds. The two surfaces that share that row (the scheduled-tasks page+and the chat dock's scheduled-tasks panel) now keep the server's sentence under the row the flip+named, until the next flip.++## Details++- `packages/web/src/features/schedules/schedule-toggle.ts` (new): `ScheduleToggleRefusal` plus+ `scheduleRefusalFor()` — the one place that decides which row draws the sentence. A task is+ named by the Agent whose directory holds the file plus the file name, so two Agents may hold+ tasks of the same name and only the refused one may show it.+- `packages/web/src/features/schedules/schedule-row.tsx`: a `refusal` prop draws one danger-ink+ `role="alert"` line under the name and its schedule line (two lines at most, the whole sentence+ on hover), reusing the shared lead-in `S.common.refused` so it reads like every other refused+ write in the app; no new copy.+- `packages/web/src/features/schedules/schedules-page.tsx`, `schedule-panel.tsx`: each keeps its+ own `toggleRefusal` state (both hosts already keep their own copy of the delete confirmation's+ refusal; the rows themselves are shared), cleared before a flip and filled from the failure via+ `apiErrorText` (so the words are the server's, or the app's sentence for that code) instead of+ `toastError`.++## Tests++- `packages/web/test/schedule-toggle.test.ts` (new, 4 cases): silent with no refusal, the named+ row gets the sentence, another task of the same Agent does not inherit it, and neither does+ another Agent's task of the same name.+- `packages/web/e2e/schedule-toggle-refusal.spec.mjs` (new, three cases against the real server):+ a refused flip leaves the reason on that row (and not on its neighbour), writes nothing (no+ toast in the notification region, the switch stays armed, the task stays enabled on the server)+ and the line is still there after the six seconds a toast lives; with the refusal lifted the+ next flip lands, the line goes and the switch follows; the dock's panel behaves the same.++## Compatibility++- No API, on-disk or request-shape change. A successful flip behaves exactly as before; only the+ failure path stopped using a toast.+- The Agent settings tab lists tasks in a table with text buttons rather than the shared row, so+ it is untouched this round — see the ledger.diff --git a/changelog/unreleased/2026-10-31-schedule-toggle-refusal.zh.md b/changelog/unreleased/2026-10-31-schedule-toggle-refusal.zh.mdnew file mode 100644index 00000000..25709cb4--- /dev/null+++ b/changelog/unreleased/2026-10-31-schedule-toggle-refusal.zh.md@@ -0,0 +1,39 @@+# 定时任务的启用开关被拒时,原因留在那一行下面,不再只活在六秒的提示里++- **日期:** 2026-10-31+- **类型:** fix+- **范围:** `web`+- **破坏性:** 无++[English](2026-10-31-schedule-toggle-refusal.md)++定时任务行的启用开关同样是**不乐观写入**:写入落地之前它不动,所以被拒的那一次什么都不会发生 ——+开关还在原位、列表也没有变。于是原因只剩一条 toast,六秒之后屏幕上就是「点了没反应」,而读者+看着的正是那个开关。两个共用这一行的界面(「定时任务」页与对话停靠栏里的定时任务面板)现在把服务端+的话留在这一行下面,直到下一次翻转。++## 细节++- `packages/web/src/features/schedules/schedule-toggle.ts`(新):`ScheduleToggleRefusal` 与+ `scheduleRefusalFor()` —— 一句话属于哪一行由这里一处决定:任务的名字是「Agent 的目录 + 文件名」,+ 两个 Agent 可以有同名任务,所以只让被拒的那一行画出这句话。+- `packages/web/src/features/schedules/schedule-row.tsx`:多一个 `refusal` 属性,在名字与排期行+ 下面画一行 danger 色的 `role="alert"`(限两行、整句挂在悬停上),引子复用全站共享的+ `S.common.refused`,与「被拒的写入」在别处读起来一致;没有新增文案。+- `packages/web/src/features/schedules/schedules-page.tsx`、`schedule-panel.tsx`:各自多一个+ `toggleRefusal` 状态(两个宿主本来就各留一份删除确认的拒绝,行本身共用),翻转前清空、被拒时+ 经 `apiErrorText` 填上(所以是服务端原话,或该码的本地化句子),不再走 `toastError`。++## 测试++- `packages/web/test/schedule-toggle.test.ts`(新,4 条):没有拒绝时不出声、被拒的那一行拿到+ 句子、同一个 Agent 的另一个任务不继承、另一个 Agent 的同名任务也不继承。+- `packages/web/e2e/schedule-toggle-refusal.spec.mjs`(新,真服务端三条):被拒的翻转把原因留在+ 那一行(旁边那一行没有)、通知区里没有可点的 toast、开关仍是开位、服务端里任务仍启用,并且+ toast 该消失的六秒之后这一行还在;放开拒绝后下一次翻转真的落地,这一行随之消失、开关跟着移动;+ 停靠栏面板里同样成立。++## 兼容++- 接口、磁盘格式、请求体都没变。成功的翻转与从前完全一致,只有失败那条路不再用 toast。+- Agent 设置页的定时任务 tab 用的是按钮与表格(不是共用的这一行),本轮没动,见台账。diff --git a/packages/web/e2e/schedule-toggle-refusal.spec.mjs b/packages/web/e2e/schedule-toggle-refusal.spec.mjsnew file mode 100644index 00000000..f15e1b0a--- /dev/null+++ b/packages/web/e2e/schedule-toggle-refusal.spec.mjs@@ -0,0 +1,209 @@+/**+ * Regression: the enable switch of a scheduled task says why a flip did not settle, under that+ * row, and the sentence outlives the six seconds a toast lives.+ *+ * The switch writes nothing optimistically — it keeps the position the server has — so a refused+ * flip used to leave no trace on the screen at all: the reason arrived as a toast, dismissed+ * itself, and a reader who looked away was left with a switch that would not move and one+ * sentence they never got to read. Both surfaces that list tasks with the shared row (the+ * scheduled-tasks page and the chat dock's panel) now keep it under the row the flip named+ * (`role="alert"`), until the next flip.+ *+ * The refusal is a real one the server can answer — `schedule_not_found`, the task file gone+ * (another window deleted it between the list read and the flip) — taken over by a route so the+ * test does not have to race the store's own refetch. The app has its own sentence for that+ * code, so the line on screen is the localized one, not the server's English.+ *+ * Every test seeds through the API: a `startAt` in the future keeps the scheduler out of the+ * way, and the seed drops a leftover file of the same name first, since a rerun of this file+ * alone shares one data root with earlier runs.+ */+import { test, expect } from "@playwright/test";+import { provisionAndLogin } from "./auth.mjs";++const BASE = process.env.BASE_URL;+const MOCK = process.env.MOCK_URL;+const P = "password123";+const AGENT = "default_agent";++/** What the server answers when the task file is gone by the time the flip is written. */+const REFUSAL = { code: "schedule_not_found", message: "Schedule does not exist: toggle_probe" };+/** The line the row draws: the shared lead-in plus the app's own sentence for that code. */+const REFUSED_LINE = "操作被拒绝:该定时任务已不存在。";++/**+ * Provision the user, give the Project a model (the onboarding overlay covers the page without+ * one), and seed one future task per name. `bindSession` also creates the Session the dock's+ * panel lists tasks of, and pins every task to it.+ */+async function projectWithTasks(page, user, names, options = {}) {+ await provisionAndLogin(page.request, user, P);+ const projectId = (await (await page.request.get(`${BASE}/api/projects`)).json()).projects[0]+ .projectId;+ const put = await page.request.put(`${BASE}/api/projects/${projectId}/models`, {+ data: {+ defaultModel: { provider: "custom", modelId: "claude-4-8" },+ models: [+ {+ provider: "custom",+ modelId: "claude-4-8",+ apiKey: "sk-mock",+ baseUrl: MOCK,+ contextWindow: 200000,+ },+ ],+ },+ });+ expect(put.ok(), "put models").toBeTruthy();++ let sessionId;+ if (options.bindSession === true) {+ const created = await page.request.post(+ `${BASE}/api/projects/${projectId}/agents/${AGENT}/sessions`,+ { data: { provider: "custom", modelId: "claude-4-8", approvalMode: "allow-all" } },+ );+ expect(created.ok(), "create session").toBeTruthy();+ sessionId = (await created.json()).session.sessionId;+ }++ const base = `${BASE}/api/projects/${projectId}/agents/${AGENT}/schedules`;+ for (const name of names) {+ await page.request.delete(`${base}/${name}`);+ const created = await page.request.post(base, {+ data: {+ name,+ prompt: "toggle refusal probe",+ enabled: true,+ startAt: new Date(Date.now() + 86_400_000).toISOString(),+ ...(sessionId === undefined ? {} : { sessionId }),+ },+ });+ expect(created.status(), `seed ${name}`).toBe(201);+ }++ /** The Project's list as the server holds it: what the page and the panel both read. */+ const listed = async () =>+ (await (await page.request.get(`${BASE}/api/projects/${projectId}/schedules`)).json())+ .schedules;+ return { projectId, sessionId, listed };+}++/** Refuse every schedule write with the "the file is gone" answer; the flips that reach it are counted. */+async function refuseFlips(page, seen) {+ let refuse = true;+ await page.route("**/api/projects/*/agents/*/schedules/*", async (route) => {+ if (route.request().method() !== "PUT") return route.fallback();+ seen.push(route.request().url());+ if (!refuse) return route.fallback();+ await route.fulfill({+ status: 404,+ contentType: "application/json",+ body: JSON.stringify({ error: REFUSAL }),+ });+ });+ return () => {+ refuse = false;+ };+}++/** The row of one task on whichever surface lists it (both wrap it in an `li`). */+function rowOf(scope, name) {+ return scope.locator("li").filter({ hasText: name });+}++/** The row's enable switch, named by what its flip would do (the task is seeded armed, so: 停用). */+function switchOf(row) {+ return row.getByRole("switch", { name: "停用" });+}++/**+ * The row's switch by role alone: its accessible name IS what the flip would do, so the name+ * changes with the position and a locator bound to one of them stops resolving after a write.+ */+function anySwitch(row) {+ return row.getByRole("switch");+}++test("a refused flip on the schedules page leaves the reason under that row, and only that row", async ({+ page,+}) => {+ const { listed } = await projectWithTasks(page, "r169page", ["toggle_probe", "quiet_probe"]);+ const before = await listed();++ await page.goto("/schedules");+ const row = rowOf(page.locator("main"), "toggle_probe");+ await expect(row).toBeVisible();+ const other = rowOf(page.locator("main"), "quiet_probe");+ await expect(other).toBeVisible();++ const flips = [];+ await refuseFlips(page, flips);+ await switchOf(row).click();++ // The reason is in the row that asked, and it is not a toast: the notification region holds no+ // dismissible button, and the neighbouring row says nothing.+ await expect(row.getByRole("alert")).toHaveText(REFUSED_LINE);+ await expect(other.getByRole("alert")).toHaveCount(0);+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);+ expect(flips).toHaveLength(1);++ // The switch kept the position the server still has, and the task is still armed there.+ await expect(switchOf(row)).toBeChecked();+ const armed = (await listed()).find((s) => s.name === "toggle_probe");+ expect(armed?.enabled).toBe(true);+ expect((await listed()).length).toBe(before.length);++ // Six seconds is how long a toast lives; this line has to still be there after it.+ await page.waitForTimeout(7_000);+ await expect(row.getByRole("alert")).toHaveText(REFUSED_LINE);+});++test("the next flip clears the line, and a flip that lands moves the switch", async ({ page }) => {+ const { listed } = await projectWithTasks(page, "r169retry", ["retry_probe"]);++ await page.goto("/schedules");+ const row = rowOf(page.locator("main"), "retry_probe");+ await expect(row).toBeVisible();++ const flips = [];+ const letThrough = await refuseFlips(page, flips);+ await switchOf(row).click();+ await expect(row.getByRole("alert")).toHaveText(REFUSED_LINE);+ await expect(anySwitch(row)).toBeChecked();++ // Same switch, second click: this time the write lands, so the sentence goes and the switch+ // moves to the position the server now has — its name along with it (停用 → 启用).+ letThrough();+ await switchOf(row).click();+ await expect(row.getByRole("alert")).toHaveCount(0);+ await expect(anySwitch(row)).not.toBeChecked();+ await expect(row.getByRole("switch", { name: "启用" })).toBeVisible();+ expect(flips).toHaveLength(2);+ expect((await listed()).find((s) => s.name === "retry_probe")?.enabled).toBe(false);+});++test("a refused flip in the chat dock's panel keeps the reason under its row too", async ({+ page,+}) => {+ const { sessionId } = await projectWithTasks(page, "r169panel", ["panel_probe"], {+ bindSession: true,+ });++ await page.goto(`/chat/${sessionId}`);+ await page.getByTestId("dock-toggle-right").click();+ const panel = page.locator('[data-testid="dock"][data-open="true"]');+ await panel.getByTestId("dock-pick-schedules").click();+ const row = rowOf(panel, "panel_probe");+ await expect(row).toBeVisible();++ const flips = [];+ await refuseFlips(page, flips);+ await switchOf(row).click();++ await expect(row.getByRole("alert")).toHaveText(REFUSED_LINE);+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);+ expect(flips).toHaveLength(1);+ await expect(switchOf(row)).toBeChecked();+ await page.waitForTimeout(7_000);+ await expect(row.getByRole("alert")).toHaveText(REFUSED_LINE);+});diff --git a/packages/web/src/features/schedules/schedule-panel.tsx b/packages/web/src/features/schedules/schedule-panel.tsxindex 48e944d8..b3caddd0 100644--- a/packages/web/src/features/schedules/schedule-panel.tsx+++ b/packages/web/src/features/schedules/schedule-panel.tsx@@ -23,7 +23,6 @@ import {Segmented,SettingsEmpty,SkeletonList,- toastError,toastSuccess,} from "@adelie/ui";import * as api from "../../api/endpoints";@@ -43,6 +42,8 @@ import {import type { ScheduleFilter } from "./schedule-panel-state";import { refreshSchedules, useProjectSchedules } from "./schedule-store";import { ScheduleSuggestions } from "./schedule-suggestions";+import { scheduleRefusalFor } from "./schedule-toggle";+import type { ScheduleToggleRefusal } from "./schedule-toggle";import { toggleBody } from "./schedule-upsert";/** How often the list refetches while on screen — about the server's own re-read cadence for the schedule directory. */@@ -61,7 +62,8 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePaconst projectId = currentProject?.projectId ?? null;const isOwner = currentProject?.role === "owner";// The shared store's list, narrowed to this conversation; only the first load's failure shows- // in place, and row actions report via toast.+ // in place, the switch's own refusals show under their row, and the rest of the row actions+ // report via toast.const { items: projectItems, error } = useProjectSchedules(projectId, session.sessionId);const items = projectItems === null ? null : sessionSchedules(projectItems, session.sessionId);const [query, setQuery] = useState("");@@ -75,6 +77,9 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePa// The server's words for a delete it refused, drawn inside that same confirmation — the// panel's copy of the page's rule, since both list the same rows (`ScheduleRow`).const [deleteRefusal, setDeleteRefusal] = useState<string | null>(null);+ // The server's words for a flip of a row's switch it refused, drawn under that row — the+ // panel's copy of the page's rule, since both list the same rows (`ScheduleRow`).+ const [toggleRefusal, setToggleRefusal] = useState<ScheduleToggleRefusal | null>(null);// AI dialog: non-null means open, seeded with a suggestion's prompt or nothing.const [ai, setAi] = useState<{ initial: string } | null>(null);@@ -104,13 +109,17 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePa*/const toggle = async (item: ProjectScheduleItem) => {if (!projectId) return;+ // The sentence on screen belonged to the attempt before, not to the one about to be made.+ setToggleRefusal(null);setBusy(true);try {await api.updateSchedule(projectId, item.agentId, item.name, toggleBody(item, !item.enabled));toastSuccess(item.enabled ? S.schedule.toastDisabled : S.schedule.toastEnabled);await refreshSchedules(projectId);} catch (e) {- toastError(apiErrorText(e));+ // Under the row, not in a toast: the switch does not move either way, so the reason has to+ // stay where the reader is looking — and it has to outlive six seconds.+ setToggleRefusal({ agentId: item.agentId, name: item.name, text: apiErrorText(e) });} finally {setBusy(false);}@@ -199,6 +208,7 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePaitem={item}owner={isOwner}busy={busy}+ refusal={scheduleRefusalFor(toggleRefusal, item)}onToggle={() => void toggle(item)}onEdit={() => setForm({ editing: item })}onDelete={() => {diff --git a/packages/web/src/features/schedules/schedule-row.tsx b/packages/web/src/features/schedules/schedule-row.tsxindex 0e0f8828..fb4a107a 100644--- a/packages/web/src/features/schedules/schedule-row.tsx+++ b/packages/web/src/features/schedules/schedule-row.tsx@@ -90,6 +90,7 @@ export function ScheduleRow({onToggle,onEdit,onDelete,+ refusal = null,}: {item: ScheduleItem;owner: boolean;@@ -97,6 +98,12 @@ export function ScheduleRow({onToggle: () => void;onEdit: () => void;onDelete: () => void;+ /**+ * The server's words for a flip of THIS row's switch it refused (the host picks the row with+ * `scheduleRefusalFor`). The switch keeps the position the server has — nothing is written+ * optimistically — so without this line the attempt leaves no trace at all.+ */+ refusal?: string | null;}) {const { locale } = useLocale();const line = describeSchedule(item, locale);@@ -124,6 +131,20 @@ export function ScheduleRow({>{line}</div>+ {/* Under the switch's row, where the reader was looking when the flip did not settle: the+ same alert shape (and the same shared lead-in) the dialogs and the messaging switch+ use for a refused write. `line-clamp-2` keeps a long server sentence from stretching+ the list; the whole text is on hover. */}+ {refusal !== null && (+ <p+ role="alert"+ data-tooltip={S.common.refused(refusal)}+ data-tooltip-content="text"+ className={`line-clamp-2 break-words text-xs ${toneInk.danger}`}+ >+ {S.common.refused(refusal)}+ </p>+ )}</div>{owner && (<>diff --git a/packages/web/src/features/schedules/schedule-toggle.ts b/packages/web/src/features/schedules/schedule-toggle.tsnew file mode 100644index 00000000..d41b484d--- /dev/null+++ b/packages/web/src/features/schedules/schedule-toggle.ts@@ -0,0 +1,41 @@+/**+ * The enable switch's refusal, and which row draws it.+ *+ * The switch writes nothing optimistically — it keeps the position the server has — so a refused+ * flip leaves no trace on the screen at all, and the only word about why was a toast that+ * dismissed itself after six seconds. That sentence now stays under that row instead, and it+ * stays until the next flip: the surfaces that list tasks (`schedule-panel.tsx` for the+ * conversation on screen, `schedules-page.tsx` for the whole Project) each keep their own copy of+ * it, the way they already keep their own copy of the delete confirmation's refusal — the rows+ * themselves are shared (`ScheduleRow`).+ *+ * Which row draws it is decided here, in one place, because both hosts ask that question: a task+ * is named by the Agent whose directory holds the file plus the file name, so two Agents may hold+ * tasks of the same name, and the sentence belongs to exactly one of them.+ */++/** The flip the server refused, named by the task it was about, with the server's words (`apiErrorText`). */+export interface ScheduleToggleRefusal {+ agentId: string;+ name: string;+ text: string;+}++/** What a row has to say to be the one the refusal names. */+export interface ScheduleTask {+ agentId: string;+ name: string;+}++/**+ * The line one row draws: the refused task's own sentence, and nothing on any other row — the+ * other rows were never written to, and a sentence about one task shown under another would read+ * as a failure of that one.+ */+export function scheduleRefusalFor(+ refusal: ScheduleToggleRefusal | null,+ task: ScheduleTask,+): string | null {+ if (refusal === null) return null;+ return refusal.agentId === task.agentId && refusal.name === task.name ? refusal.text : null;+}diff --git a/packages/web/src/features/schedules/schedules-page.tsx b/packages/web/src/features/schedules/schedules-page.tsxindex 089b5d59..ef8a57bc 100644--- a/packages/web/src/features/schedules/schedules-page.tsx+++ b/packages/web/src/features/schedules/schedules-page.tsx@@ -52,7 +52,6 @@ import {Segmented,SettingsEmpty,SkeletonList,- toastError,toastSuccess,} from "@adelie/ui";import * as api from "../../api/endpoints";@@ -66,6 +65,8 @@ import type { ScheduleFilter } from "./schedule-panel-state";import { ScheduleFormModal } from "./schedule-form-modal";import { ScheduleRow } from "./schedule-row";import { refreshSchedules, useProjectSchedules } from "./schedule-store";+import { scheduleRefusalFor } from "./schedule-toggle";+import type { ScheduleToggleRefusal } from "./schedule-toggle";import { toggleBody } from "./schedule-upsert";/**@@ -116,6 +117,10 @@ export function SchedulesPage() {// The server's words for a delete it refused, drawn inside that same confirmation: the reason// has to survive the six-second toast, because retrying is the next thing the user does.const [deleteRefusal, setDeleteRefusal] = useState<string | null>(null);+ // The server's words for a flip of a row's switch it refused, drawn under that row: the switch+ // keeps the server's position (nothing is written optimistically), so this sentence is the only+ // trace the attempt leaves on screen.+ const [toggleRefusal, setToggleRefusal] = useState<ScheduleToggleRefusal | null>(null);// The "new task" button's Agent picker.const [agentsOpen, setAgentsOpen] = useState(false);@@ -165,13 +170,17 @@ export function SchedulesPage() {*/const toggle = async (item: ProjectScheduleItem) => {if (!projectId) return;+ // The sentence on screen belonged to the attempt before, not to the one about to be made.+ setToggleRefusal(null);setBusy(true);try {await api.updateSchedule(projectId, item.agentId, item.name, toggleBody(item, !item.enabled));toastSuccess(item.enabled ? S.schedule.toastDisabled : S.schedule.toastEnabled);await refreshSchedules(projectId);} catch (e) {- toastError(apiErrorText(e));+ // Under the row, not in a toast: the switch does not move either way, so the reason has to+ // stay where the reader is looking — and it has to outlive six seconds.+ setToggleRefusal({ agentId: item.agentId, name: item.name, text: apiErrorText(e) });} finally {setBusy(false);}@@ -434,6 +443,7 @@ export function SchedulesPage() {item={item}owner={isOwner}busy={busy}+ refusal={scheduleRefusalFor(toggleRefusal, item)}onToggle={() => void toggle(item)}onEdit={() => setForm({ agentId: item.agentId, editing: item })}onDelete={() => {diff --git a/packages/web/test/schedule-toggle.test.ts b/packages/web/test/schedule-toggle.test.tsnew file mode 100644index 00000000..128ee847--- /dev/null+++ b/packages/web/test/schedule-toggle.test.ts@@ -0,0 +1,41 @@+/**+ * Which row carries the enable switch's refusal (src/features/schedules/schedule-toggle.ts).+ *+ * The two surfaces that list tasks keep their own copy of the refusal, so this is the one rule+ * they share: a task is named by its Agent's directory plus the file name, and only the row the+ * refused flip named may draw that sentence — a sentence about one task under another would read+ * as a failure of that one.+ */+import { describe, expect, it } from "vitest";+import { scheduleRefusalFor } from "../src/features/schedules/schedule-toggle";+import type { ScheduleToggleRefusal } from "../src/features/schedules/schedule-toggle";++const refused: ScheduleToggleRefusal = {+ agentId: "default_agent",+ name: "daily_probe",+ text: "该定时任务已不存在。",+};++describe("scheduleRefusalFor", () => {+ it("draws nothing while no flip has been refused", () => {+ expect(scheduleRefusalFor(null, { agentId: "default_agent", name: "daily_probe" })).toBeNull();+ });++ it("draws the sentence on the row the refused flip named", () => {+ expect(scheduleRefusalFor(refused, { agentId: "default_agent", name: "daily_probe" })).toBe(+ "该定时任务已不存在。",+ );+ });++ it("keeps quiet on another task of the same Agent — that row was never written to", () => {+ expect(+ scheduleRefusalFor(refused, { agentId: "default_agent", name: "weekly_probe" }),+ ).toBeNull();+ });++ it("keeps quiet on another Agent's task of the same name — a task is its directory plus its file", () => {+ expect(+ scheduleRefusalFor(refused, { agentId: "reviewer_agent", name: "daily_probe" }),+ ).toBeNull();+ });+});