|
3 | 3 | archiveSelectedThreadEntries, |
4 | 4 | buildMultiSelectThreadContextMenuItems, |
5 | 5 | createThreadJumpHintVisibilityController, |
| 6 | + filterSidebarV2VisibleThreads, |
6 | 7 | getSidebarThreadIdsToPrewarm, |
7 | 8 | getVisibleSidebarThreadIds, |
8 | 9 | resolveAdjacentThreadId, |
@@ -198,6 +199,55 @@ describe("resolveSidebarStageBadgeLabel", () => { |
198 | 199 | }); |
199 | 200 |
|
200 | 201 | 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 | + |
201 | 251 | it("identifies subagent threads so the sidebar can hide them", () => { |
202 | 252 | const parentId = ThreadId.make("thread-parent"); |
203 | 253 | const subagent = makeThreadFixture({ |
|
0 commit comments