@@ -80,8 +80,6 @@ function assertExactForegroundProgressState(job, semanticMessages) {
8080 }
8181 const legacy = 'ZCode reported legacy completion; awaiting confirmed turn state.' ;
8282 const terminal = 'ZCode completed the delegated turn.' ;
83- const terminalIndex = preview . indexOf ( terminal ) ;
84- if ( terminalIndex !== - 1 ) assert . ok ( preview . indexOf ( legacy ) !== - 1 && preview . indexOf ( legacy ) < terminalIndex , failure ) ;
8583 for ( const diagnostic of diagnostics ) assert . ok ( preview . filter ( ( message ) => message === diagnostic ) . length <= 1 , failure ) ;
8684 const timeoutIndex = preview . indexOf ( PROGRESS_CLEANUP_TIMEOUT_LINE . slice ( 8 , - 1 ) ) ;
8785 const archiveIndex = preview . indexOf ( PROGRESS_ARCHIVE_DISABLED_LINE . slice ( 8 , - 1 ) ) ;
@@ -98,18 +96,18 @@ function assertExactForegroundProgressState(job, semanticMessages) {
9896 assert . equal ( job . phase , phases . get ( preview . at ( - 1 ) ) , failure ) ;
9997
10098 const handshakeWindow = semanticMessages . slice ( 0 , 6 ) . slice ( - 4 ) ;
101- const suffixCandidates = [ legacy , terminal , ...diagnostics ] ;
102- const allowedPreviews = new Set ( ) ;
99+ const suffixCandidates = [ terminal , ...diagnostics ] ;
100+ const allowedPreviews = new Set ( [ JSON . stringify ( handshakeWindow ) ] ) ;
103101 /** @param {string[] } suffix @param {Set<string> } used */
104102 const enumerateSuffixes = ( suffix , used ) => {
105103 allowedPreviews . add ( JSON . stringify ( [ ...handshakeWindow , ...suffix ] . slice ( - 4 ) ) ) ;
106104 for ( const message of suffixCandidates ) {
107- if ( used . has ( message ) || message === terminal && ! used . has ( legacy )
105+ if ( used . has ( message )
108106 || message === PROGRESS_ARCHIVE_DISABLED_LINE . slice ( 8 , - 1 ) && ! used . has ( PROGRESS_CLEANUP_TIMEOUT_LINE . slice ( 8 , - 1 ) ) ) continue ;
109107 enumerateSuffixes ( [ ...suffix , message ] , new Set ( [ ...used , message ] ) ) ;
110108 }
111109 } ;
112- enumerateSuffixes ( [ ] , new Set ( ) ) ;
110+ enumerateSuffixes ( [ legacy ] , new Set ( [ legacy ] ) ) ;
113111 assert . ok ( allowedPreviews . has ( JSON . stringify ( preview ) ) , failure ) ;
114112}
115113
@@ -218,12 +216,22 @@ test('bounded foreground progress state accepts the captured Windows terminal pe
218216 ] ,
219217 } ;
220218 assertExactForegroundProgressState ( capturedWindowsState , semanticMessages ) ;
219+ assertExactForegroundProgressState ( {
220+ status : 'succeeded' , phase : 'waiting' , progressPreview : [
221+ 'ZCode completed the delegated turn.' , CONVERSATION_UNSUBSCRIBE_FAILED_MESSAGE ,
222+ 'ZCode progress cleanup reached its time limit.' , 'ZCode progress archive was disabled.' ,
223+ ] ,
224+ } , semanticMessages ) ;
221225 for ( const invalid of [
222226 { ...capturedWindowsState , phase : 'finalizing' } ,
223227 { ...capturedWindowsState , progressPreview : [ ...capturedWindowsState . progressPreview . slice ( 1 ) , 'ZCode completed a tool call.' ] } ,
224228 { ...capturedWindowsState , progressPreview : [ 'ZCode completed the delegated turn.' ] } ,
225229 { ...capturedWindowsState , progressPreview : [ 'ZCode progress archive was disabled.' , 'ZCode progress cleanup reached its time limit.' ] } ,
226230 { ...capturedWindowsState , phase : 'running' , progressPreview : semanticMessages . slice ( 1 , 5 ) } ,
231+ { ...capturedWindowsState , progressPreview : [
232+ 'ZCode tool work is still running.' , 'ZCode completed a tool call.' ,
233+ CONVERSATION_UNSUBSCRIBE_FAILED_MESSAGE , 'ZCode reported legacy completion; awaiting confirmed turn state.' ,
234+ ] } ,
227235 ] ) assert . throws ( ( ) => assertExactForegroundProgressState ( invalid , semanticMessages ) , / u n e x p e c t e d b o u n d e d f o r e g r o u n d p r o g r e s s s t a t e / ) ;
228236} ) ;
229237
0 commit comments