@@ -387,6 +387,38 @@ describe("ChatLog", () => {
387387 expect ( normalizeTestText ( chatLog . render ( 120 ) . join ( "\n" ) ) ) . toContain ( "Still streaming." ) ;
388388 } ) ;
389389
390+ it ( "preserves a delayed shared prompt and its active reply when scrollback is full" , ( ) => {
391+ const chatLog = new ChatLog ( 20 ) ;
392+ chatLog . updateAssistant ( "Already streaming." , "shared-run" ) ;
393+ for ( let index = 0 ; index < 19 ; index += 1 ) {
394+ chatLog . addSystem ( `Older notice ${ index } .` ) ;
395+ }
396+
397+ chatLog . addLiveUser ( "Sent from the other client." , {
398+ messageId : "shared-overflow-user" ,
399+ runId : "shared-run" ,
400+ } ) ;
401+ chatLog . addLiveUser ( "Sent from the other client." , {
402+ messageId : "shared-overflow-user" ,
403+ runId : "shared-run" ,
404+ } ) ;
405+
406+ const rendered = normalizeTestText ( chatLog . render ( 120 ) . join ( "\n" ) ) ;
407+ expect ( chatLog . children ) . toHaveLength ( 20 ) ;
408+ expect ( rendered ) . toContain ( "Sent from the other client." ) ;
409+ expect ( rendered ) . toContain ( "Already streaming." ) ;
410+ expect ( rendered ) . not . toContain ( "Older notice 0." ) ;
411+ expect ( rendered . match ( / S e n t f r o m t h e o t h e r c l i e n t \. / g) ) . toHaveLength ( 1 ) ;
412+ expect ( rendered . indexOf ( "Sent from the other client." ) ) . toBeLessThan (
413+ rendered . indexOf ( "Already streaming." ) ,
414+ ) ;
415+
416+ chatLog . updateAssistant ( "Still streaming after overflow." , "shared-run" ) ;
417+ expect ( normalizeTestText ( chatLog . render ( 120 ) . join ( "\n" ) ) ) . toContain (
418+ "Still streaming after overflow." ,
419+ ) ;
420+ } ) ;
421+
390422 it ( "deduplicates authoritative user events and adopts the matching pending prompt" , ( ) => {
391423 const chatLog = new ChatLog ( 40 ) ;
392424 chatLog . addPendingUser ( "shared-run" , "Persisted prompt." ) ;
0 commit comments