@@ -12,140 +12,6 @@ import { waitForFast } from "../wait-for.ts";
1212import "../../components/app-sidebar.ts" ;
1313
1414describe ( "AppSidebar agent chip" , ( ) => {
15- it ( "caps visible children until requested and resets the cap after collapse" , async ( ) => {
16- const gateway = createGateway ( { } as GatewayBrowserClient ) ;
17- const childKeys = Array . from (
18- { length : 6 } ,
19- ( _ , index ) => `agent:main:subagent:child-${ index + 1 } ` ,
20- ) ;
21- const harness = createSessionsHarness ( "main" , [ "agent:main:parent" ] ) ;
22- harness . list . mockResolvedValue ( {
23- ts : 100_000 ,
24- path : "" ,
25- count : childKeys . length ,
26- defaults : { modelProvider : null , model : null , contextTokens : null } ,
27- sessions : childKeys . map ( ( key , index ) => ( {
28- key,
29- spawnedBy : "agent:main:parent" ,
30- kind : "direct" as const ,
31- label : `Subagent: Child ${ index + 1 } ` ,
32- updatedAt : index + 1 ,
33- } ) ) ,
34- } ) ;
35- const { sidebar } = await mountSidebar ( gateway , harness . sessions ) ;
36- harness . publishList ( {
37- result : {
38- ts : 2 ,
39- path : "" ,
40- count : 1 ,
41- defaults : { modelProvider : null , model : null , contextTokens : null } ,
42- sessions : [
43- {
44- key : "agent:main:parent" ,
45- kind : "direct" ,
46- label : "Parent task" ,
47- updatedAt : 1 ,
48- childSessions : childKeys ,
49- } ,
50- ] ,
51- } ,
52- } ) ;
53- await sidebar . updateComplete ;
54-
55- const toggle = sidebar . querySelector < HTMLButtonElement > ( "[data-child-session-toggle]" ) ;
56- toggle ?. click ( ) ;
57- await waitForFast ( ( ) =>
58- expect ( sidebar . querySelectorAll ( ".sidebar-recent-session--child" ) ) . toHaveLength ( 4 ) ,
59- ) ;
60- const showMore = sidebar . querySelector < HTMLButtonElement > ( "[data-show-more-children]" ) ;
61- expect ( showMore ?. textContent ?. trim ( ) ) . toBe ( "Show 2 more" ) ;
62- expect ( showMore ?. getAttribute ( "aria-label" ) ) . toBe ( "Show 2 more" ) ;
63- expect ( sidebar . textContent ) . not . toContain ( "Subagent:" ) ;
64-
65- showMore ?. click ( ) ;
66- await waitForFast ( ( ) =>
67- expect ( sidebar . querySelectorAll ( ".sidebar-recent-session--child" ) ) . toHaveLength ( 6 ) ,
68- ) ;
69- expect ( sidebar . querySelector ( "[data-show-more-children]" ) ) . toBeNull ( ) ;
70-
71- toggle ?. click ( ) ;
72- await sidebar . updateComplete ;
73- toggle ?. click ( ) ;
74- await waitForFast ( ( ) =>
75- expect ( sidebar . querySelectorAll ( ".sidebar-recent-session--child" ) ) . toHaveLength ( 4 ) ,
76- ) ;
77- expect ( sidebar . querySelector ( "[data-show-more-children]" ) ?. textContent ) . toContain (
78- "Show 2 more" ,
79- ) ;
80- } ) ;
81-
82- it ( "keeps live children visible past the cap" , async ( ) => {
83- const gateway = createGateway ( { } as GatewayBrowserClient ) ;
84- const childKeys = Array . from (
85- { length : 6 } ,
86- ( _ , index ) => `agent:main:subagent:child-${ index + 1 } ` ,
87- ) ;
88- const harness = createSessionsHarness ( "main" , [ "agent:main:parent" ] ) ;
89- harness . list . mockResolvedValue ( {
90- ts : 100_000 ,
91- path : "" ,
92- count : childKeys . length ,
93- defaults : { modelProvider : null , model : null , contextTokens : null } ,
94- sessions : [
95- ...childKeys . map ( ( key , index ) => ( {
96- key,
97- spawnedBy : "agent:main:parent" ,
98- kind : "direct" as const ,
99- label : `Subagent: Child ${ index + 1 } ` ,
100- updatedAt : index + 1 ,
101- } ) ) ,
102- // Quiet child beyond the cap with a RUNNING grandchild: the branch
103- // must bypass the cap via the transitive runningChildCount.
104- {
105- key : "agent:main:subagent:grandchild" ,
106- spawnedBy : "agent:main:subagent:child-6" ,
107- kind : "direct" as const ,
108- label : "Subagent: Grandchild run" ,
109- updatedAt : 10 ,
110- status : "running" as const ,
111- hasActiveRun : true ,
112- } ,
113- ] ,
114- } ) ;
115- const { sidebar } = await mountSidebar ( gateway , harness . sessions ) ;
116- harness . publishList ( {
117- result : {
118- ts : 2 ,
119- path : "" ,
120- count : 1 ,
121- defaults : { modelProvider : null , model : null , contextTokens : null } ,
122- sessions : [
123- {
124- key : "agent:main:parent" ,
125- kind : "direct" ,
126- label : "Parent task" ,
127- updatedAt : 1 ,
128- childSessions : childKeys ,
129- } ,
130- ] ,
131- } ,
132- } ) ;
133- await sidebar . updateComplete ;
134-
135- sidebar
136- . querySelector < HTMLButtonElement > ( '[data-child-session-toggle="agent:main:parent"]' )
137- ?. click ( ) ;
138- await waitForFast ( ( ) =>
139- expect (
140- sidebar . querySelector ( '[data-session-key="agent:main:subagent:child-6"]' ) ,
141- ) . not . toBeNull ( ) ,
142- ) ;
143- expect ( sidebar . querySelector ( '[data-session-key="agent:main:subagent:child-5"]' ) ) . toBeNull ( ) ;
144- expect ( sidebar . querySelector ( "[data-show-more-children]" ) ?. textContent ?. trim ( ) ) . toBe (
145- "Show 1 more" ,
146- ) ;
147- } ) ;
148-
14915 it ( "loads and expands child sessions inline without root session controls" , async ( ) => {
15016 const gateway = createGateway ( { } as GatewayBrowserClient ) ;
15117 const harness = createSessionsHarness ( "main" , [ "agent:main:parent" ] ) ;
0 commit comments