@devries-cameron20 / t3code Mirror · read-only / commits / dc7216ca23
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, 06:00 UTC

fix(mobile): new-task link no longer blanks a scheduled task while it saves (#39154)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 19, 2026 at 16:34 UTC dc7216ca235274ad21218c9ab66ad6fc5e7106eb
4 files changed +43 -3
apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+10 -3
@@ -537,12 +537,19 @@ export function SettingsScheduledTaskEditRouteScreen() {
537
538 function SettingsScheduledTaskEditorScreen({ title }: { readonly title: string }) {
539 const gt = useGT();
540 - const { editor, voiceOwnerKey, readEditor, setEditor, hasChanges, draftForEnvironment } =
541 - useScheduledTaskEditor();
540 + const {
541 + editor,
542 + voiceOwnerKey,
543 + readEditor,
544 + setEditor,
545 + hasChanges,
546 + saving,
547 + setSaving,
548 + draftForEnvironment,
549 + } = useScheduledTaskEditor();
550 const { availableTargets } = useSettingsEnvironmentFilter();
551 const navigation = useNavigation();
552 const insets = useSafeAreaInsets();
545 - const [saving, setSaving] = useState(false);
553 // Set once the save lands, so the removal guard lets the editor close.
554 const saved = useRef(false);
555 const ownerKey = editor ? `${voiceOwnerKey}:${editor.environmentId}` : null;
apps/mobile/src/features/settings/scheduled-task-editor-state.test.ts
+9
@@ -8,6 +8,7 @@ import {
8 markScheduledTaskEditorSaved,
9 readScheduledTaskEditor,
10 scheduledTaskEditorSessionAtom,
11 + setScheduledTaskEditorSaving,
12 startScheduledTaskEditor,
13 takeScheduledTaskNewLink,
14 updateScheduledTaskEditor,
@@ -95,6 +96,14 @@ describe("new scheduled task link", () => {
96 expect(appAtomRegistry.get(scheduledTaskEditorSessionAtom)).toBeNull();
97 });
98
99 + it("keeps an unchanged task while its save is still pending", () => {
100 + startScheduledTaskEditor(editing);
101 + setScheduledTaskEditorSaving(true, null);
102 +
103 + takeScheduledTaskNewLink(newTaskLink);
104 + expect(appAtomRegistry.get(scheduledTaskEditorSessionAtom)?.current).toBe(editing);
105 + });
106 +
107 it("starts the new-task screen fresh after the edited task was saved", () => {
108 startScheduledTaskEditor(editing);
109 updateScheduledTaskEditor({ ...editing, draft: { ...editing.draft, prompt: "saved" } }, null);
apps/mobile/src/features/settings/scheduled-task-editor-state.ts
+19
@@ -17,6 +17,7 @@ type ScheduledTaskEditorSession = {
17 readonly id: number;
18 readonly initial: ScheduledTaskEditor | null;
19 readonly current: ScheduledTaskEditor | null;
20 + readonly saving: boolean;
21 };
22
23 export const scheduledTaskEditorSessionAtom = Atom.make<ScheduledTaskEditorSession | null>(
@@ -43,6 +44,7 @@ export function startScheduledTaskEditor(next: ScheduledTaskEditor | null): void
44 id: ++nextEditorId,
45 initial: next,
46 current: next,
47 + saving: false,
48 });
49 }
50
@@ -59,9 +61,24 @@ export function updateScheduledTaskEditor(
61 id: session?.id ?? 0,
62 initial: session ? session.initial : previous,
63 current: typeof update === "function" ? update(previous) : update,
64 + saving: session?.saving ?? false,
65 });
66 }
67
68 +/** The pending save lives with the draft so a new-task link cannot clear the task it writes. */
69 +export function setScheduledTaskEditorSaving(
70 + saving: boolean,
71 + defaultEditor: ScheduledTaskEditor | null,
72 +): void {
73 + const session = appAtomRegistry.get(scheduledTaskEditorSessionAtom);
74 + appAtomRegistry.set(
75 + scheduledTaskEditorSessionAtom,
76 + session
77 + ? { ...session, saving }
78 + : { id: 0, initial: defaultEditor, current: defaultEditor, saving },
79 + );
80 +}
81 +
82 /**
83 * A saved task is the new baseline. Without it a later new-task link reads the saved edits as
84 * unsaved, keeps them under "New", and saving there would overwrite the task.
@@ -93,6 +110,8 @@ export function takeScheduledTaskNewLink(
110 ): PartialState<NavigationState> | undefined {
111 if (findLinkedRoute(state, ["SettingsScheduledTaskNew"])) {
112 const session = appAtomRegistry.get(scheduledTaskEditorSessionAtom);
113 + // The open editor's removal guard refuses the link while the save is pending.
114 + if (session?.saving) return state;
115 if (session && scheduledTaskEditorHasChanges(session.initial, session.current)) {
116 newTaskLinkAwaitsDiscard = true;
117 } else {
apps/mobile/src/features/settings/scheduled-task-editor.tsx
+5
@@ -14,6 +14,7 @@ import { settingsTargetsForProject } from "./settings-environment-filter.logic";
14 import {
15 scheduledTaskEditorHasChanges,
16 scheduledTaskEditorSessionAtom,
17 + setScheduledTaskEditorSaving,
18 startScheduledTaskEditor,
19 updateScheduledTaskEditor,
20 readScheduledTaskEditor,
@@ -98,6 +99,8 @@ export function useScheduledTaskEditor() {
99 const editor = session ? session.current : defaultEditor;
100 const initial = session ? session.initial : defaultEditor;
101 const hasChanges = scheduledTaskEditorHasChanges(initial, editor);
102 + const saving = session?.saving ?? false;
103 + const setSaving = (next: boolean) => setScheduledTaskEditorSaving(next, defaultEditor);
104 const setEditor: Dispatch<SetStateAction<ScheduledTaskEditor | null>> = (update) => {
105 updateScheduledTaskEditor(update, defaultEditor);
106 };
@@ -111,6 +114,8 @@ export function useScheduledTaskEditor() {
114 setEditor,
115 startEditor,
116 hasChanges,
117 + saving,
118 + setSaving,
119 resetEditor,
120 draftForEnvironment,
121 };