@@ -2391,18 +2391,30 @@ export function useChat(
23912391 : undefined
23922392
23932393 const requestChatId = selectedChatIdRef . current ?? chatIdRef . current
2394+ const messageContexts = contexts ?. map ( ( c ) => ( {
2395+ kind : c . kind ,
2396+ label : c . label ,
2397+ ...( 'workflowId' in c && c . workflowId ? { workflowId : c . workflowId } : { } ) ,
2398+ ...( 'knowledgeId' in c && c . knowledgeId ? { knowledgeId : c . knowledgeId } : { } ) ,
2399+ ...( 'tableId' in c && c . tableId ? { tableId : c . tableId } : { } ) ,
2400+ ...( 'fileId' in c && c . fileId ? { fileId : c . fileId } : { } ) ,
2401+ ...( 'folderId' in c && c . folderId ? { folderId : c . folderId } : { } ) ,
2402+ } ) )
2403+
23942404 if ( requestChatId ) {
23952405 const cachedUserMsg : PersistedMessage = {
23962406 id : userMessageId ,
23972407 role : 'user' as const ,
23982408 content : message ,
23992409 timestamp : new Date ( ) . toISOString ( ) ,
24002410 ...( storedAttachments && { fileAttachments : storedAttachments } ) ,
2411+ ...( messageContexts && messageContexts . length > 0 ? { contexts : messageContexts } : { } ) ,
24012412 }
24022413 queryClient . setQueryData < TaskChatHistory > ( taskKeys . detail ( requestChatId ) , ( old ) => {
24032414 return old
24042415 ? {
24052416 ...old ,
2417+ resources : resourcesRef . current . filter ( ( r ) => r . id !== 'streaming-file' ) ,
24062418 messages : [ ...old . messages , cachedUserMsg ] ,
24072419 activeStreamId : userMessageId ,
24082420 }
@@ -2420,16 +2432,6 @@ export function useChat(
24202432 : undefined ,
24212433 } ) )
24222434
2423- const messageContexts = contexts ?. map ( ( c ) => ( {
2424- kind : c . kind ,
2425- label : c . label ,
2426- ...( 'workflowId' in c && c . workflowId ? { workflowId : c . workflowId } : { } ) ,
2427- ...( 'knowledgeId' in c && c . knowledgeId ? { knowledgeId : c . knowledgeId } : { } ) ,
2428- ...( 'tableId' in c && c . tableId ? { tableId : c . tableId } : { } ) ,
2429- ...( 'fileId' in c && c . fileId ? { fileId : c . fileId } : { } ) ,
2430- ...( 'folderId' in c && c . folderId ? { folderId : c . folderId } : { } ) ,
2431- } ) )
2432-
24332435 setMessages ( ( prev ) => [
24342436 ...prev ,
24352437 {
0 commit comments