Skip to content

Commit 97a04be

Browse files
Yusuf007Rcodex
authored andcommitted
fix: hide subagent threads from v2 lists
Co-authored-by: codex <[email protected]>
1 parent 3b6251f commit 97a04be

5 files changed

Lines changed: 127 additions & 6 deletions

File tree

‎apps/mobile/src/features/threads/threadListV2.test.ts‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,68 @@ describe("sortThreadsForListV2", () => {
5959
});
6060

6161
describe("buildThreadListV2Items", () => {
62+
it("excludes subagent child threads from top-level rows and counts", () => {
63+
const rootThreadId = ThreadId.make("root");
64+
const activeChildId = ThreadId.make("active-child");
65+
const forkId = ThreadId.make("fork");
66+
const settledChildId = ThreadId.make("settled-child");
67+
const snoozedChildId = ThreadId.make("snoozed-child");
68+
const layout = buildThreadListV2Items({
69+
threads: [
70+
makeThread({ id: rootThreadId, title: "Root" }),
71+
makeThread({
72+
id: forkId,
73+
title: "Fork",
74+
lineage: {
75+
rootThreadId,
76+
parentThreadId: rootThreadId,
77+
relationshipToParent: "fork",
78+
},
79+
}),
80+
makeThread({
81+
id: activeChildId,
82+
title: "Active child",
83+
lineage: {
84+
rootThreadId,
85+
parentThreadId: rootThreadId,
86+
relationshipToParent: "subagent",
87+
},
88+
}),
89+
makeThread({
90+
id: settledChildId,
91+
title: "Settled child",
92+
lineage: {
93+
rootThreadId,
94+
parentThreadId: rootThreadId,
95+
relationshipToParent: "subagent",
96+
},
97+
settledOverride: "settled",
98+
settledAt: "2026-06-01T12:00:00.000Z",
99+
}),
100+
makeThread({
101+
id: snoozedChildId,
102+
title: "Snoozed child",
103+
lineage: {
104+
rootThreadId,
105+
parentThreadId: rootThreadId,
106+
relationshipToParent: "subagent",
107+
},
108+
snoozedUntil: "2026-06-03T09:00:00.000Z",
109+
snoozedAt: "2026-06-01T12:00:00.000Z",
110+
}),
111+
],
112+
environmentId: null,
113+
searchQuery: "",
114+
now: NOW,
115+
settledLimit: 0,
116+
});
117+
118+
expect(layout.items.map((item) => item.thread.id)).toEqual([forkId, rootThreadId]);
119+
expect(layout.hiddenSettledCount).toBe(0);
120+
expect(layout.snoozedCount).toBe(0);
121+
expect(layout.nextSnoozeWakeAt).toBeNull();
122+
});
123+
62124
it("hides snoozed threads and counts them — visibility parity with web", () => {
63125
const layout = buildThreadListV2Items({
64126
threads: [

‎apps/mobile/src/features/threads/threadListV2.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export function buildThreadListV2Items(input: {
143143
let snoozedCount = 0;
144144
let nextSnoozeWakeAt: string | null = null;
145145
for (const thread of input.threads) {
146+
if (thread.lineage.relationshipToParent === "subagent") continue;
146147
// Callers pass live (unarchived) shells; settled threads are among them
147148
// and partition into the tail via effectiveSettled.
148149
if (input.environmentId !== null && thread.environmentId !== input.environmentId) continue;

‎apps/web/src/components/Sidebar.logic.test.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
archiveSelectedThreadEntries,
44
buildMultiSelectThreadContextMenuItems,
55
createThreadJumpHintVisibilityController,
6+
filterSidebarV2VisibleThreads,
67
getSidebarThreadIdsToPrewarm,
78
getVisibleSidebarThreadIds,
89
resolveAdjacentThreadId,
@@ -198,6 +199,55 @@ describe("resolveSidebarStageBadgeLabel", () => {
198199
});
199200

200201
describe("sidebar thread lineage helpers", () => {
202+
it("keeps only top-level, unarchived threads in the Sidebar V2 project scope", () => {
203+
const parentId = ThreadId.make("thread-parent");
204+
const projectId = ProjectId.make("project-visible");
205+
const environmentId = EnvironmentId.make("environment-visible");
206+
const root = makeThreadFixture({
207+
id: parentId,
208+
environmentId,
209+
projectId,
210+
});
211+
const subagent = makeThreadFixture({
212+
id: ThreadId.make("thread-subagent"),
213+
environmentId,
214+
projectId,
215+
lineage: {
216+
rootThreadId: parentId,
217+
parentThreadId: parentId,
218+
relationshipToParent: "subagent",
219+
},
220+
});
221+
const fork = makeThreadFixture({
222+
id: ThreadId.make("thread-fork"),
223+
environmentId,
224+
projectId,
225+
lineage: {
226+
rootThreadId: parentId,
227+
parentThreadId: parentId,
228+
relationshipToParent: "fork",
229+
},
230+
});
231+
const archived = makeThreadFixture({
232+
id: ThreadId.make("thread-archived"),
233+
environmentId,
234+
projectId,
235+
archivedAt: "2026-01-02T00:00:00.000Z",
236+
});
237+
const otherProject = makeThreadFixture({
238+
id: ThreadId.make("thread-other-project"),
239+
environmentId,
240+
projectId: ProjectId.make("project-other"),
241+
});
242+
243+
expect(
244+
filterSidebarV2VisibleThreads(
245+
[root, subagent, fork, archived, otherProject],
246+
new Set([`${environmentId}:${projectId}`]),
247+
).map((thread) => thread.id),
248+
).toEqual([parentId, fork.id]);
249+
});
250+
201251
it("identifies subagent threads so the sidebar can hide them", () => {
202252
const parentId = ThreadId.make("thread-parent");
203253
const subagent = makeThreadFixture({

‎apps/web/src/components/Sidebar.logic.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ export function isSidebarSubagentThread(thread: Pick<SidebarThreadSummary, "line
9696
return thread.lineage.relationshipToParent === "subagent";
9797
}
9898

99+
export function filterSidebarV2VisibleThreads<
100+
T extends Pick<SidebarThreadSummary, "archivedAt" | "environmentId" | "lineage" | "projectId">,
101+
>(threads: readonly T[], scopedProjectKeys: ReadonlySet<string> | null): T[] {
102+
return threads.filter(
103+
(thread) =>
104+
thread.archivedAt === null &&
105+
!isSidebarSubagentThread(thread) &&
106+
(scopedProjectKeys === null ||
107+
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
108+
);
109+
}
110+
99111
export function getSidebarForkParentThreadId(
100112
thread: Pick<SidebarThreadSummary, "forkedFrom" | "lineage">,
101113
) {

‎apps/web/src/components/SidebarV2.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import type { SidebarThreadSummary } from "../types";
102102
import { cn } from "~/lib/utils";
103103
import {
104104
formatWorkingDurationLabel,
105+
filterSidebarV2VisibleThreads,
105106
firstValidTimestampMs,
106107
hasUnseenCompletion,
107108
isTrailingDoubleClick,
@@ -1366,12 +1367,7 @@ export default function SidebarV2() {
13661367
// memo exactly at the next wake boundary.
13671368
void snoozeWakeTick;
13681369
const preciseNow = new Date().toISOString();
1369-
const visible = threads.filter(
1370-
(thread) =>
1371-
thread.archivedAt === null &&
1372-
(scopedProjectKeys === null ||
1373-
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
1374-
);
1370+
const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys);
13751371
const active: EnvironmentThreadShell[] = [];
13761372
const snoozed: EnvironmentThreadShell[] = [];
13771373
const settled: EnvironmentThreadShell[] = [];

0 commit comments

Comments
 (0)