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+codex): per-conversation typing indicator, collapsible slash tool-window, smart auto-scroll

purple5a77f702638b
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index d28ffd3c..a2f251ef 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -24,6 +24,7 @@ import { PermissionOverrideBar } from './PermissionOverrideBar'
import { RealtimeCounter } from './RealtimeCounter'
import { CodexView } from './CodexView'
import { useCodexStore } from '../../stores/codexStore'
+import { useGenerationStore } from '../../stores/generationStore'
import { useRemoteStore } from '../../stores/remoteStore'
import { useImageToolNoti } from '../../hooks/useImageToolNoti'
@@ -39,6 +40,14 @@ export function ChatView() {
const [toolsDropdownOpen, setToolsDropdownOpen] = useState(false)
const chatMode = useCodexStore((s) => s.chatMode)
+ // Per-conversation generating flag (David 2026-06-12): the typing indicator
+ // + realtime counter must show ONLY in the chat that is actually generating,
+ // not in every other chat the user switches to. `isGenerating` from the hook
+ // is global (and stays so for the input, where it guards shared stream refs);
+ // the visual indicators below read this conversation-scoped map instead.
+ const generatingMap = useGenerationStore((s) => s.generating)
+ const activeGenerating = !!activeConversationId && !!generatingMap[activeConversationId]
+
const docCount = useRAGStore((s) =>
activeConversationId ? (s.documents[activeConversationId] || []).length : 0
)
@@ -282,6 +291,7 @@ export function ChatView() {
<MessageList
isGenerating={isGenerating}
+ isThisChatGenerating={activeGenerating}
isLoadingModel={isLoadingModel}
onRegenerate={regenerateMessage}
onEdit={editAndResend}
@@ -289,7 +299,7 @@ export function ChatView() {
onApprove={approveToolCall}
onReject={rejectToolCall}
/>
- <RealtimeCounter isRunning={isGenerating} />
+ <RealtimeCounter isRunning={activeGenerating} />
{/* Remote session banners */}
{isThisRemoteActive && (
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsx
index 4dd92d09..08df68b5 100644
--- a/src/components/chat/CodexView.tsx
+++ b/src/components/chat/CodexView.tsx
@@ -1,6 +1,7 @@
import { useCodex } from '../../hooks/useCodex'
import { useCodexStore } from '../../stores/codexStore'
import { useChatStore } from '../../stores/chatStore'
+import { useGenerationStore } from '../../stores/generationStore'
import { ChatInput } from './ChatInput'
import { ToolCallBlock } from './ToolCallBlock'
import { ThinkingBlock } from './ThinkingBlock'
@@ -14,7 +15,8 @@ import { TypingIndicator } from './TypingIndicator'
import { useSettingsStore } from '../../stores/settingsStore'
import { useModelStore } from '../../stores/modelStore'
import { StagedChangesPanel } from './StagedChangesPanel'
-import { User, Code, Eye, GitBranch, Download, RefreshCw, RotateCcw, Folder } from 'lucide-react'
+import { SlashStepsBlock } from './SlashStepsBlock'
+import { User, Code, Eye, GitBranch, Download, RefreshCw, RotateCcw, Folder, X } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { checkGitInstalled, openExternal, type GitStatus } from '../../api/backend'
import { extractToolCallsWithRanges, stripRanges } from '../../lib/tool-call-repair'
@@ -74,6 +76,39 @@ function stripChannelTags(text: string): string {
// chatty small model can't stack the same line. (The old CollapsibleAnswer
// one-line-preview component was removed.)
+// One-time hint that "/" opens the coding commands (David 2026-06-12: "kleiner
+// hinweis über dem prompt fenster … nur im coding bereich … mit x zum wegdrücken,
+// soll nur einmal erscheinen"). Persisted in localStorage so it never returns
+// after dismissal. Code-view only — it's rendered solely inside CodexView.
+const SLASH_HINT_KEY = 'lu-coding-slash-hint-dismissed'
+function CodingCommandsHint() {
+ const [dismissed, setDismissed] = useState(() => {
+ try { return localStorage.getItem(SLASH_HINT_KEY) === '1' } catch { return false }
+ })
+ if (dismissed) return null
+ // Outer matches the ChatInput container (max-w-[70%] mx-auto) so the inner
+ // w-[60%] is 60 % of the REAL prompt width, centered (David 2026-06-12: "60%
+ // so breit wie das prompt fenster, in der mitte"). Monochrome — no colour, no
+ // icon — and an English UI string (David 2026-06-12: "in deutsch? … farbe weg
+ // … emoji weg").
+ return (
+ <div className="w-full max-w-[70%] mx-auto px-3 pt-1 flex justify-center">
+ <div className="w-[60%] flex items-center gap-1.5 px-2 py-1 rounded-md border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.03]">
+ <span className="flex-1 text-center text-[0.55rem] text-gray-500 dark:text-gray-400 leading-tight">
+ New — type <span className="font-mono px-1 rounded bg-gray-200/70 dark:bg-white/10">/</span> for coding commands: /review, /commit, /test, /fix …
+ </span>
+ <button
+ onClick={() => { try { localStorage.setItem(SLASH_HINT_KEY, '1') } catch { /* private mode — just hide it for this session */ } setDismissed(true) }}
+ title="Dismiss"
+ className="flex items-center justify-center w-4 h-4 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors shrink-0"
+ >
+ <X size={11} />
+ </button>
+ </div>
+ </div>
+ )
+}
+
export function CodexView() {
const { sendInstruction, stopCodex, isRunning } = useCodex()
const activeConversationId = useChatStore((s) => s.activeConversationId)
@@ -84,8 +119,31 @@ export function CodexView() {
const conversation = conversations.find(c => c.id === activeConversationId)
const messages = conversation?.messages || []
+ // Per-conversation generating flag (David 2026-06-12): the typing indicator
+ // + realtime counter + a message's live-stream state must follow the coding
+ // chat that's ACTUALLY running — not every chat the user switches to. The
+ // hook's `isRunning` is global (kept for the input, which guards shared stream
+ // refs); the visual bits below read this conversation-scoped flag instead.
+ const generatingMap = useGenerationStore((s) => s.generating)
+ const codexGenerating = !!activeConversationId && !!generatingMap[activeConversationId]
+
+ // Smart auto-scroll (David 2026-06-12: "kann nicht scrollen, bin locked, jumpt
+ // zurück auf ganz unten"). A scroll listener records whether the user is at the
+ // bottom; we only auto-pin when they are — so scrolling UP to read earlier
+ // output is never yanked back down, even when a chunky tool-call block streams
+ // in. Mirrors the normal chat's useAutoScroll, which already behaves this way.
+ const shouldAutoScroll = useRef(true)
useEffect(() => {
- if (scrollRef.current) {
+ const el = scrollRef.current
+ if (!el) return
+ const onScroll = () => {
+ shouldAutoScroll.current = el.scrollHeight - el.scrollTop - el.clientHeight < 100
+ }
+ el.addEventListener('scroll', onScroll)
+ return () => el.removeEventListener('scroll', onScroll)
+ }, [])
+ useEffect(() => {
+ if (shouldAutoScroll.current && scrollRef.current) {
scrollRef.current.scrollTop = scrollRef.current.scrollHeight
}
}, [messages, thread?.events])
@@ -250,130 +308,197 @@ export function CodexView() {
{msg.role === 'assistant' && msg.thinking && (
<ThinkingBlock
thinking={msg.thinking}
- streaming={isRunning && msg.id === messages[messages.length - 1]?.id && !cleanContent.trim()}
+ streaming={codexGenerating && msg.id === messages[messages.length - 1]?.id && !cleanContent.trim()}
/>
)}
- {/* Reflection blocks (Architect plan, RepoMap
- context, etc.) — rendered above the tool calls
- in chronological order so the user can see what
- context primed the editor model before it
- started fetching tools. */}
- {msg.role === 'assistant' && msg.agentBlocks && msg.agentBlocks.length > 0 && (
- <div className="space-y-1">
- {msg.agentBlocks
- .filter((b) => b.phase === 'reflection' && b.content)
- .map((block) => (
- <div
- key={block.id}
- className="px-2 py-1.5 rounded border border-gray-200 dark:border-white/10 bg-gray-50/60 dark:bg-white/[0.02] text-[0.7rem] text-gray-700 dark:text-gray-300"
- >
- <MarkdownRenderer content={block.content} />
- </div>
- ))}
- </div>
- )}
- {/* Interleaved blocks (Codex 2026-05) — when the
- assistant turn produced per-iteration 'answer'
- blocks, render tool_call + answer blocks in
- chronological order so commentary sits BETWEEN tool
- calls instead of all text bunching at the bottom.
- Falls back to the legacy split (tool-calls only,
- full text below) for older chats that have only
- tool_call blocks. */}
- {msg.role === 'assistant' && msg.agentBlocks && msg.agentBlocks.length > 0
- ? (() => {
- const hasAnswerBlock = msg.agentBlocks!.some(
- (b) => b.phase === 'answer' && b.content.trim(),
- )
- if (hasAnswerBlock) {
- // Interleave tool_call + answer blocks strictly by
- // timestamp so the transcript reads tool → answer →
- // tool → tool → answer … in the real order the
- // model produced them — provider/LLM-agnostic
- // (David 2026-06-02 r2). Drop answer blocks that
- // strip to empty so they can't be the "latest".
- const ordered = [...msg.agentBlocks!]
- .filter(
- (b) =>
- (b.phase === 'tool_call' && b.toolCall) ||
- (b.phase === 'answer' && stripChannelTags(b.content)),
- )
- .sort((a, b) => a.timestamp - b.timestamp)
- return (
- <div className="space-y-1">
- {ordered.map((block, idx) => {
- if (block.phase === 'tool_call' && block.toolCall) {
- return <ToolCallBlock key={block.id} toolCall={block.toolCall} />
- }
- if (block.phase === 'answer') {
- const answer = stripChannelTags(block.content)
- if (!answer) return null
- // Render EVERY answer normally + always
- // visible (David 2026-06-04: "kein Collapse,
- // ganz normal wie eine Antwort"). Skip only a
- // verbatim repeat of the previous answer so
- // chatty small models don't stack duplicates.
- const prev = ordered
- .slice(0, idx)
- .reverse()
- .find((b) => b.phase === 'answer' && stripChannelTags(b.content))
- if (prev && stripChannelTags(prev.content) === answer) return null
- return (
- <div key={block.id} className="px-1 py-0.5">
- <div className="text-[0.75rem] leading-relaxed">
- <MarkdownRenderer content={answer} />
+ {(() => {
+ const running = codexGenerating && msg.id === messages[messages.length - 1]?.id
+ const hasBlocks = !!(msg.role === 'assistant' && msg.agentBlocks && msg.agentBlocks.length > 0)
+ const stepCount = msg.agentBlocks?.filter((b) => b.phase === 'tool_call' && b.toolCall).length ?? 0
+ const hasAnswerBlock = !!(msg.agentBlocks && msg.agentBlocks.some((b) => b.phase === 'answer' && b.content.trim()))
+
+ // Reflection blocks (Architect plan, RepoMap context) —
+ // shown above the tool calls so the user sees what context
+ // primed the editor model before it started fetching tools.
+ const reflection = hasBlocks ? (
+ <div className="space-y-1">
+ {msg.agentBlocks!
+ .filter((b) => b.phase === 'reflection' && b.content)
+ .map((block) => (
+ <div
+ key={block.id}
+ className="px-2 py-1.5 rounded border border-gray-200 dark:border-white/10 bg-gray-50/60 dark:bg-white/[0.02] text-[0.7rem] text-gray-700 dark:text-gray-300"
+ >
+ <MarkdownRenderer content={block.content} />
+ </div>
+ ))}
+ </div>
+ ) : null
+
+ // Interleaved tool_call + answer blocks (Codex 2026-05) so
+ // commentary sits BETWEEN tool calls, else the legacy
+ // tool-only split. Identical logic to before — just hoisted
+ // into a value so a slash run can wrap it in the window.
+ const transcript = !hasBlocks
+ ? null
+ : hasAnswerBlock
+ ? (() => {
+ // Interleave strictly by timestamp: tool → answer →
+ // tool → tool → answer … in the real order produced
+ // (provider/LLM-agnostic, David 2026-06-02 r2). Drop
+ // answer blocks that strip to empty.
+ const ordered = [...msg.agentBlocks!]
+ .filter(
+ (b) =>
+ (b.phase === 'tool_call' && b.toolCall) ||
+ (b.phase === 'answer' && stripChannelTags(b.content)),
+ )
+ .sort((a, b) => a.timestamp - b.timestamp)
+ return (
+ <div className="space-y-1">
+ {ordered.map((block, idx) => {
+ if (block.phase === 'tool_call' && block.toolCall) {
+ return <ToolCallBlock key={block.id} toolCall={block.toolCall} />
+ }
+ if (block.phase === 'answer') {
+ const answer = stripChannelTags(block.content)
+ if (!answer) return null
+ // Render EVERY answer normally + visible
+ // (David 2026-06-04: "kein Collapse, ganz
+ // normal wie eine Antwort"). Skip only a
+ // verbatim repeat of the previous answer.
+ const prev = ordered
+ .slice(0, idx)
+ .reverse()
+ .find((b) => b.phase === 'answer' && stripChannelTags(b.content))
+ if (prev && stripChannelTags(prev.content) === answer) return null
+ return (
+ <div key={block.id} className="px-1 py-0.5">
+ <div className="text-[0.75rem] leading-relaxed">
+ <MarkdownRenderer content={answer} />
+ </div>
</div>
- </div>
- )
- }
- return null
- })}
+ )
+ }
+ return null
+ })}
+ </div>
+ )
+ })()
+ : (
+ <div className="space-y-0">
+ {msg.agentBlocks!
+ .filter((b) => b.phase === 'tool_call' && b.toolCall)
+ .map((block) => (
+ <ToolCallBlock key={block.id} toolCall={block.toolCall!} />
+ ))}
</div>
)
- }
- return (
- <div className="space-y-0">
- {msg.agentBlocks!
- .filter((b) => b.phase === 'tool_call' && b.toolCall)
- .map((block) => (
- <ToolCallBlock key={block.id} toolCall={block.toolCall!} />
- ))}
- </div>
- )
- })()
- : null}
- {/* Text content — user bubble always; assistant only
- when there are no per-iteration answer blocks (the
- interleave path above already rendered them inline).
- Assistant drops the bubble entirely to match the
- regular Chat view; user keeps theirs as the
- right-aligned anchor. */}
- {cleanContent && (msg.role === 'user' ||
- !(msg.agentBlocks && msg.agentBlocks.some((b) => b.phase === 'answer' && b.content.trim()))) && (
- <div className={
- msg.role === 'user'
- ? 'rounded-lg px-2.5 py-1.5 bg-gray-100 dark:bg-white/[0.06] border border-gray-200 dark:border-white/[0.08]'
- : 'px-1 py-0.5'
- }>
- <div className="text-[0.75rem] leading-relaxed">
- {msg.role === 'user' ? (
- <p className="text-gray-800 dark:text-gray-200 whitespace-pre-wrap">{cleanContent}</p>
- ) : (
- <MarkdownRenderer content={cleanContent} />
- )}
+ // Text content — user bubble always; assistant only when
+ // there are no per-iteration answer blocks (interleave
+ // already rendered those). Assistant drops the bubble to
+ // match the regular Chat view; user keeps the right anchor.
+ const textContent = cleanContent && (msg.role === 'user' || !hasAnswerBlock) ? (
+ <div className={
+ msg.role === 'user'
+ ? 'rounded-lg px-2.5 py-1.5 bg-gray-100 dark:bg-white/[0.06] border border-gray-200 dark:border-white/[0.08]'
+ : 'px-1 py-0.5'
+ }>
+ <div className="text-[0.75rem] leading-relaxed">
+ {msg.role === 'user' ? (
+ <p className="text-gray-800 dark:text-gray-200 whitespace-pre-wrap">{cleanContent}</p>
+ ) : (
+ <MarkdownRenderer content={cleanContent} />
+ )}
+ </div>
</div>
- </div>
- )}
+ ) : null
+
+ // Slash command (David 2026-06-12): the STEPS (tool calls +
+ // intermediate commentary) go in the collapsible window;
+ // the FINAL answer renders OUTSIDE it, normal + readable —
+ // "die finale antwort soll nicht im tool call sein, nur die
+ // letzte". Same block shape for Ollama + LM Studio, so this
+ // is backend-agnostic. The final answer = the last 'answer'
+ // block, or msg.content when the model never emitted one.
+ if (msg.role === 'assistant' && msg.slashCommand) {
+ const blocks = msg.agentBlocks || []
+ const answerBlocks = blocks
+ .filter((b) => b.phase === 'answer' && stripChannelTags(b.content))
+ .sort((a, b) => a.timestamp - b.timestamp)
+ const finalAnswerBlock = answerBlocks[answerBlocks.length - 1]
+ const finalAnswerText = finalAnswerBlock
+ ? stripChannelTags(finalAnswerBlock.content)
+ : (!hasAnswerBlock && cleanContent ? cleanContent : '')
+ // Steps = tool calls + every answer EXCEPT the final one.
+ const stepsOrdered = [...blocks]
+ .filter(
+ (b) =>
+ (b.phase === 'tool_call' && b.toolCall) ||
+ (b.phase === 'answer' &&
+ stripChannelTags(b.content) &&
+ b.id !== finalAnswerBlock?.id),
+ )
+ .sort((a, b) => a.timestamp - b.timestamp)
+ return (
+ <>
+ {(stepCount > 0 || running) && (
+ <SlashStepsBlock command={msg.slashCommand} stepCount={stepCount} running={running}>
+ <div className="space-y-1">
+ {reflection}
+ <div className="space-y-1">
+ {stepsOrdered.map((block, idx) => {
+ if (block.phase === 'tool_call' && block.toolCall) {
+ return <ToolCallBlock key={block.id} toolCall={block.toolCall} />
+ }
+ const answer = stripChannelTags(block.content)
+ if (!answer) return null
+ const prev = stepsOrdered
+ .slice(0, idx)
+ .reverse()
+ .find((b) => b.phase === 'answer' && stripChannelTags(b.content))
+ if (prev && stripChannelTags(prev.content) === answer) return null
+ return (
+ <div key={block.id} className="px-1 py-0.5">
+ <div className="text-[0.75rem] leading-relaxed">
+ <MarkdownRenderer content={answer} />
+ </div>
+ </div>
+ )
+ })}
+ </div>
+ </div>
+ </SlashStepsBlock>
+ )}
+ {finalAnswerText && (
+ <div className="px-1 py-0.5">
+ <div className="text-[0.75rem] leading-relaxed">
+ <MarkdownRenderer content={finalAnswerText} />
+ </div>
+ </div>
+ )}
+ </>
+ )
+ }
+
+ return (
+ <>
+ {reflection}
+ {transcript}
+ {textContent}
+ </>
+ )
+ })()}
</div>
</div>
)
})}
- {/* 3-dot indicator while Codex is mid-loop — parity with
- the Chat tab so users on long Gemma 4 / Codex runs
- see "still thinking" instead of staring at a frozen
- pane between iterations. */}
- {isRunning && (
+ {/* 3-dot indicator while THIS coding chat is mid-loop. Bound to
+ the per-conversation flag so switching to another (idle) chat
+ doesn't show its dots — David 2026-06-12 ("die drei ladepunkte
+ kommen in vorherigen chats auch"). */}
+ {codexGenerating && (
<TypingIndicator />
)}
</div>
@@ -381,7 +506,10 @@ export function CodexView() {
</div>
{/* Realtime counter */}
- <RealtimeCounter isRunning={isRunning} />
+ <RealtimeCounter isRunning={codexGenerating} />
+
+ {/* One-time "/" hint, directly above the prompt (Code view only). */}
+ <CodingCommandsHint />
{/* Input */}
<ChatInput
diff --git a/src/components/chat/MessageList.tsx b/src/components/chat/MessageList.tsx
index c7f3310c..39df4d19 100644
--- a/src/components/chat/MessageList.tsx
+++ b/src/components/chat/MessageList.tsx
@@ -4,7 +4,14 @@ import { MessageBubble } from './MessageBubble'
import { TypingIndicator } from './TypingIndicator'
interface Props {
+ /** GLOBAL generating flag — guards regenerate/edit so a second concurrent
+ * send (which shares the chat hook's stream refs) can't corrupt an in-flight
+ * turn. Stays global on purpose. */
isGenerating: boolean
+ /** Per-conversation generating flag — drives the 3-dot typing indicator so it
+ * shows ONLY in the chat that is actually generating, not in every chat the
+ * user switches to (David 2026-06-12). Falls back to isGenerating. */
+ isThisChatGenerating?: boolean
isLoadingModel?: boolean
onRegenerate?: (conversationId: string, assistantMessageId: string) => void
onEdit?: (conversationId: string, messageId: string, newContent: string) => void
@@ -15,7 +22,8 @@ interface Props {
onReject?: () => void
}
-export function MessageList({ isGenerating, isLoadingModel, onRegenerate, onEdit, pendingApprovalId, onApprove, onReject }: Props) {
+export function MessageList({ isGenerating, isThisChatGenerating, isLoadingModel, onRegenerate, onEdit, pendingApprovalId, onApprove, onReject }: Props) {
+ const showTyping = isThisChatGenerating ?? isGenerating
const conversation = useChatStore((s) => {
if (!s.activeConversationId) return undefined
return s.conversations.find((c) => c.id === s.activeConversationId)
@@ -61,7 +69,7 @@ export function MessageList({ isGenerating, isLoadingModel, onRegenerate, onEdit
final answer is streaming. Previously it only showed when the
last assistant message was empty, which made multi-turn agent
runs look frozen between iterations (per user feedback). */}
- {isGenerating && lastMessage?.role === 'assistant' && (
+ {showTyping && lastMessage?.role === 'assistant' && (
<TypingIndicator label={isLoadingModel ? 'Loading model...' : undefined} />
)}
</div>
diff --git a/src/components/chat/SlashStepsBlock.tsx b/src/components/chat/SlashStepsBlock.tsx
new file mode 100644
index 00000000..b3ee7cf9
--- /dev/null
+++ b/src/components/chat/SlashStepsBlock.tsx
@@ -0,0 +1,86 @@
+import { useState, useRef, useEffect, type ReactNode } from 'react'
+import { Terminal, Loader2, ChevronDown, Check } from 'lucide-react'
+
+interface Props {
+ /** Command word without the leading slash, e.g. "review". */
+ command: string
+ /** Number of tool-call steps in this run (shown in the header). */
+ stepCount: number
+ /** True while this run is still streaming (latest message + loop running). */
+ running: boolean
+ /** The fully-rendered step transcript (reflection + tool calls + answers). */
+ children: ReactNode
+}
+
+/**
+ * Coding-Agent slash-command transcript wrapped in a collapsible, tool-call-style
+ * window (David 2026-06-12: "Slash-Steps in einem tool-artigen Call-Fenster,
+ * standardmäßig zugeklappt aber trotzdem streaming bis kein Platz mehr").
+ *
+ * - Default COLLAPSED — the user sees just the header (command + step count).
+ * - While RUNNING and collapsed, a bounded, auto-scrolling preview shows the
+ * live stream: newest content sits at the bottom, older steps fade out the top
+ * once there's no more room ("bis kein Platz mehr") — progress is visible
+ * without expanding.
+ * - Click the header to expand the full transcript; click again to collapse.
+ */
+export function SlashStepsBlock({ command, stepCount, running, children }: Props) {
+ const [open, setOpen] = useState(false)
+ const previewRef = useRef<HTMLDivElement>(null)
+
+ // Keep the live preview pinned to the newest content while running + collapsed.
+ // No dep array: the children re-render as blocks stream in, so this runs each
+ // render and the preview tracks the bottom — that's the intended "stream until
+ // there's no more space, then scroll" behaviour.
+ useEffect(() => {
+ if (running && !open && previewRef.current) {
+ previewRef.current.scrollTop = previewRef.current.scrollHeight
+ }
+ })
+
+ return (
+ <div className="rounded border border-gray-200 dark:border-white/10 bg-gray-50/50 dark:bg-white/[0.02] overflow-hidden">
+ {/* Header — tool-call styling: icon + command + step count + status. */}
+ <button
+ onClick={() => setOpen((o) => !o)}
+ className="flex items-center gap-1.5 w-full px-2 py-1 text-left hover:bg-gray-100/60 dark:hover:bg-white/[0.03] transition-colors"
+ >
+ <Terminal size={10} className="text-gray-500 shrink-0" />
+ <span className="text-[0.65rem] font-mono text-gray-600 dark:text-gray-300">/{command}</span>
+ <span className="text-[0.5rem] text-gray-400 dark:text-gray-600">
+ {stepCount} {stepCount === 1 ? 'step' : 'steps'}
+ </span>
+ {running ? (
+ <Loader2 size={9} className="animate-spin text-gray-500 shrink-0" />
+ ) : (
+ <Check size={9} className="text-gray-400 dark:text-gray-500 shrink-0" />
+ )}
+ <div className="flex-1" />
+ <span className="text-[0.5rem] text-gray-400 dark:text-gray-600">
+ {open ? 'hide' : running ? 'live' : 'show'}
+ </span>
+ <ChevronDown
+ size={11}
+ className={`text-gray-400 shrink-0 transition-transform ${open ? 'rotate-180' : ''}`}
+ />
+ </button>
+
+ {open ? (
+ // Expanded — the full transcript.
+ <div className="px-2 pb-1.5 pt-0.5 border-t border-gray-100 dark:border-white/[0.05]">
+ {children}
+ </div>
+ ) : running ? (
+ // Collapsed + running — bounded auto-scrolling live peek. The top fades so
+ // streamed steps look like they scroll up out of view. pointer-events-none
+ // lets clicks fall through to the header toggle above.
+ <div
+ ref={previewRef}
+ className="px-2 pb-1.5 pt-1 max-h-[140px] overflow-hidden opacity-70 pointer-events-none border-t border-gray-100 dark:border-white/[0.05] [mask-image:linear-gradient(to_bottom,transparent,#000_28px)]"
+ >
+ {children}
+ </div>
+ ) : null}
+ </div>
+ )
+}
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index f78629c6..c8c5de19 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -7,6 +7,7 @@ import { resolveWorkspace } from '../api/agents/workspace-resolve'
import { useAgentModeStore } from '../stores/agentModeStore'
import { streamOllamaChatWithTools } from '../lib/ollama-stream-tools'
import { useChatStore } from '../stores/chatStore'
+import { useGenerationStore } from '../stores/generationStore'
import { agentVariantExists, createAgentVariant, getAgentModelName, canFixModel } from '../api/model-template-fix'
import { useModelStore } from '../stores/modelStore'
import { useSettingsStore } from '../stores/settingsStore'
@@ -454,6 +455,9 @@ export function useAgentChat() {
abortRef.current = abort
runningRef.current = true
setIsAgentRunning(true)
+ // Bind the generating flag to THIS conversation so the typing indicator
+ // shows only in the chat whose turn is in flight (David 2026-06-12).
+ useGenerationStore.getState().setGenerating(convId, true)
contentRef.current = ''
thinkingRef.current = ''
blocksRef.current = []
@@ -1289,6 +1293,7 @@ export function useAgentChat() {
}
} finally {
setIsAgentRunning(false)
+ useGenerationStore.getState().setGenerating(convId, false)
runningRef.current = false
abortRef.current = null
// Chat-tools artifact mode: attach any files the model "wrote" (captured
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index a2171182..c1a682d6 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -12,6 +12,7 @@ import { effectiveContextWindow } from "../lib/context-window"
import { useAgentChat } from "./useAgentChat"
import { useMemory } from "./useMemory"
import { useAgentModeStore } from "../stores/agentModeStore"
+import { useGenerationStore } from "../stores/generationStore"
import { detectChatToolIntent, CHAT_TOOLS } from "../lib/chat-tool-intent"
import { getProviderForModel, getProviderIdFromModel } from "../api/providers"
import { syncOllamaHealthFromError } from "../lib/sync-ollama-health"
@@ -190,6 +191,10 @@ export function useChat() {
const abort = new AbortController()
abortRef.current = abort
setIsGenerating(true)
+ // Bind the generating flag to THIS conversation so the typing indicator
+ // only shows in the chat whose turn is in flight — not in every other chat
+ // the user switches to (David 2026-06-12). Cleared in finally.
+ useGenerationStore.getState().setGenerating(convId, true)
setIsLoadingModel(true)
useModelStore.getState().setIsModelLoading(true)
contentRef.current = ""
@@ -421,6 +426,7 @@ export function useChat() {
}
} finally {
setIsGenerating(false)
+ useGenerationStore.getState().setGenerating(convId, false)
setIsLoadingModel(false)
useModelStore.getState().setIsModelLoading(false)
abortRef.current = null
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index 4624b4f6..150ab007 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -15,6 +15,7 @@ import { resolveWorkspace } from '../api/agents/workspace-resolve'
import { useAgentModeStore } from '../stores/agentModeStore'
import { loadLurules, renderRulesSection, type RulesReader } from '../lib/lurules'
import { parseAgentCommand } from '../lib/agent-commands'
+import { useGenerationStore } from '../stores/generationStore'
import { backendCall, isOllamaLocal } from '../api/backend'
import { planWithArchitect, renderArchitectPlanSection } from '../api/agents/architect'
import { fetchRepoMap, renderRepoMapSection } from '../api/agents/repo-map'
@@ -263,9 +264,12 @@ export function useCodex() {
...(displayInstruction ? { displayContent: displayInstruction } : {}),
})
- // Add empty assistant message
+ // Add empty assistant message. For a slash command, tag it so CodexView
+ // wraps the whole step transcript in a collapsible tool-call-style window
+ // (default collapsed; live-streams while running) — David 2026-06-12.
const assistantMsg = {
id: uuid(), role: 'assistant' as const, content: '', thinking: '', timestamp: Date.now(), agentBlocks: [],
+ ...(slash ? { slashCommand: slash.command.name } : {}),
}
useChatStore.getState().addMessage(convId, assistantMsg)
let thinkingContent = ''
@@ -424,6 +428,10 @@ export function useCodex() {
runningRef.current = true
setIsRunning(true)
codexStore.setThreadStatus(convId, 'running')
+ // Bind the generating flag to THIS conversation so the typing indicator +
+ // realtime counter show only in the coding chat that's actually running,
+ // not in every chat the user switches to (David 2026-06-12). Cleared below.
+ useGenerationStore.getState().setGenerating(convId, true)
// Architect / RepoMap pre-pass (B8 + B9). Both inject into the
// system prompt BEFORE the first iteration and surface a visible
@@ -951,7 +959,15 @@ export function useCodex() {
// NOT match — only "verify the (correct) path/file/location" does.
const asksForInfo = /\b(please provide|could you (?:please )?(?:provide|share|tell|give|specify|verify|confirm|clarify)|what(?:'s| is) the (?:path|file|name|location)|which file|can you (?:provide|share|specify|tell)|provide (?:the|me) (?:the )?(?:path|file|details|more)|(?:verify|confirm|clarify) (?:the )?(?:correct |right |exact |full )?(?:path|file ?path|location|directory|filename|file name)|need (?:the|more) (?:path|info|details|context))\b/i.test(turnContent)
const emptyTurn = turnContent.trim().length === 0
- if ((stalledNarration || asksForInfo || emptyTurn) && continueNudgesRemaining > 0) {
+ // Only nudge an empty turn when NOTHING has been produced yet (a true
+ // early stall). An empty turn AFTER a real answer means the model is
+ // finished — break immediately instead of spinning slow no-op nudge
+ // iterations that keep the typing dots up long after the answer is
+ // done (David 2026-06-12: "die punkte bleiben so lange obwohl keine
+ // antwort mehr kam"). Read-only report commands (/review, /explain …)
+ // legitimately end on a text answer + an empty follow-up turn.
+ const nudgeWorthy = stalledNarration || asksForInfo || (emptyTurn && !fullContent.trim())
+ if (nudgeWorthy && continueNudgesRemaining > 0) {
continueNudgesRemaining--
void diagLog('continue-nudge', { iter: i, remaining: continueNudgesRemaining, turnContentLen: turnContent.length })
messages.push({
@@ -1398,6 +1414,7 @@ export function useCodex() {
}
setIsRunning(false)
+ useGenerationStore.getState().setGenerating(convId, false)
runningRef.current = false
abortRef.current = null
clearActiveChatId()
diff --git a/src/stores/__tests__/generationStore.test.ts b/src/stores/__tests__/generationStore.test.ts
new file mode 100644
index 00000000..0385b2e9
--- /dev/null
+++ b/src/stores/__tests__/generationStore.test.ts
@@ -0,0 +1,50 @@
+import { describe, it, expect, beforeEach } from 'vitest'
+import { useGenerationStore } from '../generationStore'
+
+describe('generationStore — per-conversation generating flags', () => {
+ beforeEach(() => {
+ useGenerationStore.setState({ generating: {} })
+ })
+
+ it('starts empty', () => {
+ expect(useGenerationStore.getState().generating).toEqual({})
+ })
+
+ it('marks a conversation generating and clears it', () => {
+ const { setGenerating } = useGenerationStore.getState()
+ setGenerating('chat-a', true)
+ expect(useGenerationStore.getState().generating['chat-a']).toBe(true)
+ setGenerating('chat-a', false)
+ expect(useGenerationStore.getState().generating['chat-a']).toBeUndefined()
+ })
+
+ it('tracks two conversations independently — the bug fix', () => {
+ const { setGenerating } = useGenerationStore.getState()
+ // Generating in B must NOT mark A as generating (the typing-indicator bug).
+ setGenerating('chat-b', true)
+ expect(useGenerationStore.getState().generating['chat-b']).toBe(true)
+ expect(useGenerationStore.getState().generating['chat-a']).toBeUndefined()
+ })
+
+ it('ignores a null/undefined conversation id', () => {
+ const { setGenerating } = useGenerationStore.getState()
+ setGenerating(null, true)
+ setGenerating(undefined, true)
+ expect(useGenerationStore.getState().generating).toEqual({})
+ })
+
+ it('is a no-op (same object reference) when the flag is already set', () => {
+ const { setGenerating } = useGenerationStore.getState()
+ setGenerating('chat-a', true)
+ const ref1 = useGenerationStore.getState().generating
+ setGenerating('chat-a', true) // already true → must not replace the map
+ expect(useGenerationStore.getState().generating).toBe(ref1)
+ })
+
+ it('clearing an already-idle conversation is a no-op', () => {
+ const { setGenerating } = useGenerationStore.getState()
+ const ref1 = useGenerationStore.getState().generating
+ setGenerating('never-started', false)
+ expect(useGenerationStore.getState().generating).toBe(ref1)
+ })
+})
diff --git a/src/stores/generationStore.ts b/src/stores/generationStore.ts
new file mode 100644
index 00000000..1ed917b5
--- /dev/null
+++ b/src/stores/generationStore.ts
@@ -0,0 +1,40 @@
+import { create } from 'zustand'
+
+/**
+ * Ephemeral per-conversation "a turn is generating" flags. Deliberately NOT
+ * persisted — a crash mid-stream must never leave a stale "running" marker that
+ * survives a restart.
+ *
+ * Why this exists (David 2026-06-12): the chat / agent / codex hooks each held a
+ * single GLOBAL `isGenerating` boolean. The typing indicator (the 3 dots) and
+ * the realtime counter were gated on that global, so generating in ONE chat lit
+ * the dots in EVERY other chat you switched to ("die drei ladepunkte kommen in
+ * vorherigen chats auch"). Binding the indicators to the conversation that is
+ * actually generating fixes it — the dots show only in the chat whose turn is
+ * in flight. The Coding Agent uses its own per-thread status (codexStore), so it
+ * doesn't need this store; Chat + Agent (which share one useChat instance) do.
+ *
+ * The input's generating state stays GLOBAL on purpose: the chat hook reuses
+ * shared streaming refs, so allowing a second concurrent send from another chat
+ * would corrupt both streams. Only the visual indicators move per-conversation.
+ */
+interface GenerationState {
+ /** conversationId → true while its turn is generating. Absent = idle. */
+ generating: Record<string, boolean>
+ setGenerating: (conversationId: string | null | undefined, on: boolean) => void
+}
+
+export const useGenerationStore = create<GenerationState>((set) => ({
+ generating: {},
+ setGenerating: (conversationId, on) =>
+ set((state) => {
+ if (!conversationId) return state
+ // No-op when the flag is already in the requested state — avoids an
+ // unnecessary store update (and re-render) on every stream tick.
+ if (!!state.generating[conversationId] === on) return state
+ const next = { ...state.generating }
+ if (on) next[conversationId] = true
+ else delete next[conversationId]
+ return { generating: next }
+ }),
+}))
diff --git a/src/types/chat.ts b/src/types/chat.ts
index ad0eb3c2..5d9fef80 100644
--- a/src/types/chat.ts
+++ b/src/types/chat.ts
@@ -33,6 +33,11 @@ export interface Message {
* typed, while `content` holds the full expanded instruction the model
* actually receives. Display-only — never sent to the model. */
displayContent?: string
+ /** Coding-Agent slash command that triggered this assistant turn (e.g.
+ * "review", "init"). When set, CodexView wraps the whole step transcript in a
+ * collapsible tool-call-style window — default collapsed, live-streams while
+ * running (David 2026-06-12). Undefined for normal coding instructions. */
+ slashCommand?: string
thinking?: string
timestamp: number
images?: ImageAttachment[]