@@ -3887,8 +3887,7 @@ describe("matrix live qa scenarios", () => {
38873887 event : matrixQaMessageEvent ( {
38883888 kind : "message" ,
38893889 eventId : "$tool-progress-mention-edit" ,
3890- body :
3891- "Working...\n- `read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed`" ,
3890+ body : "Working...\n- `read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed`" ,
38923891 formattedBody :
38933892 "Working...<br><ul><li><code>read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed</code></li></ul>" ,
38943893 mentions : { } ,
@@ -3958,8 +3957,7 @@ describe("matrix live qa scenarios", () => {
39583957 event : matrixQaMessageEvent ( {
39593958 kind : "message" ,
39603959 eventId : "$tool-progress-mention-final-first-progress" ,
3961- body :
3962- "Working...\n- `read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed`" ,
3960+ body : "Working...\n- `read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed`" ,
39633961 formattedBody :
39643962 "Working...<br><ul><li><code>read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed</code></li></ul>" ,
39653963 mentions : {
@@ -3982,15 +3980,59 @@ describe("matrix live qa scenarios", () => {
39823980 ) ;
39833981 } ) ;
39843982
3983+ it ( "keeps Matrix-looking top-level tool errors inert after final-first replies" , async ( ) => {
3984+ mockMatrixQaRoomClient ( {
3985+ driverEventId : "$tool-progress-mention-top-level-trigger" ,
3986+ events : [
3987+ {
3988+ event : ( { sendTextMessage } ) =>
3989+ matrixQaMessageEvent ( {
3990+ kind : "message" ,
3991+ eventId : "$tool-progress-mention-top-level-final" ,
3992+ body : readMatrixQaReplyDirective (
3993+ mockMessageBody ( sendTextMessage , "sendTextMessage" ) ,
3994+ "MATRIX_QA_TOOL_PROGRESS_MENTION_SAFE_FIXED" ,
3995+ ) ,
3996+ } ) ,
3997+ since : "driver-sync-final" ,
3998+ } ,
3999+ {
4000+ event : matrixQaMessageEvent ( {
4001+ kind : "message" ,
4002+ eventId : "$tool-progress-mention-top-level-progress" ,
4003+ body : "⚠️ 🛠️ `show matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt (workspace)` failed" ,
4004+ formattedBody :
4005+ "<p>⚠️ 🛠️ <code>show matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt (workspace)</code> failed</p>" ,
4006+ mentions : { } ,
4007+ } ) ,
4008+ since : "driver-sync-progress" ,
4009+ } ,
4010+ ] ,
4011+ } ) ;
4012+
4013+ const scenario = requireMatrixQaScenario ( "matrix-room-tool-progress-mention-safety" ) ;
4014+
4015+ const result = await runMatrixQaScenario ( scenario , matrixQaScenarioContext ( ) ) ;
4016+ const artifacts = result . artifacts as {
4017+ previewEventId ?: unknown ;
4018+ previewFormattedBodyPreview ?: unknown ;
4019+ previewMentions ?: unknown ;
4020+ reply ?: { eventId ?: unknown } ;
4021+ } ;
4022+ expect ( artifacts . previewEventId ) . toBe ( "$tool-progress-mention-top-level-progress" ) ;
4023+ expect ( artifacts . previewFormattedBodyPreview ) . toContain ( "<code>show matrix-progress-@room" ) ;
4024+ expect ( artifacts . previewMentions ) . toEqual ( { } ) ;
4025+ expect ( artifacts . reply ?. eventId ) . toBe ( "$tool-progress-mention-top-level-final" ) ;
4026+ } ) ;
4027+
39854028 it ( "does not accept top-level finals after a Matrix mention-safety preview" , async ( ) => {
39864029 const context = matrixQaScenarioContext ( ) ;
39874030 const primeRoom = vi . fn ( ) . mockResolvedValue ( "driver-sync-start" ) ;
39884031 const sendTextMessage = vi . fn ( ) . mockResolvedValue ( "$tool-progress-mention-stale-trigger" ) ;
39894032 const previewEvent = matrixQaMessageEvent ( {
39904033 kind : "message" ,
39914034 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`" ,
4035+ body : "Working...\n- `read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed`" ,
39944036 formattedBody :
39954037 "Working...<br><ul><li><code>read matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt failed</code></li></ul>" ,
39964038 mentions : { } ,
@@ -4001,19 +4043,21 @@ describe("matrix live qa scenarios", () => {
40014043 context . observedEvents . push ( previewEvent ) ;
40024044 return { event : previewEvent , since : "driver-sync-preview" } ;
40034045 } )
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- } ) ;
4046+ . mockImplementationOnce (
4047+ async ( params : { predicate : ( event : MatrixQaObservedEvent ) => boolean } ) => {
4048+ const topLevelFinal = matrixQaMessageEvent ( {
4049+ kind : "message" ,
4050+ eventId : "$tool-progress-mention-stale-final" ,
4051+ body : readMatrixQaReplyDirective (
4052+ mockMessageBody ( sendTextMessage , "sendTextMessage" ) ,
4053+ "MATRIX_QA_TOOL_PROGRESS_MENTION_SAFE_FIXED" ,
4054+ ) ,
4055+ } ) ;
4056+ expect ( params . predicate ( topLevelFinal ) ) . toBe ( false ) ;
4057+ context . observedEvents . push ( topLevelFinal ) ;
4058+ throw new Error ( "timed out after 8000ms waiting for Matrix room event" ) ;
4059+ } ,
4060+ ) ;
40174061 createMatrixQaClient . mockReturnValue ( {
40184062 primeRoom,
40194063 sendTextMessage,
0 commit comments