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.

feat(chat): group chat, two to four models answering in turn (v1)

purple304a3ac7e557
diff --git a/src/components/chat/MessageBubble.tsx b/src/components/chat/MessageBubble.tsx
index f31e4099..e50b7d2f 100644
--- a/src/components/chat/MessageBubble.tsx
+++ b/src/components/chat/MessageBubble.tsx
@@ -207,6 +207,11 @@ 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. */}
+ {!isUser && message.modelId && (
+ <div className="text-[0.55rem] font-mono text-gray-400 dark:text-gray-500 pl-1">{message.modelId}</div>
+ )}
{/* Thinking block — auto-expands while this (last) turn is still
producing so the reasoning streams LIVE, then collapses (David 2026-06-04). */}
{!isUser && message.thinking && (
diff --git a/src/components/chat/PluginsDropdown.tsx b/src/components/chat/PluginsDropdown.tsx
index 8b5fd1e3..cc83c8d9 100644
--- a/src/components/chat/PluginsDropdown.tsx
+++ b/src/components/chat/PluginsDropdown.tsx
@@ -1,8 +1,10 @@
import { useState } from 'react'
-import { Plug, ChevronDown, Bone, User, Wrench } from 'lucide-react'
+import { Plug, ChevronDown, Bone, User, Users, Wrench } from 'lucide-react'
import { useSettingsStore } from '../../stores/settingsStore'
import { useChatStore } from '../../stores/chatStore'
+import { useModelStore } from '../../stores/modelStore'
import { useToolSupport } from '../../hooks/useToolSupport'
+import { GROUP_CHAT_MAX, isGroupChat } from '../../lib/group-chat'
import type { CavemanMode } from '../../types/settings'
const CAVEMAN_MODES: { value: CavemanMode; label: string; desc: string }[] = [
@@ -18,6 +20,7 @@ export function PluginsDropdown({ openUpward = false }: { openUpward?: boolean }
const [open, setOpen] = useState(false)
const [cavemanOpen, setCavemanOpen] = useState(false)
const [personaOpen, setPersonaOpen] = useState(false)
+ const [groupOpen, setGroupOpen] = useState(false)
const { getActivePersona, setActivePersona } = useSettingsStore()
const activePersona = getActivePersona()
const allPersonas = useSettingsStore((s) => s.personas)
@@ -48,6 +51,13 @@ export function PluginsDropdown({ openUpward = false }: { openUpward?: boolean }
// chat" bug David flagged.
const personaEnabledOnChat = activeConv?.personaEnabled === true
+ // Group chat v1 (Nurse KillJoy): the selection lives on the conversation,
+ // exactly like the persona flag, so every chat keeps its own line-up.
+ const setGroupModels = useChatStore((s) => s.setGroupModels)
+ const models = useModelStore((s) => s.models)
+ const groupModels = activeConv?.groupModels ?? []
+ const isGroupActive = isGroupChat(activeConv?.groupModels)
+
const isCavemanActive = cavemanMode && cavemanMode !== 'off'
const isPersonaActive = activePersona && activePersona.id !== 'unrestricted' && personaEnabledOnChat
const currentCaveman = CAVEMAN_MODES.find((m) => m.value === (cavemanMode || 'off'))
@@ -60,11 +70,12 @@ export function PluginsDropdown({ openUpward = false }: { openUpward?: boolean }
>
<Plug size={10} />
<span>Plugins</span>
- {(isCavemanActive || isPersonaActive || chatToolsEnabled) && (
+ {(isCavemanActive || isPersonaActive || chatToolsEnabled || isGroupActive) && (
<div className="flex gap-0.5">
{chatToolsEnabled && <div className="w-1 h-1 rounded-full bg-blue-400" />}
{isCavemanActive && <div className="w-1 h-1 rounded-full bg-amber-400" />}
{isPersonaActive && <div className="w-1 h-1 rounded-full bg-green-400" />}
+ {isGroupActive && <div className="w-1 h-1 rounded-full bg-purple-400" />}
</div>
)}
<ChevronDown size={8} className={`transition-transform ${open ? 'rotate-180' : ''}`} />
@@ -217,6 +228,72 @@ export function PluginsDropdown({ openUpward = false }: { openUpward?: boolean }
)}
</div>
+ <div className="border-t border-gray-200 dark:border-white/[0.06] my-1" />
+
+ {/* ── Group chat (v1) ─────────────────────────── */}
+ <div className="px-2.5">
+ <button
+ onClick={() => { setGroupOpen(!groupOpen); setCavemanOpen(false); setPersonaOpen(false) }}
+ className="w-full flex items-center justify-between py-1.5"
+ >
+ <div className="flex items-center gap-1.5">
+ <Users size={10} className={isGroupActive ? 'text-purple-400' : 'text-gray-400'} />
+ <span className="text-[0.6rem] font-medium text-gray-600 dark:text-gray-300">Group chat</span>
+ <span className={`text-[0.55rem] ${isGroupActive ? 'text-purple-400' : 'text-gray-500'}`}>
+ {isGroupActive ? `${groupModels.length} models` : 'Off'}
+ </span>
+ </div>
+ <ChevronDown size={9} className={`text-gray-500 transition-transform ${groupOpen ? 'rotate-180' : ''}`} />
+ </button>
+
+ {groupOpen && (activeConvId ? (
+ <div className="pb-1.5 space-y-0.5 max-h-[180px] overflow-y-auto scrollbar-thin">
+ <p className="px-2 pb-0.5 text-[0.5rem] leading-snug text-gray-400">
+ Pick 2 to {GROUP_CHAT_MAX} models. They answer in turn on every message, and each sees what the others said.
+ </p>
+ {models.map((m) => {
+ const on = groupModels.includes(m.name)
+ const full = !on && groupModels.length >= GROUP_CHAT_MAX
+ return (
+ <button
+ key={m.name}
+ disabled={full}
+ onClick={() =>
+ setGroupModels(
+ activeConvId,
+ on ? groupModels.filter((x) => x !== m.name) : [...groupModels, m.name],
+ )
+ }
+ className={`w-full flex items-center gap-1.5 px-2 py-1 rounded text-left transition-colors ${
+ on
+ ? 'bg-purple-500/10 text-purple-600 dark:text-purple-400'
+ : full
+ ? 'text-gray-400/50 cursor-default'
+ : 'text-gray-500 hover:bg-gray-50 dark:hover:bg-white/[0.04] hover:text-gray-700 dark:hover:text-gray-300'
+ }`}
+ >
+ {on && <div className="w-1 h-1 rounded-full bg-purple-400 shrink-0" />}
+ <span className="text-[0.55rem] font-medium truncate">{m.name}</span>
+ </button>
+ )
+ })}
+ {groupModels.length === 1 && (
+ <p className="px-2 text-[0.5rem] text-gray-400">One more model turns this into a group.</p>
+ )}
+ {groupModels.length > 0 && (
+ <button
+ onClick={() => setGroupModels(activeConvId, [])}
+ className="w-full px-2 py-1 rounded text-left text-[0.55rem] text-gray-500 hover:bg-gray-50 dark:hover:bg-white/[0.04] hover:text-gray-700 dark:hover:text-gray-300 transition-colors"
+ >
+ Turn off
+ </button>
+ )}
+ </div>
+ ) : (
+ <p className="pb-1.5 px-2 text-[0.5rem] text-gray-400">Open a chat first, the group lives on the conversation.</p>
+ ))}
+ </div>
+
</div>
</>
)}
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index 40aa011b..db5453ea 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -27,6 +27,7 @@ import { isThinkingCompatible, isPlainTextPlanner } from "../lib/model-compatibi
import { stripNonCanonicalTags, finalStripThinkingTags } from "../lib/thinking-stripper"
import { isMultimodalUnsupportedError, MULTIMODAL_UNSUPPORTED_MESSAGE } from "../lib/ollama-errors"
import type { ImageAttachment, Message } from "../types/chat"
+import { isGroupChat, groupSystemPrompt, groupHistory } from "../lib/group-chat"
import { log } from "../lib/logger"
/**
@@ -49,6 +50,133 @@ function lastMediaFromBlocks(m: Message): { kind: 'image' | 'video'; args?: Reco
return null
}
+/** One model's turn in a group round. Deliberately the PLAIN conversation
+ * path only: no RAG, no memory injection, no chat-tools, no caveman. The
+ * group is talk between models; every knob it skips belongs to the
+ * single-model paths and their tests. */
+async function runGroupTurn(convId: string, model: string, allModels: string[], abort: AbortController) {
+ const { settings } = useSettingsStore.getState()
+ const conv = useChatStore.getState().conversations.find((c) => c.id === convId)
+ if (!conv) return
+
+ const assistantMessage: Message = {
+ id: uuid(),
+ role: 'assistant',
+ content: '',
+ thinking: '',
+ modelId: model,
+ timestamp: Date.now(),
+ }
+ useChatStore.getState().addMessage(convId, assistantMessage)
+
+ const personaPrompt = conv.personaEnabled === true ? conv.systemPrompt : ''
+ const messages = [
+ { role: 'system' as const, content: groupSystemPrompt(model, allModels, personaPrompt) },
+ ...groupHistory(conv.messages, model),
+ ]
+
+ const providerId = getProviderIdFromModel(model)
+ const canThink = isThinkingCompatible(model)
+ const useThinking: boolean | undefined = canThink ? settings.thinkingEnabled === true : undefined
+ const keepThinking = useThinking === true
+
+ let contentAcc = ''
+ let thinkingAcc = ''
+ let inThink = false
+ let discardBuf = ''
+ let frameScheduled = false
+
+ try {
+ const { provider, modelId } = getProviderForModel(model)
+ let effectiveCtx: number | undefined = settings.contextWindowOverride || undefined
+ if (providerId === 'ollama') {
+ try {
+ effectiveCtx = effectiveContextWindow(await getModelContextCached(modelId), settings.contextWindowOverride)
+ } catch { /* keep override-or-undefined */ }
+ }
+
+ const stream = provider.chatStream(modelId, messages, {
+ temperature: settings.temperature,
+ topP: settings.topP,
+ topK: settings.topK,
+ maxTokens: settings.maxTokens || undefined,
+ contextWindow: effectiveCtx,
+ thinking: useThinking,
+ signal: abort.signal,
+ })
+
+ for await (const chunk of stream) {
+ if (abort.signal.aborted) break
+ if (chunk.thinking && keepThinking) thinkingAcc += chunk.thinking
+ if (chunk.content) {
+ for (const char of chunk.content) {
+ if (!inThink) {
+ contentAcc += char
+ if (contentAcc.endsWith('<think>')) {
+ contentAcc = contentAcc.slice(0, -7)
+ inThink = true
+ }
+ } else if (keepThinking) {
+ thinkingAcc += char
+ if (thinkingAcc.endsWith('</think>')) {
+ thinkingAcc = thinkingAcc.slice(0, -8)
+ inThink = false
+ }
+ } else {
+ discardBuf += char
+ if (discardBuf.endsWith('</think>')) {
+ discardBuf = ''
+ inThink = false
+ }
+ }
+ }
+ }
+ if ((chunk.content || (chunk.thinking && keepThinking)) && !frameScheduled) {
+ frameScheduled = true
+ requestAnimationFrame(() => {
+ useChatStore.getState().updateMessageContent(convId, assistantMessage.id, stripNonCanonicalTags(contentAcc))
+ if (keepThinking && thinkingAcc) {
+ useChatStore.getState().updateMessageThinking(convId, assistantMessage.id, thinkingAcc)
+ }
+ frameScheduled = false
+ })
+ }
+ if (chunk.done) {
+ contentAcc = finalStripThinkingTags(contentAcc, keepThinking)
+ useChatStore.getState().updateMessageContent(convId, assistantMessage.id, contentAcc)
+ if (keepThinking && thinkingAcc) {
+ useChatStore.getState().updateMessageThinking(convId, assistantMessage.id, thinkingAcc)
+ }
+ if (chunk.promptEvalCount || chunk.evalCount) {
+ const promptTokens = chunk.promptEvalCount || 0
+ const completionTokens = chunk.evalCount || 0
+ useChatStore.getState().updateMessageUsage(convId, assistantMessage.id, {
+ promptTokens,
+ completionTokens,
+ totalTokens: promptTokens + completionTokens,
+ })
+ }
+ }
+ }
+ if (!abort.signal.aborted && !contentAcc.trim()) {
+ useChatStore.getState().updateMessageContent(
+ convId,
+ assistantMessage.id,
+ `${model} didn't return a visible answer that time.`,
+ )
+ }
+ } catch (err) {
+ if ((err as Error).name !== 'AbortError') {
+ syncOllamaHealthFromError(err)
+ useChatStore.getState().updateMessageContent(
+ convId,
+ assistantMessage.id,
+ `Error from ${model}: ${(err as Error).message || 'Connection failed'}`,
+ )
+ }
+ }
+}
+
export function useChat() {
const [isGenerating, setIsGenerating] = useState(false)
const [isLoadingModel, setIsLoadingModel] = useState(false)
@@ -78,6 +206,38 @@ export function useChat() {
useGenerationStore.getState().abortConversation(useChatStore.getState().activeConversationId)
}, [])
+ /** One group round: the user's line goes in once, then every group model
+ * answers in turn on the shared, attribution-tagged history. One abort
+ * controller spans the whole round, so Stop ends the round, not just the
+ * model that happened to be talking. */
+ const runGroupRound = useCallback(async (convId: string, content: string, images: ImageAttachment[] | undefined, models: string[]) => {
+ useChatStore.getState().addMessage(convId, {
+ id: uuid(),
+ role: 'user',
+ content,
+ images,
+ timestamp: Date.now(),
+ })
+
+ const abort = new AbortController()
+ abortRef.current = abort
+ useGenerationStore.getState().registerAborter(convId, () => abort.abort())
+ setIsGenerating(true)
+ useGenerationStore.getState().setGenerating(convId, true)
+ try {
+ for (const model of models) {
+ if (abort.signal.aborted) break
+ await runGroupTurn(convId, model, models, abort)
+ }
+ } finally {
+ setIsGenerating(false)
+ useGenerationStore.getState().setGenerating(convId, false)
+ useGenerationStore.getState().clearAborter(convId)
+ abortRef.current = null
+ void flushChatPersist()
+ }
+ }, [])
+
const sendMessage = useCallback(async (content: string, images?: ImageAttachment[]) => {
const { activeModel } = useModelStore.getState()
const { settings } = useSettingsStore.getState()
@@ -120,6 +280,17 @@ export function useChat() {
return agentChat.sendAgentMessage(content, images)
}
+ // Group chat v1 (Nurse KillJoy): two to four models answer in turn in
+ // ONE conversation. Runs BEFORE the chat-tools router on purpose: a
+ // group round is a conversation, never a tool run, and the agent path
+ // has already delegated above.
+ {
+ const groupConv = store.conversations.find((c) => c.id === store.activeConversationId)
+ if (groupConv && isGroupChat(groupConv.groupModels)) {
+ return runGroupRound(groupConv.id, content, images, groupConv.groupModels)
+ }
+ }
+
// Chat-Tools routing (David 2026-06-11): web/file/image/video should work
// in PLAIN chat without flipping to full Agent mode. We route a turn through
// the chat-tools executor when it needs one of those capabilities — either
diff --git a/src/lib/__tests__/group-chat.test.ts b/src/lib/__tests__/group-chat.test.ts
new file mode 100644
index 00000000..c5bbe3dc
--- /dev/null
+++ b/src/lib/__tests__/group-chat.test.ts
@@ -0,0 +1,119 @@
+// Group chat v1 (Nurse KillJoy): turn order, attribution tagging, and the
+// store half. Component wiring is source-guarded (no render harness here).
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { describe, it, expect, beforeEach } from 'vitest'
+import { isGroupChat, groupSystemPrompt, groupHistory, GROUP_CHAT_MAX } from '../group-chat'
+import { useChatStore } from '../../stores/chatStore'
+import type { Message } from '../../types/chat'
+
+const msg = (o: Partial<Message>): Message => ({
+ id: `m-${Math.random().toString(36).slice(2)}`,
+ role: 'user',
+ content: 'hello',
+ timestamp: Date.now(),
+ ...o,
+})
+
+describe('isGroupChat', () => {
+ it('needs at least two models', () => {
+ expect(isGroupChat(undefined)).toBe(false)
+ expect(isGroupChat([])).toBe(false)
+ expect(isGroupChat(['a'])).toBe(false)
+ expect(isGroupChat(['a', 'b'])).toBe(true)
+ expect(isGroupChat(['a', 'b', 'c', 'd'])).toBe(true)
+ })
+})
+
+describe('groupSystemPrompt', () => {
+ it('names the speaker and the other participants, not the speaker twice', () => {
+ const p = groupSystemPrompt('qwen', ['qwen', 'gemma', 'llama'], '')
+ expect(p).toContain('You are "qwen"')
+ expect(p).toContain('"gemma"')
+ expect(p).toContain('"llama"')
+ expect(p.indexOf('"qwen"')).toBe(p.lastIndexOf('"qwen"'))
+ })
+
+ it('keeps the persona prompt in front when the chat has one', () => {
+ const p = groupSystemPrompt('qwen', ['qwen', 'gemma'], 'You are a pirate.')
+ expect(p.startsWith('You are a pirate.')).toBe(true)
+ expect(p).toContain('You are "qwen"')
+ })
+})
+
+describe('groupHistory', () => {
+ const history: Message[] = [
+ msg({ role: 'user', content: 'what is love' }),
+ msg({ role: 'assistant', content: 'baby dont hurt me', modelId: 'gemma' }),
+ msg({ role: 'assistant', content: 'no more', modelId: 'qwen' }),
+ msg({ role: 'assistant', content: '' }),
+ ]
+
+ it('tags the OTHER models and leaves own turns clean', () => {
+ const forQwen = groupHistory(history, 'qwen')
+ expect(forQwen[1].content).toBe('[gemma] baby dont hurt me')
+ expect(forQwen[2].content).toBe('no more')
+ })
+
+ it('leaves user lines untouched and drops empty placeholders', () => {
+ const forQwen = groupHistory(history, 'qwen')
+ expect(forQwen[0]).toMatchObject({ role: 'user', content: 'what is love' })
+ expect(forQwen).toHaveLength(3)
+ })
+
+ it('carries image attachments through', () => {
+ const withImg = [msg({ role: 'user', content: 'look', images: [{ name: 'x.png', data: 'AAA', mimeType: 'image/png' }] })]
+ const out = groupHistory(withImg, 'qwen')
+ expect(out[0].images).toEqual([{ data: 'AAA', mimeType: 'image/png' }])
+ })
+})
+
+describe('chatStore.setGroupModels', () => {
+ beforeEach(() => {
+ useChatStore.setState({ conversations: [], activeConversationId: null })
+ })
+
+ it('stores the line-up on the conversation and caps it at four', () => {
+ const id = useChatStore.getState().createConversation('gemma4:12b', '', 'lu')
+ useChatStore.getState().setGroupModels(id, ['a', 'b', 'c', 'd', 'e'])
+ const conv = useChatStore.getState().conversations[0]
+ expect(conv.groupModels).toEqual(['a', 'b', 'c', 'd'])
+ expect(conv.groupModels!.length).toBe(GROUP_CHAT_MAX)
+ })
+
+ it('clearing turns the chat back into a single-model chat', () => {
+ const id = useChatStore.getState().createConversation('gemma4:12b', '', 'lu')
+ useChatStore.getState().setGroupModels(id, ['a', 'b'])
+ useChatStore.getState().setGroupModels(id, [])
+ expect(isGroupChat(useChatStore.getState().conversations[0].groupModels)).toBe(false)
+ })
+})
+
+describe('wiring (source guards)', () => {
+ const useChatSrc = readFileSync(join(__dirname, '../../hooks/useChat.ts'), 'utf8')
+ const bubbleSrc = readFileSync(join(__dirname, '../../components/chat/MessageBubble.tsx'), 'utf8')
+ const pluginsSrc = readFileSync(join(__dirname, '../../components/chat/PluginsDropdown.tsx'), 'utf8')
+
+ it('the group branch runs BEFORE the chat-tools router', () => {
+ const branch = useChatSrc.indexOf('isGroupChat(groupConv.groupModels)')
+ const router = useChatSrc.indexOf('resolveChatToolRoute(')
+ expect(branch).toBeGreaterThan(-1)
+ expect(router).toBeGreaterThan(-1)
+ expect(branch).toBeLessThan(router)
+ })
+
+ it('every group turn is labeled and one abort spans the whole round', () => {
+ expect(useChatSrc).toContain('modelId: model')
+ expect(useChatSrc).toContain('await runGroupTurn(convId, model, models, abort)')
+ expect(useChatSrc).toContain('if (abort.signal.aborted) break')
+ })
+
+ it('the bubble names the speaker only when a turn carries a model', () => {
+ expect(bubbleSrc).toContain('{!isUser && message.modelId && (')
+ })
+
+ it('the dropdown writes the line-up onto the active conversation', () => {
+ expect(pluginsSrc).toContain('setGroupModels(')
+ expect(pluginsSrc).toContain('GROUP_CHAT_MAX')
+ })
+})
diff --git a/src/lib/group-chat.ts b/src/lib/group-chat.ts
new file mode 100644
index 00000000..2f692133
--- /dev/null
+++ b/src/lib/group-chat.ts
@@ -0,0 +1,48 @@
+// Group chat v1 (Nurse KillJoy, Discord 2026-08-07): two to four models
+// answer in turn inside ONE conversation, SillyTavern-style turn order.
+// Plain conversation only by design: the agent path and the chat-tools
+// router stay out, a group round is talk, never a tool run.
+//
+// Attribution is the whole trick. Every model receives the shared history
+// with the OTHER models' lines tagged "[model-name] ..." and its own lines
+// untagged, so each participant can tell who said what without any provider
+// support for multi-speaker roles.
+import type { Message } from '../types/chat'
+
+export const GROUP_CHAT_MIN = 2
+export const GROUP_CHAT_MAX = 4
+
+/** True when this conversation runs as a group. */
+export function isGroupChat(groupModels: string[] | undefined): groupModels is string[] {
+ return Array.isArray(groupModels) && groupModels.length >= GROUP_CHAT_MIN
+}
+
+export function groupSystemPrompt(model: string, allModels: string[], personaPrompt: string): string {
+ const others = allModels.filter((m) => m !== model).map((m) => `"${m}"`).join(', ')
+ const line =
+ `You are "${model}", one of several AI models answering in the same group conversation with ${others}. ` +
+ `Earlier assistant messages starting with a [model-name] tag were written by the other models; untagged assistant messages are your own. ` +
+ `Answer as yourself in your own voice, add something new, and do not repeat what another model already said.`
+ return personaPrompt ? `${personaPrompt}\n\n${line}` : line
+}
+
+export interface GroupWireMessage {
+ role: 'user' | 'assistant' | 'system' | 'tool'
+ content: string
+ images?: { data: string; mimeType: string }[]
+}
+
+/** The shared history as one model sees it: other speakers tagged, own turns
+ * clean, empty placeholders dropped. */
+export function groupHistory(messages: Message[], model: string): GroupWireMessage[] {
+ return messages
+ .filter((m) => m.content.trim() !== '')
+ .map((m) => ({
+ role: m.role as GroupWireMessage['role'],
+ content:
+ m.role === 'assistant' && m.modelId && m.modelId !== model
+ ? `[${m.modelId}] ${m.content}`
+ : m.content,
+ ...(m.images?.length ? { images: m.images.map((i) => ({ data: i.data, mimeType: i.mimeType })) } : {}),
+ }))
+}
diff --git a/src/stores/chatStore.ts b/src/stores/chatStore.ts
index 262f2179..2c40ad85 100644
--- a/src/stores/chatStore.ts
+++ b/src/stores/chatStore.ts
@@ -41,6 +41,8 @@ interface ChatState {
* persona's systemPrompt without changing the global Settings
* selection. */
setConversationPersonaEnabled: (id: string, enabled: boolean) => void
+ /** Group chat v1: the models that answer in turn (capped at 4). */
+ setGroupModels: (id: string, models: string[]) => void
addMessage: (conversationId: string, message: Message) => void
insertMessageBefore: (conversationId: string, beforeId: string, message: Message) => void
insertMessagesBefore: (conversationId: string, beforeId: string, messages: Message[]) => void
@@ -176,6 +178,13 @@ export const useChatStore = create<ChatState>()(
),
})),
+ setGroupModels: (id, models) =>
+ set((state) => ({
+ conversations: state.conversations.map((c) =>
+ c.id === id ? { ...c, groupModels: models.slice(0, 4), updatedAt: Date.now() } : c
+ ),
+ })),
+
addMessage: (conversationId, message) =>
set((state) => ({
conversations: state.conversations.map((c) =>
diff --git a/src/types/chat.ts b/src/types/chat.ts
index 27c34ee6..230ea404 100644
--- a/src/types/chat.ts
+++ b/src/types/chat.ts
@@ -39,6 +39,10 @@ export interface Message {
* running (David 2026-06-12). Undefined for normal coding instructions. */
slashCommand?: string
thinking?: string
+ /** Which model produced this assistant turn. Set in group chats so the
+ * bubble can label the speaker and the payload builder can tag the other
+ * models' lines. Absent on single-model chats. */
+ modelId?: string
timestamp: number
images?: ImageAttachment[]
sources?: { documentName: string; chunkIndex: number; preview: string }[]
@@ -82,6 +86,9 @@ export interface Conversation {
* individually without losing the selection in Settings. Undefined
* on legacy chats and treated as enabled. */
personaEnabled?: boolean
+ /** Group chat v1: two to four models that answer in turn on every user
+ * message. Fewer than two entries means a normal single-model chat. */
+ groupModels?: string[]
createdAt: number
updatedAt: number
}