@@ -65,6 +65,53 @@ describe('MessageContent shared thinking indicator', () => {
6565 const thinking = ( ) => container . querySelectorAll ( '[aria-hidden="false"] svg' )
6666 const groups = ( ) => container . querySelectorAll ( '[data-agent-group]' )
6767
68+ it . each ( [ undefined , 'main' ] ) (
69+ 'shows thinking after main tools finish and yields to the next tool (spanId=%s)' ,
70+ ( spanId ) => {
71+ const mainCall = ( id : string , status : ToolCallStatus ) : ContentBlock => ( {
72+ type : 'tool_call' ,
73+ spanId,
74+ toolCall : {
75+ id,
76+ name : 'sim_cli' ,
77+ status,
78+ displayTitle : 'List tables in Alfred' ,
79+ params : {
80+ args : [ 'tables' , 'list' ] ,
81+ activity : {
82+ id : 'inspect' ,
83+ title : 'Inspecting workspace resources' ,
84+ completedTitle : 'Inspected workspace resources' ,
85+ } ,
86+ } ,
87+ } ,
88+ } )
89+ render ( [ mainCall ( 'first' , 'executing' ) ] )
90+ act ( ( ) => vi . advanceTimersByTime ( 1_500 ) )
91+ expect ( thinking ( ) ) . toHaveLength ( 0 )
92+ expect ( container . querySelector ( '[class*="shimmer"]' ) ) . not . toBeNull ( )
93+
94+ const completed = [ mainCall ( 'first' , 'success' ) ]
95+ render ( completed )
96+ expect ( thinking ( ) ) . toHaveLength ( 0 )
97+ act ( ( ) => vi . advanceTimersByTime ( 1_500 ) )
98+ expect ( thinking ( ) ) . toHaveLength ( 1 )
99+ expect ( container . querySelector ( '[aria-hidden="false"]' ) ?. textContent ) . toContain ( 'Thinking' )
100+
101+ render ( [ ...completed , { type : 'thinking' , content : 'Checking the result.' , timestamp : 3 } ] )
102+ expect ( thinking ( ) ) . toHaveLength ( 1 )
103+ render ( [ ...completed , mainCall ( 'next' , 'executing' ) ] )
104+ expect ( thinking ( ) ) . toHaveLength ( 0 )
105+
106+ const finished = [ ...completed , mainCall ( 'next' , 'success' ) ]
107+ render ( finished )
108+ act ( ( ) => vi . advanceTimersByTime ( 1_500 ) )
109+ expect ( thinking ( ) ) . toHaveLength ( 1 )
110+ render ( finished , false )
111+ expect ( thinking ( ) ) . toHaveLength ( 0 )
112+ }
113+ )
114+
68115 it ( 'shares one indicator across parallel and nested empty agents' , ( ) => {
69116 render ( [ start ( 'workflow' ) , start ( 'browser' ) , start ( 'deploy' , 'workflow' ) ] )
70117 expect ( thinking ( ) ) . toHaveLength ( 1 )
0 commit comments