@@ -25,6 +25,76 @@ function transcriptMessage(
2525}
2626
2727suite . define ( ( ) => {
28+ it ( "keeps restart-recovered live tool batches in one transcript row" , async ( ) => {
29+ const context = await suite . browser . newContext ( { viewport : { height : 900 , width : 1200 } } ) ;
30+ const page = await context . newPage ( ) ;
31+ const runId = "run-restart-recovery" ;
32+ const toolResult = ( id : string , seq : number , name : string ) => ( {
33+ ...transcriptMessage (
34+ "toolResult" ,
35+ [ { type : "text" , text : `${ name } completed` } ] ,
36+ runId ,
37+ id ,
38+ seq ,
39+ ) ,
40+ toolCallId : id ,
41+ toolName : name ,
42+ } ) ;
43+ await installMockGateway ( page , {
44+ historyMessages : [
45+ {
46+ ...transcriptMessage (
47+ "user" ,
48+ "[System] Continue the interrupted turn." ,
49+ `${ runId } :user` ,
50+ "restart-recovery" ,
51+ 1 ,
52+ ) ,
53+ provenance : {
54+ kind : "internal_system" ,
55+ sourceSessionKey : "main" ,
56+ sourceTool : "main_session_restart_recovery" ,
57+ } ,
58+ } ,
59+ toolResult ( "process-1" , 2 , "process" ) ,
60+ toolResult ( "process-2" , 3 , "process" ) ,
61+ transcriptMessage ( "assistant" , "Checking the next batch." , runId , "gap-1" , 4 ) ,
62+ toolResult ( "exec-1" , 5 , "exec" ) ,
63+ toolResult ( "exec-2" , 6 , "exec" ) ,
64+ transcriptMessage ( "assistant" , "Checking the final batch." , runId , "gap-2" , 7 ) ,
65+ toolResult ( "process-3" , 8 , "process" ) ,
66+ toolResult ( "process-4" , 9 , "process" ) ,
67+ ] ,
68+ inFlightRun : { runId, text : "" } ,
69+ sessionInfo : {
70+ activeRunIds : [ runId ] ,
71+ hasActiveRun : true ,
72+ key : "main" ,
73+ } ,
74+ } ) ;
75+
76+ await page . goto ( `${ suite . server . baseUrl } chat` ) ;
77+ const summaries = page . locator ( ".chat-activity-group__summary" ) ;
78+ await expect . poll ( ( ) => summaries . count ( ) ) . toBe ( 3 ) ;
79+ const rowKeys = await summaries . evaluateAll ( ( elements ) =>
80+ elements . map (
81+ ( element ) => element . closest < HTMLElement > ( ".chat-virtual-row" ) ?. dataset . virtualRowKey ,
82+ ) ,
83+ ) ;
84+
85+ expect ( rowKeys [ 0 ] ) . toMatch ( / ^ a g e n t - r u n : / u) ;
86+ expect ( rowKeys ) . toEqual ( [ rowKeys [ 0 ] , rowKeys [ 0 ] , rowKeys [ 0 ] ] ) ;
87+ const artifactDir = process . env . OPENCLAW_CONTROL_UI_E2E_ARTIFACT_DIR ?. trim ( ) ;
88+ if ( artifactDir ) {
89+ await fs . mkdir ( artifactDir , { recursive : true } ) ;
90+ await page . locator ( ".chat-thread-inner" ) . screenshot ( {
91+ path : path . join ( artifactDir , "restart-recovery-run-frame.png" ) ,
92+ } ) ;
93+ }
94+
95+ await context . close ( ) ;
96+ } ) ;
97+
2898 it ( "renders each run as one linear response with actions only on its terminal text" , async ( ) => {
2999 const context = await suite . browser . newContext ( { viewport : { height : 900 , width : 1200 } } ) ;
30100 const page = await context . newPage ( ) ;
0 commit comments