@@ -1930,6 +1930,48 @@ describe("VoiceCallWebhookServer barge-in suppression during initial message", (
19301930 } ;
19311931 } ;
19321932
1933+ it ( "logs streaming transcripts without splitting UTF-16 surrogate pairs" , async ( ) => {
1934+ const manager = {
1935+ getActiveCalls : ( ) => [ ] ,
1936+ getCallByProviderCallId : vi . fn ( ( ) => undefined ) ,
1937+ endCall : vi . fn ( async ( ) => ( { success : true } ) ) ,
1938+ speakInitialMessage : vi . fn ( async ( ) => { } ) ,
1939+ processEvent : vi . fn ( ) ,
1940+ } as unknown as CallManager ;
1941+ const config = createConfig ( {
1942+ provider : "twilio" ,
1943+ streaming : {
1944+ ...createConfig ( ) . streaming ,
1945+ enabled : true ,
1946+ providers : {
1947+ openai : {
1948+ apiKey : "test-key" , // pragma: allowlist secret
1949+ } ,
1950+ } ,
1951+ } ,
1952+ } ) ;
1953+ const server = new VoiceCallWebhookServer ( config , manager , createTwilioProvider ( vi . fn ( ) ) ) ;
1954+ await server . start ( ) ;
1955+ const logSpy = vi . spyOn ( console , "log" ) . mockImplementation ( ( ) => { } ) ;
1956+ const warnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
1957+
1958+ try {
1959+ const transcript = `${ "a" . repeat ( 199 ) } \uD83D\uDE80tail` ;
1960+ getMediaCallbacks ( server ) . config . onTranscript ?.( "CA-utf16" , transcript ) ;
1961+
1962+ const transcriptLog = logSpy . mock . calls
1963+ . map ( ( [ message ] ) => String ( message ) )
1964+ . find ( ( message ) => message . includes ( "Transcript for CA-utf16" ) ) ;
1965+ expect ( transcriptLog ) . toContain ( `${ "a" . repeat ( 199 ) } ...` ) ;
1966+ expect ( transcriptLog ) . not . toContain ( "\uD83D" ) ;
1967+ expect ( transcriptLog ) . not . toContain ( "\uDE80" ) ;
1968+ } finally {
1969+ logSpy . mockRestore ( ) ;
1970+ warnSpy . mockRestore ( ) ;
1971+ await server . stop ( ) ;
1972+ }
1973+ } ) ;
1974+
19331975 it ( "suppresses barge-in clear while outbound conversation initial message is pending" , async ( ) => {
19341976 const call = createCall ( Date . now ( ) - 1_000 ) ;
19351977 call . callId = "call-barge" ;
0 commit comments