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

This commit is contained in:
chanx
2026-08-05 17:11:33 +08:00
committed by GitHub
parent 479c3efd74
commit 91dcecd2b9

View File

@@ -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',