@@ -2412,18 +2412,30 @@ export function useChat(
24122412 : undefined
24132413
24142414 const requestChatId = selectedChatIdRef . current ?? chatIdRef . current
2415+ const messageContexts = contexts ?. map ( ( c ) => ( {
2416+ kind : c . kind ,
2417+ label : c . label ,
2418+ ...( 'workflowId' in c && c . workflowId ? { workflowId : c . workflowId } : { } ) ,
2419+ ...( 'knowledgeId' in c && c . knowledgeId ? { knowledgeId : c . knowledgeId } : { } ) ,
2420+ ...( 'tableId' in c && c . tableId ? { tableId : c . tableId } : { } ) ,
2421+ ...( 'fileId' in c && c . fileId ? { fileId : c . fileId } : { } ) ,
2422+ ...( 'folderId' in c && c . folderId ? { folderId : c . folderId } : { } ) ,
2423+ } ) )
2424+
24152425 if ( requestChatId ) {
24162426 const cachedUserMsg : PersistedMessage = {
24172427 id : userMessageId ,
24182428 role : 'user' as const ,
24192429 content : message ,
24202430 timestamp : new Date ( ) . toISOString ( ) ,
24212431 ...( storedAttachments && { fileAttachments : storedAttachments } ) ,
2432+ ...( messageContexts && messageContexts . length > 0 ? { contexts : messageContexts } : { } ) ,
24222433 }
24232434 queryClient . setQueryData < TaskChatHistory > ( taskKeys . detail ( requestChatId ) , ( old ) => {
24242435 return old
24252436 ? {
24262437 ...old ,
2438+ resources : resourcesRef . current . filter ( ( r ) => r . id !== 'streaming-file' ) ,
24272439 messages : [ ...old . messages , cachedUserMsg ] ,
24282440 activeStreamId : userMessageId ,
24292441 }
@@ -2441,16 +2453,6 @@ export function useChat(
24412453 : undefined ,
24422454 } ) )
24432455
2444- const messageContexts = contexts ?. map ( ( c ) => ( {
2445- kind : c . kind ,
2446- label : c . label ,
2447- ...( 'workflowId' in c && c . workflowId ? { workflowId : c . workflowId } : { } ) ,
2448- ...( 'knowledgeId' in c && c . knowledgeId ? { knowledgeId : c . knowledgeId } : { } ) ,
2449- ...( 'tableId' in c && c . tableId ? { tableId : c . tableId } : { } ) ,
2450- ...( 'fileId' in c && c . fileId ? { fileId : c . fileId } : { } ) ,
2451- ...( 'folderId' in c && c . folderId ? { folderId : c . folderId } : { } ) ,
2452- } ) )
2453-
24542456 setMessages ( ( prev ) => [
24552457 ...prev ,
24562458 {
0 commit comments