Suppress model-switch warning on empty chat threads

Don't show "Model changed for this chat" toast when the thread has
no messages. On a fresh page load with a stale thread from a previous
session, this warning is confusing. The warning is only useful
mid-conversation to alert about image compatibility with the new model.

When messages.length === 0, silently update the thread's modelId and
proceed with loading.
This commit is contained in:
Daniel Han 2026-03-16 06:46:16 +00:00
commit 042598d9f1

View file

@ -352,6 +352,18 @@ export function ChatPage(): ReactElement {
.where("threadId")
.equals(activeThreadId)
.toArray();
if (messages.length === 0) {
// No history -- just switch silently
await db.threads.update(activeThreadId, { modelId: value });
await selectModel({
id: value,
isLora: meta?.isLora,
ggufVariant: meta?.ggufVariant,
isDownloaded: meta?.isDownloaded,
expectedBytes: meta?.expectedBytes,
});
return;
}
const hasImage = messages.some(messageHasImage);
const targetModel = modelsFromStore.find((model) => model.id === value);
const nonVisionWithImages = hasImage && targetModel?.isVision === false;