@@ -459,6 +459,18 @@ describe("dispatchCronDelivery — double-announce guard", () => {
459459 } ) ;
460460
461461 it ( "applies TTS directives before direct cron announce delivery and mirrors spoken text" , async ( ) => {
462+ vi . mocked ( deliverOutboundPayloads ) . mockImplementationOnce ( async ( deliveryParams ) => {
463+ deliveryParams . onPayload ?.( {
464+ text : "Morning briefing complete." ,
465+ mediaUrls : [
466+ "file:///tmp/chart.png" ,
467+ "file:///tmp/narration.ogg" ,
468+ "file:///tmp/cron-tts.mp3" ,
469+ ] ,
470+ audioAsVoice : true ,
471+ } ) ;
472+ return [ { ok : true } as never ] ;
473+ } ) ;
462474 maybeApplyTtsToPayloadMock . mockImplementation ( async ( params : { payload : unknown } ) => {
463475 const payload = params . payload as { text ?: string } ;
464476 expect ( payload . text ) . toBe ( "[[tts]] Morning briefing complete." ) ;
@@ -637,14 +649,14 @@ describe("dispatchCronDelivery — double-announce guard", () => {
637649 ) ;
638650 } ) ;
639651
640- it ( "keeps media filenames in main-session awareness before suppressing the mirror" , async ( ) => {
652+ it ( "keeps effective media-only payloads in main-session awareness before suppressing the mirror" , async ( ) => {
641653 mockResolvedOutboundRoute ( {
642654 sessionKey : "agent:main:main" ,
643655 baseSessionKey : "agent:main:main" ,
644656 } ) ;
645657 vi . mocked ( deliverOutboundPayloads ) . mockImplementationOnce ( async ( params ) => {
646658 params . onPayload ?.( {
647- text : "Main session briefing. " ,
659+ text : "" ,
648660 mediaUrls : [ "https://example.com/main-chart.png" ] ,
649661 } ) ;
650662 return [ { channel : "telegram" , messageId : "tg-main-media" } ] ;
@@ -663,7 +675,7 @@ describe("dispatchCronDelivery — double-announce guard", () => {
663675 expect ( state . result ) . toBeUndefined ( ) ;
664676 expect ( state . delivered ) . toBe ( true ) ;
665677 expect ( appendAssistantMessageToSessionTranscript ) . not . toHaveBeenCalled ( ) ;
666- expect ( enqueueSystemEvent ) . toHaveBeenCalledWith ( "Main session briefing.\nmain -chart.png" , {
678+ expect ( enqueueSystemEvent ) . toHaveBeenCalledWith ( "main -chart.png" , {
667679 sessionKey : "agent:main:main" ,
668680 contextKey : "cron-direct-delivery:v1:cron:test-job:1000:telegram::123456:" ,
669681 forceSenderIsOwnerFalse : true ,
@@ -814,6 +826,10 @@ describe("dispatchCronDelivery — double-announce guard", () => {
814826 } ) ;
815827
816828 it ( "skips main-session awareness for isolated cron jobs with implicit delivery targets" , async ( ) => {
829+ mockResolvedOutboundRoute ( {
830+ sessionKey : "agent:main:main" ,
831+ baseSessionKey : "agent:main:main" ,
832+ } ) ;
817833 const params = makeBaseParams ( {
818834 synthesizedText : "Implicit cron update." ,
819835 resolvedDeliveryMode : "implicit" ,
@@ -825,6 +841,7 @@ describe("dispatchCronDelivery — double-announce guard", () => {
825841 expect ( state . deliveryAttempted ) . toBe ( true ) ;
826842 expect ( deliverOutboundPayloads ) . toHaveBeenCalledTimes ( 1 ) ;
827843 expect ( enqueueSystemEvent ) . not . toHaveBeenCalled ( ) ;
844+ expect ( appendAssistantMessageToSessionTranscript ) . not . toHaveBeenCalled ( ) ;
828845 } ) ;
829846
830847 it ( "skips awareness text when direct delivery strips a silent caption" , async ( ) => {
0 commit comments