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): sichtbare Wartezeile fuer die lokale Spur, Stop wirkt waehrend des Wartens

purplea642824d4517
diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx
index fa616778..e2fc1c92 100644
--- a/src/components/chat/ChatInput.tsx
+++ b/src/components/chat/ChatInput.tsx
@@ -31,6 +31,16 @@ interface Props {
* and the composer says in one line why it is waiting.
*/
busyElsewhere?: boolean
+ /**
+ * THIS conversation's send is queued behind another local run (Runde 4,
+ * review-lanes.md Blocker 1+6): the built-in engine runs one slot, so a
+ * second local send waits its turn instead of racing the first one for it.
+ * Distinct from `isGenerating` (no stream is flowing yet) and from
+ * `busyElsewhere` (that one is a FOREIGN chat; this one is this chat's own
+ * send, just not admitted yet) — the composer shows Stop, same as while
+ * generating, and a line explains why nothing is happening yet.
+ */
+ waitingForLocalLane?: boolean
pendingApproval?: AgentToolCall | null
onApprove?: () => void
onReject?: () => void
@@ -98,7 +108,7 @@ function fileToImageAttachment(file: File): Promise<ImageAttachment> {
})
}
-export function ChatInput({ onSend, onStop, isGenerating, busyElsewhere, pendingApproval, onApprove, onReject, disabled, slashCommands, onAttachDocs, composerModel, composerActions, composerAbove }: Props) {
+export function ChatInput({ onSend, onStop, isGenerating, busyElsewhere, waitingForLocalLane, pendingApproval, onApprove, onReject, disabled, slashCommands, onAttachDocs, composerModel, composerActions, composerAbove }: Props) {
const [input, setInput] = useState('')
const [images, setImages] = useState<ImageAttachment[]>([])
const [isDragOver, setIsDragOver] = useState(false)
@@ -277,7 +287,7 @@ export function ChatInput({ onSend, onStop, isGenerating, busyElsewhere, pending
const sendLockRef = useRef(0)
const handleSend = () => {
const trimmed = input.trim()
- if ((!trimmed && images.length === 0) || isGenerating || busyElsewhere || disabled) return
+ if ((!trimmed && images.length === 0) || isGenerating || busyElsewhere || waitingForLocalLane || disabled) return
if (!passSendLock(sendLockRef)) return
onSend(trimmed || '(image)', images.length > 0 ? images : undefined)
setInput('')
@@ -454,6 +464,20 @@ export function ChatInput({ onSend, onStop, isGenerating, busyElsewhere, pending
</span>
</div>
)}
+ {/* Runde 4 (review-lanes.md Blocker 1+6): the built-in engine runs a
+ single slot, so a second local send queues instead of failing or
+ hanging silently. This is THIS chat's own send, already accepted,
+ just not admitted yet — Stop above already works on it (the store
+ aborter is registered the moment the run is admitted to the
+ queue, before the queue promotes it), this line only says why
+ nothing is streaming yet. Disappears the moment the run starts. */}
+ {!busyElsewhere && waitingForLocalLane && (
+ <div role="status" className={`${HINWEIS_ZEILE} ${HINWEIS_TEXT.ruhig} mb-1.5 px-1`} data-testid="composer-waiting-local-lane">
+ <span className="flex-1 min-w-0">
+ Waiting for the local model to finish another answer.
+ </span>
+ </div>
+ )}
{/* Non-image attach hint (GH #69). The clip is images-only; PDFs, Word,
and text files go through the Documents panel so the model can read them. */}
{docHint && (
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index b3ec9697..653cbb7e 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -42,6 +42,7 @@ import { CodexView } from './CodexView'
import { useCodexStore } from '../../stores/codexStore'
import { useGenerationStore } from '../../stores/generationStore'
import { composerBusy } from '../../lib/composer-busy'
+import { useIsQueuedForLocalLane } from '../../lib/run-idle'
import { useRemoteStore } from '../../stores/remoteStore'
import { displayModelName } from '../../api/providers'
import { MONOGRAM, MONOGRAM_INVERT } from '../layout/brand'
@@ -123,6 +124,11 @@ export function ChatView() {
const generatingMap = useGenerationStore((s) => s.generating)
const activeGenerating = !!activeConversationId && !!generatingMap[activeConversationId]
const busy = composerBusy(isGenerating, generatingMap, activeConversationId)
+ // Runde 4 (review-lanes.md Blocker 1+6): THIS conversation's own send is
+ // queued behind another local run. Not part of `generatingMap` (no stream
+ // is flowing yet), so `composerBusy` cannot see it — folded in here so the
+ // composer shows Stop instead of Send while it waits.
+ const queuedForLocalLane = useIsQueuedForLocalLane(activeConversationId)
const docCount = useRAGStore((s) =>
activeConversationId ? (s.documents[activeConversationId] || []).length : 0
@@ -630,8 +636,9 @@ export function ChatView() {
<ChatInput
onSend={sendMessage}
onStop={stopGeneration}
- isGenerating={busy.thisChat}
+ isGenerating={busy.thisChat || queuedForLocalLane}
busyElsewhere={busy.otherChat}
+ waitingForLocalLane={queuedForLocalLane}
pendingApproval={pendingApproval}
onApprove={approveToolCall}
onReject={rejectToolCall}
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsx
index 23424d40..ff53d655 100644
--- a/src/components/chat/CodexView.tsx
+++ b/src/components/chat/CodexView.tsx
@@ -46,6 +46,7 @@ import { Hinweis } from '../ui/Hinweis'
import { HINWEIS_TEXT } from '../../lib/hinweis'
import { stripModelNoise } from '../../lib/strip-model-noise'
import { composerBusy } from '../../lib/composer-busy'
+import { useIsQueuedForLocalLane } from '../../lib/run-idle'
// Code always drives a tool loop, so the aggressive tier applies here.
const stripChannelTags = (text: string) => stripModelNoise(text, { aggressive: true })
@@ -103,6 +104,10 @@ export function CodexView() {
// review flagged: a Chat send is blocked mid-Code-run, a Code send was not
// blocked mid-Chat-run.
const busy = composerBusy(isRunning || codexGenerating, generatingMap, activeConversationId)
+ // Runde 4 (review-lanes.md Blocker 1+6): same fold-in as ChatView.tsx. A
+ // queued send has no `generating` entry yet, so composerBusy alone cannot
+ // show it.
+ const queuedForLocalLane = useIsQueuedForLocalLane(activeConversationId)
// G8-3 (David): "sobald er fertig gedacht hat, hakt das so komisch ab und
// zoomt irgendwo ganz anders hin." The hand-rolled pin here only fired on
@@ -646,8 +651,9 @@ export function CodexView() {
// the old instance's loop is still running, which offered a second
// parallel send and no Stop button. The generating flag follows the
// conversation, not the hook instance.
- isGenerating={isRunning || codexGenerating}
+ isGenerating={isRunning || codexGenerating || queuedForLocalLane}
busyElsewhere={busy.otherChat}
+ waitingForLocalLane={queuedForLocalLane}
slashCommands="agent"
composerModel={<ModelSelector openUpward surface="code" />}
// No plan lives here. The prompt window is the prompt window
diff --git a/src/components/chat/__tests__/composer-zeigt-warten-auf-lokale-spur.test.tsx b/src/components/chat/__tests__/composer-zeigt-warten-auf-lokale-spur.test.tsx
new file mode 100644
index 00000000..23c0899c
--- /dev/null
+++ b/src/components/chat/__tests__/composer-zeigt-warten-auf-lokale-spur.test.tsx
@@ -0,0 +1,92 @@
+/**
+ * @vitest-environment jsdom
+ *
+ * Runde 4 (review-lanes.md Blocker 1+6, Schritt 2): a send that is queued
+ * behind another local run must be VISIBLE in the waiting conversation
+ * (English line, disappears once it starts) and Stop must still work while
+ * it waits.
+ *
+ * Two levels:
+ * - `ChatInput` itself: given `waitingForLocalLane`, does it show the right
+ * line and the Stop button (not Send), and does clicking Stop still call
+ * `onStop`?
+ * - `useIsQueuedForLocalLane`: does the hook that feeds that prop actually
+ * react to the real `lib/run-lanes.ts` queue (admit/release), the same
+ * module state the three send paths now book into via `runInLane`?
+ *
+ * Run: npx vitest run src/components/chat/__tests__/composer-zeigt-warten-auf-lokale-spur.test.tsx
+ */
+import { describe, it, expect, beforeEach, afterEach } from 'vitest'
+import { cleanup, fireEvent, render, screen, renderHook, act } from '@testing-library/react'
+import { ChatInput } from '../ChatInput'
+import { useIsQueuedForLocalLane } from '../../../lib/run-idle'
+import { admit, release, __resetRunLanesForTests } from '../../../lib/run-lanes'
+
+beforeEach(() => __resetRunLanesForTests())
+afterEach(() => cleanup())
+
+describe('ChatInput waehrend des Wartens auf die lokale Spur', () => {
+ it('zeigt die englische Wartezeile und den Stop-Knopf statt Senden', () => {
+ let stopped = 0
+ render(
+ <ChatInput
+ onSend={() => { throw new Error('must not send while queued') }}
+ onStop={() => { stopped += 1 }}
+ isGenerating={true}
+ waitingForLocalLane={true}
+ />,
+ )
+ const line = screen.getByTestId('composer-waiting-local-lane')
+ expect(line.textContent).toContain('Waiting for the local model to finish another answer')
+ expect(line.getAttribute('role')).toBe('status')
+
+ expect(screen.queryByRole('button', { name: 'Send message' })).toBeNull()
+ const stopBtn = screen.getByRole('button', { name: 'Stop generation' })
+ fireEvent.click(stopBtn)
+ expect(stopped).toBe(1)
+ })
+
+ it('die Zeile verschwindet, sobald der Lauf nicht mehr wartet', () => {
+ render(
+ <ChatInput onSend={() => {}} onStop={() => {}} isGenerating={false} waitingForLocalLane={false} />,
+ )
+ expect(screen.queryByTestId('composer-waiting-local-lane')).toBeNull()
+ expect(screen.getByRole('button', { name: 'Send message' })).toBeTruthy()
+ })
+
+ it('COUNTER-CHECK: busyElsewhere (fremde Unterhaltung) verdraengt die eigene Wartezeile', () => {
+ // Beide koennten technisch gleichzeitig wahr sein (eine andere Unterhaltung
+ // laeuft UND diese wartet auf die lokale Spur); die fremde Meldung hat
+ // Vorrang, weil sie den dringlicheren Fall beschreibt (jemand anders haelt
+ // gerade ueberhaupt die Maschine).
+ render(
+ <ChatInput onSend={() => {}} onStop={() => {}} isGenerating={true} busyElsewhere={true} waitingForLocalLane={true} />,
+ )
+ expect(screen.getByTestId('composer-busy-elsewhere')).toBeTruthy()
+ expect(screen.queryByTestId('composer-waiting-local-lane')).toBeNull()
+ })
+})
+
+describe('useIsQueuedForLocalLane reagiert auf die echte Warteschlange', () => {
+ it('wird wahr, waehrend die Unterhaltung wartet, und wieder falsch, sobald sie dran ist', () => {
+ const { result, rerender } = renderHook(({ id }: { id: string }) => useIsQueuedForLocalLane(id), {
+ initialProps: { id: 'conv-b' },
+ })
+ expect(result.current).toBe(false)
+
+ act(() => {
+ // conv-a holds the lane first, so conv-b's admit queues instead of starting.
+ admit('local', 'conv-a', () => {})
+ admit('local', 'conv-b', () => {})
+ })
+ rerender({ id: 'conv-b' })
+ expect(result.current).toBe(true)
+
+ act(() => {
+ // conv-a releases the lane; conv-b is promoted out of the queue.
+ release('conv-a')
+ })
+ rerender({ id: 'conv-b' })
+ expect(result.current).toBe(false)
+ })
+})
diff --git a/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx b/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx
index 970d085a..34f5ddf6 100644
--- a/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx
+++ b/src/components/chat/__tests__/senden-und-stop-je-unterhaltung.test.tsx
@@ -14,7 +14,7 @@
* vollstaendiges "jede Unterhaltung darf gleichzeitig senden" hing an den
* geteilten Stream-Puffern in useChat.ts (contentRef, thinkingRef, abortRef)
* und useAgentChat.ts, rund 110 Zugriffe, und daran, dass `runInLane` aus
- * lib/run-slot.ts bis heute keinen Aufrufer in der Produktion hat: ohne
+ * lib/run-slot.ts damals keinen Aufrufer in der Produktion hatte: ohne
* Warteschlange liefen zwei lokale Laeufe gegen einen llama-server mit einem
* einzigen Slot. useChat.ts hat seine Haelfte seit B2 Commit 1/2
* (ChatRun-Objekt statt Refs, generationStore statt abortRef): siehe
@@ -22,8 +22,11 @@
* Haelfte seit B2 NEUER FUND (AgentRunState-Objekt statt Refs,
* activeAgentRuns statt abortRef/abortConvRef/runningRef, Wiedereintritts-
* Riegel je Unterhaltung statt app-weit): siehe
- * useAgentChat-zwei-agentenlaeufe-vermischen-nicht.test.ts. Die
- * Warteschlange (`runInLane`) steht weiter aus, die Oberflaeche unten haelt
+ * useAgentChat-zwei-agentenlaeufe-vermischen-nicht.test.ts. Runde 4
+ * (review-lanes.md Blocker 1+6) hat `runInLane` seither in alle drei
+ * Sendewege verdrahtet: siehe useChat-lokale-spur-reiht-zweite-sendung-ein,
+ * useAgentChat-lokale-spur-reiht-zweiten-agentenlauf-ein und
+ * useCodex-lokale-spur-reiht-zweiten-lauf-ein. Die Oberflaeche unten haelt
* die App-weite Fahne fuer Regenerate/Edit deshalb bewusst, nicht mehr wegen
* geteilter Puffer. Was hier steht, ist das, was schon vorher richtig wurde:
* der laufende Chat behaelt Stop und bricht nur sich selbst ab, der andere
@@ -205,8 +208,14 @@ describe('Stop bricht nur die eigene Erzeugung ab', () => {
it('der Komposer liest nicht mehr die app-weite Fahne', () => {
const view = src('../ChatView.tsx')
const composer = view.slice(view.indexOf('<ChatInput'), view.indexOf('composerActions='))
- expect(composer).toContain('isGenerating={busy.thisChat}')
+ // Runde 4 (review-lanes.md Blocker 1+6): `isGenerating` traegt jetzt auch
+ // den Warteschlangen-Fall (`queuedForLocalLane`), damit der Stop-Knopf
+ // schon waehrend des Wartens auf die lokale Spur steht, nicht erst wenn
+ // der Strom beginnt. Die Aussage dieses Tests bleibt dieselbe: kein
+ // app-weites `isGenerating`, alles hier ist je-Unterhaltung.
+ expect(composer).toContain('isGenerating={busy.thisChat || queuedForLocalLane}')
expect(composer).toContain('busyElsewhere={busy.otherChat}')
+ expect(composer).toContain('waitingForLocalLane={queuedForLocalLane}')
expect(composer).not.toContain('isGenerating={isGenerating}')
// Die MessageList behaelt die app-weite Fahne mit Absicht: Regenerate und
// Edit STARTEN einen Lauf, und solange die Stream-Puffer geteilt sind,
diff --git a/src/lib/run-idle.ts b/src/lib/run-idle.ts
index 665ce57e..e9f67dd9 100644
--- a/src/lib/run-idle.ts
+++ b/src/lib/run-idle.ts
@@ -57,6 +57,7 @@
* so a deleted coding chat leaves its thread behind — and its status keeps
* voting in `anyRunActive` below.
*/
+import { useSyncExternalStore } from 'react'
import { useGenerationStore } from '../stores/generationStore'
import { useCodexStore } from '../stores/codexStore'
import { isRunStopped } from './run-stop'
@@ -188,6 +189,23 @@ export function isRunActive(conversationId: string | null | undefined): boolean
return isActiveCodexStatus(runStatusOf(conversationId))
}
+/**
+ * React hook: is THIS conversation waiting in the local lane's queue right
+ * now (Runde 4, review-lanes.md Blocker 1+6)?
+ *
+ * ChatView and CodexView both need this for the same two things: showing the
+ * Stop button (not Send) while a send is queued, and the "waiting for the
+ * local model" line. `useSyncExternalStore` with `subscribeRunLanes` is the
+ * plain React wrapper around the module state `lib/run-lanes.ts` already
+ * keeps and already wakes on — no second copy of "is it queued", the two
+ * view components just read the same one fact reactively instead of via
+ * `getState()`-equivalent calls that would not trigger a re-render when a
+ * run gets promoted out of the queue.
+ */
+export function useIsQueuedForLocalLane(conversationId: string | null | undefined): boolean {
+ return useSyncExternalStore(subscribeRunLanes, () => isRunQueued(conversationId))
+}
+
/**
* Wake `listener` whenever ANY of the three sources moves: a generating flag,
* a coding thread's status, or the local lane's queue.