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 23, 01:45 UTC
fix(server,mobile): a message you send resumes a held queue, and mobile can resume one (#21473)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 18, 2026 at 23:01 UTC
62d98096ca0d07959ed417c24a69679f6582c764
9 files changed
+216
-14
apps/mobile/src/features/threads/ThreadComposer.tsx
+26
@@ -162,6 +162,8 @@ export interface ThreadComposerProps {
162
readonly onNativePasteText: (paste: ComposerTextPaste) => Promise<void>;
163
readonly onRemoveDraftImage: (imageId: string) => void;
164
readonly onStopThread: () => void;
165
+ /** Present while the thread's queue is held. */
166
+ readonly onResumeQueue: (() => Promise<void>) | null;
167
readonly onSendMessage: (followUp?: ActiveTurnComposerAction) => Promise<MessageId | null>;
168
readonly onShowUsageLimits: (report: UsageLimitsReport | null) => void;
169
readonly canSwitchProvider: boolean;
@@ -357,6 +359,16 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
359
(queuedEdit?.existingAttachments.length ?? 0) > 0;
360
const stripAttachments = composerStripAttachments(draftAttachments);
361
const showStopAction = !hasContent && props.canStopThread && queuedEdit === null;
362
+ const onResumeQueue = props.onResumeQueue;
363
+ const [resumingQueue, setResumingQueue] = useState(false);
364
+ const showResumeAction =
365
+ !hasContent && !showStopAction && queuedEdit === null && onResumeQueue !== null;
366
+ const handleResumeQueue = async () => {
367
+ if (resumingQueue || onResumeQueue === null) return;
368
+ setResumingQueue(true);
369
+ await onResumeQueue();
370
+ setResumingQueue(false);
371
+ };
372
373
const uploadStates = useAtomValue(composerAttachmentUploadsAtom);
374
const attachmentsUploading =
@@ -955,6 +967,13 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
967
disabled={!props.canOperateThread}
968
onPress={props.onStopThread}
969
/>
970
+ ) : showResumeAction ? (
971
+ <ComposerActionButton
972
+ accessibilityLabel="Resume queue"
973
+ icon="play"
974
+ disabled={!props.canOperateThread || resumingQueue}
975
+ onPress={() => void handleResumeQueue()}
976
+ />
977
) : (
978
<SendActionButton
979
accessibilityLabel={sendBlockedReason ?? sendLabel}
@@ -1050,6 +1069,13 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1069
disabled={!props.canOperateThread}
1070
onPress={props.onStopThread}
1071
/>
1072
+ ) : showResumeAction && voicePresentation.showsSend ? (
1073
+ <ComposerActionButton
1074
+ accessibilityLabel="Resume queue"
1075
+ icon="play"
1076
+ disabled={!props.canOperateThread || resumingQueue}
1077
+ onPress={() => void handleResumeQueue()}
1078
+ />
1079
) : voicePresentation.showsSend ? (
1080
<SendActionButton
1081
accessibilityLabel={sendBlockedReason ?? sendLabel}
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+3
@@ -217,6 +217,8 @@ export interface ThreadDetailScreenProps {
217
readonly onNativePasteText: (paste: ComposerTextPaste) => Promise<void>;
218
readonly onRemoveDraftImage: (imageId: string) => void;
219
readonly onStopThread: () => void;
220
+ /** Present while the thread's queue is held. */
221
+ readonly onResumeQueue: (() => Promise<void>) | null;
222
readonly onSendMessage: (followUp?: ActiveTurnComposerAction) => Promise<MessageId | null>;
223
readonly onReconnectEnvironment: () => void;
224
readonly canSwitchThreadProvider: boolean;
@@ -1343,6 +1345,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
1345
onNativePasteText={props.onNativePasteText}
1346
onRemoveDraftImage={props.onRemoveDraftImage}
1347
onStopThread={props.onStopThread}
1348
+ onResumeQueue={props.onResumeQueue}
1349
onSendMessage={handleSendMessage}
1350
onShowUsageLimits={showUsageLimits}
1351
canSwitchProvider={props.canSwitchThreadProvider}
apps/mobile/src/features/threads/ThreadQueueControl.tsx
+1
-1
@@ -189,7 +189,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
189
>
190
{workflow?.isHeld && queuedRuns.length > 0 ? (
191
<View className="gap-2 py-3">
192
- <Text className="text-sm text-foreground-muted">Queue held after restart</Text>
192
+ <Text className="text-sm text-foreground-muted">Queue paused</Text>
193
<Button
194
label="Resume queue"
195
disabled={resuming || busyRunId !== null}
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+10
@@ -291,6 +291,7 @@ function ThreadRouteContent(
291
const gitActions = useSelectedThreadGitActions();
292
const requests = useSelectedThreadRequests();
293
const interruptThreadTurn = useAtomCommand(threadEnvironment.interruptTurn, "thread interrupt");
294
+ const resumeThreadQueue = useAtomCommand(threadEnvironment.resumeThreadQueue, "resume queue");
295
const loadEarlierHistory = useAtomCommand(threadEnvironment.loadEarlierHistory, {
296
label: "load earlier thread history",
297
reportFailure: false,
@@ -564,6 +565,14 @@ function ThreadRouteContent(
565
});
566
};
567
568
+ const handleResumeQueue = async () => {
569
+ if (!selectedThread) return;
570
+ await resumeThreadQueue({
571
+ environmentId: selectedThread.environmentId,
572
+ input: { threadId: selectedThread.id },
573
+ });
574
+ };
575
+
576
const handleOpenTerminal = (nextTerminalId?: string | null) => {
577
terminalDebugLog("terminal-menu:open-existing", {
578
terminalId: nextTerminalId ?? null,
@@ -956,6 +965,7 @@ function ThreadRouteContent(
965
onRemoveDraftImage={composer.onRemoveDraftImage}
966
serverConfig={serverConfig}
967
onStopThread={awaitingBootstrapTurn ? handleCancelWorktreeSetup : handleStopThread}
968
+ onResumeQueue={composer.queueHeld ? handleResumeQueue : null}
969
onSendMessage={composer.onSendMessage}
970
onReconnectEnvironment={handleReconnectEnvironment}
971
canSwitchThreadProvider={composer.canSwitchThreadProvider}
apps/mobile/src/state/use-thread-composer-state.ts
+4
@@ -351,6 +351,9 @@ export function useThreadComposerState() {
351
})();
352
// A compacting turn cannot take steering input, so follow-ups queue meanwhile.
353
const canSteerActiveTurn = queueWorkflow?.canPromoteToSteer === true && !isCompacting;
354
+ // A stop or a restart holds the queue, completion wakes included, until it
355
+ // is resumed; the queue sheet lists only the user's own messages.
356
+ const queueHeld = queueWorkflow?.isHeld === true;
357
358
const runlessWorkStartedAt = selectedThreadProjection
359
? deriveRunlessWorkStartedAt(selectedThreadProjection.projection)
@@ -966,6 +969,7 @@ export function useThreadComposerState() {
969
composerDraftKey,
970
followUpBehavior,
971
canSteerActiveTurn,
972
+ queueHeld,
973
queuedRunEdit,
974
isSavingQueuedEdit,
975
cancelQueuedRunEdit,
apps/server/src/orchestration-v2/Orchestrator.ts
+46
-8
@@ -4999,11 +4999,48 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4999
: undefined;
5000
const queueBehindRun = activeRun ?? worktreeMissingRun;
5001
const pendingMergeBackTransfers = pendingMergeBackTransfersForThread(projection);
5002
- const shouldQueue =
5003
- queueBehindRun !== undefined &&
5004
- (dispatchMode.type === "defer_start" ||
5005
- dispatchMode.type === "start_immediately" ||
5006
- dispatchMode.type === "queue_after_active");
5002
+ const startsOrQueuesRun =
5003
+ dispatchMode.type === "defer_start" ||
5004
+ dispatchMode.type === "start_immediately" ||
5005
+ dispatchMode.type === "queue_after_active";
5006
+ const shouldQueue = queueBehindRun !== undefined && startsOrQueuesRun;
5007
+ // A message the user sends from a client means they are back, so the
5008
+ // queue a stop or a restart held runs again, in its order, rather than
5009
+ // waiting for a Resume.
5010
+ // Continuations and scheduled tasks the server sends for them are not
5011
+ // them coming back. Starting the queue still re-holds it for a failed
5012
+ // provider or a usage limit; a queue held after worktree setup failed
5013
+ // keeps its hold until a worktree exists, even once later messages have
5014
+ // run, since its messages would start in the project checkout.
5015
+ const worktreeSetupUnresolved =
5016
+ projection.thread.worktreePath === null &&
5017
+ projection.runs.some(
5018
+ (run) =>
5019
+ (run.status === "failed" || run.status === "interrupted") &&
5020
+ run.workspacePreparation?.type === "worktree",
5021
+ );
5022
+ const sentByUserFromClient =
5023
+ command.createdBy === "user" &&
5024
+ (command.creationSource === "web" || command.creationSource === "mobile") &&
5025
+ command.scheduledTaskId === undefined;
5026
+ const heldRunsToRelease =
5027
+ sentByUserFromClient && startsOrQueuesRun && !worktreeSetupUnresolved
5028
+ ? projection.runs.filter((run) => run.status === "queued" && run.queueHeld === true)
5029
+ : [];
5030
+ const releasedAt = yield* DateTime.now;
5031
+ for (const held of heldRunsToRelease) {
5032
+ yield* emit(
5033
+ events,
5034
+ command,
5035
+ )({
5036
+ type: "run.updated",
5037
+ threadId: command.threadId,
5038
+ runId: held.id,
5039
+ providerInstanceId: held.providerInstanceId,
5040
+ occurredAt: releasedAt,
5041
+ payload: { ...held, queueHeld: false },
5042
+ });
5043
+ }
5044
if (shouldQueue) {
5045
if (pendingMergeBackTransfers.length > 0) {
5046
return yield* new OrchestratorDispatchError({
@@ -5113,9 +5150,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5150
activeAttemptId: attemptId,
5151
status: "queued",
5152
...(worktreeMissingRun !== undefined ||
5116
- projection.runs.some(
5117
- (candidate) => candidate.status === "queued" && candidate.queueHeld === true,
5118
- )
5153
+ (heldRunsToRelease.length === 0 &&
5154
+ projection.runs.some(
5155
+ (candidate) => candidate.status === "queued" && candidate.queueHeld === true,
5156
+ ))
5157
? { queueHeld: true }
5158
: {}),
5159
queuePosition:
apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
+32
-2
@@ -1815,8 +1815,38 @@ it.effect.each(["failed", "interrupted"] as const)(
1815
});
1816
assert.equal(queued.delivery, "queued");
1817
const projection = yield* threads.getThreadProjection(launched.threadId);
1818
- assert.equal(projection.runs.at(-1)?.status, "queued");
1819
- assert.equal(projection.runs.at(-1)?.queueHeld, true);
1818
+ const held = projection.runs.at(-1)!;
1819
+ assert.equal(held.status, "queued");
1820
+ assert.equal(held.queueHeld, true);
1821
+
1822
+ // A message the user starts does not release it: the held message would
1823
+ // run after it in the project checkout.
1824
+ yield* threads.sendToThread({
1825
+ projectId,
1826
+ commandId: CommandId.make(`command:launch:late-queued-follow-up-${ending}:start`),
1827
+ threadId: launched.threadId,
1828
+ messageId: MessageId.make(`message:launch:late-queued-follow-up-${ending}:start`),
1829
+ text: "Sent after setup",
1830
+ attachments: [],
1831
+ mode: "auto",
1832
+ createdBy: "user",
1833
+ creationSource: "web",
1834
+ });
1835
+ // Nor does the next one, though the run that message started is now the
1836
+ // latest and carries no workspace preparation.
1837
+ yield* threads.sendToThread({
1838
+ projectId,
1839
+ commandId: CommandId.make(`command:launch:late-queued-follow-up-${ending}:again`),
1840
+ threadId: launched.threadId,
1841
+ messageId: MessageId.make(`message:launch:late-queued-follow-up-${ending}:again`),
1842
+ text: "Sent after that",
1843
+ attachments: [],
1844
+ mode: "auto",
1845
+ createdBy: "user",
1846
+ creationSource: "web",
1847
+ });
1848
+ const after = yield* threads.getThreadProjection(launched.threadId);
1849
+ assert.isTrue(after.runs.find((run) => run.id === held.id)?.queueHeld);
1850
}).pipe(Effect.provide(harness.layer));
1851
},
1852
);
apps/server/src/orchestration-v2/ThreadStop.test.ts
+90
@@ -12,6 +12,7 @@ import {
12
ProviderSessionId,
13
ProviderTurnId,
14
RuntimeRequestId,
15
+ ScheduledTaskId,
16
ThreadId,
17
TurnItemId,
18
} from "@t3tools/contracts";
@@ -538,6 +539,95 @@ it.effect.each(["thread.stop", "run.interrupt"] as const)(
539
}).pipe(Effect.provide(layerTest)),
540
);
541
542
+it.effect("a message the user sends after Stop releases the held queue; an agent's does not", () =>
543
+ Effect.gen(function* () {
544
+ const orchestrator = yield* Orchestrator.OrchestratorV2;
545
+ const projections = yield* ProjectionStore.ProjectionStoreV2;
546
+ const threadId = ThreadId.make("thread:stop-release");
547
+ const agentSend = (text: string) =>
548
+ orchestrator.dispatch({
549
+ type: "message.dispatch",
550
+ commandId: CommandId.make(`agent-send:${text}`),
551
+ threadId,
552
+ messageId: MessageId.make(`message:${threadId}:${text}`),
553
+ text,
554
+ attachments: [],
555
+ dispatchMode: { type: "queue_after_active" },
556
+ createdBy: "agent",
557
+ creationSource: "mcp",
558
+ });
559
+ yield* createWatchingThread(threadId, 6);
560
+ yield* send(threadId, "active", "start_immediately");
561
+ yield* send(threadId, "queued before the stop", "queue_after_active");
562
+ yield* orchestrator.dispatch({
563
+ type: "thread.stop",
564
+ commandId: CommandId.make("stop-release"),
565
+ threadId,
566
+ });
567
+ assert.deepEqual((yield* threadState(threadId)).runs, ["interrupted", "queued:held"]);
568
+
569
+ // An agent's message starts on the idle thread, but the hold is the user's.
570
+ yield* agentSend("agent nudge");
571
+ assert.deepEqual((yield* threadState(threadId)).runs, [
572
+ "interrupted",
573
+ "queued:held",
574
+ "starting",
575
+ ]);
576
+ const nudge = (yield* orchestrator.getThreadProjection(threadId)).runs.at(-1)!;
577
+ const now = yield* DateTime.now;
578
+ yield* projections.apply({
579
+ id: EventId.make("event:stop-release:nudge-completed"),
580
+ type: "run.updated",
581
+ threadId,
582
+ runId: nudge.id,
583
+ occurredAt: now,
584
+ payload: { ...nudge, status: "completed", completedAt: now },
585
+ });
586
+
587
+ // A scheduled task the user created is not the user coming back.
588
+ yield* orchestrator.dispatch({
589
+ type: "message.dispatch",
590
+ commandId: CommandId.make("scheduled-send"),
591
+ threadId,
592
+ messageId: MessageId.make(`message:${threadId}:scheduled`),
593
+ text: "Nightly check",
594
+ attachments: [],
595
+ dispatchMode: { type: "queue_after_active" },
596
+ createdBy: "user",
597
+ creationSource: "web",
598
+ scheduledTaskId: ScheduledTaskId.make("scheduled:nightly"),
599
+ });
600
+ const scheduled = (yield* orchestrator.getThreadProjection(threadId)).runs.at(-1)!;
601
+ assert.deepEqual((yield* threadState(threadId)).runs, [
602
+ "interrupted",
603
+ "queued:held",
604
+ "completed",
605
+ "starting",
606
+ ]);
607
+ yield* projections.apply({
608
+ id: EventId.make("event:stop-release:scheduled-completed"),
609
+ type: "run.updated",
610
+ threadId,
611
+ runId: scheduled.id,
612
+ occurredAt: now,
613
+ payload: { ...scheduled, status: "completed", completedAt: now },
614
+ });
615
+
616
+ // The user is back: the held message follows their run, and a wake that
617
+ // queues behind it is not held by the old Stop.
618
+ yield* send(threadId, "back", "start_immediately");
619
+ yield* agentSend("task finished");
620
+ assert.deepEqual((yield* threadState(threadId)).runs, [
621
+ "interrupted",
622
+ "queued",
623
+ "completed",
624
+ "completed",
625
+ "starting",
626
+ "queued",
627
+ ]);
628
+ }).pipe(Effect.provide(layerTest)),
629
+);
630
+
631
it.effect(
632
"thread.stop ends an idle thread's watches and accepts a thread with nothing to stop",
633
() =>
docs/user/composer.md
+4
-3
@@ -206,9 +206,10 @@ Queued messages appear above the composer. Rows show a thumbnail of any attached
206
the text. Drag a row by its handle to reorder it, use the handle's arrow keys, promote the message
207
to a steer, or remove it.
208
209
-If the server restarts, saved queued messages keep their order and are held. Press
210
-**Resume** in an empty composer on web or desktop, or **Resume queue** in the queue
211
-sheet on mobile, to continue. You can edit, reorder, or remove held messages without starting them.
209
+If you stop the agent or the server restarts, queued messages keep their order and are held.
210
+Press **Resume** in an empty composer on web and desktop, or **Resume queue** on mobile, to
211
+continue. Sending a new message also resumes the queue, unless it steers a turn that is already
212
+running. You can edit, reorder, or remove held messages without starting them.
213
214
The pencil on a queued row opens that message in the composer for editing. The original message
215
stays in the queue until you save, and its row is highlighted while you edit. The message's