The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): new thread project list no longer shifts when the No project option appears (#23391)
Co-authored-by: jdlar18 <215521440+jdlar18@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Juan De la Rosa committed
Oct 31, 2026 at 03:47 UTC
7fe6934ed5d4ea9012b8da60a78d8ac29ecda5e1
3 files changed
+129
-21
apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
+23
-20
@@ -10,7 +10,6 @@ import {
10
type StaticScreenProps,
11
} from "@react-navigation/native";
12
import { SymbolView } from "../../components/ui/AppSymbol";
13
-import { availableScratchWorkspaceRoot } from "@t3tools/client-runtime/operations/projects";
13
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
14
import {
15
isAtomCommandInterrupted,
@@ -35,7 +34,11 @@ import { useWorkspaceState } from "../../state/workspace";
34
35
import { useIncomingShare } from "../sharing/IncomingShareProvider";
36
import { useNewTaskFlow } from "./new-task-flow-provider";
38
-import { filterProjectScopes, getProjectScopeSelectionTarget } from "./new-task-project-selection";
37
+import {
38
+ filterProjectScopes,
39
+ getProjectScopeSelectionTarget,
40
+ resolveNewTaskScratchOption,
41
+} from "./new-task-project-selection";
42
import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
43
44
type NewTaskRouteParams = {
@@ -196,20 +199,15 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
199
const openScratch = useAtomCommand(projectEnvironment.openScratch, {
200
reportFailure: false,
201
});
199
- const scratchEnvironments = connectedEnvironments.filter(
200
- (environment) =>
201
- availableScratchWorkspaceRoot(
202
- environment.connectionState,
203
- serverConfigs.get(environment.environmentId),
204
- ) !== null,
205
- );
206
- const scratchEnvironment =
207
- scratchEnvironments.find(
208
- (environment) => environment.environmentId === selectedEnvironmentId,
209
- ) ??
210
- scratchEnvironments[0] ??
211
- null;
212
- const canStartScratch = scratchEnvironment !== null && reservedDestinationProject === null;
202
+ const scratchOption =
203
+ reservedDestinationProject === null
204
+ ? resolveNewTaskScratchOption({
205
+ environments: connectedEnvironments,
206
+ serverConfigs,
207
+ selectedEnvironmentId,
208
+ })
209
+ : null;
210
+ const canStartScratch = scratchOption?.ready === true;
211
const scratchStartInFlightRef = useRef(false);
212
213
async function selectProject(project: EnvironmentProject): Promise<void> {
@@ -249,8 +247,8 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
247
}
248
249
async function startScratch(): Promise<void> {
252
- if (!scratchEnvironment || scratchStartInFlightRef.current) return;
253
- const environmentId = scratchEnvironment.environmentId;
250
+ if (!canStartScratch || !scratchOption || scratchStartInFlightRef.current) return;
251
+ const environmentId = scratchOption.environmentId;
252
scratchStartInFlightRef.current = true;
253
const result = await openScratch({ environmentId, input: {} });
254
if (result._tag === "Failure") {
@@ -331,13 +329,14 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
329
: {}),
330
}}
331
>
334
- {canStartScratch && listScopes.length > 0 ? (
332
+ {scratchOption !== null && listScopes.length > 0 ? (
333
Platform.OS === "android" ? (
334
<View collapsable={false} className="overflow-hidden rounded-[28px] bg-grouped-card">
335
<NavigationRow
336
className="bg-grouped-card"
337
title="No project"
338
subtitle="Start a task without a project"
339
+ disabled={!canStartScratch}
340
onPress={() => void startScratch()}
341
leading={
342
<SymbolView
@@ -354,8 +353,12 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
353
<Pressable
354
accessibilityRole="button"
355
accessibilityLabel="No project"
356
+ disabled={!canStartScratch}
357
onPress={() => void startScratch()}
358
- className="flex-row items-center gap-3 bg-grouped-card px-4 py-3.5"
358
+ className={cn(
359
+ "flex-row items-center gap-3 bg-grouped-card px-4 py-3.5",
360
+ !canStartScratch && "opacity-45",
361
+ )}
362
>
363
<View className="h-7 w-7 items-center justify-center">
364
<SymbolView
apps/mobile/src/features/threads/new-task-project-selection.test.ts
+76
@@ -8,6 +8,7 @@ import {
8
newTaskDestination,
9
resolveDraftProjectSelection,
10
resolveEnvironmentProjectMatch,
11
+ resolveNewTaskScratchOption,
12
} from "./new-task-project-selection";
13
14
function makeProject(
@@ -250,3 +251,78 @@ describe("newTaskDestination", () => {
251
).toEqual(picker);
252
});
253
});
254
+
255
+describe("resolveNewTaskScratchOption", () => {
256
+ const environmentId = EnvironmentId.make("environment");
257
+ const otherId = EnvironmentId.make("other");
258
+ const configs = new Map([[environmentId, { scratchWorkspaceRoot: "/scratch" }]]);
259
+
260
+ it("offers the option from the cached config while the environment is still connecting", () => {
261
+ expect(
262
+ resolveNewTaskScratchOption({
263
+ environments: [{ environmentId, connectionState: "connecting" }],
264
+ serverConfigs: configs,
265
+ selectedEnvironmentId: null,
266
+ }),
267
+ ).toEqual({ environmentId, ready: false });
268
+ });
269
+
270
+ it("becomes ready without changing environment once connected", () => {
271
+ expect(
272
+ resolveNewTaskScratchOption({
273
+ environments: [{ environmentId, connectionState: "connected" }],
274
+ serverConfigs: configs,
275
+ selectedEnvironmentId: null,
276
+ }),
277
+ ).toEqual({ environmentId, ready: true });
278
+ });
279
+
280
+ it("hides the option when no environment reports a scratch root", () => {
281
+ expect(
282
+ resolveNewTaskScratchOption({
283
+ environments: [{ environmentId, connectionState: "connected" }],
284
+ serverConfigs: new Map([[environmentId, {}]]),
285
+ selectedEnvironmentId: null,
286
+ }),
287
+ ).toBeNull();
288
+ expect(
289
+ resolveNewTaskScratchOption({
290
+ environments: [{ environmentId, connectionState: "connected" }],
291
+ serverConfigs: new Map(),
292
+ selectedEnvironmentId: null,
293
+ }),
294
+ ).toBeNull();
295
+ });
296
+
297
+ it("prefers a connected environment over the selected one that is still reconnecting", () => {
298
+ expect(
299
+ resolveNewTaskScratchOption({
300
+ environments: [
301
+ { environmentId, connectionState: "reconnecting" },
302
+ { environmentId: otherId, connectionState: "connected" },
303
+ ],
304
+ serverConfigs: new Map([
305
+ [environmentId, { scratchWorkspaceRoot: "/scratch" }],
306
+ [otherId, { scratchWorkspaceRoot: "/other-scratch" }],
307
+ ]),
308
+ selectedEnvironmentId: environmentId,
309
+ }),
310
+ ).toEqual({ environmentId: otherId, ready: true });
311
+ });
312
+
313
+ it("keeps the selected environment when every offering environment is connected", () => {
314
+ expect(
315
+ resolveNewTaskScratchOption({
316
+ environments: [
317
+ { environmentId: otherId, connectionState: "connected" },
318
+ { environmentId, connectionState: "connected" },
319
+ ],
320
+ serverConfigs: new Map([
321
+ [environmentId, { scratchWorkspaceRoot: "/scratch" }],
322
+ [otherId, { scratchWorkspaceRoot: "/other-scratch" }],
323
+ ]),
324
+ selectedEnvironmentId: environmentId,
325
+ }),
326
+ ).toEqual({ environmentId, ready: true });
327
+ });
328
+});
apps/mobile/src/features/threads/new-task-project-selection.ts
+30
-1
@@ -1,5 +1,7 @@
1
+import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
2
+import { availableScratchWorkspaceRoot } from "@t3tools/client-runtime/operations/projects";
3
import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
2
-import { repositoryGroupingKeyOf, type EnvironmentId } from "@t3tools/contracts";
4
+import { repositoryGroupingKeyOf, type EnvironmentId, type ServerConfig } from "@t3tools/contracts";
5
6
import { scopedProjectKey } from "../../lib/scopedEntities";
7
import type { HomeProjectScope } from "../home/homeThreadList";
@@ -46,6 +48,33 @@ export function filterProjectScopes(
48
);
49
}
50
51
+// Cached configuration reserves the row; connection readiness only gates activation.
52
+export function resolveNewTaskScratchOption(input: {
53
+ readonly environments: ReadonlyArray<{
54
+ readonly environmentId: EnvironmentId;
55
+ readonly connectionState: EnvironmentConnectionPhase;
56
+ }>;
57
+ readonly serverConfigs: ReadonlyMap<EnvironmentId, Pick<ServerConfig, "scratchWorkspaceRoot">>;
58
+ readonly selectedEnvironmentId: EnvironmentId | null;
59
+}) {
60
+ const offering = input.environments.filter(
61
+ (environment) =>
62
+ (input.serverConfigs.get(environment.environmentId)?.scratchWorkspaceRoot ?? null) !== null,
63
+ );
64
+ const ready = offering.filter(
65
+ (environment) =>
66
+ availableScratchWorkspaceRoot(
67
+ environment.connectionState,
68
+ input.serverConfigs.get(environment.environmentId),
69
+ ) !== null,
70
+ );
71
+ const candidates = ready.length > 0 ? ready : offering;
72
+ const environment =
73
+ candidates.find((candidate) => candidate.environmentId === input.selectedEnvironmentId) ??
74
+ candidates[0];
75
+ return environment ? { environmentId: environment.environmentId, ready: ready.length > 0 } : null;
76
+}
77
+
78
export function resolveEnvironmentProjectMatch(
79
projectsOnTarget: ReadonlyArray<EnvironmentProject>,
80
selectedProject: EnvironmentProject | null,