@@ -1008,6 +1008,91 @@ test("streamed assistant blocks defer their spacer until first render", async ()
10081008 }
10091009} )
10101010
1011+ test ( "first entry after prior scrollback gets a spacer" , async ( ) => {
1012+ const out = await createTestRenderer ( {
1013+ width : 80 ,
1014+ screenMode : "split-footer" ,
1015+ footerHeight : 6 ,
1016+ externalOutputMode : "capture-stdout" ,
1017+ consoleMode : "disabled" ,
1018+ } )
1019+ active . push ( out . renderer )
1020+
1021+ const treeSitterClient = new MockTreeSitterClient ( { autoResolveTimeout : 0 } )
1022+ treeSitterClient . setMockResult ( { highlights : [ ] } )
1023+
1024+ const scrollback = new RunScrollbackStream ( out . renderer , RUN_THEME_FALLBACK , {
1025+ treeSitterClient,
1026+ wrote : true ,
1027+ } )
1028+
1029+ await scrollback . append ( {
1030+ kind : "user" ,
1031+ text : "use subagent to explore run.ts" ,
1032+ phase : "start" ,
1033+ source : "system" ,
1034+ } )
1035+
1036+ const commits = claimCommits ( out . renderer )
1037+ try {
1038+ expect ( commits ) . toHaveLength ( 2 )
1039+ expect ( renderCommit ( commits [ 0 ] ! ) . trim ( ) ) . toBe ( "" )
1040+ expect ( renderCommit ( commits [ 1 ] ! ) . trim ( ) ) . toBe ( "› use subagent to explore run.ts" )
1041+ } finally {
1042+ destroyCommits ( commits )
1043+ }
1044+ } )
1045+
1046+ test ( "first streamed entry after prior scrollback gets a spacer" , async ( ) => {
1047+ const out = await createTestRenderer ( {
1048+ width : 80 ,
1049+ screenMode : "split-footer" ,
1050+ footerHeight : 6 ,
1051+ externalOutputMode : "capture-stdout" ,
1052+ consoleMode : "disabled" ,
1053+ } )
1054+ active . push ( out . renderer )
1055+
1056+ const treeSitterClient = new MockTreeSitterClient ( { autoResolveTimeout : 0 } )
1057+ treeSitterClient . setMockResult ( { highlights : [ ] } )
1058+
1059+ const scrollback = new RunScrollbackStream ( out . renderer , RUN_THEME_FALLBACK , {
1060+ treeSitterClient,
1061+ wrote : true ,
1062+ } )
1063+
1064+ for ( const chunk of [ "Exploring" , " run.ts" , " via" , " a codebase-aware" , " subagent next." ] ) {
1065+ await scrollback . append ( {
1066+ kind : "assistant" ,
1067+ text : chunk ,
1068+ phase : "progress" ,
1069+ source : "assistant" ,
1070+ messageID : "msg-1" ,
1071+ partID : "part-1" ,
1072+ } )
1073+ }
1074+
1075+ const progress = claimCommits ( out . renderer )
1076+ try {
1077+ expect ( progress ) . toHaveLength ( 0 )
1078+ } finally {
1079+ destroyCommits ( progress )
1080+ }
1081+
1082+ await scrollback . complete ( )
1083+
1084+ const commits = claimCommits ( out . renderer )
1085+ try {
1086+ expect ( commits ) . toHaveLength ( 2 )
1087+ expect ( renderCommit ( commits [ 0 ] ! ) . trim ( ) ) . toBe ( "" )
1088+ expect ( renderCommit ( commits [ 1 ] ! ) . replace ( / \n / g, " " ) ) . toContain (
1089+ "Exploring run.ts via a codebase-aware subagent next." ,
1090+ )
1091+ } finally {
1092+ destroyCommits ( commits )
1093+ }
1094+ } )
1095+
10111096test ( "coalesces same-line tool progress into one snapshot" , async ( ) => {
10121097 const out = await createTestRenderer ( {
10131098 width : 80 ,
0 commit comments