@devries-cameron20 / t3code-1 / commits / c5dfb8ffa3
Fork 0

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

fix(mobile): new thread starts in the thread list's filtered project (#36234)

Julius Marminge committed Nov 13, 2026 at 09:36 UTC c5dfb8ffa395b720c3d140330e231eb2057d6f36
8 files changed +157 -50
apps/mobile/src/features/home/HomeRouteScreen.tsx
+14 -27
@@ -9,10 +9,7 @@ import { useMemo, useState } from "react";
9 import { Platform } from "react-native";
10
11 import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
12 -import {
13 - pickableProjectGroups,
14 - resolveScratchProjectScopeKey,
15 -} from "@t3tools/client-runtime/state/project-grouping";
12 +import { pickableProjectGroups } from "@t3tools/client-runtime/state/project-grouping";
13
14 import { useProjects } from "../../state/entities";
15 import { steadyNavigationThreadShellsAtom } from "../../state/threads";
@@ -31,7 +28,7 @@ import {
28 useAtomValueWhileVisible,
29 useHomeRouteVisible,
30 } from "./home-route-visibility";
34 -import { buildHomeProjectScopes } from "./homeThreadList";
31 +import { buildHomeProjectScopes, resolveHomeProjectFilterScope } from "./homeThreadList";
32 import { usePendingTaskListActions } from "./usePendingTaskListActions";
33 import { useThreadListActions } from "./useThreadListActions";
34 import { useWorkspaceTabs } from "../layout/workspace/WorkspaceTabsContext";
@@ -130,35 +127,25 @@ export function HomeRouteScreen() {
127 setSelectedProjectKey,
128 } = useHomeListOptions(availableEnvironmentIds);
129 const selectedEnvironmentId = listOptions.selectedEnvironmentId;
133 - // A legacy per-environment scratch key resolves here on every render; the stored
134 - // value is only rewritten when the user picks a filter.
135 - const resolvedProjectKey = resolveScratchProjectScopeKey(
136 - listOptions.selectedProjectKey,
137 - projects,
138 - {
139 - sidebarProjectGroupingMode: listOptions.projectGroupingMode,
140 - sidebarProjectGroupingOverrides: {},
141 - },
130 + const projectScopes = useMemo(
131 + () =>
132 + buildHomeProjectScopes({
133 + projects,
134 + environmentId: selectedEnvironmentId,
135 + projectGroupingMode: listOptions.projectGroupingMode,
136 + }),
137 + [listOptions.projectGroupingMode, projects, selectedEnvironmentId],
138 );
139 const projectFilterOptions = useMemo(
140 () =>
145 - pickableProjectGroups(
146 - buildHomeProjectScopes({
147 - projects,
148 - environmentId: selectedEnvironmentId,
149 - projectGroupingMode: listOptions.projectGroupingMode,
150 - }),
151 - ).map((scope) => ({
141 + pickableProjectGroups(projectScopes).map((scope) => ({
142 key: scope.key,
143 label: scope.title,
144 })),
155 - [listOptions.projectGroupingMode, projects, selectedEnvironmentId],
145 + [projectScopes],
146 );
157 - const selectedProjectKey = projectFilterOptions.some(
158 - (project) => project.key === resolvedProjectKey,
159 - )
160 - ? resolvedProjectKey
161 - : null;
147 + const selectedProjectKey =
148 + resolveHomeProjectFilterScope(projectScopes, projects, listOptions)?.key ?? null;
149
150 if (layout.usesSplitView && !nativePrimaryColumn) {
151 return (
apps/mobile/src/features/home/homeThreadList.ts
+23 -1
@@ -1,4 +1,8 @@
1 -import { buildProjectGroups } from "@t3tools/client-runtime/state/project-grouping";
1 +import {
2 + buildProjectGroups,
3 + pickableProjectGroups,
4 + resolveScratchProjectScopeKey,
5 +} from "@t3tools/client-runtime/state/project-grouping";
6 import type {
7 EnvironmentProject,
8 EnvironmentThreadShell,
@@ -70,6 +74,24 @@ export function buildHomeProjectScopes(input: {
74 });
75 }
76
77 +/** The scope the thread list's project filter shows; an archived or unknown key shows all projects. */
78 +export function resolveHomeProjectFilterScope(
79 + scopes: ReadonlyArray<HomeProjectScope>,
80 + projects: ReadonlyArray<EnvironmentProject>,
81 + options: {
82 + readonly selectedProjectKey: string | null;
83 + readonly projectGroupingMode: SidebarProjectGroupingMode;
84 + },
85 +): HomeProjectScope | null {
86 + // A legacy per-environment scratch key resolves here; the stored value is only
87 + // rewritten when the user picks a filter.
88 + const key = resolveScratchProjectScopeKey(options.selectedProjectKey, projects, {
89 + sidebarProjectGroupingMode: options.projectGroupingMode,
90 + sidebarProjectGroupingOverrides: {},
91 + });
92 + return pickableProjectGroups(scopes).find((scope) => scope.key === key) ?? null;
93 +}
94 +
95 export function findHomeProjectScope(
96 scopes: ReadonlyArray<HomeProjectScope>,
97 key: string | null,
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+30 -1
@@ -59,6 +59,8 @@ import { useProjects } from "../../state/entities";
59 import { environmentThreadShells } from "../../state/threads";
60 import { withKnownPullRequestSummary } from "../../state/use-thread-pr";
61 import { mobilePreferencesAtom } from "../../state/preferences";
62 +import { savedConnectionsByIdAtom } from "../../state/use-remote-environment-registry";
63 +import { workspaceConnections } from "../../state/workspace";
64 import {
65 DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS,
66 resolveMobileProjectGroupingSettings,
@@ -83,7 +85,8 @@ import {
85 import { startOpeningDetail } from "./workspace/useSelectWorkspaceDetail";
86 import { useWorkspaceTabs } from "./workspace/WorkspaceTabsContext";
87 import { HomeListOptionsProvider } from "../home/home-list-options";
86 -import { newTaskDestination } from "../threads/new-task-project-selection";
88 +import { buildHomeProjectScopes, resolveHomeProjectFilterScope } from "../home/homeThreadList";
89 +import { newTaskDestination, newTaskFilteredProject } from "../threads/new-task-project-selection";
90 import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
91 import { PaneContext } from "../../components/ui/Pane";
92 import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
@@ -606,12 +609,38 @@ function AdaptiveWorkspaceLayoutContent(
609 : undefined;
610 const preferences = appAtomRegistry.get(mobilePreferencesAtom);
611 const saved = AsyncResult.isSuccess(preferences) ? preferences.value : undefined;
612 + // Resolve the thread list's filter as useHomeListOptions does: a removed connection's filter reads as all.
613 + const listFilters = saved?.threadListFilters;
614 + const listEnvironmentId =
615 + listFilters?.environmentId != null &&
616 + appAtomRegistry.get(savedConnectionsByIdAtom)[listFilters.environmentId] !== undefined
617 + ? listFilters.environmentId
618 + : null;
619 + const filteredScope = resolveHomeProjectFilterScope(
620 + buildHomeProjectScopes({ projects, environmentId: listEnvironmentId, projectGroupingMode }),
621 + projects,
622 + { selectedProjectKey: listFilters?.projectKey ?? null, projectGroupingMode },
623 + );
624 + const connectedEnvironmentIds = new Set(
625 + appAtomRegistry
626 + .get(workspaceConnections.environmentsAtom)
627 + .filter((environment) => environment.connectionState === "connected")
628 + .map((environment) => environment.environmentId),
629 + );
630 handleSelectThreadRoute(
631 newTaskDestination({
632 projects,
633 requestId: uuidv4(),
634 useLastProject: saved?.useLastProjectForNewThreads,
635 currentProject: environmentId && projectId ? { environmentId, projectId } : undefined,
636 + filteredProject: filteredScope
637 + ? newTaskFilteredProject(
638 + filteredScope,
639 + listEnvironmentId,
640 + connectedEnvironmentIds,
641 + saved?.lastThreadProject,
642 + )
643 + : undefined,
644 lastProject: saved?.lastThreadProject,
645 }),
646 );
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+3 -14
@@ -1,10 +1,7 @@
1 import { useActiveNewTask } from "../../state/active-new-task";
2 import { ThreadUndoNotice } from "../home/ThreadUndoNotice";
3 import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
4 -import {
5 - pickableProjectGroups,
6 - resolveScratchProjectScopeKey,
7 -} from "@t3tools/client-runtime/state/project-grouping";
4 +import { pickableProjectGroups } from "@t3tools/client-runtime/state/project-grouping";
5 import {
6 useAppearancePreferences,
7 useAndroidFloatingTabs,
@@ -48,7 +45,7 @@ import { requestThreadMessageJump } from "./threadMessageJump";
45 import { useThreadListSearchMatches } from "./useThreadListSearchMatches";
46 import { useHomeListOptions } from "../home/home-list-options";
47 import { buildHomeListFilterMenuItems } from "../home/home-list-filter-menu";
51 -import { buildHomeProjectScopes } from "../home/homeThreadList";
48 +import { buildHomeProjectScopes, resolveHomeProjectFilterScope } from "../home/homeThreadList";
49 import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
50 import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
51 import { useThreadListActions } from "../home/useThreadListActions";
@@ -172,12 +169,6 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
169 )
170 ? [options.selectedEnvironmentId]
171 : [];
175 - // A legacy per-environment scratch key resolves here on every render; the stored
176 - // value is only rewritten when the user picks a filter.
177 - const resolvedProjectKey = resolveScratchProjectScopeKey(options.selectedProjectKey, projects, {
178 - sidebarProjectGroupingMode: options.projectGroupingMode,
179 - sidebarProjectGroupingOverrides: {},
180 - });
172 const projectScopes = useMemo(
173 () =>
174 buildHomeProjectScopes({
@@ -206,9 +197,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
197 ),
198 [projectScopes],
199 );
209 - // An archived project's filter reads as all projects, matching the filter menu.
210 - const selectedProjectScope =
211 - pickableProjectGroups(projectScopes).find((scope) => scope.key === resolvedProjectKey) ?? null;
200 + const selectedProjectScope = resolveHomeProjectFilterScope(projectScopes, projects, options);
201 const threadSearch = useThreadSearch(
202 searchEnvironmentIds,
203 props.searchQuery,
apps/mobile/src/features/threads/new-task-project-selection.test.ts
+54 -1
@@ -6,6 +6,7 @@ import type { HomeProjectScope } from "../home/homeThreadList";
6 import {
7 getProjectScopeSelectionTarget,
8 newTaskDestination,
9 + newTaskFilteredProject,
10 resolveDraftProjectSelection,
11 resolveEnvironmentProjectMatch,
12 resolveNewTaskScratchOption,
@@ -77,6 +78,37 @@ describe("getProjectScopeSelectionTarget", () => {
78 });
79 });
80
81 +describe("newTaskFilteredProject", () => {
82 + it("never starts in an archived copy of the filtered project", () => {
83 + const mac = { ...makeProject("t3code", "mac"), archivedAt: "2026-01-01T00:00:00.000Z" };
84 + const server = makeProject("t3code", "server");
85 + expect(
86 + newTaskFilteredProject(
87 + makeScope([mac, server]),
88 + null,
89 + new Set([mac.environmentId, server.environmentId]),
90 + { environmentId: "mac", projectId: "t3code" },
91 + ),
92 + ).toEqual({ environmentId: "server", projectId: "t3code" });
93 + });
94 +
95 + it("prefers the remembered copy of the filtered project", () => {
96 + const mac = makeProject("t3code", "mac");
97 + const server = makeProject("t3code", "server");
98 + const connected = new Set([mac.environmentId, server.environmentId]);
99 + const filtered = (last?: { readonly environmentId: string; readonly projectId: string }) =>
100 + newTaskFilteredProject(makeScope([mac, server]), null, connected, last);
101 + expect(filtered({ environmentId: "server", projectId: "t3code" })).toEqual({
102 + environmentId: "server",
103 + projectId: "t3code",
104 + });
105 + expect(filtered({ environmentId: "server", projectId: "other" })).toEqual({
106 + environmentId: "mac",
107 + projectId: "t3code",
108 + });
109 + });
110 +});
111 +
112 describe("resolveEnvironmentProjectMatch", () => {
113 it("follows the same repository onto the target machine", () => {
114 const selected = makeProject("t3code", "mac", { repositoryKey: "github.com/t3tools/t3code" });
@@ -173,6 +205,7 @@ describe("newTaskDestination", () => {
205 readonly useLastProject: boolean | undefined;
206 readonly projects: ReadonlyArray<EnvironmentProject>;
207 readonly current?: EnvironmentProject;
208 + readonly filtered?: EnvironmentProject;
209 readonly last?: { readonly environmentId: string; readonly projectId: string };
210 }) {
211 return newTaskDestination({
@@ -183,17 +216,22 @@ describe("newTaskDestination", () => {
216 environmentId: options.current.environmentId,
217 projectId: options.current.id,
218 },
219 + filteredProject: options.filtered && {
220 + environmentId: options.filtered.environmentId,
221 + projectId: options.filtered.id,
222 + },
223 lastProject: options.last,
224 });
225 }
226
190 - it("starts in the current thread's project ahead of the remembered one", () => {
227 + it("starts in the current thread's project ahead of the filtered and remembered ones", () => {
228 const projects = [makeProject("remembered"), makeProject("current", "other-environment")];
229 expect(
230 destination({
231 useLastProject: true,
232 projects,
233 current: projects[1],
234 + filtered: projects[0],
235 last: { environmentId: "environment", projectId: "remembered" },
236 }),
237 ).toEqual({
@@ -201,6 +239,20 @@ describe("newTaskDestination", () => {
239 });
240 });
241
242 + it("starts in the thread list's filtered project ahead of the remembered one", () => {
243 + const projects = [makeProject("bravo"), makeProject("alpha")];
244 + expect(
245 + destination({
246 + useLastProject: true,
247 + projects,
248 + filtered: projects[1],
249 + last: { environmentId: "environment", projectId: "bravo" },
250 + }),
251 + ).toEqual({
252 + draft: { requestId: "request", environmentId: "environment", projectId: "alpha" },
253 + });
254 + });
255 +
256 it("opens the picker for an archived last project, but keeps an archived current one", () => {
257 const archived = { ...makeProject("archived"), archivedAt: "2026-01-01T00:00:00.000Z" };
258 expect(
@@ -262,6 +314,7 @@ describe("newTaskDestination", () => {
314 useLastProject: false,
315 projects: [only],
316 current: only,
317 + filtered: only,
318 last: { environmentId: "environment", projectId: "only" },
319 }),
320 ).toEqual(picker);
apps/mobile/src/features/threads/new-task-project-selection.ts
+27 -1
@@ -147,11 +147,35 @@ export function resolveDraftProjectSelection(
147
148 type ProjectRef = { readonly environmentId: string; readonly projectId: string };
149
150 +/** The live copy of the thread list's filtered project a new thread starts in: the remembered one if it is a copy. */
151 +export function newTaskFilteredProject(
152 + scope: HomeProjectScope,
153 + preferredEnvironmentId: EnvironmentId | null,
154 + connectedEnvironmentIds: ReadonlySet<EnvironmentId>,
155 + lastProject: ProjectRef | undefined,
156 +): ProjectRef | undefined {
157 + const live = scope.projects.filter((project) => project.archivedAt == null);
158 + if (live.length === 0) return undefined;
159 + const project =
160 + live.find(
161 + (candidate) =>
162 + candidate.environmentId === lastProject?.environmentId &&
163 + candidate.id === lastProject.projectId,
164 + ) ??
165 + getProjectScopeSelectionTarget(
166 + { ...scope, projects: live },
167 + preferredEnvironmentId,
168 + connectedEnvironmentIds,
169 + );
170 + return { environmentId: project.environmentId, projectId: project.id };
171 +}
172 +
173 export function newTaskDestination(options: {
174 readonly projects: ReadonlyArray<EnvironmentProject>;
175 readonly requestId: string;
176 readonly useLastProject: boolean | undefined;
177 readonly currentProject: ProjectRef | undefined;
178 + readonly filteredProject: ProjectRef | undefined;
179 readonly lastProject: ProjectRef | undefined;
180 }) {
181 const find = (ref: ProjectRef | undefined) =>
@@ -164,7 +188,9 @@ export function newTaskDestination(options: {
188 const project =
189 options.useLastProject === false
190 ? undefined
167 - : (find(options.currentProject) ?? (last?.archivedAt == null ? last : undefined));
191 + : (find(options.currentProject) ??
192 + find(options.filteredProject) ??
193 + (last?.archivedAt == null ? last : undefined));
194 return project
195 ? {
196 draft: {
apps/mobile/src/state/use-remote-environment-registry.ts
+1 -1
@@ -100,7 +100,7 @@ const EMPTY_RUNTIME_STATE_ATOM = Atom.make<EnvironmentRuntimeState | null>(null)
100 Atom.withLabel("mobile:environment-runtime-state:empty"),
101 );
102
103 -const savedConnectionsByIdAtom = Atom.make((get) => {
103 +export const savedConnectionsByIdAtom = Atom.make((get) => {
104 const catalog = get(environmentCatalog.catalogValueAtom);
105 return Object.fromEntries(
106 [...catalog.entries.keys()].flatMap((environmentId) => {
docs/user/thread-sidebar.md
+5 -4
@@ -13,10 +13,11 @@ Its branch and workspace mode come from your configured defaults. To continue in
13 an existing worktree, use **New thread in this worktree** from the branch toolbar.
14
15 On mobile, **New thread** starts in the current thread's project, or else in the
16 -last project you opened or chose on that device. If neither is available, the
17 -project picker opens. Turn off **Settings → General → Use last project** to
18 -choose a project every time. When you pick a project that is on more than one
19 -machine, the thread starts on a connected one if any is connected.
16 +project the thread list is filtered to, or else in the last project you opened
17 +or chose on that device. If none is available, the project picker opens. Turn
18 +off **Settings → General → Use last project** to choose a project every time.
19 +When you pick a project that is on more than one machine, the thread starts on
20 +a connected one if any is connected.
21
22 When you change a new thread's project, T3 Code stays in the current environment
23 if that project exists there. Otherwise it selects an environment that has it.