@@ -53,6 +53,55 @@ function messageRecord(group: MessageGroup, index = 0): Record<string, unknown>
5353 return requireRecord ( group . messages [ index ] ?. message ) ;
5454}
5555
56+ describe ( "buildChatItems working spark" , ( ) => {
57+ const hasReadingIndicator = ( props : Partial < BuildChatItemsProps > ) =>
58+ buildChatItems ( createProps ( props ) ) . some ( ( item ) => item . kind === "reading-indicator" ) ;
59+ const liveTool = ( resultReceived : boolean ) => ( {
60+ role : "assistant" ,
61+ toolCallId : "tool-1" ,
62+ content : [ { type : "toolcall" , name : "exec" , arguments : { } } ] ,
63+ timestamp : 1_000 ,
64+ __openclawToolStreamLive : true ,
65+ __openclawToolStreamResultReceived : resultReceived ,
66+ } ) ;
67+
68+ it ( "shows the spark while a run works with nothing streaming" , ( ) => {
69+ expect ( hasReadingIndicator ( { runWorking : true } ) ) . toBe ( true ) ;
70+ } ) ;
71+
72+ it ( "keeps the spark during a background reload with visible content" , ( ) => {
73+ expect (
74+ hasReadingIndicator ( {
75+ runWorking : true ,
76+ loading : true ,
77+ messages : [ { role : "assistant" , content : "answer" , timestamp : 1 } ] ,
78+ } ) ,
79+ ) . toBe ( true ) ;
80+ } ) ;
81+
82+ it ( "yields to the initial-load skeleton on an empty thread" , ( ) => {
83+ expect ( hasReadingIndicator ( { runWorking : true , loading : true } ) ) . toBe ( false ) ;
84+ } ) ;
85+
86+ it ( "does not stack the spark under a visible running tool row" , ( ) => {
87+ expect ( hasReadingIndicator ( { runWorking : true , toolMessages : [ liveTool ( false ) ] } ) ) . toBe ( false ) ;
88+ } ) ;
89+
90+ it ( "returns the spark once the running tool resolves" , ( ) => {
91+ expect ( hasReadingIndicator ( { runWorking : true , toolMessages : [ liveTool ( true ) ] } ) ) . toBe ( true ) ;
92+ } ) ;
93+
94+ it ( "keeps the spark when tool calls are hidden" , ( ) => {
95+ expect (
96+ hasReadingIndicator ( {
97+ runWorking : true ,
98+ showToolCalls : false ,
99+ toolMessages : [ liveTool ( false ) ] ,
100+ } ) ,
101+ ) . toBe ( true ) ;
102+ } ) ;
103+ } ) ;
104+
56105describe ( "buildChatItems" , ( ) => {
57106 it ( "keeps consecutive user messages from different senders in separate groups" , ( ) => {
58107 const groups = messageGroups ( {
0 commit comments