fix: hide subagent threads from v2 lists
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
f4264b19a0
commit
feec7b1aa9
5 files changed
+127
-6
No files matched your search
@@ -259,6 +259,68 @@ describe("sortThreadsForListV2", () => {
|
||||
});
|
||||
|
||||
describe("buildThreadListV2Items", () => {
|
||||
it("excludes subagent child threads from top-level rows and counts", () => {
|
||||
const rootThreadId = ThreadId.make("root");
|
||||
const activeChildId = ThreadId.make("active-child");
|
||||
const forkId = ThreadId.make("fork");
|
||||
const settledChildId = ThreadId.make("settled-child");
|
||||
const snoozedChildId = ThreadId.make("snoozed-child");
|
||||
const layout = buildThreadListV2Items({
|
||||
threads: [
|
||||
makeThread({ id: rootThreadId, title: "Root" }),
|
||||
makeThread({
|
||||
id: forkId,
|
||||
title: "Fork",
|
||||
lineage: {
|
||||
rootThreadId,
|
||||
parentThreadId: rootThreadId,
|
||||
relationshipToParent: "fork",
|
||||
},
|
||||
}),
|
||||
makeThread({
|
||||
id: activeChildId,
|
||||
title: "Active child",
|
||||
lineage: {
|
||||
rootThreadId,
|
||||
parentThreadId: rootThreadId,
|
||||
relationshipToParent: "subagent",
|
||||
},
|
||||
}),
|
||||
makeThread({
|
||||
id: settledChildId,
|
||||
title: "Settled child",
|
||||
lineage: {
|
||||
rootThreadId,
|
||||
parentThreadId: rootThreadId,
|
||||
relationshipToParent: "subagent",
|
||||
},
|
||||
settledOverride: "settled",
|
||||
settledAt: "2026-06-01T12:00:00.000Z",
|
||||
}),
|
||||
makeThread({
|
||||
id: snoozedChildId,
|
||||
title: "Snoozed child",
|
||||
lineage: {
|
||||
rootThreadId,
|
||||
parentThreadId: rootThreadId,
|
||||
relationshipToParent: "subagent",
|
||||
},
|
||||
snoozedUntil: "2026-06-03T09:00:00.000Z",
|
||||
snoozedAt: "2026-06-01T12:00:00.000Z",
|
||||
}),
|
||||
],
|
||||
environmentId: null,
|
||||
searchQuery: "",
|
||||
now: NOW,
|
||||
settledLimit: 0,
|
||||
});
|
||||
|
||||
expect(layout.items.map((item) => item.thread.id)).toEqual([forkId, rootThreadId]);
|
||||
expect(layout.hiddenSettledCount).toBe(0);
|
||||
expect(layout.snoozedCount).toBe(0);
|
||||
expect(layout.nextSnoozeWakeAt).toBeNull();
|
||||
});
|
||||
|
||||
it("hides snoozed threads and counts them — visibility parity with web", () => {
|
||||
const layout = buildThreadListV2Items({
|
||||
threads: [
|
||||
|
||||
@@ -359,6 +359,7 @@ export function buildThreadListV2Items(input: {
|
||||
const snoozed: EnvironmentThreadShell[] = [];
|
||||
let nextSnoozeWakeAt: string | null = null;
|
||||
for (const thread of input.threads) {
|
||||
if (thread.lineage.relationshipToParent === "subagent") continue;
|
||||
// Callers pass live (unarchived) shells; settled threads are among them
|
||||
// and partition into the tail via effectiveSettled.
|
||||
if (input.environmentId !== null && thread.environmentId !== input.environmentId) continue;
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
buildBulkTitleRegenerationContextMenuItem,
|
||||
buildMultiSelectThreadContextMenuItems,
|
||||
createThreadJumpHintVisibilityController,
|
||||
filterSidebarV2VisibleThreads,
|
||||
getSidebarThreadIdsToPrewarm,
|
||||
getVisibleSidebarThreadIds,
|
||||
resolveAdjacentThreadId,
|
||||
@@ -236,6 +237,55 @@ describe("resolveSidebarStageBadgeLabel", () => {
|
||||
});
|
||||
|
||||
describe("sidebar thread lineage helpers", () => {
|
||||
it("keeps only top-level, unarchived threads in the Sidebar V2 project scope", () => {
|
||||
const parentId = ThreadId.make("thread-parent");
|
||||
const projectId = ProjectId.make("project-visible");
|
||||
const environmentId = EnvironmentId.make("environment-visible");
|
||||
const root = makeThreadFixture({
|
||||
id: parentId,
|
||||
environmentId,
|
||||
projectId,
|
||||
});
|
||||
const subagent = makeThreadFixture({
|
||||
id: ThreadId.make("thread-subagent"),
|
||||
environmentId,
|
||||
projectId,
|
||||
lineage: {
|
||||
rootThreadId: parentId,
|
||||
parentThreadId: parentId,
|
||||
relationshipToParent: "subagent",
|
||||
},
|
||||
});
|
||||
const fork = makeThreadFixture({
|
||||
id: ThreadId.make("thread-fork"),
|
||||
environmentId,
|
||||
projectId,
|
||||
lineage: {
|
||||
rootThreadId: parentId,
|
||||
parentThreadId: parentId,
|
||||
relationshipToParent: "fork",
|
||||
},
|
||||
});
|
||||
const archived = makeThreadFixture({
|
||||
id: ThreadId.make("thread-archived"),
|
||||
environmentId,
|
||||
projectId,
|
||||
archivedAt: "2026-01-02T00:00:00.000Z",
|
||||
});
|
||||
const otherProject = makeThreadFixture({
|
||||
id: ThreadId.make("thread-other-project"),
|
||||
environmentId,
|
||||
projectId: ProjectId.make("project-other"),
|
||||
});
|
||||
|
||||
expect(
|
||||
filterSidebarV2VisibleThreads(
|
||||
[root, subagent, fork, archived, otherProject],
|
||||
new Set([`${environmentId}:${projectId}`]),
|
||||
).map((thread) => thread.id),
|
||||
).toEqual([parentId, fork.id]);
|
||||
});
|
||||
|
||||
it("identifies subagent threads so the sidebar can hide them", () => {
|
||||
const parentId = ThreadId.make("thread-parent");
|
||||
const subagent = makeThreadFixture({
|
||||
|
||||
@@ -54,6 +54,18 @@ export function isSidebarSubagentThread(thread: Pick<SidebarThreadSummary, "line
|
||||
return thread.lineage.relationshipToParent === "subagent";
|
||||
}
|
||||
|
||||
export function filterSidebarV2VisibleThreads<
|
||||
T extends Pick<SidebarThreadSummary, "archivedAt" | "environmentId" | "lineage" | "projectId">,
|
||||
>(threads: readonly T[], scopedProjectKeys: ReadonlySet<string> | null): T[] {
|
||||
return threads.filter(
|
||||
(thread) =>
|
||||
thread.archivedAt === null &&
|
||||
!isSidebarSubagentThread(thread) &&
|
||||
(scopedProjectKeys === null ||
|
||||
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
|
||||
);
|
||||
}
|
||||
|
||||
export function getSidebarForkParentThreadId(
|
||||
thread: Pick<SidebarThreadSummary, "forkedFrom" | "lineage">,
|
||||
) {
|
||||
|
||||
@@ -112,6 +112,7 @@ import { buildThreadActionMenuItems } from "./threadActionMenu.logic";
|
||||
import {
|
||||
buildBulkTitleRegenerationContextMenuItem,
|
||||
formatWorkingDurationLabel,
|
||||
filterSidebarV2VisibleThreads,
|
||||
firstValidTimestampMs,
|
||||
hasUnseenCompletion,
|
||||
isTrailingDoubleClick,
|
||||
@@ -1711,12 +1712,7 @@ export default function SidebarV2() {
|
||||
// memo exactly at the next wake boundary.
|
||||
void snoozeWakeTick;
|
||||
const preciseNow = new Date().toISOString();
|
||||
const visible = threads.filter(
|
||||
(thread) =>
|
||||
thread.archivedAt === null &&
|
||||
(scopedProjectKeys === null ||
|
||||
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
|
||||
);
|
||||
const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys);
|
||||
const pinned: EnvironmentThreadShell[] = [];
|
||||
const active: EnvironmentThreadShell[] = [];
|
||||
const snoozed: EnvironmentThreadShell[] = [];
|
||||
|
||||
Reference in new issue
Block a user