@devries-cameron20 / t3code-1 / commits / 250e502bfa
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(mobile): scheduled-task edits made in quick succession are no longer lost (#27220)

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

tcrapts committed Nov 14, 2026 at 13:06 UTC 250e502bfa1921f1ae5a102184e9f5f00c2fcb15
3 files changed +401 -81
apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.test.tsx new
+264
@@ -0,0 +1,264 @@
1 +import { RegistryContext } from "@effect/atom-react";
2 +import {
3 + EnvironmentId,
4 + ProjectId,
5 + ProviderInstanceId,
6 + ScheduledTaskId,
7 + type ScheduledTask,
8 +} from "@t3tools/contracts";
9 +import { Atom } from "effect/reactivity";
10 +import { act, type ReactNode } from "react";
11 +import { createRoot, type Root } from "react-dom/client";
12 +import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
13 +
14 +const { Children, mocks } = vi.hoisted(() => ({
15 + Children: ({ children }: { children?: ReactNode }) => children,
16 + mocks: { upsert: vi.fn(), alert: vi.fn(), tasks: [] as ScheduledTask[] },
17 +}));
18 +vi.mock("react-native", () => ({
19 + Platform: { OS: "ios" },
20 + View: Children,
21 + TextInput: () => null,
22 + Pressable: ({ children, onPress }: { children?: ReactNode; onPress: () => void }) => (
23 + <button onClick={onPress}>{children}</button>
24 + ),
25 +}));
26 +vi.mock("@react-navigation/native", () => ({
27 + useNavigation: () => ({ isFocused: () => false }),
28 + usePreventRemove: () => {},
29 +}));
30 +vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ bottom: 0 }) }));
31 +vi.mock("@expo/ui/community/datetime-picker", () => ({ DateTimePicker: () => null }));
32 +vi.mock("../../components/ui/Dialog", () => ({ alert: mocks.alert }));
33 +vi.mock("../../components/ui/AppText", () => ({ AppText: Children }));
34 +vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
35 +vi.mock("../../components/EnvironmentMachineSymbol", () => ({
36 + EnvironmentMachineSymbol: () => null,
37 + ENVIRONMENT_MACHINE_SYMBOLS: {},
38 +}));
39 +vi.mock("../../components/ui/Menu", () => ({
40 + Menu: ({
41 + actions,
42 + onPressAction,
43 + }: {
44 + actions: readonly { id: string; title: string }[];
45 + onPressAction: (event: { nativeEvent: { event: string } }) => void;
46 + }) =>
47 + actions.map(({ id, title }) => (
48 + <button key={id} onClick={() => onPressAction({ nativeEvent: { event: id } })}>
49 + Select {title}
50 + </button>
51 + )),
52 +}));
53 +vi.mock("../../components/ui/ScreenScrollView", () => ({ ScreenScrollView: Children }));
54 +vi.mock("./components/SettingsScreen", () => ({ SettingsScreen: Children }));
55 +vi.mock("./components/SettingsSection", () => ({ SettingsSection: Children }));
56 +vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({
57 + useSettingsEnvironmentMenu: () => null,
58 +}));
59 +vi.mock("./components/ScheduledTaskPromptField", () => ({ ScheduledTaskPromptField: () => null }));
60 +vi.mock("../layout/workspace/useSelectWorkspaceDetail", () => ({
61 + useSelectWorkspaceDetail: () => vi.fn(),
62 +}));
63 +vi.mock("../../state/threads", () => ({ threadFamilies: {} }));
64 +vi.mock("../../lib/copyTextWithHaptic", () => ({ tryCopyTextWithHaptic: vi.fn() }));
65 +vi.mock("../voice-input/useVoiceInputController", () => ({
66 + useVoiceInputController: () => ({ blocksSubmission: false }),
67 +}));
68 +vi.mock("../../components/ui/Button", () => ({
69 + Button: ({ label, onPress }: { label: string; onPress: () => void }) => (
70 + <button onClick={onPress}>{label}</button>
71 + ),
72 +}));
73 +vi.mock("../../components/ui/SegmentedControl", () => ({
74 + SegmentedControl: ({
75 + options,
76 + onSelect,
77 + }: {
78 + options: readonly { value: string; label: string }[];
79 + onSelect: (value: string) => void;
80 + }) =>
81 + options.map(({ value, label }) => (
82 + <button key={value} onClick={() => onSelect(value)}>
83 + {label}
84 + </button>
85 + )),
86 +}));
87 +vi.mock("../../components/ui/ThemedSwitch", () => ({
88 + ThemedSwitch: ({
89 + value,
90 + onValueChange,
91 + }: {
92 + value: boolean;
93 + onValueChange: (value: boolean) => void;
94 + }) => <button onClick={() => onValueChange(!value)}>Toggle enabled</button>,
95 +}));
96 +vi.mock("../../state/entities", () => ({
97 + useProjects: () => [
98 + { environmentId: "environment", id: "project", title: "Project" },
99 + { environmentId: "target", id: "target-project", title: "Target project" },
100 + ],
101 + useServerConfigs: () => new Map(),
102 + useEnvironmentServerConfig: () => null,
103 + useThreadShell: () => null,
104 +}));
105 +vi.mock("./settings-environment-filter", () => ({
106 + useSettingsEnvironmentFilter: () => ({
107 + selectedTargets: [{ environmentId: "environment", label: "Environment" }],
108 + availableTargets: [
109 + { environmentId: "environment", label: "Environment" },
110 + { environmentId: "target", label: "Target" },
111 + ],
112 + selectedProjectKey: null,
113 + projectGroups: [],
114 + }),
115 +}));
116 +vi.mock("../../lib/modelOptions", () => ({
117 + buildModelOptions: () => [],
118 + resolveDefaultableModelSelection: () => null,
119 + resolveNewTaskModelSelection: () => null,
120 +}));
121 +vi.mock("../../state/session", () => ({
122 + readEnvironmentScope: () => true,
123 + usePreparedConnection: () => ({ _tag: "None" }),
124 +}));
125 +vi.mock("../../state/server", () => ({
126 + serverEnvironment: {
127 + scheduledTasksLive: () => ({}),
128 + upsertScheduledTask: { permissionAtom: () => Atom.make(true) },
129 + },
130 +}));
131 +vi.mock("../../state/query", () => ({
132 + useEnvironmentQuery: () => ({ data: { tasks: mocks.tasks, threads: [] } }),
133 +}));
134 +vi.mock("../../state/use-atom-command", () => ({ useAtomCommand: () => mocks.upsert }));
135 +
136 +import { appAtomRegistry } from "../../state/atom-registry";
137 +import { editDraft } from "./scheduledTaskDraft";
138 +import {
139 + scheduledTaskEditorSessionAtom,
140 + startScheduledTaskEditor,
141 +} from "./scheduled-task-editor-state";
142 +import { SettingsScheduledTaskEditRouteScreen } from "./SettingsScheduledTasksRouteScreen";
143 +
144 +let root: Root;
145 +let container: HTMLDivElement;
146 +beforeEach(() => {
147 + (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
148 + container = document.createElement("div");
149 + root = createRoot(container);
150 + mocks.alert.mockReset();
151 + mocks.upsert.mockReset();
152 + mocks.upsert.mockResolvedValue({ _tag: "Success" });
153 + const task: ScheduledTask = {
154 + id: ScheduledTaskId.make("task"),
155 + title: "Task",
156 + prompt: "Prompt",
157 + enabled: true,
158 + schedule: { type: "fixed_time", timeOfDay: "05:00" },
159 + projectId: ProjectId.make("project"),
160 + threadId: null,
161 + workspaceStrategy: { type: "root" },
162 + modelSelection: {
163 + instanceId: ProviderInstanceId.make("codex"),
164 + model: "model",
165 + },
166 + runtimeMode: "full-access",
167 + interactionMode: "default",
168 + createdBy: "user",
169 + creationSource: "mobile",
170 + createdAt: "2026-10-22T00:00:00.000Z",
171 + updatedAt: "2026-10-22T00:00:00.000Z",
172 + nextRunAt: null,
173 + lastRunAt: null,
174 + lastRunStatus: "never",
175 + lastRunError: null,
176 + runCount: 0,
177 + };
178 + mocks.tasks = [task];
179 + const draft = editDraft(task);
180 + startScheduledTaskEditor({
181 + environmentId: EnvironmentId.make("environment"),
182 + environmentLabel: "Environment",
183 + draft: { ...draft, schedule: { ...draft.schedule, intervalMinutes: "60" } },
184 + });
185 + act(() =>
186 + root.render(
187 + <RegistryContext.Provider value={appAtomRegistry}>
188 + <SettingsScheduledTaskEditRouteScreen />
189 + </RegistryContext.Provider>,
190 + ),
191 + );
192 +});
193 +afterEach(() => {
194 + act(() => root.unmount());
195 + appAtomRegistry.set(scheduledTaskEditorSessionAtom, null);
196 +});
197 +function button(label: string) {
198 + const element = Array.from(container.querySelectorAll("button")).find(
199 + (button) => button.textContent === label,
200 + );
201 + if (!element) throw new Error(`Missing button: ${label}`);
202 + return element;
203 +}
204 +describe("scheduled task batched edits", () => {
205 + it("submits the selected interval when saved before React commits", async () => {
206 + await act(async () => {
207 + button("Interval").click();
208 + button("Save changes").click();
209 + });
210 + expect(mocks.alert).not.toHaveBeenCalled();
211 + expect(mocks.upsert).toHaveBeenCalledExactlyOnceWith({
212 + environmentId: "environment",
213 + input: expect.objectContaining({
214 + id: "task",
215 + requireExisting: true,
216 + schedule: { type: "interval", everyMs: 3_600_000 },
217 + }),
218 + });
219 + });
220 + it("retains the interval when enabled changes before React commits", async () => {
221 + act(() => {
222 + button("Interval").click();
223 + button("Toggle enabled").click();
224 + });
225 + expect(appAtomRegistry.get(scheduledTaskEditorSessionAtom)?.current?.draft.schedule.mode).toBe(
226 + "interval",
227 + );
228 + await act(async () => button("Save changes").click());
229 + expect(mocks.alert).not.toHaveBeenCalled();
230 + expect(mocks.upsert).toHaveBeenCalledExactlyOnceWith({
231 + environmentId: "environment",
232 + input: expect.objectContaining({
233 + id: "task",
234 + requireExisting: true,
235 + enabled: false,
236 + schedule: { type: "interval", everyMs: 3_600_000 },
237 + }),
238 + });
239 + });
240 + it("keeps every webhook filter added before React commits", () => {
241 + act(() => button("On webhook").click());
242 + act(() => {
243 + button("Add filter").click();
244 + button("Add filter").click();
245 + });
246 + expect(
247 + appAtomRegistry.get(scheduledTaskEditorSessionAtom)?.current?.draft.schedule.filters,
248 + ).toHaveLength(2);
249 + });
250 + it("keeps the target project when an old picker fires after changing environments", () => {
251 + const editor = appAtomRegistry.get(scheduledTaskEditorSessionAtom)?.current;
252 + if (!editor) throw new Error("Missing editor");
253 + act(() => startScheduledTaskEditor({ ...editor, draft: { ...editor.draft, task: null } }));
254 + act(() => {
255 + button("Select Target").click();
256 + button("Interval").click();
257 + button("Select Project").click();
258 + });
259 + expect(appAtomRegistry.get(scheduledTaskEditorSessionAtom)?.current).toMatchObject({
260 + environmentId: "target",
261 + draft: { projectId: "target-project", schedule: { mode: "interval" } },
262 + });
263 + });
264 +});
apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+136 -81
@@ -267,11 +267,13 @@ function SelectRow(props: {
267 function WebhookFilterRows(props: {
268 readonly filters: ReadonlyArray<WebhookFilterDraft>;
269 readonly disabled: boolean;
270 - readonly onChange: (filters: ReadonlyArray<WebhookFilterDraft>) => void;
270 + readonly onChange: (
271 + update: (filters: ReadonlyArray<WebhookFilterDraft>) => ReadonlyArray<WebhookFilterDraft>,
272 + ) => void;
273 }) {
272 - const update = (index: number, patch: Partial<WebhookFilterDraft>) =>
273 - props.onChange(
274 - props.filters.map((filter, at) => (at === index ? { ...filter, ...patch } : filter)),
274 + const update = (id: WebhookFilterDraft["id"], patch: Partial<WebhookFilterDraft>) =>
275 + props.onChange((filters) =>
276 + filters.map((filter) => (filter.id === id ? { ...filter, ...patch } : filter)),
277 );
278 return (
279 <>
@@ -284,7 +286,9 @@ function WebhookFilterRows(props: {
286 accessibilityLabel={`Remove filter ${index + 1}`}
287 disabled={props.disabled}
288 hitSlop={8}
287 - onPress={() => props.onChange(removeWebhookFilterDraft(props.filters, filter.id))}
289 + onPress={() =>
290 + props.onChange((filters) => removeWebhookFilterDraft(filters, filter.id))
291 + }
292 className="active:opacity-70"
293 >
294 <SymbolView name="trash" size={16} tintColorClassName="accent-danger-foreground" />
@@ -295,7 +299,7 @@ function WebhookFilterRows(props: {
299 value={filter.path}
300 placeholder="body.action"
301 disabled={props.disabled}
298 - onChange={(path) => update(index, { path })}
302 + onChange={(path) => update(filter.id, { path })}
303 />
304 <SelectRow
305 label="Test"
@@ -307,7 +311,7 @@ function WebhookFilterRows(props: {
311 }))}
312 onSelect={(id) => {
313 const known = WEBHOOK_FILTER_OPS.find((option) => option.op === id);
310 - if (known) update(index, { op: known.op });
314 + if (known) update(filter.id, { op: known.op });
315 }}
316 />
317 {filter.op === "exists" ? null : (
@@ -316,7 +320,7 @@ function WebhookFilterRows(props: {
320 value={filter.value}
321 placeholder={filter.op === "in" ? "opened, reopened" : "opened"}
322 disabled={props.disabled}
319 - onChange={(value) => update(index, { value })}
323 + onChange={(value) => update(filter.id, { value })}
324 />
325 )}
326 </View>
@@ -325,7 +329,13 @@ function WebhookFilterRows(props: {
329 <Pressable
330 accessibilityRole="button"
331 disabled={props.disabled}
328 - onPress={() => props.onChange([...props.filters, emptyWebhookFilterDraft()])}
332 + onPress={() =>
333 + props.onChange((filters) =>
334 + filters.length < MAX_WEBHOOK_FILTERS
335 + ? [...filters, emptyWebhookFilterDraft()]
336 + : filters,
337 + )
338 + }
339 className="min-h-14 flex-row items-center gap-3 border-t border-border-subtle px-4 py-3 active:opacity-70"
340 >
341 <Text textRole="body" className="min-w-0 flex-1 text-foreground">
@@ -590,8 +600,19 @@ function SettingsScheduledTaskEditorScreen({ title }: { readonly title: string }
600 voiceInput={voiceInput}
601 />
602 }
593 - setDraft={(draft) => {
594 - if (!saving) setEditor({ ...editor, draft });
603 + setDraft={(update) => {
604 + if (!saving)
605 + setEditor((current) =>
606 + current ? { ...current, draft: update(current.draft) } : current,
607 + );
608 + }}
609 + setEnvironmentDraft={(update) => {
610 + if (!saving)
611 + setEditor((current) =>
612 + current && current.environmentId === editor.environmentId
613 + ? { ...current, draft: update(current.draft) }
614 + : current,
615 + );
616 }}
617 onSaved={() => {
618 saved.current = true;
@@ -599,18 +620,21 @@ function SettingsScheduledTaskEditorScreen({ title }: { readonly title: string }
620 if (navigation.isFocused()) navigation.goBack();
621 }}
622 onChangeEnvironment={(target) => {
602 - if (target.environmentId === editor.environmentId) return;
603 - setEditor({
604 - environmentId: target.environmentId,
605 - environmentLabel: target.label,
606 - draft: {
607 - ...draftForEnvironment(target.environmentId),
608 - title: editor.draft.title,
609 - prompt: editor.draft.prompt,
610 - schedule: editor.draft.schedule,
611 - enabled: editor.draft.enabled,
612 - },
613 - });
623 + setEditor((current) =>
624 + !current || target.environmentId === current.environmentId
625 + ? current
626 + : {
627 + environmentId: target.environmentId,
628 + environmentLabel: target.label,
629 + draft: {
630 + ...draftForEnvironment(target.environmentId),
631 + title: current.draft.title,
632 + prompt: current.draft.prompt,
633 + schedule: current.draft.schedule,
634 + enabled: current.draft.enabled,
635 + },
636 + },
637 + );
638 }}
639 />
640 ) : (
@@ -635,6 +659,7 @@ function TaskForm({
659 dictationPending,
660 promptField,
661 setDraft,
662 + setEnvironmentDraft,
663 onSaved,
664 onChangeEnvironment,
665 }: {
@@ -646,10 +671,12 @@ function TaskForm({
671 readonly setSaving: (saving: boolean) => void;
672 readonly dictationPending: boolean;
673 readonly promptField: ReactNode;
649 - readonly setDraft: (draft: Draft) => void;
674 + readonly setDraft: (update: (current: Draft) => Draft) => void;
675 + readonly setEnvironmentDraft: (update: (current: Draft) => Draft) => void;
676 readonly onSaved: () => void;
677 readonly onChangeEnvironment: (target: SettingsTarget) => void;
678 }) {
679 + const { readEditor } = useScheduledTaskEditor();
680 const navigation = useNavigation<NativeStackNavigationProp<ScheduledTaskRoutes>>();
681 const tasks = useEnvironmentQuery(
682 serverEnvironment.scheduledTasksLive({ environmentId, input: {} }),
@@ -699,6 +726,9 @@ function TaskForm({
726 draft.task?.schedule.type === "once";
727 const offersThreadModes = config?.environment.capabilities.scheduledTaskThreadModes === true;
728 const save = async () => {
729 + const current = readEditor();
730 + if (!current || current.environmentId !== environmentId) return;
731 + const draft = current.draft;
732 if (
733 !readEnvironmentScope(environmentId, AuthOrchestrationOperateScope) ||
734 submissionPending.current ||
@@ -853,7 +883,7 @@ function TaskForm({
883 disabled={saving}
884 value={draft.title}
885 placeholder="Check for issues"
856 - onChange={(title) => setDraft({ ...draft, title })}
886 + onChange={(title) => setDraft((current) => ({ ...current, title }))}
887 />
888 {promptField}
889 </SettingsSection>
@@ -873,21 +903,23 @@ function TaskForm({
903 onSelect={(id) => {
904 const project = projects.find((item) => item.id === id);
905 if (!project) return;
876 - const keepsExplicitModel =
877 - draft.modelSelectionIsExplicit &&
878 - (draft.modelSelection === null ||
879 - !config?.settings ||
880 - resolveProjectProviderInstanceEnabled(
881 - config.settings,
882 - project.id,
883 - draft.modelSelection.instanceId,
884 - ));
885 - setDraft({
886 - ...changeDraftProject(draft, project.id),
887 - modelSelection: keepsExplicitModel
888 - ? draft.modelSelection
889 - : scheduledTaskDefaultModel(config, project),
890 - modelSelectionIsExplicit: keepsExplicitModel,
906 + setEnvironmentDraft((current) => {
907 + const keepsExplicitModel =
908 + current.modelSelectionIsExplicit &&
909 + (current.modelSelection === null ||
910 + !config?.settings ||
911 + resolveProjectProviderInstanceEnabled(
912 + config.settings,
913 + project.id,
914 + current.modelSelection.instanceId,
915 + ));
916 + return {
917 + ...changeDraftProject(current, project.id),
918 + modelSelection: keepsExplicitModel
919 + ? current.modelSelection
920 + : scheduledTaskDefaultModel(config, project),
921 + modelSelectionIsExplicit: keepsExplicitModel,
922 + };
923 });
924 }}
925 />
@@ -935,9 +967,9 @@ function TaskForm({
967 )}
968 onSelect={(id) => {
969 if (id === "new_thread")
938 - setDraft({ ...unbindDraftFromThread(draft), threadMode: id });
970 + setDraft((current) => ({ ...unbindDraftFromThread(current), threadMode: id }));
971 else if (id === "continue" || id === "fresh_session")
940 - setDraft({ ...draft, threadMode: id });
972 + setDraft((current) => ({ ...current, threadMode: id }));
973 }}
974 />
975 ) : null}
@@ -985,7 +1017,7 @@ function TaskForm({
1017 ]}
1018 onSelect={(id) => {
1019 if (id === "worktree" || id === "root" || id === "existing_worktree")
988 - setDraft({ ...draft, workspace: id });
1020 + setDraft((current) => ({ ...current, workspace: id }));
1021 }}
1022 />
1023 {draft.workspace === "worktree" ? (
@@ -1008,10 +1040,10 @@ function TaskForm({
1040 value={draft.checkoutPath}
1041 borderTop
1042 onChange={(checkoutPath) =>
1011 - setDraft({
1012 - ...draft,
1013 - checkoutPath: resolvePastedPath(draft.checkoutPath, checkoutPath),
1014 - })
1043 + setEnvironmentDraft((current) => ({
1044 + ...current,
1045 + checkoutPath: resolvePastedPath(current.checkoutPath, checkoutPath),
1046 + }))
1047 }
1048 />
1049 ) : null}
@@ -1036,21 +1068,21 @@ function TaskForm({
1068 onSelect={(mode) => {
1069 setTimePickerOpen(false);
1070 setRunAtPicker(null);
1039 - setDraft({
1040 - ...draft,
1071 + setDraft((current) => ({
1072 + ...current,
1073 prompt:
1042 - mode === "webhook" && !draft.prompt.trim()
1074 + mode === "webhook" && !current.prompt.trim()
1075 ? DEFAULT_WEBHOOK_PROMPT
1044 - : draft.prompt,
1076 + : current.prompt,
1077 schedule: {
1046 - ...draft.schedule,
1078 + ...current.schedule,
1079 mode,
1080 runAt:
1049 - mode === "once" && !draft.schedule.runAt
1081 + mode === "once" && !current.schedule.runAt
1082 ? new Date(Math.ceil(Date.now() / 3_600_000) * 3_600_000).toISOString()
1051 - : draft.schedule.runAt,
1083 + : current.schedule.runAt,
1084 },
1053 - });
1085 + }));
1086 }}
1087 />
1088 </View>
@@ -1089,7 +1121,10 @@ function TaskForm({
1121 onDismiss={() => setTimePickerOpen(false)}
1122 onValueChange={(_, selected) => {
1123 const timeOfDay = `${String(selected.getHours()).padStart(2, "0")}:${String(selected.getMinutes()).padStart(2, "0")}`;
1092 - setDraft({ ...draft, schedule: { ...draft.schedule, timeOfDay } });
1124 + setDraft((current) => ({
1125 + ...current,
1126 + schedule: { ...current.schedule, timeOfDay },
1127 + }));
1128 }}
1129 />
1130 ) : null}
@@ -1118,19 +1153,21 @@ function TaskForm({
1153 })),
1154 ]}
1155 onSelect={(id) => {
1121 - const weekdays =
1122 - id === "every_day"
1123 - ? DAYS.map((day) => day.index)
1124 - : id === "weekdays"
1125 - ? [1, 2, 3, 4, 5]
1126 - : (() => {
1127 - const day = DAYS.find((item) => String(item.index) === id);
1128 - if (!day) return draft.schedule.weekdays;
1129 - return draft.schedule.weekdays.includes(day.index)
1130 - ? draft.schedule.weekdays.filter((index) => index !== day.index)
1131 - : [...draft.schedule.weekdays, day.index];
1132 - })();
1133 - setDraft({ ...draft, schedule: { ...draft.schedule, weekdays } });
1156 + setDraft((current) => {
1157 + const weekdays =
1158 + id === "every_day"
1159 + ? DAYS.map((day) => day.index)
1160 + : id === "weekdays"
1161 + ? [1, 2, 3, 4, 5]
1162 + : (() => {
1163 + const day = DAYS.find((item) => String(item.index) === id);
1164 + if (!day) return current.schedule.weekdays;
1165 + return current.schedule.weekdays.includes(day.index)
1166 + ? current.schedule.weekdays.filter((index) => index !== day.index)
1167 + : [...current.schedule.weekdays, day.index];
1168 + })();
1169 + return { ...current, schedule: { ...current.schedule, weekdays } };
1170 + });
1171 }}
1172 />
1173 </>
@@ -1175,10 +1212,10 @@ function TaskForm({
1212 onValueChange={(_, selected) => {
1213 // Android shows a dialog that closes on pick; iOS stays inline.
1214 if (Platform.OS === "android") setRunAtPicker(null);
1178 - setDraft({
1179 - ...draft,
1180 - schedule: { ...draft.schedule, runAt: selected.toISOString() },
1181 - });
1215 + setDraft((current) => ({
1216 + ...current,
1217 + schedule: { ...current.schedule, runAt: selected.toISOString() },
1218 + }));
1219 }}
1220 />
1221 ) : null}
@@ -1206,14 +1243,20 @@ function TaskForm({
1243 disabled={saving}
1244 borderTop
1245 onChange={(maxDeliveryAgeMinutes) =>
1209 - setDraft({ ...draft, schedule: { ...draft.schedule, maxDeliveryAgeMinutes } })
1246 + setDraft((current) => ({
1247 + ...current,
1248 + schedule: { ...current.schedule, maxDeliveryAgeMinutes },
1249 + }))
1250 }
1251 />
1252 <WebhookFilterRows
1253 filters={draft.schedule.filters}
1254 disabled={saving}
1215 - onChange={(filters) =>
1216 - setDraft({ ...draft, schedule: { ...draft.schedule, filters } })
1255 + onChange={(update) =>
1256 + setDraft((current) => ({
1257 + ...current,
1258 + schedule: { ...current.schedule, filters: update(current.schedule.filters) },
1259 + }))
1260 }
1261 />
1262 <FormField
@@ -1223,7 +1266,10 @@ function TaskForm({
1266 disabled={saving}
1267 borderTop
1268 onChange={(replayKey) =>
1226 - setDraft({ ...draft, schedule: { ...draft.schedule, replayKey } })
1269 + setDraft((current) => ({
1270 + ...current,
1271 + schedule: { ...current.schedule, replayKey },
1272 + }))
1273 }
1274 />
1275 <Text className="px-4 pb-3 text-sm text-foreground-muted">
@@ -1236,7 +1282,10 @@ function TaskForm({
1282 disabled={saving}
1283 borderTop
1284 onChange={(coalesceKey) =>
1239 - setDraft({ ...draft, schedule: { ...draft.schedule, coalesceKey } })
1285 + setDraft((current) => ({
1286 + ...current,
1287 + schedule: { ...current.schedule, coalesceKey },
1288 + }))
1289 }
1290 />
1291 <FormField
@@ -1247,7 +1296,10 @@ function TaskForm({
1296 disabled={saving}
1297 borderTop
1298 onChange={(coalesceWindowSeconds) =>
1250 - setDraft({ ...draft, schedule: { ...draft.schedule, coalesceWindowSeconds } })
1299 + setDraft((current) => ({
1300 + ...current,
1301 + schedule: { ...current.schedule, coalesceWindowSeconds },
1302 + }))
1303 }
1304 />
1305 <Text className="px-4 pb-3 text-sm text-foreground-muted">
@@ -1264,7 +1316,10 @@ function TaskForm({
1316 disabled={saving}
1317 borderTop
1318 onChange={(intervalMinutes) =>
1267 - setDraft({ ...draft, schedule: { ...draft.schedule, intervalMinutes } })
1319 + setDraft((current) => ({
1320 + ...current,
1321 + schedule: { ...current.schedule, intervalMinutes },
1322 + }))
1323 }
1324 />
1325 {!(parseIntervalMinutes(draft.schedule.intervalMinutes) >= 1) ? (
@@ -1287,7 +1342,7 @@ function TaskForm({
1342 <ThemedSwitch
1343 accessibilityLabel="Task enabled"
1344 value={draft.enabled}
1290 - onValueChange={(enabled) => setDraft({ ...draft, enabled })}
1345 + onValueChange={(enabled) => setDraft((current) => ({ ...current, enabled }))}
1346 />
1347 </View>
1348 </SettingsSection>
apps/mobile/vite.config.ts
+1
@@ -26,6 +26,7 @@ const reactTests = [
26 "src/features/files/ZipArchiveView.test.tsx",
27 "src/features/pull-requests/guide/useReviewGuide.test.tsx",
28 "src/features/settings/SettingsServerControlsRouteScreen.test.tsx",
29 + "src/features/settings/SettingsScheduledTasksRouteScreen.test.tsx",
30 "src/features/settings/components/BranchNamingSettings.test.tsx",
31 "src/features/settings/components/SettingsDragHandle.test.tsx",
32 "src/features/threads/ThreadMarkdownImage.test.tsx",