@@ -7380,6 +7380,38 @@ describe("dispatchReplyFromConfig", () => {
73807380 expect ( blockReplySentTexts ) . toContain ( "The answer is 42" ) ;
73817381 } ) ;
73827382
7383+ it ( "keeps Telegram isReasoning block replies out of final TTS fallback" , async ( ) => {
7384+ setNoAbort ( ) ;
7385+ ttsMocks . state . synthesizeFinalAudio = true ;
7386+ const dispatcher = createDispatcher ( ) ;
7387+ const ctx = buildTestCtx ( { Provider : "telegram" , Surface : "telegram" } ) ;
7388+ const blockReplySentTexts : string [ ] = [ ] ;
7389+ const replyResolver = async (
7390+ _ctx : MsgContext ,
7391+ opts ?: GetReplyOptions ,
7392+ ) : Promise < ReplyPayload | undefined > => {
7393+ await opts ?. onBlockReply ?.( { text : "thinking..." , isReasoning : true } ) ;
7394+ await opts ?. onBlockReply ?.( { text : "The answer is 42" } ) ;
7395+ return undefined ;
7396+ } ;
7397+ ( dispatcher . sendBlockReply as ReturnType < typeof vi . fn > ) . mockImplementation (
7398+ ( payload : ReplyPayload ) => {
7399+ if ( payload . text ) {
7400+ blockReplySentTexts . push ( payload . text ) ;
7401+ }
7402+ return true ;
7403+ } ,
7404+ ) ;
7405+
7406+ await dispatchReplyFromConfig ( { ctx, cfg : emptyConfig , dispatcher, replyResolver } ) ;
7407+
7408+ expect ( blockReplySentTexts ) . toEqual ( [ "thinking..." , "The answer is 42" ] ) ;
7409+ const ttsCall = ttsMocks . maybeApplyTtsToPayload . mock . calls
7410+ . map ( ( [ call ] ) => call as { kind ?: unknown ; payload ?: ReplyPayload } )
7411+ . find ( ( call ) => call . kind === "final" ) ;
7412+ expect ( ttsCall ?. payload ) . toEqual ( { text : "The answer is 42" } ) ;
7413+ } ) ;
7414+
73837415 it ( "strips split TTS directives from streamed block text before delivery" , async ( ) => {
73847416 setNoAbort ( ) ;
73857417 ttsMocks . state . synthesizeFinalAudio = true ;
0 commit comments