@@ -280,7 +280,7 @@ describe("web processMessage inbound contract", () => {
280280 expect ( groupHistories . get ( "whatsapp:default:group:[email protected] " ) ?? [ ] ) . toHaveLength ( 0 ) ; 281281 } ) ;
282282
283- it ( "suppresses non-final WhatsApp payload delivery" , async ( ) => {
283+ it ( "suppresses tool payload delivery but allows block and final " , async ( ) => {
284284 const rememberSentText = vi . fn ( ) ;
285285 await processMessage ( createWhatsAppDirectStreamingArgs ( { rememberSentText } ) ) ;
286286
@@ -291,21 +291,46 @@ describe("web processMessage inbound contract", () => {
291291 expect ( deliver ) . toBeTypeOf ( "function" ) ;
292292
293293 await deliver ?.( { text : "tool payload" } , { kind : "tool" } ) ;
294- await deliver ?.( { text : "block payload" } , { kind : "block" } ) ;
295294 expect ( deliverWebReplyMock ) . not . toHaveBeenCalled ( ) ;
296- expect ( rememberSentText ) . not . toHaveBeenCalled ( ) ;
297295
298- await deliver ?.( { text : "final payload" } , { kind : "final " } ) ;
296+ await deliver ?.( { text : "block payload" } , { kind : "block " } ) ;
299297 expect ( deliverWebReplyMock ) . toHaveBeenCalledTimes ( 1 ) ;
300- expect ( rememberSentText ) . toHaveBeenCalledTimes ( 1 ) ;
298+
299+ await deliver ?.( { text : "final payload" } , { kind : "final" } ) ;
300+ expect ( deliverWebReplyMock ) . toHaveBeenCalledTimes ( 2 ) ;
301+ expect ( rememberSentText ) . toHaveBeenCalledTimes ( 2 ) ;
301302 } ) ;
302303
303- it ( "forces disableBlockStreaming for WhatsApp dispatch " , async ( ) => {
304+ it ( "respects per-account blockStreaming config for disableBlockStreaming " , async ( ) => {
304305 await processMessage ( createWhatsAppDirectStreamingArgs ( ) ) ;
305306
306307 // oxlint-disable-next-line typescript/no-explicit-any
307308 const replyOptions = ( capturedDispatchParams as any ) ?. replyOptions ;
308- expect ( replyOptions ?. disableBlockStreaming ) . toBe ( true ) ;
309+ // blockStreaming: true in config → disableBlockStreaming: false
310+ expect ( replyOptions ?. disableBlockStreaming ) . toBe ( false ) ;
311+ } ) ;
312+
313+ it ( "leaves disableBlockStreaming undefined when blockStreaming not configured" , async ( ) => {
314+ const args = makeProcessMessageArgs ( {
315+ routeSessionKey : "agent:main:whatsapp:direct:+1555" ,
316+ groupHistoryKey : "+1555" ,
317+ cfg : {
318+ messages : { } ,
319+ session : { store : sessionStorePath } ,
320+ } as unknown as ReturnType < typeof import ( "../../../../../src/config/config.js" ) . loadConfig > ,
321+ msg : {
322+ id : "msg1" ,
323+ from : "+1555" ,
324+ to : "+2000" ,
325+ chatType : "direct" ,
326+ body : "hi" ,
327+ } ,
328+ } ) ;
329+ await processMessage ( args ) ;
330+
331+ // oxlint-disable-next-line typescript/no-explicit-any
332+ const replyOptions = ( capturedDispatchParams as any ) ?. replyOptions ;
333+ expect ( replyOptions ?. disableBlockStreaming ) . toBeUndefined ( ) ;
309334 } ) ;
310335
311336 it ( "passes sendComposing through as the reply typing callback" , async ( ) => {
0 commit comments