Skip to content

Commit 542ce60

Browse files
t3dotggclaude
andcommitted
Show the quick new-thread button on multi-machine project groups
Instead of hiding the plus on aggregated groups, target the member that owns the group's newest thread — the machine the user last worked on. The draft's computer picker covers switching from there. Synthetic pending-project groups still hide the button (placeholder shells). Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 21eb3bd commit 542ce60

6 files changed

Lines changed: 97 additions & 13 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,8 @@ export function HomeScreen(props: HomeScreenProps) {
253253
// target project, and `pending-project:` groups hold a placeholder
254254
// built from queued-task metadata rather than a real project shell,
255255
// so the quick new-thread button is single-real-project only.
256-
onNewThread={
257-
item.group.projects.length === 1 && !item.group.key.startsWith("pending-project:")
258-
? props.onNewThreadInProject
259-
: undefined
260-
}
256+
newThreadTarget={item.group.newThreadTarget}
257+
onNewThread={props.onNewThreadInProject}
261258
project={item.group.representative}
262259
threadCount={item.group.threads.length + item.group.pendingTasks.length}
263260
title={item.group.title}

‎apps/mobile/src/features/home/homeListItems.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function makeGroup(key: string, threadCount: number): HomeThreadGroup {
7070
// All threads inside the recency window, so the baseline stays at the
7171
// initial page size and the pagination expectations below hold.
7272
recentThreads: threads,
73+
newThreadTarget: project,
7374
};
7475
}
7576

@@ -171,6 +172,7 @@ describe("buildHomeListLayout", () => {
171172
pendingTasks: [],
172173
threads,
173174
recentThreads: threads.slice(0, 3),
175+
newThreadTarget: project,
174176
};
175177

176178
const collapsedToRecent = buildHomeListLayout({

‎apps/mobile/src/features/home/homeThreadList.test.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,53 @@ describe("buildHomeThreadGroups", () => {
314314
group?.threads.map((thread) => thread.id),
315315
);
316316
});
317+
318+
it("targets quick new threads at the group member with the newest thread", () => {
319+
const laptopEnv = EnvironmentId.make("environment-laptop");
320+
const desktopEnv = EnvironmentId.make("environment-desktop");
321+
const repositoryIdentity = {
322+
canonicalKey: "github.com/pingdotgg/t3code",
323+
locator: {
324+
source: "git-remote" as const,
325+
remoteName: "origin",
326+
remoteUrl: "[email protected]:pingdotgg/t3code.git",
327+
},
328+
};
329+
const laptopProject = makeProject({
330+
environmentId: laptopEnv,
331+
id: ProjectId.make("project-laptop"),
332+
title: "t3code",
333+
repositoryIdentity,
334+
});
335+
const desktopProject = makeProject({
336+
environmentId: desktopEnv,
337+
id: ProjectId.make("project-desktop"),
338+
title: "t3code",
339+
repositoryIdentity,
340+
});
341+
const threads = [
342+
makeThread({
343+
environmentId: laptopEnv,
344+
id: ThreadId.make("thread-laptop"),
345+
projectId: laptopProject.id,
346+
title: "Older laptop thread",
347+
updatedAt: "2026-06-27T00:00:00.000Z",
348+
}),
349+
makeThread({
350+
environmentId: desktopEnv,
351+
id: ThreadId.make("thread-desktop"),
352+
projectId: desktopProject.id,
353+
title: "Newest desktop thread",
354+
updatedAt: "2026-06-28T00:00:00.000Z",
355+
}),
356+
];
357+
358+
// Aggregated into one group by repository; the quick new-thread target
359+
// must follow the newest thread (desktop), not the arbitrary first member.
360+
const groups = buildGroups([laptopProject, desktopProject], threads);
361+
expect(groups).toHaveLength(1);
362+
expect(groups[0]?.projects).toHaveLength(2);
363+
expect(groups[0]?.newThreadTarget?.environmentId).toBe(desktopEnv);
364+
expect(groups[0]?.newThreadTarget?.id).toBe(desktopProject.id);
365+
});
317366
});

‎apps/mobile/src/features/home/homeThreadList.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
SidebarThreadSortOrder,
1515
} from "@t3tools/contracts";
1616
import * as Arr from "effect/Array";
17+
import * as Option from "effect/Option";
1718
import * as Order from "effect/Order";
1819

1920
import { scopedProjectKey } from "../../lib/scopedEntities";
@@ -39,6 +40,15 @@ export interface HomeThreadGroup {
3940
readonly threads: ReadonlyArray<EnvironmentThreadShell>;
4041
/** Subset shown by default: threads from the last few days, or the most recent few. */
4142
readonly recentThreads: ReadonlyArray<EnvironmentThreadShell>;
43+
/**
44+
* Where a quick "new thread in this project" should land. For aggregated
45+
* groups (same repo on several machines) this is the member that owns the
46+
* group's most recent thread — the machine the user last worked on — rather
47+
* than the arbitrary first member; the draft's computer picker covers
48+
* switching from there. Null only for synthetic pending-project groups,
49+
* whose single "project" is a placeholder built from queued-task metadata.
50+
*/
51+
readonly newThreadTarget: EnvironmentProject | null;
4252
}
4353

4454
interface MutableHomeThreadGroup {
@@ -205,6 +215,24 @@ export function buildHomeThreadGroups(input: {
205215
? selectRecentThreads(sortedThreads, input.threadSortOrder, now)
206216
: sortedThreads;
207217

218+
// Sorted newest-first, so the first thread whose project is a group member
219+
// marks the machine the user last worked on.
220+
const lastActiveProject = Arr.findFirst(sortedThreads, (thread) =>
221+
group.projects.some(
222+
(project) =>
223+
project.environmentId === thread.environmentId && project.id === thread.projectId,
224+
),
225+
).pipe(
226+
Option.flatMap((thread) =>
227+
Arr.findFirst(
228+
group.projects,
229+
(project) =>
230+
project.environmentId === thread.environmentId && project.id === thread.projectId,
231+
),
232+
),
233+
Option.getOrNull,
234+
);
235+
208236
result.push({
209237
key: group.key,
210238
title,
@@ -213,6 +241,9 @@ export function buildHomeThreadGroups(input: {
213241
pendingTasks: matchingPendingTasks,
214242
threads: sortedThreads,
215243
recentThreads,
244+
newThreadTarget: group.key.startsWith("pending-project:")
245+
? null
246+
: (lastActiveProject ?? representative),
216247
});
217248
}
218249

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,8 @@ function ThreadNavigationSidebarPane(
420420
// Same gating as the compact Home list: aggregated groups have no
421421
// single target project, and pending-project groups hold a
422422
// placeholder shell rather than a real project.
423-
onNewThread={
424-
item.group.projects.length === 1 && !item.group.key.startsWith("pending-project:")
425-
? props.onNewThreadInProject
426-
: undefined
427-
}
423+
newThreadTarget={item.group.newThreadTarget}
424+
onNewThread={props.onNewThreadInProject}
428425
project={item.group.representative}
429426
threadCount={item.group.threads.length + item.group.pendingTasks.length}
430427
title={item.group.title}

‎apps/mobile/src/features/threads/thread-list-items.tsx‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,24 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
4343
readonly isFirst: boolean;
4444
readonly groupKey: string;
4545
readonly onGroupAction: (key: string, action: HomeGroupDisplayAction) => void;
46+
/** Project a quick new thread should target; null hides the button. */
47+
readonly newThreadTarget?: EnvironmentProject | null;
4648
readonly onNewThread?: (project: EnvironmentProject) => void;
4749
}) {
4850
const iconMutedColor = useThemeColor("--color-icon-muted");
49-
const { groupKey, onGroupAction, onNewThread, project } = props;
51+
const { groupKey, onGroupAction, onNewThread } = props;
52+
const newThreadTarget = props.newThreadTarget ?? null;
5053
const compact = props.variant === "compact";
5154
const handleToggle = useCallback(
5255
() => onGroupAction(groupKey, "toggle-collapsed"),
5356
[groupKey, onGroupAction],
5457
);
55-
const handleNewThread = useCallback(() => onNewThread?.(project), [onNewThread, project]);
58+
const handleNewThread = useCallback(() => {
59+
if (newThreadTarget) {
60+
onNewThread?.(newThreadTarget);
61+
}
62+
}, [newThreadTarget, onNewThread]);
63+
const showNewThreadButton = onNewThread !== undefined && newThreadTarget !== null;
5664

5765
// The new-thread button is a SIBLING of the collapse toggle, not a child:
5866
// nested touchables are unreachable to VoiceOver/TalkBack (the parent
@@ -111,7 +119,7 @@ export const ThreadListGroupHeader = memo(function ThreadListGroupHeader(props:
111119
{props.threadCount}
112120
</Text>
113121
</Pressable>
114-
{onNewThread ? (
122+
{showNewThreadButton ? (
115123
<Pressable
116124
accessibilityLabel={`Create new thread in ${props.title}`}
117125
accessibilityRole="button"

0 commit comments

Comments
 (0)