Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: applying model config in one multi-chat card no longer overrides sibling cards (#17866)

chanx91dcecd2b9c5
diff --git a/web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx b/web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
index 22cf808fd4..634404f5ff 100644
--- a/web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
+++ b/web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
@@ -158,9 +158,22 @@ const ChatCard = forwardRef(function ChatCard(
const { data: currentDialog } = useFetchChat();
const findLlmByUuid = useFindLlmByUuid();
+ // Each card must keep its own independently selected model after the initial
+ // sync. Without this guard, clicking "Apply" in one card patches the dialog
+ // (which invalidates [FetchChat] and refetches currentDialog), and the
+ // changed currentDialog.llm_id would then overwrite every other card's
+ // llm_id via this effect. Sync only when dialogId changes (initial load or
+ // conversation switch), not when currentDialog.llm_id changes due to Apply.
+ const syncedDialogIdRef = useRef<string | undefined>(undefined);
useLayoutEffect(() => {
- form.setValue('llm_id', currentDialog?.llm_id || '');
- }, [currentDialog?.llm_id, form]);
+ if (
+ syncedDialogIdRef.current !== dialogId &&
+ currentDialog?.llm_id
+ ) {
+ form.setValue('llm_id', currentDialog.llm_id);
+ syncedDialogIdRef.current = dialogId;
+ }
+ }, [currentDialog?.llm_id, dialogId, form]);
const isLatestChat = idx === chatBoxIds.length - 1;
@@ -176,6 +189,7 @@ const ChatCard = forwardRef(function ChatCard(
params: {
...currentDialog,
llm_id: llmId,
+ tenant_llm_id: llmId,
llm_setting: {
...omit(values, 'llm_id'),
model_type: findLlmByUuid(llmId)?.model_type || 'chat',