fix: handle undefined model in createMessagePair function (#20663)

- Add a null check when looking up model to prevent JavaScript error when trying to add a message pair in a chat with an invalid/corrupt model ID.
This commit is contained in:
G30
2026-01-15 01:43:25 -05:00
committed by GitHub
parent de0cbb9073
commit 1555252c4a

View File

@@ -1282,6 +1282,11 @@
const modelId = selectedModels[0];
const model = $models.filter((m) => m.id === modelId).at(0);
if (!model) {
toast.error($i18n.t('Model not found'));
return;
}
const messages = createMessagesList(history, history.currentId);
const parentMessage = messages.length !== 0 ? messages.at(-1) : null;