Skip to content

Commit df60348

Browse files
committed
fix(web): hide native subagent threads in the legacy sidebar
1 parent 79ad856 commit df60348

2 files changed

Lines changed: 54 additions & 52 deletions

File tree

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ import {
188188
archiveSelectedThreadEntries,
189189
buildMultiSelectThreadContextMenuItems,
190190
deleteSelectedThreadEntries,
191+
filterSidebarV2VisibleThreads,
191192
getSidebarThreadIdsToPrewarm,
192193
resolveAdjacentThreadId,
193194
isContextMenuPointerDown,
@@ -1344,7 +1345,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
13441345
});
13451346
};
13461347
const visibleProjectThreads = sortThreads(
1347-
projectThreads.filter((thread) => thread.archivedAt === null),
1348+
filterSidebarV2VisibleThreads(projectThreads, null),
13481349
threadSortOrder,
13491350
);
13501351
const projectStatus = resolveProjectStatusIndicator(
@@ -3459,7 +3460,7 @@ export default function LegacySidebar() {
34593460
}, []);
34603461

34613462
const visibleThreads = useMemo(
3462-
() => sidebarThreads.filter((thread) => thread.archivedAt === null),
3463+
() => filterSidebarV2VisibleThreads(sidebarThreads, null),
34633464
[sidebarThreads],
34643465
);
34653466
const sortedProjects = useMemo(() => {
@@ -3498,9 +3499,7 @@ export default function LegacySidebar() {
34983499
() =>
34993500
sortedProjects.flatMap((project) => {
35003501
const projectThreads = sortThreads(
3501-
(threadsByProjectKey.get(project.projectKey) ?? []).filter(
3502-
(thread) => thread.archivedAt === null,
3503-
),
3502+
filterSidebarV2VisibleThreads(threadsByProjectKey.get(project.projectKey) ?? [], null),
35043503
sidebarThreadSortOrder,
35053504
);
35063505
const projectExpanded = resolveProjectExpanded(

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

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -398,54 +398,57 @@ describe("resolveSidebarStageBadgeLabel", () => {
398398
});
399399

400400
describe("sidebar thread lineage helpers", () => {
401-
it("keeps only top-level, unarchived threads in the Sidebar V2 project scope", () => {
402-
const parentId = ThreadId.make("thread-parent");
403-
const projectId = ProjectId.make("project-visible");
404-
const environmentId = EnvironmentId.make("environment-visible");
405-
const root = makeThreadFixture({
406-
id: parentId,
407-
environmentId,
408-
projectId,
409-
});
410-
const subagent = makeThreadFixture({
411-
id: ThreadId.make("thread-subagent"),
412-
environmentId,
413-
projectId,
414-
lineage: {
415-
rootThreadId: parentId,
416-
parentThreadId: parentId,
417-
relationshipToParent: "subagent",
418-
},
419-
});
420-
const fork = makeThreadFixture({
421-
id: ThreadId.make("thread-fork"),
422-
environmentId,
423-
projectId,
424-
lineage: {
425-
rootThreadId: parentId,
426-
parentThreadId: parentId,
427-
relationshipToParent: "fork",
428-
},
429-
});
430-
const archived = makeThreadFixture({
431-
id: ThreadId.make("thread-archived"),
432-
environmentId,
433-
projectId,
434-
archivedAt: "2026-01-02T00:00:00.000Z",
435-
});
436-
const otherProject = makeThreadFixture({
437-
id: ThreadId.make("thread-other-project"),
438-
environmentId,
439-
projectId: ProjectId.make("project-other"),
440-
});
401+
it.each([false, true])(
402+
"excludes archived threads and subagents while keeping roots and forks (project-scoped: %s)",
403+
(projectScoped) => {
404+
const parentId = ThreadId.make("thread-parent");
405+
const projectId = ProjectId.make("project-visible");
406+
const environmentId = EnvironmentId.make("environment-visible");
407+
const root = makeThreadFixture({
408+
id: parentId,
409+
environmentId,
410+
projectId,
411+
});
412+
const subagent = makeThreadFixture({
413+
id: ThreadId.make("thread-subagent"),
414+
environmentId,
415+
projectId,
416+
lineage: {
417+
rootThreadId: parentId,
418+
parentThreadId: parentId,
419+
relationshipToParent: "subagent",
420+
},
421+
});
422+
const fork = makeThreadFixture({
423+
id: ThreadId.make("thread-fork"),
424+
environmentId,
425+
projectId,
426+
lineage: {
427+
rootThreadId: parentId,
428+
parentThreadId: parentId,
429+
relationshipToParent: "fork",
430+
},
431+
});
432+
const archived = makeThreadFixture({
433+
id: ThreadId.make("thread-archived"),
434+
environmentId,
435+
projectId,
436+
archivedAt: "2026-01-02T00:00:00.000Z",
437+
});
438+
const otherProject = makeThreadFixture({
439+
id: ThreadId.make("thread-other-project"),
440+
environmentId,
441+
projectId: ProjectId.make("project-other"),
442+
});
441443

442-
expect(
443-
filterSidebarV2VisibleThreads(
444-
[root, subagent, fork, archived, otherProject],
445-
new Set([`${environmentId}:${projectId}`]),
446-
).map((thread) => thread.id),
447-
).toEqual([parentId, fork.id]);
448-
});
444+
expect(
445+
filterSidebarV2VisibleThreads(
446+
[root, subagent, fork, archived, otherProject],
447+
projectScoped ? new Set([`${environmentId}:${projectId}`]) : null,
448+
).map((thread) => thread.id),
449+
).toEqual(projectScoped ? [parentId, fork.id] : [parentId, fork.id, otherProject.id]);
450+
},
451+
);
449452

450453
it("identifies subagent threads so the sidebar can hide them", () => {
451454
const parentId = ThreadId.make("thread-parent");

0 commit comments

Comments
 (0)