Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(chat): every answer records the model that wrote it, and the chat says so

purple04c51ed2fcd3
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index 1f3ed0e0..829756df 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -15,6 +15,7 @@ import { useSettingsStore } from '../../stores/settingsStore'
import { FileText, ChevronDown, Download, Wrench, Radio, RefreshCw, X } from 'lucide-react'
import { PluginsDropdown } from './PluginsDropdown'
import { ModelSelector } from '../models/ModelSelector'
+import { ConversationModelNote } from './ConversationModelNote'
import { GoalBar } from './GoalBar'
import { PlanBar } from './PlanBar'
import { LoopBar } from './LoopBar'
@@ -348,7 +349,14 @@ export function ChatView() {
// mode has here. Plain chat leaves "/cmd" as ordinary text.
slashCommands={isAgentActive}
onAttachDocs={appMode !== 'cloud' ? () => setRagPanelOpen(true) : undefined}
- composerModel={<ModelSelector openUpward />}
+ composerModel={
+ <div className="flex items-center gap-1.5">
+ {/* What this chat's answers were written by, when that is
+ not what the picker says (Meldung 4, R5 re-measure). */}
+ <ConversationModelNote />
+ <ModelSelector openUpward />
+ </div>
+ }
// No plan lives here. The prompt window is the prompt window
// (David, 2026-08-22): the plan band sits under the header row
// above, next to the other standing status controls.
diff --git a/src/components/chat/ConversationModelNote.tsx b/src/components/chat/ConversationModelNote.tsx
new file mode 100644
index 00000000..5c745f5f
--- /dev/null
+++ b/src/components/chat/ConversationModelNote.tsx
@@ -0,0 +1,41 @@
+/**
+ * What the open chat actually ran on, when that is not what the picker beside
+ * it says.
+ *
+ * Meldung 4 of the R5 re-measure on the 2.6.7 Windows build (2026-08-30). The
+ * only model name near a chat was the picker's, and the picker names the
+ * global choice. So opening a 13 hour old chat while the pick stood on
+ * Qwen3-4B put "Qwen3-4B" beside a transcript Hermes had written, three times
+ * over in three measured cases.
+ *
+ * The picker is not moved: it says what the NEXT answer runs on, which is its
+ * job and is true. This says what the answers on screen came from, which
+ * nothing said. It is sourced from the conversation alone (the last assistant
+ * turn's own record, falling back to the conversation field for chats from
+ * before that record existed) and never from the global pick, and it is drawn
+ * only when the two differ, so a chat continuing on its own model shows one
+ * name and not the same name twice.
+ */
+
+import { useChatStore } from '../../stores/chatStore'
+import { useModelStore } from '../../stores/modelStore'
+import { conversationModel, conversationModelDiffers } from '../../lib/conversation-model'
+import { displayModelName } from '../../api/providers/registry'
+
+export function ConversationModelNote() {
+ const conv = useChatStore((s) => s.conversations.find((c) => c.id === s.activeConversationId))
+ const activeModel = useModelStore((s) => s.activeModel)
+
+ if (!conversationModelDiffers(conv, activeModel)) return null
+ const ran = conversationModel(conv)
+
+ return (
+ <span
+ className="hidden sm:flex items-center gap-1 h-[26px] px-2 rounded-md border border-white/[0.06] text-[0.6rem] text-gray-500 dark:text-gray-400 shrink-0"
+ title={`The answers in this chat were written by ${ran}. The picker beside this is what the next answer would run on.`}
+ >
+ <span className="opacity-70">answers:</span>
+ <span className="max-w-[110px] truncate leading-none">{displayModelName(ran).split(':')[0]}</span>
+ </span>
+ )
+}
diff --git a/src/components/chat/MessageBubble.tsx b/src/components/chat/MessageBubble.tsx
index ad77165c..252acf5e 100644
--- a/src/components/chat/MessageBubble.tsx
+++ b/src/components/chat/MessageBubble.tsx
@@ -209,8 +209,12 @@ function MessageBubbleImpl({ message, onRegenerate, onEdit, pendingApprovalId, o
</div>
<div className="max-w-[80%] space-y-0.5">
- {/* Group chat: name the speaker. Only group turns carry modelId, so
- single-model chats render exactly as before. */}
+ {/* Name the model that produced this answer. Group chats have always
+ done this; since the R5 re-measure (2026-08-30) every assistant
+ turn carries it, because the app had no model name at a single
+ answer anywhere and therefore no way to be honest about an older
+ chat. Turns from before that carry none and get no line, rather
+ than a guess. */}
{!isUser && message.modelId && (
<div className="text-[0.55rem] font-mono text-gray-400 dark:text-gray-500 pl-1">{message.modelId}</div>
)}
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index 9780c10c..6905ddda 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -400,6 +400,11 @@ export function useAgentChat() {
role: 'assistant' as const,
content: '',
thinking: '',
+ // Same record the plain path writes (Meldung 4, R5 re-measure
+ // 2026-08-30): the answer names the model that produced it. modelToUse
+ // rather than activeModel, because that is the runner this turn goes to,
+ // including the "-agent" variant when one exists.
+ modelId: modelToUse,
timestamp: Date.now(),
agentBlocks: [],
}
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index 432a65d5..d1d7a3ec 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -437,6 +437,12 @@ export function useChat() {
role: "assistant" as const,
content: "",
thinking: "",
+ // The answer records the model that produced it (Meldung 4, R5
+ // re-measure 2026-08-30). The conversation field alone could not: it
+ // holds one name for a chat two models may have answered in, and it is
+ // rewritten every time the picker moves. Written here, at the turn, so
+ // it is a measurement and not a guess.
+ modelId: activeModel,
timestamp: Date.now(),
}
useChatStore.getState().addMessage(convId, assistantMessage)
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index 905e8945..0f4b45cb 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -460,6 +460,9 @@ export function useCodex() {
// (default collapsed; live-streams while running) — David 2026-06-12.
const assistantMsg = {
id: uuid(), role: 'assistant' as const, content: '', thinking: '', timestamp: Date.now(), agentBlocks: [],
+ // The answer records the model that produced it, same as both chat
+ // paths (Meldung 4, R5 re-measure 2026-08-30).
+ modelId: activeModel,
...(slash ? { slashCommand: slash.command.name } : {}),
}
useChatStore.getState().addMessage(convId, assistantMsg)
diff --git a/src/lib/__tests__/conversation-model.test.ts b/src/lib/__tests__/conversation-model.test.ts
new file mode 100644
index 00000000..008240a7
--- /dev/null
+++ b/src/lib/__tests__/conversation-model.test.ts
@@ -0,0 +1,158 @@
+/**
+ * Meldung 4 of the R5 re-measure on the 2.6.7 Windows build
+ * (2026-08-30, ergebnis-r5-nachmessung.md).
+ *
+ * The app names a model beside every chat and that name was always the global
+ * pick, never the chat's. Three cases were measured on the box:
+ *
+ * 1. global set to mlabonne_gemma-3-4b, then the 12 hour old chat PROBE-C
+ * opened. It read mlabonne_gemma-3-4b-it-abliterated-Q4_K_M. Every answer
+ * in that chat came from Hermes.
+ * 2. global set to Qwen3-4B, then KANARIE2 (13 h old) and R5N-A opened. Both
+ * read Qwen3-4B-Q4_K_M.
+ * 3. the display read Hermes-3-Llama-3.2-3B while the last answer of the
+ * open chat came provably from Qwen3-4B-Q4_K_M.
+ *
+ * The saved history could not have answered better. It held a `model` field
+ * per conversation and none per message (0 hits for a message level "model" in
+ * store_backup.json), so once two models have answered in one chat the model
+ * of the last answer was not derivable at all. And even a single-answer chat
+ * was wrong: a slip into Cloud mode sent one question to
+ * google/gemma-4-26B-A4B-it while the record for that conversation read
+ * openai::Hermes-3-Llama-3.2-3B.Q4_K_M.
+ *
+ * Run: npx vitest run src/lib/__tests__/conversation-model.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+import { conversationModel, conversationModelDiffers } from '../conversation-model'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const src = (p: string) => readFileSync(resolve(here, '../..', p), 'utf8')
+
+const HERMES = 'openai::Hermes-3-Llama-3.2-3B.Q4_K_M'
+const QWEN = 'openai::Qwen3-4B-Q4_K_M'
+const GEMMA = 'openai::mlabonne_gemma-3-4b-it-abliterated-Q4_K_M'
+const CLOUD = 'lu-cloud::google/gemma-4-26B-A4B-it'
+
+const user = (content = 'q') => ({ role: 'user' as const, content })
+const answer = (modelId?: string) => ({ role: 'assistant' as const, modelId })
+
+describe('a conversation says which model wrote its answers', () => {
+ it('THE FIX: case 1 of the re-measure, a Hermes chat opened under a Gemma pick', () => {
+ const conv = {
+ // The record on the conversation followed the picker at some point, so
+ // it cannot be trusted either. The answers can.
+ model: GEMMA,
+ messages: [user(), answer(HERMES), user(), answer(HERMES)],
+ }
+ expect(conversationModel(conv)).toBe(HERMES)
+ expect(conversationModelDiffers(conv, GEMMA)).toBe(true)
+ })
+
+ it('THE FIX: case 3, two models answered in one chat and the last one counts', () => {
+ const conv = {
+ model: HERMES,
+ messages: [user(), answer(HERMES), user(), answer(QWEN)],
+ }
+ expect(conversationModel(conv)).toBe(QWEN)
+ })
+
+ it('THE FIX: the cloud slip, one answer and the conversation field disagreeing', () => {
+ const conv = { model: HERMES, messages: [user(), answer(CLOUD)] }
+ expect(conversationModel(conv)).toBe(CLOUD)
+ })
+
+ it('THE FIX: an old chat with no model on its answers claims nothing new', () => {
+ // The honest answer for a chat written before the record existed is the
+ // conversation field, which is exactly what was known before and no more.
+ const conv = { model: HERMES, messages: [user(), answer(undefined)] }
+ expect(conversationModel(conv)).toBe(HERMES)
+ })
+
+ it('THE FIX: an old chat under a different pick still reports its own field', () => {
+ const conv = { model: HERMES, messages: [user(), answer(undefined)] }
+ expect(conversationModelDiffers(conv, QWEN)).toBe(true)
+ expect(conversationModel(conv)).toBe(HERMES)
+ })
+
+ it('NEGATIVE CONTROL: the global pick is never the answer', () => {
+ // The whole defect in one line. Whatever is picked globally, a chat that
+ // knows nothing says nothing, it does not borrow the pick.
+ expect(conversationModel({ model: '', messages: [] })).toBe('')
+ expect(conversationModel(null)).toBe('')
+ expect(conversationModel(undefined)).toBe('')
+ })
+
+ it('NEGATIVE CONTROL: a chat that has never answered reports no difference', () => {
+ // Nothing to be honest or dishonest about yet, and the picker beside it
+ // already says what the next answer would run on.
+ expect(conversationModelDiffers({ model: HERMES, messages: [user()] }, QWEN)).toBe(false)
+ expect(conversationModelDiffers({ model: '', messages: [] }, QWEN)).toBe(false)
+ })
+
+ it('NEGATIVE CONTROL: a chat continuing on its own model does not print it twice', () => {
+ const conv = { model: QWEN, messages: [user(), answer(QWEN)] }
+ expect(conversationModelDiffers(conv, QWEN)).toBe(false)
+ })
+
+ it('NEGATIVE CONTROL: a blank modelId is not a claim', () => {
+ const conv = { model: HERMES, messages: [user(), answer(' ')] }
+ expect(conversationModel(conv)).toBe(HERMES)
+ })
+})
+
+describe('every assistant turn records the model that produced it', () => {
+ it('THE FIX: plain chat writes the model onto the answer', () => {
+ expect(src('hooks/useChat.ts')).toMatch(/modelId: activeModel,/)
+ })
+
+ it('THE FIX: the agent path writes the runner it actually resolved', () => {
+ expect(src('hooks/useAgentChat.ts')).toMatch(/modelId: modelToUse,/)
+ })
+
+ it('THE FIX: the coding path writes it too', () => {
+ expect(src('hooks/useCodex.ts')).toMatch(/modelId: activeModel,/)
+ })
+
+ it('THE FIX: the answer bubble already renders that name, for every chat', () => {
+ expect(src('components/chat/MessageBubble.tsx'))
+ .toMatch(/\{!isUser && message\.modelId && \(/)
+ })
+})
+
+describe('the conversation displays read the conversation, not the picker', () => {
+ it('THE FIX: the export header names the model of the last answer', () => {
+ expect(src('lib/chat-export.ts')).toMatch(/_Model: \$\{conversationModelOf\(conversation\)\}/)
+ })
+
+ it('THE FIX: the composer says what the open chat ran on when it differs', () => {
+ const note = src('components/chat/ConversationModelNote.tsx')
+ expect(note).toMatch(/conversationModelDiffers\(conv, activeModel\)/)
+ expect(src('components/chat/ChatView.tsx')).toMatch(/<ConversationModelNote \/>/)
+ })
+
+ it('NEGATIVE CONTROL: nothing writes a model into an old message', () => {
+ // No migration touches modelId. A guess written to disk is
+ // indistinguishable from a measurement a week later, which is the whole
+ // reason this defect was hard to see in the first place. The existing
+ // rehydrate migration walks the same messages (it repairs agentBlocks),
+ // so this pins that it leaves the model field alone.
+ const store = src('stores/chatStore.ts')
+ const migration = store.slice(
+ store.indexOf('export function migratePersistedChat'),
+ store.indexOf('interface ChatState'),
+ )
+ expect(migration).not.toMatch(/modelId/)
+ expect(src('lib/conversation-model.ts')).not.toMatch(/modelId\s*=/)
+ })
+
+ it('NEGATIVE CONTROL: the picker still shows the pick, it was never wrong about that', () => {
+ // ModelSelector answers "what does the next message run on". Moving it
+ // onto the conversation would have made it lie in the other direction.
+ expect(src('components/models/ModelSelector.tsx'))
+ .toMatch(/const activeDisplayName = activeModel/)
+ })
+})
diff --git a/src/lib/chat-export.ts b/src/lib/chat-export.ts
index 221ca098..40e7f5ac 100644
--- a/src/lib/chat-export.ts
+++ b/src/lib/chat-export.ts
@@ -8,11 +8,17 @@
import type { Conversation } from '../types/chat'
import { isTauri, backendCall } from '../api/backend'
+import { conversationModelOf } from './conversation-model'
export function exportAsMarkdown(conversation: Conversation): string {
const lines: string[] = []
lines.push(`# ${conversation.title}`)
- lines.push(`_Model: ${conversation.model} | ${new Date(conversation.createdAt).toLocaleString()}_`)
+ // The model of the last answer, not the conversation field. That field is
+ // rewritten every time the picker moves, so an export could name a model
+ // that produced none of the text below it (Meldung 4, R5 re-measure
+ // 2026-08-30). Old chats whose answers carry no model fall back to the
+ // field, which is all that was ever known about them.
+ lines.push(`_Model: ${conversationModelOf(conversation)} | ${new Date(conversation.createdAt).toLocaleString()}_`)
lines.push('')
if (conversation.systemPrompt) {
diff --git a/src/lib/conversation-model.ts b/src/lib/conversation-model.ts
new file mode 100644
index 00000000..64577616
--- /dev/null
+++ b/src/lib/conversation-model.ts
@@ -0,0 +1,88 @@
+/**
+ * Which model a conversation ran on.
+ *
+ * Meldung 4 of the R5 re-measure on the 2.6.7 Windows build (2026-08-30). The
+ * app names a model beside every chat, and that name was always the globally
+ * picked one, never the chat's. Three measured cases on the box:
+ *
+ * - global set to mlabonne_gemma-3-4b, then the 12 hour old chat PROBE-C
+ * opened: it read mlabonne_gemma-3-4b. Every answer in it came from Hermes.
+ * - global set to Qwen3-4B, then KANARIE2 (13 h old) and R5N-A opened: both
+ * read Qwen3-4B.
+ * - the display read Hermes while the last answer of the open chat came
+ * provably from Qwen3-4B.
+ *
+ * The saved history could not have answered better: it kept a `model` field
+ * per CONVERSATION and none per message (0 hits for a message level "model" in
+ * store_backup.json). Once two models have answered in one chat, the model of
+ * the last answer is not derivable from that at all. And a single-answer chat
+ * was wrong too: a slip into Cloud mode sent one question to
+ * google/gemma-4-26B-A4B-it while the saved record for that same conversation
+ * read openai::Hermes-3-Llama-3.2-3B.Q4_K_M.
+ *
+ * So every assistant turn now records the model that produced it, and this is
+ * the one reader for "which model does this conversation speak with". It never
+ * looks at the global pick.
+ *
+ * Old messages carry no model field and none is invented for them. No
+ * migration writes anything into them either: a guess written to disk is
+ * indistinguishable from a measurement a week later. They fall back to the
+ * conversation field, which is exactly what was known before and no more.
+ */
+
+import type { Conversation, Message } from '../types/chat'
+
+/** The conversation shape this needs. Kept structural so a caller with a
+ * partial conversation (a test, an export of one chat) can ask too. */
+export interface ConversationModelSource {
+ model?: string
+ messages?: Pick<Message, 'role' | 'modelId'>[]
+}
+
+/**
+ * The model of the last assistant answer, or the conversation field when no
+ * answer names one, or '' when neither does.
+ *
+ * `''` on purpose rather than the active pick: a chat that has never run is a
+ * chat with nothing to claim, and the picker beside it already says what the
+ * NEXT answer would run on.
+ */
+export function conversationModel(conv: ConversationModelSource | null | undefined): string {
+ if (!conv) return ''
+ const messages = conv.messages ?? []
+ for (let i = messages.length - 1; i >= 0; i--) {
+ const m = messages[i]
+ if (m.role !== 'assistant') continue
+ const id = m.modelId?.trim()
+ if (id) return id
+ // An assistant turn from before this was recorded. It is the newest thing
+ // we have and it says nothing, so nothing further back can say more:
+ // fall through to what the conversation knows.
+ break
+ }
+ return conv.model?.trim() ?? ''
+}
+
+/**
+ * Does the open chat need to say what it ran on, next to a picker that says
+ * something else.
+ *
+ * Only then. A chat whose answers came from the model that is picked right now
+ * would just have the same name printed twice, and a chat with no answers yet
+ * has nothing to report.
+ */
+export function conversationModelDiffers(
+ conv: ConversationModelSource | null | undefined,
+ activeModel: string | null,
+): boolean {
+ const ran = conversationModel(conv)
+ if (!ran) return false
+ const hasAnswer = (conv?.messages ?? []).some((m) => m.role === 'assistant')
+ if (!hasAnswer) return false
+ return ran !== (activeModel ?? '')
+}
+
+/** Full conversation objects go through the same reader. */
+export function conversationModelOf(conv: Conversation): string {
+ return conversationModel(conv)
+}