@@ -3982,6 +3982,52 @@ describe("matrix live qa scenarios", () => {
39823982 ) ;
39833983 } ) ;
39843984
3985+ it ( "does not accept top-level finals after a Matrix mention-safety preview" , async ( ) => {
3986+ const context = matrixQaScenarioContext ( ) ;
3987+ const primeRoom = vi . fn ( ) . mockResolvedValue ( "driver-sync-start" ) ;
3988+ const sendTextMessage = vi . fn ( ) . mockResolvedValue ( "$tool-progress-mention-stale-trigger" ) ;
3989+ const previewEvent = matrixQaMessageEvent ( {
3990+ kind : "message" ,
3991+ eventId : "$tool-progress-mention-stale-preview" ,
3992+ body :
3993+ "Working...\n- `read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed`" ,
3994+ formattedBody :
3995+ "Working...<br><ul><li><code>read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed</code></li></ul>" ,
3996+ mentions : { } ,
3997+ } ) ;
3998+ const waitForRoomEvent = vi
3999+ . fn ( )
4000+ . mockImplementationOnce ( async ( ) => {
4001+ context . observedEvents . push ( previewEvent ) ;
4002+ return { event : previewEvent , since : "driver-sync-preview" } ;
4003+ } )
4004+ . mockImplementationOnce ( async ( params : { predicate : ( event : MatrixQaObservedEvent ) => boolean } ) => {
4005+ const topLevelFinal = matrixQaMessageEvent ( {
4006+ kind : "message" ,
4007+ eventId : "$tool-progress-mention-stale-final" ,
4008+ body : readMatrixQaReplyDirective (
4009+ mockMessageBody ( sendTextMessage , "sendTextMessage" ) ,
4010+ "MATRIX_QA_TOOL_PROGRESS_MENTION_SAFE_FIXED" ,
4011+ ) ,
4012+ } ) ;
4013+ expect ( params . predicate ( topLevelFinal ) ) . toBe ( false ) ;
4014+ context . observedEvents . push ( topLevelFinal ) ;
4015+ throw new Error ( "timed out after 8000ms waiting for Matrix room event" ) ;
4016+ } ) ;
4017+ createMatrixQaClient . mockReturnValue ( {
4018+ primeRoom,
4019+ sendTextMessage,
4020+ waitForRoomEvent,
4021+ } ) ;
4022+
4023+ const scenario = requireMatrixQaScenario ( "matrix-room-tool-progress-mention-safety" ) ;
4024+
4025+ await expect ( runMatrixQaScenario ( scenario , context ) ) . rejects . toThrow (
4026+ / t i m e d o u t a f t e r 8 0 0 0 m s w a i t i n g f o r M a t r i x r o o m e v e n t / ,
4027+ ) ;
4028+ expect ( waitForRoomEvent ) . toHaveBeenCalledTimes ( 2 ) ;
4029+ } ) ;
4030+
39854031 it ( "preserves separate finalized block events when Matrix block streaming is enabled" , async ( ) => {
39864032 const primeRoom = vi . fn ( ) . mockResolvedValue ( "driver-sync-start" ) ;
39874033 const sendTextMessage = vi . fn ( ) . mockResolvedValue ( "$block-stream-trigger" ) ;
0 commit comments