@devries-cameron20 / t3code Mirror · read-only / commits / fe873f82c1
Fork 0

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 21, 16:00 UTC

fix(web): confirm before deleting scheduled tasks (#23578)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Victor committed Nov 14, 2026 at 01:55 UTC fe873f82c1be21c52effe9b5288ef417b01b2460
2 files changed +52 -1
apps/web/src/components/settings/ScheduledTasksSettings.browser.test.tsx
+45 -1
@@ -15,6 +15,7 @@ import { page, userEvent } from "vite-plus/test/browser";
15 import "~/index.css";
16 import { act, render } from "../../../test/render";
17 import { ScheduledTasksSettings } from "./ScheduledTasksSettings";
18 +import { ConfirmDialogHost } from "../ConfirmDialogHost";
19
20 const environmentId = EnvironmentId.make("laptop");
21 const projectId = ProjectId.make("project");
@@ -47,13 +48,19 @@ const threadFamilyRead = {
48 threads: [{ id: task.threadId, title: "Fix login bug" }],
49 };
50
50 -const state = vi.hoisted(() => ({ connected: true, tasksLoaded: true, secondary: false }));
51 +const state = vi.hoisted(() => ({
52 + connected: true,
53 + tasksLoaded: true,
54 + secondary: false,
55 + remove: vi.fn(),
56 +}));
57 const secondaryId = EnvironmentId.make("secondary");
58 const permissions = new Map<string, Atom.Writable<boolean>>();
59
60 function setup() {
61 state.connected = true;
62 state.tasksLoaded = true;
63 + state.remove.mockReset().mockResolvedValue({ _tag: "Success", value: { id: task.id } });
64 state.secondary = false;
65 permissions.clear();
66 permissions.set(environmentId, Atom.make(true));
@@ -65,6 +72,11 @@ function secondaryEnvironment() {
72 return { ...environment(), environmentId: secondaryId, label: "Secondary" };
73 }
74
75 +vi.mock(import("../../state/session"), async (original) => ({
76 + ...(await original()),
77 + readEnvironmentScope: () => true,
78 +}));
79 +
80 function environment() {
81 return {
82 environmentId,
@@ -104,6 +116,10 @@ vi.mock(import("../../state/server"), async (original) => {
116 ...actual,
117 serverEnvironment: {
118 ...actual.serverEnvironment,
119 + deleteScheduledTask: {
120 + ...actual.serverEnvironment.deleteScheduledTask,
121 + run: state.remove,
122 + },
123 upsertScheduledTask: {
124 ...actual.serverEnvironment.upsertScheduledTask,
125 permissionAtom: (id: string | null) => permissions.get(id ?? "")!,
@@ -146,6 +162,34 @@ vi.mock(import("../../hooks/useSettings"), async (original) => ({
162 }));
163
164 describe("ScheduledTasksSettings", () => {
165 + it("only deletes a scheduled task after confirmation, including after cancelling", async () => {
166 + setup();
167 + await using screen = await render(
168 + <>
169 + <ScheduledTasksSettings />
170 + <ConfirmDialogHost />
171 + </>,
172 + );
173 + await userEvent.click(screen.getByRole("button", { name: "Actions for Review issues" }));
174 + await userEvent.click(page.getByRole("menuitem", { name: "Delete", exact: true }));
175 + await expect.element(page.getByRole("alertdialog")).toBeVisible();
176 + expect(state.remove).not.toHaveBeenCalled();
177 + await userEvent.click(page.getByRole("button", { name: "Cancel", exact: true }));
178 + expect(state.remove).not.toHaveBeenCalled();
179 + await expect
180 + .element(screen.getByRole("button", { name: "Actions for Review issues" }))
181 + .toBeVisible();
182 + await userEvent.click(screen.getByRole("button", { name: "Actions for Review issues" }));
183 + await userEvent.click(page.getByRole("menuitem", { name: "Delete", exact: true }));
184 + await userEvent.click(page.getByRole("button", { name: "Confirm", exact: true }));
185 + await vi.waitFor(() =>
186 + expect(state.remove).toHaveBeenCalledExactlyOnceWith(expect.anything(), {
187 + environmentId,
188 + input: { id: task.id },
189 + }),
190 + );
191 + });
192 +
193 it("creates on a permitted secondary and reacts to permission changes", async () => {
194 setup();
195 state.secondary = true;
apps/web/src/components/settings/ScheduledTasksSettings.tsx
+7
@@ -753,6 +753,13 @@ function ScheduledTaskRow({
753 });
754 const act = async (action: "toggle" | "run" | "delete") => {
755 if (busy || !readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return;
756 + if (action === "delete") {
757 + const message = `Delete "${task.title}"?\nThis cannot be undone.`;
758 + const confirmed =
759 + (await requestConfirmDialog(message, { variant: "destructive" })) ??
760 + window.confirm(message);
761 + if (!confirmed) return;
762 + }
763 setBusy(true);
764 const result =
765 action === "toggle"