@devries-cameron20 / t3code-1 / commits / 00c636e4b0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(mobile): picking a project on two machines starts on the connected one (#25839)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 27, 2026 at 03:27 UTC 00c636e4b02a84c18fe7fcb1b709847e9cbb7541
4 files changed +39 -2
apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
+6
@@ -188,6 +188,11 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
188 ) ?? null)
189 : null;
190 const { connectedEnvironments } = useRemoteConnectionStatus();
191 + const connectedEnvironmentIds = new Set(
192 + connectedEnvironments
193 + .filter((environment) => environment.connectionState === "connected")
194 + .map((environment) => environment.environmentId),
195 + );
196 const openScratch = useAtomCommand(projectEnvironment.openScratch, {
197 reportFailure: false,
198 });
@@ -461,6 +466,7 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
466 const selectionTarget = getProjectScopeSelectionTarget(
467 scope,
468 selectedEnvironmentId,
469 + connectedEnvironmentIds,
470 );
471 if (Platform.OS === "android") {
472 return (
apps/mobile/src/features/threads/new-task-project-selection.test.ts
+21
@@ -4,6 +4,7 @@ import { describe, expect, it } from "vite-plus/test";
4 import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
5 import type { HomeProjectScope } from "../home/homeThreadList";
6 import {
7 + getProjectScopeSelectionTarget,
8 newTaskDestination,
9 resolveDraftProjectSelection,
10 resolveEnvironmentProjectMatch,
@@ -53,6 +54,26 @@ function makeScope(projects: ReadonlyArray<EnvironmentProject>): HomeProjectScop
54 };
55 }
56
57 +describe("getProjectScopeSelectionTarget", () => {
58 + it("prefers a connected copy of a project that spans environments", () => {
59 + const mac = makeProject("t3code", "mac");
60 + const server = makeProject("t3code", "server");
61 + const target = (connected: ReadonlyArray<string>, preferred: string | null = null) =>
62 + getProjectScopeSelectionTarget(
63 + makeScope([mac, server]),
64 + preferred === null ? null : EnvironmentId.make(preferred),
65 + new Set(connected.map((id) => EnvironmentId.make(id))),
66 + );
67 + expect(target(["server"])).toBe(server);
68 + expect(target(["server"], "mac")).toBe(server);
69 + expect(target(["mac", "server"], "server")).toBe(server);
70 + expect(target(["mac", "server"])).toBe(mac);
71 + // With nothing connected, the usual order still applies.
72 + expect(target([], "server")).toBe(server);
73 + expect(target([])).toBe(mac);
74 + });
75 +});
76 +
77 describe("resolveEnvironmentProjectMatch", () => {
78 it("follows the same repository onto the target machine", () => {
79 const selected = makeProject("t3code", "mac", { repositoryKey: "github.com/t3tools/t3code" });
apps/mobile/src/features/threads/new-task-project-selection.ts
+10 -1
@@ -10,12 +10,21 @@ type DraftProjectSelectionResolution =
10 | { readonly kind: "pick" }
11 | { readonly kind: "dismiss" };
12
13 +/**
14 + * The copy of a project a new thread starts in: the preferred environment's, then the
15 + * representative. A connected copy wins over a disconnected one.
16 + */
17 export function getProjectScopeSelectionTarget(
18 scope: HomeProjectScope,
19 preferredEnvironmentId: EnvironmentId | null,
20 + connectedEnvironmentIds: ReadonlySet<EnvironmentId>,
21 ): EnvironmentProject {
22 + const rank = (project: EnvironmentProject) =>
23 + project.environmentId === preferredEnvironmentId ? 0 : project === scope.representative ? 1 : 2;
24 + const ordered = [...scope.projects].sort((left, right) => rank(left) - rank(right));
25 return (
18 - scope.projects.find((project) => project.environmentId === preferredEnvironmentId) ??
26 + ordered.find((project) => connectedEnvironmentIds.has(project.environmentId)) ??
27 + ordered[0] ??
28 scope.representative
29 );
30 }
docs/user/thread-sidebar.md
+2 -1
@@ -13,7 +13,8 @@ an existing worktree, use **New thread in this worktree** from the branch toolba
13 On mobile, **New thread** starts in the current thread's project, or else in the
14 last project you opened or chose on that device. If neither is available, the
15 project picker opens. Turn off **Settings → General → Use last project** to
16 -choose a project every time.
16 +choose a project every time. When you pick a project that is on more than one
17 +machine, the thread starts on a connected one if any is connected.
18
19 When you change a new thread's project, T3 Code stays in the current environment
20 if that project exists there. Otherwise it selects an environment that has it.