@@ -50,6 +50,10 @@ const loadConversationSeedMock = mock(async () => ({
5050 organizationId : "org-1" ,
5151 websiteId : "site-1" ,
5252 visitorId : "visitor-1" ,
53+ title : null as string | null ,
54+ titleSource : null as "ai" | "user" | null ,
55+ visitorTitle : null as string | null ,
56+ visitorTitleLanguage : null as string | null ,
5357 } ,
5458 triggerMetadata : {
5559 id : "msg-1" ,
@@ -58,6 +62,9 @@ const loadConversationSeedMock = mock(async () => ({
5862 } ,
5963} ) ) ;
6064const loadIntakeContextMock = mock ( async ( ) => ( {
65+ websiteDefaultLanguage : "en" ,
66+ visitorLanguage : "es" ,
67+ autoTranslateEnabled : true ,
6168 conversationHistory : [ ] ,
6269 decisionMessages : [ ] ,
6370 generationEntries : [ ] ,
@@ -215,6 +222,10 @@ describe("runBackgroundPipeline", () => {
215222 organizationId : "org-1" ,
216223 websiteId : "site-1" ,
217224 visitorId : "visitor-1" ,
225+ title : null as string | null ,
226+ titleSource : null as "ai" | "user" | null ,
227+ visitorTitle : null as string | null ,
228+ visitorTitleLanguage : null as string | null ,
218229 } ,
219230 triggerMetadata : {
220231 id : "msg-1" ,
@@ -223,6 +234,9 @@ describe("runBackgroundPipeline", () => {
223234 } ,
224235 } ) ;
225236 loadIntakeContextMock . mockResolvedValue ( {
237+ websiteDefaultLanguage : "en" ,
238+ visitorLanguage : "es" ,
239+ autoTranslateEnabled : true ,
226240 conversationHistory : [ ] ,
227241 decisionMessages : [ ] ,
228242 generationEntries : [ ] ,
@@ -342,6 +356,74 @@ describe("runBackgroundPipeline", () => {
342356 ) ;
343357 } ) ;
344358
359+ it ( "passes multilingual title state into the background analysis runtime" , async ( ) => {
360+ loadConversationSeedMock . mockResolvedValueOnce ( {
361+ conversation : {
362+ id : "conv-1" ,
363+ organizationId : "org-1" ,
364+ websiteId : "site-1" ,
365+ visitorId : "visitor-1" ,
366+ title : "Billing question" ,
367+ titleSource : "ai" ,
368+ visitorTitle : "Pregunta de facturacion" ,
369+ visitorTitleLanguage : "es" ,
370+ } ,
371+ triggerMetadata : {
372+ id : "msg-1" ,
373+ createdAt : "2026-03-04T10:00:00.000Z" ,
374+ conversationId : "conv-1" ,
375+ } ,
376+ } ) ;
377+ loadIntakeContextMock . mockResolvedValueOnce ( {
378+ websiteDefaultLanguage : "en" ,
379+ visitorLanguage : "es" ,
380+ autoTranslateEnabled : true ,
381+ conversationHistory : [ ] ,
382+ decisionMessages : [ ] ,
383+ generationEntries : [ ] ,
384+ visitorContext : null ,
385+ conversationState : {
386+ hasHumanAssignee : false ,
387+ assigneeIds : [ ] ,
388+ participantIds : [ ] ,
389+ isEscalated : false ,
390+ escalationReason : null ,
391+ } ,
392+ triggerMessage : {
393+ messageId : "msg-1" ,
394+ content : "Necesito ayuda con la facturacion" ,
395+ senderType : "visitor" ,
396+ senderId : null ,
397+ senderName : null ,
398+ timestamp : "2026-03-04T10:00:00.000Z" ,
399+ visibility : "public" ,
400+ } ,
401+ hasLaterHumanMessage : false ,
402+ hasLaterAiMessage : false ,
403+ } ) ;
404+
405+ const { runBackgroundPipeline } = await modulePromise ;
406+ const result = await runBackgroundPipeline ( {
407+ db : { } as never ,
408+ input : baseInput ,
409+ } ) ;
410+
411+ expect ( result . status ) . toBe ( "completed" ) ;
412+ expect ( runGenerationRuntimeMock ) . toHaveBeenCalledWith (
413+ expect . objectContaining ( {
414+ websiteDefaultLanguage : "en" ,
415+ visitorLanguage : "es" ,
416+ autoTranslateEnabled : true ,
417+ conversation : expect . objectContaining ( {
418+ title : "Billing question" ,
419+ titleSource : "ai" ,
420+ visitorTitle : "Pregunta de facturacion" ,
421+ visitorTitleLanguage : "es" ,
422+ } ) ,
423+ } )
424+ ) ;
425+ } ) ;
426+
345427 it ( "returns skipped when the analysis run makes no metadata mutation" , async ( ) => {
346428 runGenerationRuntimeMock . mockResolvedValueOnce ( {
347429 status : "completed" ,
0 commit comments