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(group): a skipped or stopped speaker keeps what it wrote; round bar shows the place first

purple93ce632e164e
diff --git a/src/components/chat/GroupRoundBar.tsx b/src/components/chat/GroupRoundBar.tsx
index 9e4182a8..052fb69b 100644
--- a/src/components/chat/GroupRoundBar.tsx
+++ b/src/components/chat/GroupRoundBar.tsx
@@ -46,8 +46,10 @@ export function GroupRoundBar({ onStop }: { onStop: () => void }) {
return (
<div data-testid="group-round-bar" data-state="running" className="flex items-center gap-1 min-w-0 t-micro text-gray-500">
<Users size={10} className="shrink-0 text-purple-400" />
- <span className="truncate" data-testid="group-round-speaker">
- {memberLabel(live.speaker, speakers)} <span className="lu-hud-num">{live.index + 1}/{live.total}</span>
+ <span className="flex items-center gap-1 min-w-0" data-testid="group-round-speaker">
+ {/* The place first: a long model name is cut, the place never. */}
+ <span className="lu-hud-num shrink-0">{live.index + 1}/{live.total}</span>
+ <span className="truncate">{memberLabel(live.speaker, speakers)}</span>
</span>
<button
onClick={() => skipGroupSpeaker(convId)}
diff --git a/src/components/chat/__tests__/group-order-and-round-controls.test.tsx b/src/components/chat/__tests__/group-order-and-round-controls.test.tsx
index fa8e14ee..68cc8dca 100644
--- a/src/components/chat/__tests__/group-order-and-round-controls.test.tsx
+++ b/src/components/chat/__tests__/group-order-and-round-controls.test.tsx
@@ -106,7 +106,7 @@ describe('GH #200: the round bar', () => {
const stop = vi.fn()
groupTurnStarted(convId, { speaker: B, index: 1, total: 3 }, skip)
render(<GroupRoundBar onStop={stop} />)
- expect(screen.getByTestId('group-round-speaker').textContent).toBe('baron 2/3')
+ expect(screen.getByTestId('group-round-speaker').textContent).toBe('2/3baron')
fireEvent.click(screen.getByTestId('group-skip-speaker'))
expect(skip).toHaveBeenCalledTimes(1)
fireEvent.click(screen.getByTestId('group-stop-round'))
diff --git a/src/hooks/__tests__/group-round-control.test.ts b/src/hooks/__tests__/group-round-control.test.ts
index 2ec9a0b2..044d78c9 100644
--- a/src/hooks/__tests__/group-round-control.test.ts
+++ b/src/hooks/__tests__/group-round-control.test.ts
@@ -49,11 +49,14 @@ let requests: Request[] = []
let calls: Record<string, number> = {}
/** Models whose answer waits until the request is aborted. */
let hang = new Set<string>()
+/** Models that write a few words and then wait until the request is aborted. */
+let partial = new Set<string>()
beforeEach(() => {
requests = []
calls = {}
hang = new Set()
+ partial = new Set()
__resetRunLanesForTests()
useChatStore.setState({ conversations: [], activeConversationId: null })
useGenerationStore.setState({ generating: {}, aborters: {}, runs: {} })
@@ -71,6 +74,17 @@ beforeEach(() => {
const body = JSON.parse(String((init as RequestInit).body)) as Request
requests.push(body)
calls[body.model] = (calls[body.model] ?? 0) + 1
+ if (partial.has(body.model)) {
+ const signal = (init as RequestInit).signal
+ const enc = new TextEncoder()
+ const stream = new ReadableStream({
+ start(c) {
+ c.enqueue(enc.encode(`data: ${JSON.stringify({ choices: [{ delta: { content: 'half an answer' } }] })}\n\n`))
+ signal?.addEventListener('abort', () => c.error(Object.assign(new Error('aborted'), { name: 'AbortError' })))
+ },
+ })
+ return new Response(stream, { status: 200, headers: { 'content-type': 'text/event-stream' } })
+ }
if (hang.has(body.model)) {
const signal = (init as RequestInit).signal
await new Promise<never>((_, reject) => {
@@ -205,6 +219,25 @@ describe('GH #200: order, who answers, skip', () => {
expect(skipGroupSpeaker(id)).toBe(false)
})
+ it('what a skipped speaker had already written stays in the chat', async () => {
+ // Found on the Mac build: a window in the background paints no frames, so
+ // the streamed words had never reached the store when the skip came, and
+ // the turn was taken for an empty one and removed.
+ vi.stubGlobal('requestAnimationFrame', () => 1)
+ vi.stubGlobal('cancelAnimationFrame', () => {})
+ const id = openGroup()
+ partial.add('walt')
+ const { result } = renderHook(() => useChat())
+ let round!: Promise<void>
+ act(() => { round = result.current.sendMessage('go') })
+ await vi.waitFor(() => expect(asked()).toEqual(['walt']))
+ await new Promise((r) => setTimeout(r, 50))
+ expect(skipGroupSpeaker(id)).toBe(true)
+ await act(async () => { await round })
+ expect(said(id)).toEqual(['half an answer', 'baron 1', 'clara 1'])
+ vi.unstubAllGlobals()
+ })
+
it('negative control: "Stop round" ends the round, nobody after answers', async () => {
const id = openGroup()
hang.add('walt')
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index 82aab23f..9efec067 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -244,6 +244,15 @@ async function runGroupTurn(convId: string, model: string, allModels: string[],
const others = allModels
.filter((m) => m !== model)
.flatMap((m) => (speakers[m].name === m ? [m] : [m, speakers[m].name]))
+ // A stopped or skipped turn keeps what it had written. The stream is written
+ // to the store once per frame, and a window in the background paints no
+ // frames: on the Mac build a skipped speaker's words had never reached the
+ // store, so the turn read as empty and was removed (GH #200).
+ const keepWhatWasWritten = () => {
+ if (abort.signal.aborted && contentAcc.trim()) {
+ useChatStore.getState().updateMessageContent(convId, assistantMessage.id, stripImpersonatedSpeakers(stripNonCanonicalTags(contentAcc), others))
+ }
+ }
try {
// Local speakers share ONE engine process. llama-server holds a single
@@ -375,6 +384,7 @@ async function runGroupTurn(convId: string, model: string, allModels: string[],
}
thinkClock.end()
frames.close()
+ keepWhatWasWritten()
if (!abort.signal.aborted && !contentAcc.trim()) {
// Empty turn: say WHY, length-aware, not a flat "didn't return an answer".
// The bubble already labels the speaker, so no model prefix here.
@@ -386,6 +396,7 @@ async function runGroupTurn(convId: string, model: string, allModels: string[],
}
} catch (err) {
frames.close()
+ keepWhatWasWritten()
if ((err as Error).name !== 'AbortError') {
syncOllamaHealthFromError(err)
// Bug B3 round 2: a group round on a strict template used to paste the