The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): resume continues a usage-limited thread before its queue (#27662)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
AbdelrahmanTamer21 committed
Nov 1, 2026 at 03:40 UTC
cbb0417df5507c19bf85717662e4c96437291c7c
10 files changed
+264
-31
apps/mobile/src/features/threads/ThreadComposer.tsx
+2
-2
@@ -1101,7 +1101,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1101
) : showResumeAction ? (
1102
<ComposerActionButton
1103
size={usesLargeControls ? "large" : "regular"}
1104
- accessibilityLabel="Resume queue"
1104
+ accessibilityLabel="Resume thread"
1105
icon="play"
1106
disabled={!props.canOperateThread || resumingQueue}
1107
onPress={() => void handleResumeQueue()}
@@ -1170,7 +1170,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1170
) : showResumeAction && voicePresentation.showsSend ? (
1171
<ComposerActionButton
1172
size={usesLargeControls ? "large" : "regular"}
1173
- accessibilityLabel="Resume queue"
1173
+ accessibilityLabel="Resume thread"
1174
icon="play"
1175
disabled={!props.canOperateThread || resumingQueue}
1176
onPress={() => void handleResumeQueue()}
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+45
-5
@@ -20,6 +20,7 @@ import {
20
AuthTerminalReadScope,
21
DEFAULT_SERVER_SETTINGS,
22
EnvironmentId,
23
+ MessageId,
24
ThreadId,
25
type ProjectScript,
26
} from "@t3tools/contracts";
@@ -54,6 +55,10 @@ import {
55
} from "../../state/use-remote-environment-registry";
56
import { useKnownTerminalSessions } from "../../state/use-terminal-session";
57
import { uuidv4 } from "../../lib/uuid";
58
+import {
59
+ isAtomCommandInterrupted,
60
+ squashAtomCommandFailure,
61
+} from "@t3tools/client-runtime/state/runtime";
62
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
63
import { useSelectedThreadDetailState } from "../../state/use-thread-detail";
64
import { useThreadSelection } from "../../state/use-thread-selection";
@@ -101,6 +106,7 @@ import {
106
threadRouteOpensDraft,
107
} from "./thread-route-hydration";
108
import { ThreadHeader } from "./ThreadHeader";
109
+import { resumeThread } from "./resume-thread";
110
import {
111
useAndroidWorkspaceBack,
112
useWorkspaceBackNavigation,
@@ -379,7 +385,22 @@ function ThreadRouteContent(
385
const gitActions = useSelectedThreadGitActions();
386
const requests = useSelectedThreadRequests();
387
const interruptThreadTurn = useAtomCommand(threadEnvironment.interruptTurn, "thread interrupt");
382
- const resumeThreadQueue = useAtomCommand(threadEnvironment.resumeThreadQueue, "resume queue");
388
+ const resumeThreadQueue = useAtomCommand(threadEnvironment.resumeThreadQueue, {
389
+ label: "resume queue",
390
+ reportFailure: false,
391
+ });
392
+ const continueThreadRun = useAtomCommand(threadEnvironment.startTurn, {
393
+ label: "continue thread",
394
+ reportFailure: false,
395
+ });
396
+ const setThreadRuntimeMode = useAtomCommand(threadEnvironment.setRuntimeMode, {
397
+ label: "set thread runtime mode",
398
+ reportFailure: false,
399
+ });
400
+ const setThreadInteractionMode = useAtomCommand(threadEnvironment.setInteractionMode, {
401
+ label: "set thread interaction mode",
402
+ reportFailure: false,
403
+ });
404
const loadEarlierHistory = useAtomCommand(threadEnvironment.loadEarlierHistory, {
405
label: "load earlier thread history",
406
reportFailure: false,
@@ -683,10 +704,27 @@ function ThreadRouteContent(
704
705
const handleResumeQueue = async () => {
706
if (!selectedThread) return;
686
- await resumeThreadQueue({
687
- environmentId: selectedThread.environmentId,
688
- input: { threadId: selectedThread.id },
707
+ const result = await resumeThread({
708
+ thread: selectedThread,
709
+ resumableRunId: composer.resumableRunId,
710
+ queueHeld: composer.queueHeld,
711
+ runtimeMode: composer.runtimeMode ?? selectedThread.runtimeMode,
712
+ interactionMode: composer.interactionMode ?? selectedThread.interactionMode,
713
+ modelSelection: composer.modelSelection,
714
+ messageId: MessageId.make(uuidv4()),
715
+ createdAt: new Date().toISOString(),
716
+ setRuntimeMode: setThreadRuntimeMode,
717
+ setInteractionMode: setThreadInteractionMode,
718
+ startTurn: continueThreadRun,
719
+ resumeQueue: resumeThreadQueue,
720
});
721
+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
722
+ const error = squashAtomCommandFailure(result);
723
+ Dialog.alert(
724
+ "Could not resume thread",
725
+ error instanceof Error ? error.message : "Try again.",
726
+ );
727
+ }
728
};
729
730
const handleOpenTerminal = (nextTerminalId?: string | null) => {
@@ -1071,7 +1109,9 @@ function ThreadRouteContent(
1109
onRemoveDraftImage={composer.onRemoveDraftImage}
1110
serverConfig={serverConfig}
1111
onStopThread={awaitingBootstrapTurn ? handleCancelWorktreeSetup : handleStopThread}
1074
- onResumeQueue={composer.queueHeld ? handleResumeQueue : null}
1112
+ onResumeQueue={
1113
+ composer.queueHeld || composer.resumableRunId !== null ? handleResumeQueue : null
1114
+ }
1115
onSendMessage={composer.onSendMessage}
1116
onReconnectEnvironment={handleReconnectEnvironment}
1117
canSwitchThreadProvider={composer.canSwitchThreadProvider}
apps/mobile/src/features/threads/resume-thread.test.ts
new
+90
@@ -0,0 +1,90 @@
1
+import { EnvironmentId, MessageId, RunId, ThreadId } from "@t3tools/contracts";
2
+import * as Cause from "effect/Cause";
3
+import { AsyncResult } from "effect/reactivity";
4
+import { describe, expect, it } from "vite-plus/test";
5
+
6
+import { resumeThread } from "./resume-thread";
7
+
8
+const runId = RunId.make("run-limited");
9
+const failure = AsyncResult.failure(Cause.fail(new Error("not connected")));
10
+
11
+function setup(options: { readonly startTurnFails?: boolean } = {}) {
12
+ const calls: Array<{ readonly command: string; readonly input: unknown }> = [];
13
+ const record =
14
+ (command: string, fails = false) =>
15
+ async (request: { readonly input: unknown }) => {
16
+ calls.push({ command, input: request.input });
17
+ return fails ? failure : AsyncResult.success(undefined);
18
+ };
19
+ const base = {
20
+ thread: {
21
+ environmentId: EnvironmentId.make("env"),
22
+ id: ThreadId.make("thread"),
23
+ runtimeMode: "full-access",
24
+ interactionMode: "default",
25
+ },
26
+ runtimeMode: "full-access",
27
+ interactionMode: "default",
28
+ modelSelection: null,
29
+ messageId: MessageId.make("message"),
30
+ createdAt: "2026-10-30T00:00:00.000Z",
31
+ setRuntimeMode: record("setRuntimeMode"),
32
+ setInteractionMode: record("setInteractionMode"),
33
+ startTurn: record("startTurn", options.startTurnFails),
34
+ resumeQueue: record("resumeQueue"),
35
+ } as const;
36
+ return { calls, base };
37
+}
38
+
39
+describe("resumeThread", () => {
40
+ it("continues the limited run before resuming its held queue", async () => {
41
+ const { calls, base } = setup();
42
+ const result = await resumeThread({ ...base, resumableRunId: runId, queueHeld: true });
43
+
44
+ expect(result._tag).toBe("Success");
45
+ expect(calls.map((call) => call.command)).toEqual(["startTurn", "resumeQueue"]);
46
+ expect(calls[0]?.input).toMatchObject({
47
+ manualContinuationOfRunId: runId,
48
+ dispatchMode: "start",
49
+ });
50
+ });
51
+
52
+ it("does not resume the queue when the continuation fails", async () => {
53
+ const { calls, base } = setup({ startTurnFails: true });
54
+ const result = await resumeThread({ ...base, resumableRunId: runId, queueHeld: true });
55
+
56
+ expect(result).toBe(failure);
57
+ expect(calls.map((call) => call.command)).toEqual(["startTurn"]);
58
+ });
59
+
60
+ it("only continues the run when nothing is queued", async () => {
61
+ const { calls, base } = setup();
62
+ await resumeThread({ ...base, resumableRunId: runId, queueHeld: false });
63
+
64
+ expect(calls.map((call) => call.command)).toEqual(["startTurn"]);
65
+ });
66
+
67
+ it("saves changed modes to the thread before continuing", async () => {
68
+ const { calls, base } = setup();
69
+ await resumeThread({
70
+ ...base,
71
+ runtimeMode: "approval-required",
72
+ interactionMode: "plan",
73
+ resumableRunId: runId,
74
+ queueHeld: false,
75
+ });
76
+
77
+ expect(calls.map((call) => call.command)).toEqual([
78
+ "setRuntimeMode",
79
+ "setInteractionMode",
80
+ "startTurn",
81
+ ]);
82
+ });
83
+
84
+ it("resumes a held queue directly when no run needs continuing", async () => {
85
+ const { calls, base } = setup();
86
+ await resumeThread({ ...base, resumableRunId: null, queueHeld: true });
87
+
88
+ expect(calls.map((call) => call.command)).toEqual(["resumeQueue"]);
89
+ });
90
+});
apps/mobile/src/features/threads/resume-thread.ts
new
+83
@@ -0,0 +1,83 @@
1
+import type {
2
+ ResumeThreadQueueInput,
3
+ SetThreadInteractionModeInput,
4
+ SetThreadRuntimeModeInput,
5
+ StartThreadTurnInput,
6
+} from "@t3tools/client-runtime/operations";
7
+import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
8
+import type {
9
+ EnvironmentId,
10
+ MessageId,
11
+ ModelSelection,
12
+ ProviderInteractionMode,
13
+ RunId,
14
+ RuntimeMode,
15
+ ThreadId,
16
+} from "@t3tools/contracts";
17
+
18
+type Command<Input, E> = (request: {
19
+ readonly environmentId: EnvironmentId;
20
+ readonly input: Input;
21
+}) => Promise<AtomCommandResult<unknown, E>>;
22
+
23
+/** Resolves to the first failed command's result, or the last successful one. */
24
+export async function resumeThread<E>(input: {
25
+ readonly thread: {
26
+ readonly environmentId: EnvironmentId;
27
+ readonly id: ThreadId;
28
+ readonly runtimeMode: RuntimeMode;
29
+ readonly interactionMode: ProviderInteractionMode;
30
+ };
31
+ readonly resumableRunId: RunId | null;
32
+ readonly queueHeld: boolean;
33
+ readonly runtimeMode: RuntimeMode;
34
+ readonly interactionMode: ProviderInteractionMode;
35
+ readonly modelSelection: ModelSelection | null;
36
+ readonly messageId: MessageId;
37
+ readonly createdAt: string;
38
+ readonly setRuntimeMode: Command<SetThreadRuntimeModeInput, E>;
39
+ readonly setInteractionMode: Command<SetThreadInteractionModeInput, E>;
40
+ readonly startTurn: Command<StartThreadTurnInput, E>;
41
+ readonly resumeQueue: Command<ResumeThreadQueueInput, E>;
42
+}): Promise<AtomCommandResult<unknown, E>> {
43
+ const { thread, runtimeMode, interactionMode, createdAt } = input;
44
+ const environmentId = thread.environmentId;
45
+ // The server holds the queue behind a stopped or usage-limited run until that run is continued.
46
+ if (input.resumableRunId !== null) {
47
+ // A turn on an existing thread runs with the thread's saved modes, not the turn's.
48
+ if (runtimeMode !== thread.runtimeMode) {
49
+ const saved = await input.setRuntimeMode({
50
+ environmentId,
51
+ input: { threadId: thread.id, runtimeMode, createdAt },
52
+ });
53
+ if (saved._tag === "Failure") return saved;
54
+ }
55
+ if (interactionMode !== thread.interactionMode) {
56
+ const saved = await input.setInteractionMode({
57
+ environmentId,
58
+ input: { threadId: thread.id, interactionMode, createdAt },
59
+ });
60
+ if (saved._tag === "Failure") return saved;
61
+ }
62
+ const continued = await input.startTurn({
63
+ environmentId,
64
+ input: {
65
+ creationSource: "mobile",
66
+ threadId: thread.id,
67
+ manualContinuationOfRunId: input.resumableRunId,
68
+ ...(input.modelSelection ? { modelSelection: input.modelSelection } : {}),
69
+ message: {
70
+ messageId: input.messageId,
71
+ role: "user",
72
+ text: "Continue where you left off.",
73
+ attachments: [],
74
+ },
75
+ runtimeMode,
76
+ interactionMode,
77
+ dispatchMode: "start",
78
+ },
79
+ });
80
+ if (continued._tag === "Failure" || !input.queueHeld) return continued;
81
+ }
82
+ return input.resumeQueue({ environmentId, input: { threadId: thread.id } });
83
+}
apps/mobile/src/state/use-thread-composer-state.ts
+5
@@ -8,6 +8,7 @@ import type { ThreadCheckpointSummary } from "@t3tools/client-runtime/state/thre
8
import { resolvePendingHandoff } from "@t3tools/client-runtime/handoff";
9
import {
10
deriveProviderSubagentStatus,
11
+ deriveResumableRunId,
12
deriveRunlessWorkStartedAt,
13
deriveThreadActivityRun,
14
deriveThreadRuntime,
@@ -361,6 +362,9 @@ export function useThreadComposerState() {
362
// A stop or a restart holds the queue, completion wakes included, until it
363
// is resumed; the queue sheet lists only the user's own messages.
364
const queueHeld = queueWorkflow?.isHeld === true;
365
+ const resumableRunId = selectedThreadProjection
366
+ ? deriveResumableRunId(selectedThreadProjection.projection, selectedThreadRuntime)
367
+ : null;
368
369
const runlessWorkStartedAt = selectedThreadProjection
370
? deriveRunlessWorkStartedAt(selectedThreadProjection.projection)
@@ -749,6 +753,7 @@ export function useThreadComposerState() {
753
followUpBehavior,
754
canSteerActiveTurn,
755
queueHeld,
756
+ resumableRunId,
757
queuedRunEdit,
758
isSavingQueuedEdit,
759
cancelQueuedRunEdit,
apps/web/src/components/ChatView.tsx
+5
-14
@@ -42,10 +42,6 @@ import { RightPanelSurfaceContent } from "./chat/RightPanelSurfaceContent";
42
import { usePendingThreadRequests } from "./chat/usePendingThreadRequests";
43
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
44
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
45
-import {
46
- latestExecutedRun,
47
- latestRootProviderFailure,
48
-} from "@t3tools/shared/orchestrationV2ThreadError";
45
import type { UsageLimitSourceSnapshots } from "@t3tools/contracts";
46
import { feedbackBannerItem } from "./chat/ComposerFeedback";
47
import { useUsageLimitsPanel } from "./chat/useUsageLimitsPanel";
@@ -77,6 +73,7 @@ import {
73
import {
74
deriveProviderSubagentStatus,
75
deriveReportedModelSelection,
76
+ deriveResumableRunId,
77
formatModelSelectionEffort,
78
deriveRunlessWorkStartedAt,
79
deriveThreadActivityRun,
@@ -815,16 +812,10 @@ export default function ChatView(props: ChatViewProps) {
812
isServerThread &&
813
serverProjection?.runs.some((run) => run.status === "queued" && run.queueHeld === true) ===
814
true;
818
- const resumableRunId = (() => {
819
- if (!isServerThread || serverProjection === null) return null;
820
- const run = latestExecutedRun(serverProjection.runs);
821
- if (run?.status === "interrupted") return run.id;
822
- return run?.status === "failed" &&
823
- serverRuntime?.lastErrorClass === "usage_limit" &&
824
- latestRootProviderFailure(run, serverProjection.turnItems)?.class === "usage_limit"
825
- ? run.id
826
- : null;
827
- })();
815
+ const resumableRunId =
816
+ !isServerThread || serverProjection === null
817
+ ? null
818
+ : deriveResumableRunId(serverProjection, serverRuntime);
819
const parentSubagentThreadId =
820
activeThread?.lineage.relationshipToParent === "subagent"
821
? activeThread.lineage.parentThreadId
docs/user/composer.md
+2
-2
@@ -213,8 +213,8 @@ images. **Send now** sends a message right away, into the running turn if there
213
also edit or remove it.
214
215
If you stop the agent or the server restarts, queued messages keep their order and are held.
216
-Press **Resume** in an empty composer on web and desktop, or **Resume queue** on mobile, to
217
-continue. Sending a new message also resumes the queue, unless it steers a turn that is already
216
+Press **Resume** in an empty composer to continue. **Resume** also continues a stopped
217
+run or one that hit a usage limit, even with nothing queued. Sending a new message also resumes the queue, unless it steers a turn that is already
218
running. You can edit or remove held messages without starting them.
219
220
The pencil on a queued message opens it in the composer for editing. The original message
docs/user/thread-sidebar.md
+3
-2
@@ -238,8 +238,9 @@ from its context menu, or **Copy thread** from its long-press menu on mobile.
238
**Limited** means the provider stopped on a usage or rate limit. The conversation
239
keeps the provider's explanation. Retry after the limit resets, or switch to
240
another provider instance.
241
-On web and desktop, press **Resume** in an empty composer to continue a limited
242
-or interrupted turn manually.
241
+Press **Resume** in an empty composer to continue a limited or interrupted turn
242
+manually. Do this when the provider reports no reset time, because nothing
243
+continues the turn on its own.
244
Queued messages stay saved while the limit blocks the thread. They run after
245
the continuation finishes. If the queue was held by a restart, resume it then.
246
packages/client-runtime/src/state/threadExecution.test.ts
+13
-6
@@ -22,6 +22,7 @@ import {
22
deriveReportedModelSelection,
23
deriveLatestThreadRun,
24
deriveProviderSubagentStatus,
25
+ deriveResumableRunId,
26
deriveRunlessWorkStartedAt,
27
deriveThreadActivityRun,
28
deriveThreadRuntime,
@@ -84,6 +85,7 @@ describe("thread execution presentation", () => {
85
lastError: "Plan limit reached",
86
lastErrorClass: "usage_limit",
87
});
88
+ expect(deriveResumableRunId(projection, deriveThreadRuntime(projection))).toBe(failed.id);
89
expect(
90
deriveThreadRuntime({
91
...projection,
@@ -154,6 +156,7 @@ describe("thread execution presentation", () => {
156
lastError: "Plan limit reached",
157
lastErrorClass: "usage_limit",
158
});
159
+ expect(deriveResumableRunId(projection, deriveThreadRuntime(projection))).toBe(failed.id);
160
const cancelledQueued = {
161
...run("cancelled-queued", 3, "cancelled"),
162
startedAt: null,
@@ -165,12 +168,15 @@ describe("thread execution presentation", () => {
168
expect(
169
deriveThreadRuntime({ ...projection, runs: [failed, queued, cancelledQueued] }),
170
).toMatchObject({ status: "failed", lastErrorClass: "usage_limit" });
168
- expect(
169
- deriveThreadRuntime({
170
- ...projection,
171
- turnItems: [{ ...item, failure: { ...item.failure, class: "provider_error" as const } }],
172
- }),
173
- ).toMatchObject({ status: "queued", lastErrorClass: null });
171
+ const providerError = {
172
+ ...projection,
173
+ turnItems: [{ ...item, failure: { ...item.failure, class: "provider_error" as const } }],
174
+ };
175
+ expect(deriveThreadRuntime(providerError)).toMatchObject({
176
+ status: "queued",
177
+ lastErrorClass: null,
178
+ });
179
+ expect(deriveResumableRunId(providerError, deriveThreadRuntime(providerError))).toBeNull();
180
});
181
182
it("keeps live activity attached to an executing run when a newer run is queued", () => {
@@ -231,6 +237,7 @@ describe("thread execution presentation", () => {
237
status: "interrupted",
238
activeRunId: null,
239
});
240
+ expect(deriveResumableRunId(projection, deriveThreadRuntime(projection))).toBe(interrupted.id);
241
242
const resumed = { ...projection, runs: [interrupted, { ...held, queueHeld: false }] };
243
expect(deriveThreadRuntime(resumed)).toMatchObject({ status: "queued" });
packages/client-runtime/src/state/threadExecution.ts
+16
@@ -1,4 +1,5 @@
1
import {
2
+ latestExecutedRun,
3
latestRootProviderFailure,
4
latestUnheldRun,
5
threadErrorSummary,
@@ -16,6 +17,7 @@ import {
17
type OrchestrationV2ExecutionNode,
18
type OrchestrationV2ThreadProjection,
19
orchestrationV2RunWorkStartedAt,
20
+ type RunId,
21
type ThreadId,
22
} from "@t3tools/contracts";
23
import {
@@ -210,6 +212,20 @@ export function formatProviderSubagentStatus(
212
return live ? `${label} ${elapsed}` : `${label} in ${elapsed}`;
213
}
214
215
+/** The run a manual continuation resumes; the server holds the queue until it does. */
216
+export function deriveResumableRunId(
217
+ projection: Pick<ThreadStructure, "runs" | "turnItems">,
218
+ runtime: Pick<ThreadStructureRuntime, "lastErrorClass"> | null,
219
+): RunId | null {
220
+ const run = latestExecutedRun(projection.runs);
221
+ if (run?.status === "interrupted") return run.id;
222
+ return run?.status === "failed" &&
223
+ runtime?.lastErrorClass === "usage_limit" &&
224
+ latestRootProviderFailure(run, projection.turnItems)?.class === "usage_limit"
225
+ ? run.id
226
+ : null;
227
+}
228
+
229
export function deriveThreadRuntime(
230
projection: ThreadStructure & Pick<OrchestrationV2ThreadProjection, "updatedAt">,
231
): ThreadRuntimeSummary | null {