Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadRelationshipsControl.browser.test.tsx

727 lines24.1 KB

1import "~/index.css";
2import * as DateTime from "effect/DateTime";
3import {
4 EnvironmentId,
5 NodeId,
6 ProviderDriverKind,
7 ProviderInstanceId,
8 ThreadId,
9 type OrchestrationV2ThreadProjection,
10 type ServerProvider,
11} from "@t3tools/contracts";
12import * as Cause from "effect/Cause";
13import { AsyncResult } from "effect/reactivity";
14import { expect, it, vi } from "vite-plus/test";
15import { page, userEvent } from "vite-plus/test/browser";
16​
17import "~/index.css";
18​
19const state = vi.hoisted(() => ({
20 projection: null as unknown,
21 commandSucceeds: false,
22 relatedShells: [] as unknown[],
23 providers: new Map<EnvironmentId, ReadonlyArray<ServerProvider>>(),
24 threadTitles: {} as Record<string, string>,
25 archivedThreads: [] as unknown[],
26}));
27​
28vi.mock(import("../../state/query"), async (original) => ({
29 ...(await original()),
30 useEnvironmentQuery: ((atom: unknown) =>
31 atom === null
32 ? { data: null, isSuccess: false, isPending: false }
33 : { data: state.threadTitles, isSuccess: true, isPending: false }) as never,
34}));
35​
36vi.mock(import("@effect/atom-react"), async (original) => ({
37 ...(await original()),
38 useAtomValue: (() => false) as never,
39}));
40​
41vi.mock(import("../../state/entities"), () => ({
42 useQuietThreadShell: (() => null) as never,
43 useQuietThreadProjection: ((ref: unknown) =>
44 ref === null ? null : { projection: state.projection }) as never,
45 useThreadRelationshipShells: (() =>
46 state.projection === null
47 ? []
48 : [(state.projection as { thread: unknown }).thread, ...state.relatedShells]) as never,
49 useProjects: (() => []) as never,
50 useHiddenThreadKeys: (() => new Set()) as never,
51 useAnyEnvironmentHiding: (() => false) as never,
52}));
53vi.mock(import("../../state/environments"), () => ({
54 // The click rule reads the client setting, whose module asks for these.
55 useEnvironments: (() => []) as never,
56 usePrimaryEnvironment: (() => null) as never,
57 useEnvironment: (() => null) as never,
58 useEnvironmentProviders: () => state.providers,
59}));
60vi.mock(import("../../state/peerLinks"), () => ({
61 peerLinkEnvironment: { readThread: {} } as never,
62 useLinkedEnvironments: (() => new Map()) as never,
63}));
64vi.mock(import("../../lib/archivedThreadsState"), () => ({
65 useArchivedThreadSnapshots: (() => ({
66 snapshots: [{ environmentId: "environment", snapshot: { threads: state.archivedThreads } }],
67 })) as never,
68}));
69vi.mock(import("../../state/use-atom-command"), () => ({
70 useAtomCommand: (() => async () =>
71 state.commandSucceeds
72 ? AsyncResult.success(undefined)
73 : AsyncResult.failure(Cause.fail(new Error("Connection lost")))) as never,
74}));
75​
76import { scopeThreadRef } from "@t3tools/client-runtime/environment";
77​
78import { act, fakeTimers, render } from "../../../test/render";
79import { isMacPlatform } from "../../lib/utils";
80import { selectThreadRightPanelState, useRightPanelStore } from "../../rightPanelStore";
81import { makeThreadProjectionFixture } from "../../test-fixtures";
82import { ScrollArea } from "../ui/scroll-area";
83import { ToastProvider } from "../ui/toast";
84import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl";
85​
86const environmentId = EnvironmentId.make("environment");
87const threadId = ThreadId.make("fork");
88​
89function setup() {
90 useRightPanelStore.setState(useRightPanelStore.getInitialState());
91 state.commandSucceeds = false;
92 state.relatedShells = [];
93 state.providers = new Map();
94 state.threadTitles = { source: "Source" };
95 state.archivedThreads = [];
96 state.projection = {
97 thread: {
98 id: threadId,
99 title: "Fork",
100 activeProviderThreadId: null,
101 lineage: { parentThreadId: ThreadId.make("source"), relationshipToParent: "fork" },
102 forkedFrom: null,
103 },
104 runs: [{ id: "run", ordinal: 1, status: "completed" }],
105 subagents: [],
106 contextTransfers: [],
107 providerThreads: [],
108 providerSessions: [{ id: "session", status: "ready" }],
109 };
111​
112it.each([
113 ["merge", "Could not merge back"],
114 ["disconnect", "Could not disconnect agent session"],
115])("reports a rejected %s command and clears the busy state", async (action, title) => {
116 setup();
117 await using screen = await render(
118 <ToastProvider timeout={0}>
119 <ThreadRelationshipsPanel
120 environmentId={environmentId}
121 threadId={threadId}
122 showLineage
123 showSideChats
124 />
125 </ToastProvider>,
126 );
127​
128 if (action === "merge") {
129 await screen.getByRole("button", { name: "Merge back to source conversation" }).click();
130 } else {
131 await screen.getByRole("button", { name: "More thread actions" }).click();
132 await page.getByRole("menuitem", { name: "Disconnect agent session" }).click();
133 }
134​
135 await expect.element(page.getByText(title, { exact: true })).toBeVisible();
136 await expect
137 .element(
138 screen.getByRole("button", {
139 name: action === "merge" ? "Merge back to source conversation" : "More thread actions",
140 }),
141 )
142 .toBeEnabled();
143});
144​
145it.each([
146 ["merge", "Could not merge back"],
147 ["disconnect", "Could not disconnect agent session"],
148])("clears the previous %s error after a successful retry", async (action, title) => {
149 setup();
150 await using screen = await render(
151 <ToastProvider timeout={0}>
152 <ThreadRelationshipsPanel
153 environmentId={environmentId}
154 threadId={threadId}
155 showLineage
156 showSideChats
157 />
158 </ToastProvider>,
159 { router: "/environment/fork" },
160 );
161​
162 const runAction = async () => {
163 if (action === "merge") {
164 await screen.getByRole("button", { name: "Merge back to source conversation" }).click();
165 } else {
166 await screen.getByRole("button", { name: "More thread actions" }).click();
167 await page.getByRole("menuitem", { name: "Disconnect agent session" }).click();
168 }
169 };
170​
171 await runAction();
172 await expect.element(page.getByText(title, { exact: true })).toBeVisible();
173 expect(screen.router?.state.location.pathname).toBe("/environment/fork");
174​
175 state.commandSucceeds = true;
176 await runAction();
177​
178 await expect.element(page.getByText(title, { exact: true })).not.toBeInTheDocument();
179 await vi.waitFor(() => {
180 expect(screen.router?.state.location.pathname).toBe(
181 action === "merge" ? "/environment/source" : "/environment/fork",
182 );
183 });
184 if (action === "disconnect") {
185 await expect.element(screen.getByRole("button", { name: "More thread actions" })).toBeEnabled();
186 }
187});
188​
189it("opens an idle child beside the thread, and in its place with the modifier", async () => {
190 setup();
191 const projection = makeThreadProjectionFixture();
192 const childId = ThreadId.make("omitted-child");
193 const environmentId = EnvironmentId.make("local");
194 state.projection = {
195 ...projection,
196 subagents: [
197 {
198 id: NodeId.make("agent"),
199 threadId: projection.thread.id,
200 runId: null,
201 parentNodeId: NodeId.make("parent"),
202 origin: "app_owned",
203 createdBy: "agent",
204 driver: "codex",
205 providerInstanceId: projection.thread.providerInstanceId,
206 providerThreadId: null,
207 childThreadId: childId,
208 nativeTaskRef: null,
209 prompt: "Inspect the change",
210 title: "Idle child",
211 model: null,
212 status: "completed",
213 result: null,
214 startedAt: null,
215 completedAt: projection.thread.updatedAt,
216 updatedAt: projection.thread.updatedAt,
217 },
218 ],
219 };
220 await using screen = await render(
221 <ThreadRelationshipsPanel
222 environmentId={environmentId}
223 threadId={projection.thread.id}
224 showLineage
225 showSideChats
226 />,
227 );
228 await screen.getByRole("button", { name: /Previous agents/ }).click();
229 const child = screen.getByRole("button", { name: /Idle child/ });
230 await expect.element(child).toBeEnabled();
231 const panelRef = scopeThreadRef(environmentId, projection.thread.id);
232 const panel = () =>
233 selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, panelRef);
234 await child.click();
235 expect(panel()).toMatchObject({
236 isOpen: true,
237 activeSurfaceId: "thread:omitted-child",
238 surfaces: [{ kind: "thread", threadId: childId }],
239 });
240 expect(screen.router?.state.location.pathname).toBe("/");
241 // Idle children can be omitted from the shell; the route loads the child's own detail.
242 await child.click({ modifiers: [isMacPlatform(navigator.platform) ? "Meta" : "Control"] });
243 await vi.waitFor(() =>
244 expect(screen.router?.state.location.pathname).toBe("/local/omitted-child"),
245 );
246 expect(panel().surfaces).toHaveLength(1);
247});
248​
249it("keeps focus on the list when Show more pages reveal the last rows", async () => {
250 setup();
251 const projection = makeThreadProjectionFixture();
252 const environmentId = EnvironmentId.make("local");
253 const { updatedAt } = projection.thread;
254 state.projection = {
255 ...projection,
256 subagents: Array.from({ length: 7 }, (_, index) => ({
257 id: NodeId.make(`agent-${index}`),
258 threadId: projection.thread.id,
259 runId: null,
260 parentNodeId: NodeId.make("parent"),
261 origin: "app_owned",
262 createdBy: "agent",
263 driver: "codex",
264 providerInstanceId: projection.thread.providerInstanceId,
265 providerThreadId: null,
266 childThreadId: ThreadId.make(`omitted-child-${index}`),
267 nativeTaskRef: null,
268 prompt: `Inspect the change part ${index}`,
269 title: `Agent ${index}`,
270 model: null,
271 status: "completed",
272 result: null,
273 startedAt: null,
274 completedAt: updatedAt,
275 updatedAt,
276 })),
277 };
278 await using screen = await render(
279 <ThreadRelationshipsPanel
280 environmentId={environmentId}
281 threadId={projection.thread.id}
282 showLineage
283 showSideChats
284 />,
285 );
286 await screen.getByRole("button", { name: /Previous agents/ }).click();
287 await screen.getByRole("button", { name: "Show 1 more" }).click();
288 await expect.element(screen.getByRole("list", { name: "Related threads" })).toHaveFocus();
289});
290​
291it("shows a lineage thread's full title in its tooltip", async () => {
292 setup();
293 const longTitle = "Compare the lineage tooltip against a title that the row truncates";
294 const sourceThread = {
295 ...(state.projection as { thread: Record<string, unknown> }).thread,
296 id: "source",
297 title: longTitle,
298 lineage: { parentThreadId: null, relationshipToParent: null },
299 };
300 state.relatedShells = [sourceThread];
301 await using _screen = await render(
302 <ThreadRelationshipsPanel
303 environmentId={environmentId}
304 threadId={threadId}
305 showLineage
306 showSideChats={false}
307 />,
308 );
309​
310 await userEvent.hover(page.getByText(longTitle, { exact: true }));
311 await vi.waitFor(() =>
312 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(longTitle),
313 );
314});
315​
316it("updates the lineage hover card when a delegated child changes Fast mode", async () => {
317 setup();
318 const projection = makeThreadProjectionFixture();
319 const childId = ThreadId.make("opus-child");
320 const instanceId = ProviderInstanceId.make("claudeAgent");
321 const model = "claude-opus-5-5";
322 const title = "Opus child";
323 const selection = (fastMode: boolean) => ({
324 instanceId,
325 model,
326 options: [{ id: "fastMode", value: fastMode }],
327 });
328 const provider: ServerProvider = {
329 instanceId,
330 driver: ProviderDriverKind.make("claudeAgent"),
331 enabled: true,
332 installed: true,
333 version: null,
334 status: "ready",
335 auth: { status: "authenticated" },
336 checkedAt: DateTime.formatIso(projection.thread.updatedAt),
337 models: [
338 {
339 slug: model,
340 name: "Opus 5.5",
341 isCustom: false,
342 capabilities: {
343 optionDescriptors: [{ id: "fastMode", label: "Fast", type: "boolean" }],
344 },
345 },
346 ],
347 slashCommands: [],
348 skills: [],
349 };
350 state.providers.set(environmentId, [provider]);
351 state.projection = {
352 ...projection,
353 subagents: [
354 {
355 id: NodeId.make("agent"),
356 threadId: projection.thread.id,
357 runId: null,
358 parentNodeId: NodeId.make("parent"),
359 childThreadId: childId,
360 providerThreadId: null,
361 nativeTaskRef: null,
362 prompt: "Inspect the change",
363 title,
364 origin: "app_owned",
365 createdBy: "agent",
366 status: "running",
367 driver: provider.driver,
368 providerInstanceId: instanceId,
369 model,
370 modelSelection: selection(false),
371 result: null,
372 startedAt: projection.thread.updatedAt,
373 completedAt: null,
374 updatedAt: projection.thread.updatedAt,
375 },
376 ],
377 } satisfies OrchestrationV2ThreadProjection;
378 const childShell = (fastMode: boolean) => ({
379 ...projection.thread,
380 id: childId,
381 title,
382 providerInstanceId: instanceId,
383 modelSelection: selection(fastMode),
384 lineage: { parentThreadId: projection.thread.id, relationshipToParent: "subagent" },
385 });
386 const panel = () => (
387 <ThreadRelationshipsPanel
388 environmentId={environmentId}
389 threadId={projection.thread.id}
390 showLineage
391 showSideChats={false}
392 />
393 );
394​
395 state.relatedShells = [childShell(true)];
396 await using screen = await render(panel());
397 await userEvent.hover(screen.getByText(title, { exact: true }));
398 const popup = page.getByText("Opus 5.5", { exact: true });
399 const fast = page.getByText("Fast mode on", { exact: true });
400 await expect.element(fast).toBeInTheDocument();
401​
402 state.relatedShells = [childShell(false)];
403 await screen.rerender(panel());
404 await expect.element(popup).toBeVisible();
405 await expect.element(fast).not.toBeInTheDocument();
406});
407​
408it("shows a side chat's full title in its tooltip", async () => {
409 setup();
410 const longTitle = "Side chat question with a title that the side chat row truncates";
411 state.relatedShells = [
412 {
413 id: "side",
414 title: longTitle,
415 lineage: {
416 parentThreadId: threadId,
417 relationshipToParent: "fork",
418 rootThreadId: threadId,
419 sideChat: true,
420 },
421 },
422 ];
423 await using _screen = await render(
424 <ThreadRelationshipsPanel
425 environmentId={environmentId}
426 threadId={threadId}
427 showLineage={false}
428 showSideChats
429 />,
430 );
431​
432 await userEvent.hover(page.getByText(longTitle, { exact: true }));
433 await vi.waitFor(() =>
434 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(longTitle),
435 );
436});
437​
438it("shows a remote subagent's full title in its tooltip even when its environment is unavailable", async () => {
439 setup();
440 const longTitle = "Investigate a remote subagent issue across linked environments";
441 const remoteEnvId = EnvironmentId.make("remote-env");
442 const remoteThreadId = ThreadId.make("remote-thread");
443 const now = DateTime.makeUnsafe("2026-10-31T20:00:00.000Z");
444 state.projection = {
445 ...(state.projection as Record<string, unknown>),
446 subagents: [
447 {
448 id: NodeId.make("remote-agent"),
449 threadId,
450 runId: null,
451 parentNodeId: NodeId.make("parent"),
452 origin: "app_owned",
453 createdBy: "agent",
454 driver: "codex",
455 providerInstanceId: "provider",
456 providerThreadId: null,
457 childThreadId: null,
458 nativeTaskRef: null,
459 prompt: "Run remote task",
460 title: longTitle,
461 model: null,
462 status: "completed",
463 result: null,
464 startedAt: null,
465 completedAt: null,
466 updatedAt: now,
467 remoteChild: {
468 environmentId: remoteEnvId,
469 threadId: remoteThreadId,
470 label: "Remote VM with a long machine name in the office",
471 },
472 },
473 ],
474 };
475 await using screen = await render(
476 <div style={{ width: 320 }}>
477 <ThreadRelationshipsPanel
478 environmentId={environmentId}
479 threadId={threadId}
480 showLineage
481 showSideChats={false}
482 />
483 </div>,
484 { router: "/environment/fork" },
485 );
486​
487 // A finished remote task sits with the other finished agents, not in its own list.
488 await expect
489 .element(screen.getByRole("button", { name: new RegExp(longTitle) }))
490 .not.toBeInTheDocument();
491 await screen.getByRole("button", { name: /Previous agents/ }).click();
492 const row = screen.getByRole("button", { name: new RegExp(longTitle) });
493 // A long environment label must not squeeze the title out of the row.
494 expect(
495 page.getByText(longTitle, { exact: true }).element().getBoundingClientRect().width,
496 ).toBeGreaterThan(0);
497 await userEvent.hover(row);
498 await vi.waitFor(() =>
499 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(longTitle),
500 );
501 // This client is not connected there, so the row reads the thread through this environment.
502 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(
503 "Read the thread on Remote VM with a long machine name in the office",
504 );
505​
506 await row.click({ force: true });
507 expect(screen.router?.state.location.pathname).toBe("/environment/fork");
508});
509​
510it("shows how long a running remote subagent has been running, as a local one does", async () => {
511 setup();
512 const remoteTitle = "Remote subagent running on a linked machine";
513 using _timers = fakeTimers();
514 vi.setSystemTime(new Date("2026-11-23T12:12:00.000Z"));
515 const startedAt = DateTime.makeUnsafe("2026-11-23T12:00:00.000Z");
516 state.projection = {
517 ...(state.projection as Record<string, unknown>),
518 subagents: [
519 {
520 id: NodeId.make("remote-agent"),
521 threadId,
522 runId: null,
523 parentNodeId: NodeId.make("parent"),
524 origin: "app_owned",
525 createdBy: "agent",
526 driver: "remote",
527 providerInstanceId: "provider",
528 providerThreadId: null,
529 childThreadId: null,
530 nativeTaskRef: null,
531 prompt: "Run remote task",
532 title: remoteTitle,
533 model: null,
534 status: "running",
535 result: null,
536 startedAt,
537 completedAt: null,
538 updatedAt: startedAt,
539 remoteChild: {
540 environmentId: EnvironmentId.make("remote-env"),
541 threadId: ThreadId.make("remote-thread"),
542 label: "127x05",
543 },
544 },
545 ],
546 };
547 await using screen = await render(
548 <ThreadRelationshipsPanel
549 environmentId={environmentId}
550 threadId={threadId}
551 showLineage
552 showSideChats={false}
553 />,
554 { router: "/environment/fork" },
555 );
556​
557 // Assert synchronously: expect.element polls on timers this test fakes.
558 const row = screen.getByRole("button", { name: new RegExp(remoteTitle) });
559 expect(row.element().textContent).toContain("12m");
560});
561​
562it("explains why Merge back is unavailable before the fork completes a run", async () => {
563 setup();
564 state.projection = { ...(state.projection as Record<string, unknown>), runs: [] };
565 await using screen = await render(
566 <ThreadRelationshipsPanel
567 environmentId={environmentId}
568 threadId={threadId}
569 showLineage
570 showSideChats={false}
571 />,
572 { router: "/environment/fork" },
573 );
574​
575 const mergeBack = screen.getByRole("button", { name: "Merge back to source conversation" });
576 await userEvent.hover(mergeBack);
577 await vi.waitFor(() =>
578 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toBe(
579 "Complete a run in this fork before merging it back",
580 ),
581 );
582​
583 state.commandSucceeds = true;
584 await mergeBack.click({ force: true });
585 expect(screen.router?.state.location.pathname).toBe("/environment/fork");
586});
587​
588it("shows a delegated-from thread's full title in its tooltip even when its environment is unavailable", async () => {
589 setup();
590 const longTitle = "Parent task delegated from another machine that has a long description";
591 state.projection = {
592 ...(state.projection as Record<string, unknown>),
593 thread: {
594 ...(state.projection as { thread: Record<string, unknown> }).thread,
595 delegatedFrom: {
596 environmentId: EnvironmentId.make("parent-env"),
597 threadId: ThreadId.make("parent-thread"),
598 title: longTitle,
599 },
600 },
601 };
602 await using screen = await render(
603 <ThreadRelationshipsPanel
604 environmentId={environmentId}
605 threadId={threadId}
606 showLineage
607 showSideChats={false}
608 />,
609 { router: "/environment/fork" },
610 );
611​
612 const row = screen.getByRole("button", { name: new RegExp(longTitle) });
613 await userEvent.hover(row);
614 await vi.waitFor(() =>
615 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(longTitle),
616 );
617 expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(
618 "Delegated from a linked environment. Connect to it to open the parent thread.",
619 );
620​
621 await row.click({ force: true });
622 expect(screen.router?.state.location.pathname).toBe("/environment/fork");
623});
624​
625it("hides a deleted fork and keeps unloaded and archived forks with their current titles", async () => {
626 setup();
627 const projection = makeThreadProjectionFixture();
628 state.threadTitles = { "unloaded-fork": "Unloaded fork", "archived-fork": "Archived fork" };
629 state.archivedThreads = [
630 {
631 ...projection.thread,
632 id: ThreadId.make("archived-fork"),
633 title: "Old archived title",
634 archivedAt: projection.thread.updatedAt,
635 lineage: { parentThreadId: projection.thread.id, relationshipToParent: "fork" },
636 },
637 ];
638 state.projection = {
639 ...projection,
640 contextTransfers: ["deleted-fork", "unloaded-fork", "archived-fork"].map((id) => ({
641 sourceThreadId: projection.thread.id,
642 targetThreadId: ThreadId.make(id),
643 status: "pending",
644 })),
645 };
646 await using screen = await render(
647 <ThreadRelationshipsPanel
648 environmentId={environmentId}
649 threadId={projection.thread.id}
650 showLineage
651 showSideChats
652 />,
653 );
654 await expect.element(screen.getByText("Unloaded fork", { exact: true })).toBeVisible();
655 await expect.element(screen.getByText("Archived fork", { exact: true })).toBeVisible();
656 await expect.element(screen.getByText("deleted-fork", { exact: true })).not.toBeInTheDocument();
657});
658​
659it("shares the hover delay between adjacent lineage rows", async () => {
660 setup();
661 state.relatedShells = [
662 { id: "source", title: "First agent", lineage: { parentThreadId: null } },
663 {
664 id: "child",
665 title: "Second agent",
666 lineage: { parentThreadId: threadId, relationshipToParent: "fork", sideChat: false },
667 },
668 ];
669 await using screen = await render(
670 <ThreadRelationshipsPanel
671 environmentId={environmentId}
672 threadId={threadId}
673 showLineage
674 showSideChats={false}
675 />,
676 );
677 using _timers = fakeTimers();
678 const first = screen.getByRole("button", { name: /^First agent/ });
679 const second = screen.getByRole("button", { name: /^Second agent/ });
680 await userEvent.hover(first);
681 await act(() => vi.advanceTimersByTime(200));
682 expect(first.element()).toHaveAttribute("data-popup-open");
683 await userEvent.hover(second);
684 await act(() => vi.advanceTimersByTime(1));
685 expect(second.element()).toHaveAttribute("data-popup-open");
686});
687​
688it.each([1, 18])("continues scrolling the panel past a list of %i subagents", async (count) => {
689 setup();
690 const projection = makeThreadProjectionFixture();
691 state.projection = projection;
692 state.relatedShells = Array.from({ length: count }, (_, index) => ({
693 id: ThreadId.make(`subagent-${index}`),
694 title: `Subagent ${index}`,
695 forkedFrom: null,
696 lineage: { parentThreadId: projection.thread.id, relationshipToParent: "subagent" },
697 activityRunStatus: "running",
698 status: "running",
699 }));
700 await using screen = await render(
701 <div data-testid="panel" style={{ height: 320, width: 280 }}>
702 <ScrollArea>
703 <ThreadRelationshipsPanel
704 environmentId={environmentId}
705 threadId={projection.thread.id}
706 showLineage
707 showSideChats
708 />
709 <div style={{ height: 600 }} />
710 </ScrollArea>
711 </div>,
712 );
713 if (count > 6) {
714 await screen.getByRole("button", { name: "Show 12 more" }).click();
715 await expect.element(screen.getByText("Subagent 17", { exact: true })).toBeInTheDocument();
716 }
717 const list = screen.getByRole("list", { name: "Related threads" }).element();
718 const viewport = screen
719 .getByTestId("panel")
720 .element()
721 .querySelector<HTMLElement>("[data-slot=scroll-area-viewport]")!;
722 list.scrollTop = list.scrollHeight;
723 if (count > 6) expect(list.scrollTop).toBeGreaterThan(0);
724 viewport.scrollTop = 0;
725 await userEvent.wheel(list, { delta: { y: 300 } });
726 await vi.waitFor(() => expect(viewport.scrollTop).toBeGreaterThan(0));
727});