From c121a5542fa7eb47fbf83e2e7aec223a46400744 Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Wed, 4 Nov 2026 10:39:14 +1100 Subject: [PATCH 1/9] fix(mobile): a thread's goal pill can be cleared or resumed The goal pill was read-only, so clearing a goal meant typing /goal clear by hand. It now carries Clear, and Resume where the web client shows it, sent as a standalone queued command without touching the composer draft. --- .../features/threads/NewTaskDraftScreen.tsx | 1 + .../features/threads/ThreadDetailScreen.tsx | 40 ++++++++++++- .../features/threads/ThreadRouteScreen.tsx | 1 + .../threads/floating-working-control.tsx | 56 +++++++++++-------- .../threads/floating-working-status.ts | 7 ++- .../src/state/thread-task-permissions.test.ts | 25 +++++++++ .../src/state/use-thread-composer-state.ts | 51 +++++++++++++++++ 7 files changed, 155 insertions(+), 26 deletions(-) diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx index a3b02b8985d4d..9b8a25073083f 100644 --- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx @@ -970,6 +970,7 @@ export function NewTaskDraftScreen(props: { onResumeQueue={null} onSendMessage={handleStart} offersSideChat={false} + onSendCommand={async () => null} onReconnectEnvironment={() => onReconnectEnvironment(selectedProject.environmentId)} canSwitchThreadProvider onRespondToApproval={async () => {}} diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index f3c81cc9b1363..4de44f2450e0d 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -184,7 +184,11 @@ import { FLOATING_WORKING_CONTROL_COVERAGE, FloatingWorkingControl, } from "./floating-working-control"; -import { connectionFloatingStatus, type FloatingWorkingStatus } from "./floating-working-status"; +import { + connectionFloatingStatus, + type FloatingStatusAction, + type FloatingWorkingStatus, +} from "./floating-working-status"; import { derivePendingUserInputMaxHeight, ESTIMATED_KEYBOARD_HEIGHT, @@ -298,6 +302,8 @@ export interface ThreadDetailScreenProps { ) => Promise, onWillEnqueue?: () => void, ) => Promise; + /** Queues a standalone text command, such as `/goal clear`, without touching the draft. */ + readonly onSendCommand: (text: string) => Promise; readonly onReconnectEnvironment: () => void; readonly canSwitchThreadProvider: boolean; readonly onRespondToApproval: ApprovalResponder; @@ -732,6 +738,18 @@ function ThreadDetailBody( ); } }; + const [goalCommandPending, setGoalCommandPending] = useState(false); + const runGoalCommand = async (command: string) => { + if (goalCommandPending || !props.canOperateThread) return; + setGoalCommandPending(true); + try { + await props.onSendCommand(command); + } catch (error) { + Dialog.alert("Could not update goal", error instanceof Error ? error.message : "Try again."); + } finally { + setGoalCommandPending(false); + } + }; const pendingBackgroundWork = presentPendingBackgroundWork( props.selectedThread.pendingBackgroundTasks, ); @@ -864,11 +882,31 @@ function ThreadDetailBody( }; } if (props.selectedThread.goal !== null && contentPresentationKind === "ready") { + // The pill only shows while idle, so Resume never interrupts running work. const goal = presentProviderGoal(props.selectedThread.goal, false); + // Claude goals can only be cleared; the server rejects `/goal resume` there. + const goalProvider = props.serverConfig?.providers.find( + (provider) => provider.instanceId === props.selectedThread.modelSelection.instanceId, + ); + const canResumeGoal = goal.canResume && goalProvider?.driver !== "claudeAgent"; + const goalAction = ( + label: string, + accessibilityLabel: string, + command: string, + ): FloatingStatusAction => ({ + label, + accessibilityLabel, + disabled: !props.canOperateThread || goalCommandPending, + onPress: () => void runGoalCommand(command), + }); return { kind: "goal", label: goal.title, accessibilityLabel: `${goal.title}: ${goal.objective}`, + actions: [ + ...(canResumeGoal ? [goalAction("Resume", "Resume goal", "/goal resume")] : []), + goalAction("Clear", "Clear goal", "/goal clear"), + ], }; } if (extensionStatus !== null && contentPresentationKind === "ready") { diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index 365d6d584c292..ccc580d5c933c 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -1061,6 +1061,7 @@ function ThreadRouteContent( } onSendMessage={composer.onSendMessage} offersSideChat={composer.sideChatUnavailableReason === null} + onSendCommand={composer.onSendCommand} onReconnectEnvironment={handleReconnectEnvironment} canSwitchThreadProvider={composer.canSwitchThreadProvider} onRespondToApproval={requests.onRespondToApproval} diff --git a/apps/mobile/src/features/threads/floating-working-control.tsx b/apps/mobile/src/features/threads/floating-working-control.tsx index a41fc2b3de39c..5067301ed7683 100644 --- a/apps/mobile/src/features/threads/floating-working-control.tsx +++ b/apps/mobile/src/features/threads/floating-working-control.tsx @@ -1,7 +1,7 @@ import type { SubagentPillSegment } from "@t3tools/client-runtime/state/thread-subagents"; import { formatDuration } from "@t3tools/shared/orchestrationTiming"; import { GlassContainer, GlassView } from "expo-glass-effect"; -import { type ReactNode, useEffect, useRef, useState } from "react"; +import { Fragment, type ReactNode, useEffect, useRef, useState } from "react"; import { type LayoutChangeEvent, Pressable, @@ -29,7 +29,7 @@ import { ControlPill } from "../../components/ui/ControlPill"; import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass"; import { BrowserPreviewButton } from "../browser/browser-preview-button"; import { DevicePreviewButton } from "../devices/device-preview-button"; -import type { FloatingWorkingStatus } from "./floating-working-status"; +import type { FloatingStatusAction, FloatingWorkingStatus } from "./floating-working-status"; import { ShimmeringWorkContent } from "./thread-work-log"; import { useVisibleSecondClock } from "./use-visible-second-clock"; @@ -89,12 +89,16 @@ export function FloatingWorkingControl(props: { const extensionStatus = props.extensionStatus ?? null; const extensionOnly = props.status?.kind === "extension"; const useGlass = NATIVE_LIQUID_GLASS_SUPPORTED && !extensionOnly; - const action = - props.status?.kind === "background" || - props.status?.kind === "lifecycle" || - props.status?.kind === "stop" - ? props.status.action - : null; + const actions: ReadonlyArray = + props.status?.kind === "goal" + ? props.status.actions + : props.status?.kind === "background" || + props.status?.kind === "lifecycle" || + props.status?.kind === "stop" + ? props.status.action === null + ? [] + : [props.status.action] + : []; const [agentsWidth, setAgentsWidth] = useState(0); const hasQueue = props.queuedCount > 0; const hasPreview = props.devicePreview !== null || props.browserPreview !== null; @@ -107,7 +111,7 @@ export function FloatingWorkingControl(props: { 0, Math.min(overlayWidth, windowWidth) - reservedWidth - - (action !== null ? actionWidth : 0) - + (actions.length > 0 ? actionWidth : 0) - (hasQueue ? queueWidth : 0) - (hasAgents ? agentsWidth : 0) - (hasPreview ? previewWidth : 0), @@ -179,7 +183,7 @@ export function FloatingWorkingControl(props: { const capsuleInteractive = statusInteractive || extensionStatus !== null || - action !== null || + actions.length > 0 || hasQueue || hasAgents || hasPreview; @@ -229,24 +233,28 @@ export function FloatingWorkingControl(props: { ) : null} - {action !== null ? ( + {actions.length > 0 ? ( setActionWidth(settleWidth(event.nativeEvent.layout.width))} className="h-11 flex-row items-center" > - - - - {action.label} - - + {actions.map((action) => ( + + + + + {action.label} + + + + ))} ) : null} {hasPreview ? ( diff --git a/apps/mobile/src/features/threads/floating-working-status.ts b/apps/mobile/src/features/threads/floating-working-status.ts index e3c137ebfd259..9225bbfa08035 100644 --- a/apps/mobile/src/features/threads/floating-working-status.ts +++ b/apps/mobile/src/features/threads/floating-working-status.ts @@ -37,7 +37,12 @@ export type FloatingWorkingStatus = readonly unresponsive: boolean; readonly action: FloatingStatusAction | null; } - | { readonly kind: "goal"; readonly label: string; readonly accessibilityLabel: string } + | { + readonly kind: "goal"; + readonly label: string; + readonly accessibilityLabel: string; + readonly actions: ReadonlyArray; + } | { readonly kind: "extension"; readonly label: string; readonly onPress: () => void } | { readonly kind: "preparing"; readonly label: string } | { diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index 5a31c1955b928..d485fbeef81f3 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -416,6 +416,31 @@ describe("mobile task permissions", () => { ); }); + it("queues a goal command without sending or clearing the composer draft", async () => { + state.grantedEnvironments.add("secondary"); + const composer = useThreadComposerState(); + expect(await composer.onSendCommand("/goal clear")).toBe("message"); + expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining({ + environmentId: "secondary", + threadId: "thread", + text: "/goal clear", + attachments: [], + modelSelection: state.thread.modelSelection, + }), + ); + expect(state.clearDraft).not.toHaveBeenCalled(); + expect(state.draft.text).toBe("Keep my draft"); + }); + + it("rechecks the operate grant before queueing a command", async () => { + state.grantedEnvironments.add("secondary"); + const composer = useThreadComposerState(); + state.grantedEnvironments.delete("secondary"); + expect(await composer.onSendCommand("/goal clear")).toBeNull(); + expect(state.enqueue).not.toHaveBeenCalled(); + }); + it("rechecks the target environment before an approval response", async () => { state.grantedEnvironments.add("secondary"); const requests = useSelectedThreadRequests(); diff --git a/apps/mobile/src/state/use-thread-composer-state.ts b/apps/mobile/src/state/use-thread-composer-state.ts index 465a8a425d292..527e9516bb2f9 100644 --- a/apps/mobile/src/state/use-thread-composer-state.ts +++ b/apps/mobile/src/state/use-thread-composer-state.ts @@ -817,6 +817,56 @@ export function useThreadComposerState(input: { return null; })(); + /** Queues a standalone text command such as `/goal clear` and leaves the composer draft alone. */ + const onSendCommand = async (text: string) => { + if ( + !selectedThreadShell || + selectedThreadCreation !== null || + (selectedEnvironmentRuntime?.connectionState === "connected" && + !readEnvironmentScope(selectedThreadShell.environmentId, AuthOrchestrationOperateScope)) + ) { + return null; + } + const thread = selectedThreadShell; + const threadKey = scopedThreadKey(thread.environmentId, thread.id); + const draft = getComposerDraftSnapshot(threadKey); + const modelSelection = draft.modelSelection ?? thread.modelSelection; + const serverConfig = selectedEnvironmentRuntime?.serverConfig; + if ( + selectedEnvironmentRuntime?.connectionState === "connected" && + isModelSelectionUnavailable(serverConfig, modelSelection, thread.projectId) + ) { + const { title, detail } = describeUnavailableModelSelection( + serverConfig, + modelSelection, + thread.projectId, + ); + Dialog.alert(title, detail); + return null; + } + const provider = serverConfig?.providers.find( + (entry) => entry.instanceId === modelSelection.instanceId, + ); + const metadata = makeQueuedMessageMetadata(); + const messageId = MessageId.make(metadata.messageId); + await enqueueThreadOutboxMessage({ + environmentId: thread.environmentId, + threadId: thread.id, + messageId, + commandId: CommandId.make(metadata.commandId), + text, + attachments: [], + modelSelection, + runtimeMode: draft.runtimeMode ?? thread.runtimeMode, + interactionMode: resolveProviderInteractionMode( + provider, + draft.interactionMode ?? thread.interactionMode, + ), + createdAt: metadata.createdAt, + }); + return messageId; + }; + const onChangeDraftMessage = (value: string) => { if (!selectedThreadShell) { return; @@ -879,6 +929,7 @@ export function useThreadComposerState(input: { onNativePasteText, onRemoveDraftImage, onSendMessage, + onSendCommand, sideChatUnavailableReason, }; } From 3d2ff0dd7f9af12457aaf26151348f645fde920c Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Wed, 4 Nov 2026 11:29:49 +1100 Subject: [PATCH 2/9] fix(mobile): goal commands use the thread's model and compile under React Compiler A draft model override could send /goal resume to the wrong provider, and the try/finally in the goal handler blocked React Compiler. --- .../mobile/src/features/threads/ThreadDetailScreen.tsx | 4 ++-- apps/mobile/src/state/thread-task-permissions.test.ts | 10 ++++++++++ apps/mobile/src/state/use-thread-composer-state.ts | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index 4de44f2450e0d..4eb30d05e37b0 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -742,13 +742,13 @@ function ThreadDetailBody( const runGoalCommand = async (command: string) => { if (goalCommandPending || !props.canOperateThread) return; setGoalCommandPending(true); + // No `finally`: React Compiler cannot lower it. try { await props.onSendCommand(command); } catch (error) { Dialog.alert("Could not update goal", error instanceof Error ? error.message : "Try again."); - } finally { - setGoalCommandPending(false); } + setGoalCommandPending(false); }; const pendingBackgroundWork = presentPendingBackgroundWork( props.selectedThread.pendingBackgroundTasks, diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index d485fbeef81f3..064704f2439d1 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -433,6 +433,16 @@ describe("mobile task permissions", () => { expect(state.draft.text).toBe("Keep my draft"); }); + it("sends a goal command with the thread's model, not the draft's", async () => { + state.grantedEnvironments.add("secondary"); + state.draft.modelSelection = { instanceId: "claudeAgent", model: "claude-sonnet-5-5" }; + const composer = useThreadComposerState(); + await composer.onSendCommand("/goal resume"); + expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining({ modelSelection: state.thread.modelSelection }), + ); + }); + it("rechecks the operate grant before queueing a command", async () => { state.grantedEnvironments.add("secondary"); const composer = useThreadComposerState(); diff --git a/apps/mobile/src/state/use-thread-composer-state.ts b/apps/mobile/src/state/use-thread-composer-state.ts index 527e9516bb2f9..d18e36f6df288 100644 --- a/apps/mobile/src/state/use-thread-composer-state.ts +++ b/apps/mobile/src/state/use-thread-composer-state.ts @@ -830,7 +830,8 @@ export function useThreadComposerState(input: { const thread = selectedThreadShell; const threadKey = scopedThreadKey(thread.environmentId, thread.id); const draft = getComposerDraftSnapshot(threadKey); - const modelSelection = draft.modelSelection ?? thread.modelSelection; + // Goal commands belong to the provider that owns the goal, not a model picked in the draft. + const modelSelection = thread.modelSelection; const serverConfig = selectedEnvironmentRuntime?.serverConfig; if ( selectedEnvironmentRuntime?.connectionState === "connected" && From e2ce03a12459e1be1a66775e5841c63d878f6f77 Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Wed, 4 Nov 2026 11:38:49 +1100 Subject: [PATCH 3/9] test(mobile): brand the provider instance id in the goal command test --- apps/mobile/src/state/thread-task-permissions.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index 064704f2439d1..2cdbfc78a2410 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -435,7 +435,10 @@ describe("mobile task permissions", () => { it("sends a goal command with the thread's model, not the draft's", async () => { state.grantedEnvironments.add("secondary"); - state.draft.modelSelection = { instanceId: "claudeAgent", model: "claude-sonnet-5-5" }; + state.draft.modelSelection = { + instanceId: ProviderInstanceId.make("claudeAgent"), + model: "claude-sonnet-5-5", + }; const composer = useThreadComposerState(); await composer.onSendCommand("/goal resume"); expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( From 44ad6da5887a69896380f3327cbfeb81f0c46cf6 Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Fri, 6 Nov 2026 10:07:27 +1100 Subject: [PATCH 4/9] test(mobile): goal command tests pass the side-chat input --- apps/mobile/src/state/thread-task-permissions.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index 2cdbfc78a2410..124f9a5dbba6e 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -418,7 +418,7 @@ describe("mobile task permissions", () => { it("queues a goal command without sending or clearing the composer draft", async () => { state.grantedEnvironments.add("secondary"); - const composer = useThreadComposerState(); + const composer = useThreadComposerState(NO_SIDE_CHATS); expect(await composer.onSendCommand("/goal clear")).toBe("message"); expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( expect.objectContaining({ @@ -439,7 +439,7 @@ describe("mobile task permissions", () => { instanceId: ProviderInstanceId.make("claudeAgent"), model: "claude-sonnet-5-5", }; - const composer = useThreadComposerState(); + const composer = useThreadComposerState(NO_SIDE_CHATS); await composer.onSendCommand("/goal resume"); expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( expect.objectContaining({ modelSelection: state.thread.modelSelection }), @@ -448,7 +448,7 @@ describe("mobile task permissions", () => { it("rechecks the operate grant before queueing a command", async () => { state.grantedEnvironments.add("secondary"); - const composer = useThreadComposerState(); + const composer = useThreadComposerState(NO_SIDE_CHATS); state.grantedEnvironments.delete("secondary"); expect(await composer.onSendCommand("/goal clear")).toBeNull(); expect(state.enqueue).not.toHaveBeenCalled(); From 094ecfb2180df3fa50c0a196e88aab7d68311016 Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Fri, 6 Nov 2026 10:21:23 +1100 Subject: [PATCH 5/9] fix(mobile): goal actions stay hidden while a run is queued A queued run is busy but has no work start time, so the idle check let Clear and Resume through. --- apps/mobile/src/features/threads/ThreadDetailScreen.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index 4eb30d05e37b0..7242fc37db892 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -881,8 +881,13 @@ function ThreadDetailBody( }, }; } - if (props.selectedThread.goal !== null && contentPresentationKind === "ready") { - // The pill only shows while idle, so Resume never interrupts running work. + if ( + props.selectedThread.goal !== null && + !props.activeThreadBusy && + contentPresentationKind === "ready" + ) { + // The pill only shows while idle (a queued run is busy but has no work start time), so + // Resume never interrupts running work. const goal = presentProviderGoal(props.selectedThread.goal, false); // Claude goals can only be cleared; the server rejects `/goal resume` there. const goalProvider = props.serverConfig?.providers.find( From b160b7d7169c4e2600d6b954318e69c5c33a08e3 Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Fri, 6 Nov 2026 10:40:42 +1100 Subject: [PATCH 6/9] fix(mobile): goal commands use the thread's runtime and interaction mode A draft in plan mode or a stricter runtime mode no longer rides along with Clear and Resume. --- apps/mobile/src/state/thread-task-permissions.test.ts | 9 +++++++-- apps/mobile/src/state/use-thread-composer-state.ts | 11 +++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index 124f9a5dbba6e..9d84552a3aaed 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -433,16 +433,21 @@ describe("mobile task permissions", () => { expect(state.draft.text).toBe("Keep my draft"); }); - it("sends a goal command with the thread's model, not the draft's", async () => { + it("sends a goal command with the thread's model and modes, not the draft's", async () => { state.grantedEnvironments.add("secondary"); state.draft.modelSelection = { instanceId: ProviderInstanceId.make("claudeAgent"), model: "claude-sonnet-5-5", }; + Object.assign(state.draft, { runtimeMode: "approval-required", interactionMode: "plan" }); const composer = useThreadComposerState(NO_SIDE_CHATS); await composer.onSendCommand("/goal resume"); expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( - expect.objectContaining({ modelSelection: state.thread.modelSelection }), + expect.objectContaining({ + modelSelection: state.thread.modelSelection, + runtimeMode: state.thread.runtimeMode, + interactionMode: state.thread.interactionMode, + }), ); }); diff --git a/apps/mobile/src/state/use-thread-composer-state.ts b/apps/mobile/src/state/use-thread-composer-state.ts index d18e36f6df288..cc6e27839e6c3 100644 --- a/apps/mobile/src/state/use-thread-composer-state.ts +++ b/apps/mobile/src/state/use-thread-composer-state.ts @@ -828,9 +828,7 @@ export function useThreadComposerState(input: { return null; } const thread = selectedThreadShell; - const threadKey = scopedThreadKey(thread.environmentId, thread.id); - const draft = getComposerDraftSnapshot(threadKey); - // Goal commands belong to the provider that owns the goal, not a model picked in the draft. + // Goal commands belong to the thread itself, not the model or modes picked in the draft. const modelSelection = thread.modelSelection; const serverConfig = selectedEnvironmentRuntime?.serverConfig; if ( @@ -858,11 +856,8 @@ export function useThreadComposerState(input: { text, attachments: [], modelSelection, - runtimeMode: draft.runtimeMode ?? thread.runtimeMode, - interactionMode: resolveProviderInteractionMode( - provider, - draft.interactionMode ?? thread.interactionMode, - ), + runtimeMode: thread.runtimeMode, + interactionMode: resolveProviderInteractionMode(provider, thread.interactionMode), createdAt: metadata.createdAt, }); return messageId; From 2a985afa248661d589c245af8f246797f9ee8d1d Mon Sep 17 00:00:00 2001 From: ravdeep kainth Date: Mon, 9 Nov 2026 12:10:16 +1100 Subject: [PATCH 7/9] fix(mobile): goal commands use the default interaction mode after the plan-mode removal --- apps/mobile/src/state/use-thread-composer-state.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/mobile/src/state/use-thread-composer-state.ts b/apps/mobile/src/state/use-thread-composer-state.ts index cc6e27839e6c3..1b8e3c6816419 100644 --- a/apps/mobile/src/state/use-thread-composer-state.ts +++ b/apps/mobile/src/state/use-thread-composer-state.ts @@ -843,9 +843,6 @@ export function useThreadComposerState(input: { Dialog.alert(title, detail); return null; } - const provider = serverConfig?.providers.find( - (entry) => entry.instanceId === modelSelection.instanceId, - ); const metadata = makeQueuedMessageMetadata(); const messageId = MessageId.make(metadata.messageId); await enqueueThreadOutboxMessage({ @@ -857,7 +854,7 @@ export function useThreadComposerState(input: { attachments: [], modelSelection, runtimeMode: thread.runtimeMode, - interactionMode: resolveProviderInteractionMode(provider, thread.interactionMode), + interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE, createdAt: metadata.createdAt, }); return messageId; From aa8dfe1dc9aaa38642b7b8da7f6614bf58879705 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 19 Nov 2026 18:54:17 +0000 Subject: [PATCH 8/9] fix(mobile): translate goal pill actions and fold goal command tests Adds the goal action strings to every mobile locale and merges the two composer tests into one case that proves the command uses the thread's model and runtime mode and leaves the draft alone. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/i18n/translations/de.json | 4 +++ apps/mobile/src/i18n/translations/en.json | 4 +++ apps/mobile/src/i18n/translations/es.json | 4 +++ apps/mobile/src/i18n/translations/fr.json | 4 +++ apps/mobile/src/i18n/translations/ja.json | 4 +++ apps/mobile/src/i18n/translations/ko.json | 4 +++ apps/mobile/src/i18n/translations/pt-BR.json | 4 +++ apps/mobile/src/i18n/translations/ru.json | 4 +++ apps/mobile/src/i18n/translations/sv.json | 4 +++ apps/mobile/src/i18n/translations/zh.json | 4 +++ .../src/state/thread-task-permissions.test.ts | 26 +++++-------------- 11 files changed, 47 insertions(+), 19 deletions(-) diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json index 2b33c6db04ae1..c3538631daf3a 100644 --- a/apps/mobile/src/i18n/translations/de.json +++ b/apps/mobile/src/i18n/translations/de.json @@ -4373,6 +4373,7 @@ "f360accf1ccac178": "Runde gestoppt; der Agentenprozess läuft weiter", "967f83de030790dd": "{count, plural, =0 {Er wird mit anderen arbeitenden Threads geteilt. Stoppe diese, um ihn freizugeben.} one {Er wird mit {count} arbeitenden Thread geteilt. Stoppe diesen, um ihn freizugeben.} other {Er wird mit {count} arbeitenden Threads geteilt. Stoppe diese, um ihn freizugeben.}}", "5536ab75119ee3f9": "Thread konnte nicht aktualisiert werden", + "04c7bba52daa6f53": "Ziel konnte nicht aktualisiert werden", "f5f145b33e2a9380": "Wird gestoppt...", "e734a8e4a58a3835": "Stoppen", "0ce0ab7586e91607": "Hintergrundarbeit stoppen", @@ -4395,6 +4396,9 @@ "a20b495b9e6f82b9": "Wird gestartet…", "7917e738e8c3fd41": "Genehmigungsanfrage von {title} öffnen", "54c8b8a3c6e6046b": "Frage von {title} öffnen", + "715be2d41b9f1b72": "Ziel fortsetzen", + "5d0c71caa8f328b0": "Löschen", + "efe8657d62633cd4": "Ziel löschen", "cebceafe7ddc7d5d": "Feedback zur Genehmigung", "0830bd81f19bb753": "Sende Feedback zur Genehmigung ohne Anhänge oder zusätzlichen Kontext.", "d15878f290283f53": "Nachricht konnte nicht bearbeitet werden", diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json index fa572328fc871..9ed3d39750028 100644 --- a/apps/mobile/src/i18n/translations/en.json +++ b/apps/mobile/src/i18n/translations/en.json @@ -4374,6 +4374,7 @@ "f360accf1ccac178": "Turn stopped; the agent process kept running", "967f83de030790dd": "{count, plural, =0 {It is shared with other working threads. Stop those to free it.} one {It is shared with {count} working thread. Stop those to free it.} other {It is shared with {count} working threads. Stop those to free it.}}", "5536ab75119ee3f9": "Could not update thread", + "04c7bba52daa6f53": "Could not update goal", "f5f145b33e2a9380": "Stopping...", "e734a8e4a58a3835": "Stop", "0ce0ab7586e91607": "Stop background work", @@ -4396,6 +4397,9 @@ "a20b495b9e6f82b9": "Starting…", "7917e738e8c3fd41": "Open approval from {title}", "54c8b8a3c6e6046b": "Open question from {title}", + "715be2d41b9f1b72": "Resume goal", + "5d0c71caa8f328b0": "Clear", + "efe8657d62633cd4": "Clear goal", "cebceafe7ddc7d5d": "Approval feedback", "0830bd81f19bb753": "Send approval feedback without attachments or added context.", "d15878f290283f53": "Could not edit message", diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json index 3a4bc17fd3ada..4fc0aeeaeea94 100644 --- a/apps/mobile/src/i18n/translations/es.json +++ b/apps/mobile/src/i18n/translations/es.json @@ -4366,6 +4366,7 @@ "f360accf1ccac178": "Turno detenido; el proceso del agente siguió ejecutándose", "967f83de030790dd": "{count, plural, =0 {Se comparte con otros hilos en curso. Detenlos para liberarlo.} one {Se comparte con {count} hilo en curso. Detenlo para liberarlo.} other {Se comparte con {count} hilos en curso. Detenlos para liberarlo.}}", "5536ab75119ee3f9": "No se pudo actualizar el hilo", + "04c7bba52daa6f53": "No se pudo actualizar el objetivo", "f5f145b33e2a9380": "Deteniendo...", "e734a8e4a58a3835": "Detener", "0ce0ab7586e91607": "Detener el trabajo en segundo plano", @@ -4388,6 +4389,9 @@ "a20b495b9e6f82b9": "Iniciando…", "7917e738e8c3fd41": "Abrir la aprobación de {title}", "54c8b8a3c6e6046b": "Abrir la pregunta de {title}", + "715be2d41b9f1b72": "Reanudar objetivo", + "5d0c71caa8f328b0": "Borrar", + "efe8657d62633cd4": "Borrar objetivo", "cebceafe7ddc7d5d": "Comentarios de la aprobación", "0830bd81f19bb753": "Envía los comentarios de aprobación sin adjuntos ni contexto añadido.", "d15878f290283f53": "No se pudo editar el mensaje", diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json index 4e094c01b5bce..b3f0a83dd2902 100644 --- a/apps/mobile/src/i18n/translations/fr.json +++ b/apps/mobile/src/i18n/translations/fr.json @@ -4367,6 +4367,7 @@ "f360accf1ccac178": "Tour arrêté ; le processus de l’agent continue de tourner", "967f83de030790dd": "{count, plural, =0 {Il est partagé avec d’autres fils en cours. Arrêtez-les pour le libérer.} one {Il est partagé avec {count} fil en cours. Arrêtez-le pour le libérer.} other {Il est partagé avec {count} fils en cours. Arrêtez-les pour le libérer.}}", "5536ab75119ee3f9": "Impossible de mettre à jour le fil", + "04c7bba52daa6f53": "Impossible de mettre à jour l’objectif", "f5f145b33e2a9380": "Arrêt...", "e734a8e4a58a3835": "Arrêter", "0ce0ab7586e91607": "Arrêter le travail en arrière-plan", @@ -4389,6 +4390,9 @@ "a20b495b9e6f82b9": "Démarrage…", "7917e738e8c3fd41": "Ouvrir l’approbation de {title}", "54c8b8a3c6e6046b": "Ouvrir la question de {title}", + "715be2d41b9f1b72": "Reprendre l’objectif", + "5d0c71caa8f328b0": "Effacer", + "efe8657d62633cd4": "Effacer l’objectif", "cebceafe7ddc7d5d": "Retour sur l’approbation", "0830bd81f19bb753": "Envoyez votre réponse à l’approbation sans pièces jointes ni contexte ajouté.", "d15878f290283f53": "Impossible de modifier le message", diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json index 261f141b613ef..d6a4c3027930f 100644 --- a/apps/mobile/src/i18n/translations/ja.json +++ b/apps/mobile/src/i18n/translations/ja.json @@ -4348,6 +4348,7 @@ "f360accf1ccac178": "ターンは停止しましたが、エージェントのプロセスは実行されたままです", "967f83de030790dd": "{count, plural, =0 {作業中の他のスレッドと共有されています。解放するにはそれらを停止してください。} other {作業中の {count} 個のスレッドと共有されています。解放するにはそれらを停止してください。}}", "5536ab75119ee3f9": "スレッドを更新できませんでした", + "04c7bba52daa6f53": "目標を更新できませんでした", "f5f145b33e2a9380": "停止しています...", "e734a8e4a58a3835": "停止", "0ce0ab7586e91607": "バックグラウンドの作業を停止", @@ -4370,6 +4371,9 @@ "a20b495b9e6f82b9": "開始しています…", "7917e738e8c3fd41": "{title} からの承認を開く", "54c8b8a3c6e6046b": "{title} からの質問を開く", + "715be2d41b9f1b72": "目標を再開", + "5d0c71caa8f328b0": "クリア", + "efe8657d62633cd4": "目標をクリア", "cebceafe7ddc7d5d": "承認へのフィードバック", "0830bd81f19bb753": "承認のフィードバックは、添付ファイルや追加のコンテキストなしで送信してください。", "d15878f290283f53": "メッセージを編集できませんでした", diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json index e21d3b00822af..06d7e6667b060 100644 --- a/apps/mobile/src/i18n/translations/ko.json +++ b/apps/mobile/src/i18n/translations/ko.json @@ -4353,6 +4353,7 @@ "f360accf1ccac178": "턴이 중지되었지만 에이전트 프로세스가 계속 실행 중입니다", "967f83de030790dd": "{count, plural, =0 {다른 작업 중인 스레드와 공유되어 있습니다. 해제하려면 해당 스레드를 중지하세요.} other {작업 중인 스레드 {count}개와 공유되어 있습니다. 해제하려면 해당 스레드를 중지하세요.}}", "5536ab75119ee3f9": "스레드를 업데이트할 수 없습니다", + "04c7bba52daa6f53": "목표를 업데이트할 수 없습니다", "f5f145b33e2a9380": "중지하는 중...", "e734a8e4a58a3835": "중지", "0ce0ab7586e91607": "백그라운드 작업 중지", @@ -4375,6 +4376,9 @@ "a20b495b9e6f82b9": "시작하는 중…", "7917e738e8c3fd41": "{title}의 승인 요청 열기", "54c8b8a3c6e6046b": "{title}의 질문 열기", + "715be2d41b9f1b72": "목표 재개", + "5d0c71caa8f328b0": "지우기", + "efe8657d62633cd4": "목표 지우기", "cebceafe7ddc7d5d": "승인 피드백", "0830bd81f19bb753": "첨부 파일이나 추가 컨텍스트 없이 승인 피드백을 보내세요.", "d15878f290283f53": "메시지를 편집할 수 없습니다", diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json index 6c7cdf3098bd4..0243ceb3fc5df 100644 --- a/apps/mobile/src/i18n/translations/pt-BR.json +++ b/apps/mobile/src/i18n/translations/pt-BR.json @@ -4367,6 +4367,7 @@ "f360accf1ccac178": "Turno parado; o processo do agente continuou em execução", "967f83de030790dd": "{count, plural, =0 {Ele é compartilhado com outras threads em andamento. Pare-as para liberá-lo.} one {Ele é compartilhado com {count} thread em andamento. Pare-a para liberá-lo.} other {Ele é compartilhado com {count} threads em andamento. Pare-as para liberá-lo.}}", "5536ab75119ee3f9": "Não foi possível atualizar a thread", + "04c7bba52daa6f53": "Não foi possível atualizar a meta", "f5f145b33e2a9380": "Parando...", "e734a8e4a58a3835": "Parar", "0ce0ab7586e91607": "Parar trabalho em segundo plano", @@ -4389,6 +4390,9 @@ "a20b495b9e6f82b9": "Iniciando…", "7917e738e8c3fd41": "Abrir aprovação de {title}", "54c8b8a3c6e6046b": "Abrir pergunta de {title}", + "715be2d41b9f1b72": "Retomar meta", + "5d0c71caa8f328b0": "Limpar", + "efe8657d62633cd4": "Limpar meta", "cebceafe7ddc7d5d": "Feedback da aprovação", "0830bd81f19bb753": "Envie o feedback da aprovação sem anexos nem contexto adicional.", "d15878f290283f53": "Não foi possível editar a mensagem", diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json index 3c74c7fe4be49..278eec4fd10b5 100644 --- a/apps/mobile/src/i18n/translations/ru.json +++ b/apps/mobile/src/i18n/translations/ru.json @@ -4445,6 +4445,7 @@ "f360accf1ccac178": "Ход остановлен; процесс агента продолжает работать", "967f83de030790dd": "{count, plural, =0 {Он используется другими работающими тредами. Остановите их, чтобы освободить его.} one {Он используется {count} работающим тредом. Остановите его, чтобы освободить.} few {Он используется {count} работающими тредами. Остановите их, чтобы освободить его.} many {Он используется {count} работающими тредами. Остановите их, чтобы освободить его.} other {Он используется {count} работающего треда. Остановите их, чтобы освободить его.}}", "5536ab75119ee3f9": "Не удалось обновить тред", + "04c7bba52daa6f53": "Не удалось обновить цель", "f5f145b33e2a9380": "Остановка...", "e734a8e4a58a3835": "Остановить", "0ce0ab7586e91607": "Остановить фоновую работу", @@ -4467,6 +4468,9 @@ "a20b495b9e6f82b9": "Запуск…", "7917e738e8c3fd41": "Открыть запрос подтверждения из {title}", "54c8b8a3c6e6046b": "Открыть вопрос из {title}", + "715be2d41b9f1b72": "Возобновить цель", + "5d0c71caa8f328b0": "Очистить", + "efe8657d62633cd4": "Очистить цель", "cebceafe7ddc7d5d": "Отзыв на подтверждение", "0830bd81f19bb753": "Отправьте отзыв на подтверждение без вложений и добавленного контекста.", "d15878f290283f53": "Не удалось изменить сообщение", diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json index e393eb249899f..a07d612669ebf 100644 --- a/apps/mobile/src/i18n/translations/sv.json +++ b/apps/mobile/src/i18n/translations/sv.json @@ -4373,6 +4373,7 @@ "f360accf1ccac178": "Omgången stoppades; agentprocessen fortsatte att köras", "967f83de030790dd": "{count, plural, =0 {Den delas med andra arbetande trådar. Stoppa dem för att frigöra den.} one {Den delas med {count} arbetande tråd. Stoppa den för att frigöra den.} other {Den delas med {count} arbetande trådar. Stoppa dem för att frigöra den.}}", "5536ab75119ee3f9": "Kunde inte uppdatera tråden", + "04c7bba52daa6f53": "Det gick inte att uppdatera målet", "f5f145b33e2a9380": "Stoppar...", "e734a8e4a58a3835": "Stoppa", "0ce0ab7586e91607": "Stoppa bakgrundsarbete", @@ -4395,6 +4396,9 @@ "a20b495b9e6f82b9": "Startar…", "7917e738e8c3fd41": "Öppna godkännande från {title}", "54c8b8a3c6e6046b": "Öppna fråga från {title}", + "715be2d41b9f1b72": "Återuppta mål", + "5d0c71caa8f328b0": "Rensa", + "efe8657d62633cd4": "Rensa mål", "cebceafe7ddc7d5d": "Feedback på godkännande", "0830bd81f19bb753": "Skicka feedback om godkännandet utan bilagor eller tillagd kontext.", "d15878f290283f53": "Kunde inte redigera meddelandet", diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json index be595b718cbac..b5ec5dae84882 100644 --- a/apps/mobile/src/i18n/translations/zh.json +++ b/apps/mobile/src/i18n/translations/zh.json @@ -4356,6 +4356,7 @@ "f360accf1ccac178": "这一轮已停止,但智能体进程仍在运行", "967f83de030790dd": "{count, plural, =0 {它被其他正在工作的会话共用。停止那些会话即可释放。} other {它被 {count} 个正在工作的会话共用。停止那些会话即可释放。}}", "5536ab75119ee3f9": "无法更新会话", + "04c7bba52daa6f53": "无法更新目标", "f5f145b33e2a9380": "正在停止…", "e734a8e4a58a3835": "停止", "0ce0ab7586e91607": "停止后台工作", @@ -4378,6 +4379,9 @@ "a20b495b9e6f82b9": "正在启动…", "7917e738e8c3fd41": "打开来自 {title} 的批准请求", "54c8b8a3c6e6046b": "打开来自 {title} 的问题", + "715be2d41b9f1b72": "恢复目标", + "5d0c71caa8f328b0": "清除", + "efe8657d62633cd4": "清除目标", "cebceafe7ddc7d5d": "批准反馈", "0830bd81f19bb753": "发送审批反馈时请不要带附件或额外上下文。", "d15878f290283f53": "无法编辑消息", diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index 1cc0ebbd9c4b0..721463f52ec6d 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -560,8 +560,13 @@ describe("mobile task permissions", () => { ); }); - it("queues a goal command without sending or clearing the composer draft", async () => { + it("queues a goal command with the thread's settings and leaves the draft alone", async () => { state.grantedEnvironments.add("secondary"); + state.draft.modelSelection = { + instanceId: ProviderInstanceId.make("claudeAgent"), + model: "claude-sonnet-5-5", + }; + Object.assign(state.draft, { runtimeMode: "approval-required" }); const composer = useThreadComposerState(NO_SIDE_CHATS); expect(await composer.onSendCommand("/goal clear")).toBe("message"); expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( @@ -571,30 +576,13 @@ describe("mobile task permissions", () => { text: "/goal clear", attachments: [], modelSelection: state.thread.modelSelection, + runtimeMode: state.thread.runtimeMode, }), ); expect(state.clearDraft).not.toHaveBeenCalled(); expect(state.draft.text).toBe("Keep my draft"); }); - it("sends a goal command with the thread's model and modes, not the draft's", async () => { - state.grantedEnvironments.add("secondary"); - state.draft.modelSelection = { - instanceId: ProviderInstanceId.make("claudeAgent"), - model: "claude-sonnet-5-5", - }; - Object.assign(state.draft, { runtimeMode: "approval-required", interactionMode: "plan" }); - const composer = useThreadComposerState(NO_SIDE_CHATS); - await composer.onSendCommand("/goal resume"); - expect(state.enqueue).toHaveBeenCalledExactlyOnceWith( - expect.objectContaining({ - modelSelection: state.thread.modelSelection, - runtimeMode: state.thread.runtimeMode, - interactionMode: state.thread.interactionMode, - }), - ); - }); - it("rechecks the operate grant before queueing a command", async () => { state.grantedEnvironments.add("secondary"); const composer = useThreadComposerState(NO_SIDE_CHATS); From 1f8554b26c60b4b9ad238320fe3cb1091c38e8dc Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 19 Nov 2026 19:11:21 +0000 Subject: [PATCH 9/9] fix(mobile): a rejected goal command no longer replaces the composer draft The outbox restored every rejected message into the composer, so a rejected /goal clear overwrote whatever the user was typing. Goal commands are now queued with restoreToDraft: false, and a rejection only removes the message and shows the error. Co-authored-by: voida6 Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/state/thread-outbox-model.ts | 2 ++ .../src/state/thread-task-permissions.test.ts | 1 + .../src/state/threadOutboxDelivery.test.ts | 24 +++++++++++++++++++ apps/mobile/src/state/threadOutboxDelivery.ts | 8 +++++++ .../src/state/use-thread-composer-state.ts | 1 + 5 files changed, 36 insertions(+) diff --git a/apps/mobile/src/state/thread-outbox-model.ts b/apps/mobile/src/state/thread-outbox-model.ts index 2ab60eec8c2db..e0305b547d011 100644 --- a/apps/mobile/src/state/thread-outbox-model.ts +++ b/apps/mobile/src/state/thread-outbox-model.ts @@ -56,6 +56,7 @@ export const QueuedThreadMessageSchema = Schema.Struct({ messageId: MessageId, commandId: CommandId, text: Schema.String, + restoreToDraft: Schema.optional(Schema.Boolean), context: Schema.optional(OrchestrationMessageContext), attachments: Schema.Array(DraftComposerAttachmentSchema), modelSelection: Schema.optional(ModelSelection), @@ -88,6 +89,7 @@ export interface QueuedThreadMessage { readonly messageId: MessageId; readonly commandId: CommandId; readonly text: string; + readonly restoreToDraft?: boolean; readonly context?: OrchestrationMessageContext; readonly attachments: ReadonlyArray; readonly modelSelection?: ModelSelectionType; diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index 721463f52ec6d..b2b83204b2f67 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -574,6 +574,7 @@ describe("mobile task permissions", () => { environmentId: "secondary", threadId: "thread", text: "/goal clear", + restoreToDraft: false, attachments: [], modelSelection: state.thread.modelSelection, runtimeMode: state.thread.runtimeMode, diff --git a/apps/mobile/src/state/threadOutboxDelivery.test.ts b/apps/mobile/src/state/threadOutboxDelivery.test.ts index e77ce11e2c724..51691aca707ea 100644 --- a/apps/mobile/src/state/threadOutboxDelivery.test.ts +++ b/apps/mobile/src/state/threadOutboxDelivery.test.ts @@ -939,6 +939,30 @@ describe("thread outbox recovery rollback", () => { }), ); + it.effect("keeps the draft unchanged when a standalone goal command is rejected", () => + Effect.gen(function* () { + const message: QueuedThreadMessage = { + ...queuedMessage({ messageId: "goal-rejected", text: "/goal clear" }), + restoreToDraft: false, + modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" }, + runtimeMode: "full-access", + }; + const threadKey = `${message.environmentId}:${message.threadId}`; + appAtomRegistry.set(composerDrafts.composerDraftsAtom, { + [threadKey]: { text: "Keep my draft", attachments: [], runtimeMode: "approval-required" }, + }); + const draft = composerDrafts.getComposerDraftSnapshot(threadKey); + yield* Effect.promise(() => harness.manager.enqueue(message)); + expect(yield* restoreRejectedQueuedMessage(message, "rejected")).toBe("restored"); + expect(composerDrafts.getComposerDraftSnapshot(threadKey)).toEqual(draft); + expect(remainingMessages()).toEqual([]); + expect(appAtomRegistry.get(threadComposerErrorsAtom)[threadKey]).toEqual({ + message: "rejected", + messageId: message.messageId, + }); + }), + ); + it.effect("does not record a creation outcome for a rejected follow-up message", () => Effect.gen(function* () { const message = queuedMessage({ messageId: "message-followup-restore", text: "follow up" }); diff --git a/apps/mobile/src/state/threadOutboxDelivery.ts b/apps/mobile/src/state/threadOutboxDelivery.ts index d9e56da0d9229..53692212126b2 100644 --- a/apps/mobile/src/state/threadOutboxDelivery.ts +++ b/apps/mobile/src/state/threadOutboxDelivery.ts @@ -478,6 +478,14 @@ export const restoreRejectedQueuedMessage = Effect.fn("ThreadOutbox.restoreRejec return "deferred" as const; } const revision = threadOutboxRevision(queuedMessage.messageId); + if (queuedMessage.restoreToDraft === false) { + const removed = yield* storage("remove-unsendable", queuedMessage.messageId, () => + removeThreadOutboxMessage(queuedMessage, revision, () => !editing()), + ); + if (!removed) return "deferred" as const; + setThreadComposerError(threadKey, message, queuedMessage.messageId); + return "restored" as const; + } yield* storage("load-drafts", queuedMessage.messageId, () => waitForComposerDraftsLoaded()); if (editing()) return "deferred" as const; const originalDraft = getComposerDraftSnapshot(draftKey); diff --git a/apps/mobile/src/state/use-thread-composer-state.ts b/apps/mobile/src/state/use-thread-composer-state.ts index bb1dd216de9f4..48e7fc02b5b32 100644 --- a/apps/mobile/src/state/use-thread-composer-state.ts +++ b/apps/mobile/src/state/use-thread-composer-state.ts @@ -1013,6 +1013,7 @@ export function useThreadComposerState(input: { messageId, commandId: CommandId.make(metadata.commandId), text, + restoreToDraft: false, attachments: [], modelSelection, runtimeMode: thread.runtimeMode,