The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): a new thread's first send no longer sticks on Starting (#25477)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 26, 2026 at 05:54 UTC
59a3f52ad332bc93f3fe20e3c634da474d203cab
7 files changed
+103
-28
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+1
@@ -1290,6 +1290,7 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
1290
<ThreadFeed
1291
environmentId={props.environmentId}
1292
threadId={props.selectedThread.id}
1293
+ detailRef={props.selectedThreadDetailRef}
1294
workspaceRoot={props.threadCwd}
1295
feed={props.selectedThreadFeed}
1296
pendingHandoff={props.pendingHandoff}
apps/mobile/src/features/threads/ThreadFeed.tsx
+5
-6
@@ -51,6 +51,7 @@ import {
51
type OrchestrationV2ProjectedTurnItem,
52
type RunId,
53
type ScheduledTaskId,
54
+ type ScopedThreadRef,
55
} from "@t3tools/contracts";
56
import { renderAssistantCitationsAsText } from "@t3tools/shared/assistantCitations";
57
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
@@ -332,6 +333,8 @@ export interface ThreadFeedProps {
333
readonly onEditPendingMessage: ((message: QueuedThreadMessage) => void) | null;
334
readonly environmentId: EnvironmentId;
335
readonly threadId: ThreadId;
336
+ /** Null while the thread's creation is queued: reading detail then caches a not-found as deleted. */
337
+ readonly detailRef: ScopedThreadRef | null;
338
readonly threadTitle: string;
339
readonly workspaceRoot?: string | null;
340
readonly feed: ReadonlyArray<ThreadFeedEntry>;
@@ -2098,12 +2101,8 @@ export const ThreadFeed = memo(function ThreadFeed({
2101
...props
2102
}: ThreadFeedProps & { readonly ref?: Ref<ThreadFeedHandle> }) {
2103
const { listRef, onEndFollowEnabledChange, onHeaderMaterialVisibilityChange } = props;
2101
- const workflowOpening = useWorkflowOpening(props.environmentId, props.threadId);
2102
- const guestThreadRef = useMemo(
2103
- () => scopeThreadRef(props.environmentId, props.threadId),
2104
- [props.environmentId, props.threadId],
2105
- );
2106
- const guestShare = useThreadGuestShare(guestThreadRef);
2104
+ const workflowOpening = useWorkflowOpening(props.detailRef);
2105
+ const guestShare = useThreadGuestShare(props.detailRef);
2106
const deviceType = useDeviceType();
2107
const duoColumns = useNativeWorkspaceColumnsSupported() && isDuoDevice(deviceType);
2108
const openPullRequest = useOpenPullRequest();
apps/mobile/src/features/threads/thread-workflow-opening.tsx
+10
-4
@@ -6,7 +6,9 @@ import {
6
workflowOpeningParentThreadId,
7
type RuntimeSubagent,
8
} from "@t3tools/client-runtime/state/subagentRuntime";
9
-import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
9
+import type { EnvironmentId, ScopedThreadRef, ThreadId } from "@t3tools/contracts";
10
+import type { EnvironmentThread } from "@t3tools/client-runtime/state/shell";
11
+import { Atom } from "effect/reactivity";
12
import { useState } from "react";
13
import { Pressable, View } from "react-native";
14
@@ -20,8 +22,10 @@ import { useOpenLinkedThread } from "./useOpenLinkedThread";
22
23
const FOLDED_SCRIPT_LINES = 10;
24
23
-export function useWorkflowOpening(environmentId: EnvironmentId, threadId: ThreadId) {
24
- const threadAtom = environmentThreadDetails.threadAtom(scopeThreadRef(environmentId, threadId));
25
+const NO_THREAD_ATOM = Atom.make<EnvironmentThread | null>(null);
26
+
27
+export function useWorkflowOpening(ref: ScopedThreadRef | null) {
28
+ const threadAtom = ref === null ? NO_THREAD_ATOM : environmentThreadDetails.threadAtom(ref);
29
// Selected as a primitive so an ordinary thread's updates never change the result.
30
const parentId = useAtomValue(threadAtom, (thread) =>
31
thread === null
@@ -35,7 +39,9 @@ export function useWorkflowOpening(environmentId: EnvironmentId, threadId: Threa
39
parentId === null ? null : (thread?.projection ?? null),
40
);
41
const parentSubagents = useAtomValue(
38
- environmentThreadDetails.threadAtom(scopeThreadRef(environmentId, parentId ?? threadId)),
42
+ ref === null || parentId === null
43
+ ? NO_THREAD_ATOM
44
+ : environmentThreadDetails.threadAtom(scopeThreadRef(ref.environmentId, parentId)),
45
(parent) => (parentId === null ? null : (parent?.projection.subagents ?? null)),
46
);
47
return projection === null
apps/mobile/src/lib/filePreview.test.ts
+2
@@ -435,6 +435,7 @@ describe("ThreadInlineFilePreview playback", () => {
435
createElement(ThreadFeed, {
436
environmentId,
437
threadId,
438
+ detailRef: null,
439
threadTitle: "preview",
440
workspaceRoot: "/repo",
441
feed,
@@ -1374,6 +1375,7 @@ describe("ThreadFeed previews", () => {
1375
createElement(ThreadFeed, {
1376
environmentId,
1377
threadId,
1378
+ detailRef: null,
1379
threadTitle: "preview",
1380
workspaceRoot: "/repo",
1381
feed: feedFor(threadId),
apps/mobile/src/state/pending-thread-creation.test.ts
+49
@@ -10,6 +10,7 @@ import { describe, expect, it } from "vite-plus/test";
10
11
import {
12
resolvePendingThreadCreation,
13
+ selectThreadCreationDetail,
14
type PendingThreadCreation,
15
} from "./pending-thread-creation";
16
import type { QueuedThreadMessage } from "./thread-outbox-model";
@@ -138,3 +139,51 @@ describe("resolvePendingThreadCreation", () => {
139
).toBeNull();
140
});
141
});
142
+
143
+describe("selectThreadCreationDetail", () => {
144
+ const threadKey = `${creation.environmentId}:${creation.threadId}`;
145
+ const threadRef = { environmentId: creation.environmentId, threadId: creation.threadId };
146
+
147
+ it("withholds the detail ref until the creation is delivered", () => {
148
+ const queued = selectThreadCreationDetail({
149
+ threadRef,
150
+ threadKey,
151
+ queuedMessagesByThreadKey: { [threadKey]: [creation] },
152
+ outcomes: {},
153
+ });
154
+ expect(queued).toEqual({
155
+ pendingCreation: { message: creation, outcome: null },
156
+ detailRef: null,
157
+ });
158
+
159
+ const failed = selectThreadCreationDetail({
160
+ threadRef,
161
+ threadKey,
162
+ queuedMessagesByThreadKey: {},
163
+ outcomes: { [threadKey]: { kind: "failed", message: creation, reason: "Checkout failed" } },
164
+ });
165
+ expect(failed.pendingCreation?.outcome?.kind).toBe("failed");
166
+ expect(failed.detailRef).toBeNull();
167
+
168
+ const delivered = selectThreadCreationDetail({
169
+ threadRef,
170
+ threadKey,
171
+ queuedMessagesByThreadKey: {},
172
+ outcomes: { [threadKey]: { kind: "delivered", message: creation } },
173
+ });
174
+ expect(delivered.pendingCreation?.outcome?.kind).toBe("delivered");
175
+ expect(delivered.detailRef).toBe(threadRef);
176
+ });
177
+
178
+ it("does not hold back existing threads with only follow-ups queued", () => {
179
+ const { creation: _creation, ...followUp } = creation;
180
+ expect(
181
+ selectThreadCreationDetail({
182
+ threadRef,
183
+ threadKey,
184
+ queuedMessagesByThreadKey: { [threadKey]: [followUp] },
185
+ outcomes: {},
186
+ }),
187
+ ).toEqual({ pendingCreation: null, detailRef: threadRef });
188
+ });
189
+});
apps/mobile/src/state/pending-thread-creation.ts
+29
@@ -21,6 +21,35 @@ export type PendingThreadCreation = {
21
readonly outcome: PendingThreadCreationOutcome | null;
22
};
23
24
+export function selectThreadCreationDetail<Ref>(input: {
25
+ readonly threadRef: Ref | null;
26
+ readonly threadKey: string | null;
27
+ readonly queuedMessagesByThreadKey: Readonly<
28
+ Record<string, ReadonlyArray<QueuedThreadMessage> | undefined>
29
+ >;
30
+ readonly outcomes: Readonly<Record<string, PendingThreadCreationOutcome | undefined>>;
31
+}): { readonly pendingCreation: PendingThreadCreation | null; readonly detailRef: Ref | null } {
32
+ const pendingCreation = ((): PendingThreadCreation | null => {
33
+ if (input.threadKey === null) {
34
+ return null;
35
+ }
36
+ const queued = input.queuedMessagesByThreadKey[input.threadKey]?.find(
37
+ (message) => message.creation !== undefined,
38
+ );
39
+ const outcome = input.outcomes[input.threadKey] ?? null;
40
+ const message = queued ?? outcome?.message ?? null;
41
+ return message === null ? null : { message, outcome };
42
+ })();
43
+ // The shell can arrive before creation is acknowledged. Wait for delivery
44
+ // before subscribing: an early not-found is cached as a deleted thread.
45
+ // Every detail reader must use this ref, not the route id.
46
+ const detailRef =
47
+ pendingCreation === null || pendingCreation.outcome?.kind === "delivered"
48
+ ? input.threadRef
49
+ : null;
50
+ return { pendingCreation, detailRef };
51
+}
52
+
53
export function resolvePendingThreadCreation(input: {
54
readonly threadKey: string | null;
55
readonly pending: PendingThreadCreation | null;
apps/mobile/src/state/use-thread-selection.ts
+7
-18
@@ -26,6 +26,7 @@ import {
26
resolvePendingThreadCreation,
27
pendingThreadCreationOutcomesAtom,
28
pendingThreadCreationShell,
29
+ selectThreadCreationDetail,
30
type PendingThreadCreation,
31
} from "./pending-thread-creation";
32
import {
@@ -145,24 +146,12 @@ function useResolvedThreadSelection(params: ThreadSelectionRouteParams | undefin
146
: scopedThreadKey(selectedThreadRef.environmentId, selectedThreadRef.threadId);
147
const queuedMessagesByThreadKey = useThreadOutboxMessages();
148
const creationOutcome = useAtomValue(pendingThreadCreationOutcomesAtom);
148
- const pendingCreation = ((): PendingThreadCreation | null => {
149
- if (selectedThreadKey === null) {
150
- return null;
151
- }
152
- const queued = queuedMessagesByThreadKey[selectedThreadKey]?.find(
153
- (message) => message.creation !== undefined,
154
- );
155
- const outcome = creationOutcome[selectedThreadKey] ?? null;
156
- const message = queued ?? outcome?.message ?? null;
157
- return message === null ? null : { message, outcome };
158
- })();
159
- // The shell can arrive before creation is acknowledged. Wait for delivery
160
- // before subscribing: an early not-found is cached as a deleted thread.
161
- // Every detail reader must use this ref, not the route id.
162
- const selectedThreadDetailRef =
163
- pendingCreation === null || pendingCreation.outcome?.kind === "delivered"
164
- ? selectedThreadRef
165
- : null;
149
+ const { pendingCreation, detailRef: selectedThreadDetailRef } = selectThreadCreationDetail({
150
+ threadRef: selectedThreadRef,
151
+ threadKey: selectedThreadKey,
152
+ queuedMessagesByThreadKey,
153
+ outcomes: creationOutcome,
154
+ });
155
const [previousCreation, setPreviousCreation] = useState<PendingThreadCreation | null>(null);
156
const needsDetail =
157
selectedThreadShell === null || pendingCreation !== null || previousCreation !== null;