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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(code): failed runs name the real backend and offer a way on (CA U7)
purple39d1e674525d
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsxindex 638dbbee..ebb0ac60 100644--- a/src/components/chat/CodexView.tsx+++ b/src/components/chat/CodexView.tsx@@ -10,6 +10,7 @@ import { useBackgroundAgentWake } from '../../hooks/useBackgroundAgentWake'import { useGenerationStore } from '../../stores/generationStore'import { ChatInput } from './ChatInput'import { SteerNote } from './SteerNote'+import { RunErrorActions } from './RunErrorActions'import { useSteerQueue } from '../../hooks/useSteerQueue'import { ChatFileChip } from './ChatFileChip'import { FILE_ONLY_TEXT } from '../../lib/chat-files'@@ -118,6 +119,13 @@ export function CodexView() {const conversation = conversations.find(c => c.id === activeConversationId)const messages = conversation?.messages || []+ // CA U7: Try again under the newest failed answer sends the instruction it answered.+ const lastAssistantId = [...messages].reverse().find((m) => m.role === 'assistant')?.id+ const lastInstruction = (() => {+ const at = messages.findIndex((m) => m.id === lastAssistantId)+ for (let i = at - 1; i >= 0; i--) if (messages[i].role === 'user') return (messages[i].content || '').trim()+ return ''+ })()// Per-conversation generating flag (2026-06-12): the typing indicator// + realtime counter + a message's live-stream state must follow the coding@@ -737,6 +745,13 @@ export function CodexView() {{msg.role === 'assistant' && (<RequestUsageLine usage={msg.requestUsage} className="block px-1" />)}+ {/* CA U7: the newest failed answer offers a way on. */}+ {!readOnly && msg.role === 'assistant' && msg.error && !codexGenerating && msg.id === lastAssistantId && (+ <RunErrorActions+ error={msg.error}+ onRetry={lastInstruction ? () => sendInstruction(lastInstruction, { shownMode }) : undefined}+ />+ )}</div></div>)diff --git a/src/components/chat/RunErrorActions.tsx b/src/components/chat/RunErrorActions.tsxnew file mode 100644index 00000000..6eba6f8b--- /dev/null+++ b/src/components/chat/RunErrorActions.tsx@@ -0,0 +1,34 @@+/**+ * What the user can do about a run that ended on an error (CA U7): try the+ * same instruction again, or pick another model. Shown under the newest+ * failed answer only, and never while a run is going.+ */+import { RotateCcw, Cpu } from 'lucide-react'+import type { MessageError } from '../../types/chat'+import { useUIStore } from '../../stores/uiStore'++/** Kinds no retry fixes on its own. */+const NO_RETRY: ReadonlySet<MessageError['kind']> = new Set(['credits', 'session'])++export function RunErrorActions({ error, onRetry }: { error: MessageError; onRetry?: () => void }) {+ return (+ <div className="flex flex-wrap items-center gap-1.5 px-1 pt-1.5" data-testid="run-error-actions">+ {onRetry && !NO_RETRY.has(error.kind) && (+ <button+ type="button"+ onClick={onRetry}+ className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md t-control text-gray-800 dark:text-gray-100 border border-gray-300 dark:border-white/15 hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors"+ >+ <RotateCcw size={12} /> Try again+ </button>+ )}+ <button+ type="button"+ onClick={() => useUIStore.getState().askForModel()}+ className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md t-control text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/[0.06] transition-colors"+ >+ <Cpu size={12} /> Choose another model+ </button>+ </div>+ )+}diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex d98921f4..4629a573 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -1776,7 +1776,7 @@ export function useAgentChat() {scheduleUIUpdate()// CA U6: one pass without tools says what is done and what is open.{- const summary = await finishWithoutTools({ provider, model: modelToUse, messages: agentMessages, signal: abort.signal })+ const summary = (isLocalModelByName(activeModel) ? await finishWithoutTools({ provider, model: modelToUse, messages: agentMessages, signal: abort.signal }) : null)if (summary) { runState.content += finishSection(summary); scheduleUIUpdate() }}break@@ -3012,7 +3012,7 @@ export function useAgentChat() {scheduleUIUpdate()// CA U6: one pass without tools says what is done and what is open.{- const summary = await finishWithoutTools({ provider, model: modelToUse, messages: agentMessages, signal: abort.signal })+ const summary = (isLocalModelByName(activeModel) ? await finishWithoutTools({ provider, model: modelToUse, messages: agentMessages, signal: abort.signal }) : null)if (summary) { runState.content += finishSection(summary); scheduleUIUpdate() }}addBlock(runState, convId!, assistantMessage.id, {@@ -3525,7 +3525,7 @@ export function useAgentChat() {scheduleUIUpdate()// CA U6: one pass without tools says what is done and what is open.{- const summary = await finishWithoutTools({ provider, model: modelToUse, messages: agentMessages, signal: abort.signal })+ const summary = (isLocalModelByName(activeModel) ? await finishWithoutTools({ provider, model: modelToUse, messages: agentMessages, signal: abort.signal }) : null)if (summary) { runState.content += finishSection(summary); scheduleUIUpdate() }}breakdiff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex 180500b9..743d26cf 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -29,6 +29,8 @@ import {import { setExplicitFanout } from '../api/agents/sub-agent'import { appendTaskReport } from '../lib/agent-task-report'import { finishWithoutTools, finishSection } from '../lib/agent-core/finish'+import { useProviderStore } from '../stores/providerStore'+import { networkHint, runErrorKind } from '../lib/agent-core/run-error'import { appendSteers } from '../lib/agent-core/steer'import { useSteerStore } from '../stores/steerStore'import { useAgentTaskStore } from '../stores/agentTaskStore'@@ -1337,7 +1339,7 @@ export function useCodex() {const halted = (fullContent ? fullContent + '\n\n' : '') + budget.haltMessage()useChatStore.getState().updateMessageContent(convId!, assistantMsg.id, halted)// CA U6: one pass without tools says what is done and what is open.- const summary = await finishWithoutTools({ provider, model: modelToUse, messages, signal: abort.signal })+ const summary = (isLocalModelByName(activeModel) ? await finishWithoutTools({ provider, model: modelToUse, messages, signal: abort.signal }) : null)if (summary) useChatStore.getState().updateMessageContent(convId!, assistantMsg.id, halted + finishSection(summary))break}@@ -2266,7 +2268,7 @@ export function useCodex() {const msg = `\n\n_(halted: ${batchVerdict.reason}. The model is looping. Try a stronger model for multi-step code tasks, or rephrase the instruction.)_`useChatStore.getState().updateMessageContent(convId, assistantMsg.id, fullContent + msg){- const summary = await finishWithoutTools({ provider, model: modelToUse, messages, signal: abort.signal })+ const summary = (isLocalModelByName(activeModel) ? await finishWithoutTools({ provider, model: modelToUse, messages, signal: abort.signal }) : null)if (summary) useChatStore.getState().updateMessageContent(convId, assistantMsg.id, fullContent + msg + finishSection(summary))}// A halt has to be visible in the thread itself, not only as a@@ -2733,7 +2735,7 @@ export function useCodex() {const msg = `\n\n_(halted: ${failVerdict.reason}. The model is looping. Try a stronger model for multi-step code tasks, or rephrase the instruction.)_`useChatStore.getState().updateMessageContent(convId, assistantMsg.id, fullContent + msg){- const summary = await finishWithoutTools({ provider, model: modelToUse, messages, signal: abort.signal })+ const summary = (isLocalModelByName(activeModel) ? await finishWithoutTools({ provider, model: modelToUse, messages, signal: abort.signal }) : null)if (summary) useChatStore.getState().updateMessageContent(convId, assistantMsg.id, fullContent + msg + finishSection(summary))}addBlock({@@ -2841,7 +2843,9 @@ export function useCodex() {// which for a TypeError from fetch is just "Failed to fetch".let hint = ''if (/Failed to fetch|NetworkError|net::ERR/i.test(msg)) {- hint = '\n\nHint: the Ollama server is unreachable. Is `ollama serve` running on localhost:11434?'+ // CA U7: the backend this run used, not always Ollama.+ const cfg = (useProviderStore.getState().providers as Record<string, { name?: string; baseUrl?: string } | undefined>)[providerId]+ hint = `\n\nHint: ${networkHint({ providerId, name: cfg?.name, baseUrl: cfg?.baseUrl, local: isLocalModelByName(activeModel) })}`} else if (code === 'tools_unsupported' || /does not support tools|tool.*not.*support/i.test(msg)) {markToolsUnsupported(modelToUse)hint = '\n\nHint: this model does not support tool calling, so Code mode cannot use it. Pick a model that supports tool calling (Qwen 3, Llama 3.1+, Gemma 4) or an LU Cloud model shown with the tools badge.'@@ -2876,8 +2880,16 @@ export function useCodex() {})return}+ const answerLength = fullContent.lengthfullContent += `\n\nError: ${msg}${hint}`useChatStore.getState().updateMessageContent(convId, assistantMsg.id, fullContent)+ // The error as a field too (CA U7), like the Agent tab: the transcript+ // offers Try again under it, and the phone draws its own box.+ useChatStore.getState().updateMessageError(convId, assistantMsg.id, {+ kind: runErrorKind({ message: msg, status, code }),+ detail: `${msg}${hint}`.trim(),+ at: answerLength,+ })codexStore.addEvent(convId, {id: uuid(), type: 'error', content: msg, timestamp: Date.now(),})diff --git a/src/lib/agent-core/__tests__/finish.test.ts b/src/lib/agent-core/__tests__/finish.test.tsindex 45989289..1dd89db5 100644--- a/src/lib/agent-core/__tests__/finish.test.ts+++ b/src/lib/agent-core/__tests__/finish.test.ts@@ -31,6 +31,8 @@ describe('a clean end at the limit (CA U6)', () => {const src = (p: string) => readFileSync(resolve(__dirname, '../../..', p), 'utf8')for (const f of ['hooks/useAgentChat.ts', 'hooks/useCodex.ts']) {expect(src(f).match(/finishWithoutTools\(/g)?.length).toBe(3)+ // Local models only (C83: a paid run would send its whole history again).+ expect(src(f).match(/isLocalModelByName\(activeModel\) \? await finishWithoutTools\(/g)?.length).toBe(3)const brake = src(f).indexOf("if (brake.action === 'halt')")expect(src(f).slice(brake, brake + 500)).not.toContain('finishWithoutTools')}diff --git a/src/lib/agent-core/__tests__/run-error.test.ts b/src/lib/agent-core/__tests__/run-error.test.tsnew file mode 100644index 00000000..0d5532dc--- /dev/null+++ b/src/lib/agent-core/__tests__/run-error.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it } from 'vitest'+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'+import { networkHint, runErrorKind } from '../run-error'++describe('a failed coding run, in words (CA U7)', () => {+ it('names the backend the run used instead of always Ollama', () => {+ expect(networkHint({ providerId: 'ollama', name: 'Ollama', baseUrl: 'http://localhost:11434', local: true })).toBe("LU can't reach Ollama at localhost:11434. Is it running?")+ expect(networkHint({ providerId: 'openai', name: 'LM Studio', baseUrl: 'http://127.0.0.1:1234/v1', local: true })).toBe("LU can't reach LM Studio at 127.0.0.1:1234. Is it running?")+ expect(networkHint({ providerId: 'lu-cloud', local: false })).toMatch(/LU Cloud.*internet/)+ expect(networkHint({ providerId: 'anthropic', name: 'Anthropic', local: false })).toMatch(/^No connection to Anthropic/)+ })++ it('sorts the error into the kinds the transcript knows', () => {+ expect(runErrorKind({ message: 'TypeError: Failed to fetch' })).toBe('network')+ expect(runErrorKind({ message: 'x', status: 429 })).toBe('limit')+ expect(runErrorKind({ message: 'x', status: 401 })).toBe('session')+ expect(runErrorKind({ message: 'x', code: 'credits_exhausted' })).toBe('credits')+ expect(runErrorKind({ message: 'x', status: 502 })).toBe('engine')+ expect(runErrorKind({ message: 'x', status: 400 })).toBe('generic')+ })++ it('the Code tab records the error as a field and no longer blames Ollama for every backend', () => {+ const src = readFileSync(resolve(__dirname, '../../../hooks/useCodex.ts'), 'utf8')+ expect(src).not.toContain('Is `ollama serve` running on localhost:11434?')+ expect(src).toMatch(/updateMessageError\(convId, assistantMsg\.id, \{\s*kind: runErrorKind/)+ })+})diff --git a/src/lib/agent-core/finish.ts b/src/lib/agent-core/finish.tsindex aa77dc03..a2b7a9a8 100644--- a/src/lib/agent-core/finish.ts+++ b/src/lib/agent-core/finish.ts@@ -7,8 +7,9 @@* what was done, what is open and what comes next. This is that pass: one call,* no tools, a short answer, and on any failure the old line stays alone.*- * Not used for the cost brake (another paid call is the opposite of braking)- * or for Stop (the user asked for silence).+ * Local models only: on a paid provider the pass would send the whole run's+ * history once more (C83: 400k tokens per request), which is the opposite of+ * stopping. Never at the cost brake, never on Stop (the user asked for silence).*/import type { ChatMessage } from '../../api/providers/types'import { settleThinking } from '../thinking-stripper'diff --git a/src/lib/agent-core/run-error.ts b/src/lib/agent-core/run-error.tsnew file mode 100644index 00000000..20917c5b--- /dev/null+++ b/src/lib/agent-core/run-error.ts@@ -0,0 +1,27 @@+/**+ * What went wrong in a coding run, in words, and which kind it is (CA U7).+ *+ * The Code tab ended every connection failure with "Is `ollama serve` running+ * on localhost:11434?", also for LM Studio, the LU Engine and every cloud+ * provider. It now names the backend the run actually used, and records the+ * error as a field on the message (types/chat.ts MessageError), the way the+ * Agent tab already does, so the transcript can offer Try again.+ */+import type { MessageErrorKind } from '../../types/chat'++export function networkHint(opts: { providerId: string; name?: string; baseUrl?: string; local: boolean }): string {+ const name = opts.name?.trim() || (opts.providerId === 'ollama' ? 'Ollama' : opts.providerId)+ const where = opts.baseUrl?.replace(/^https?:\/\//, '').replace(/\/v1\/?$/, '')+ if (opts.providerId === 'lu-cloud') return 'No connection to LU Cloud. Check your internet connection, then try again.'+ if (opts.local) return `LU can't reach ${name}${where ? ` at ${where}` : ''}. Is it running?`+ return `No connection to ${name}. Check your internet connection, then try again.`+}++export function runErrorKind(opts: { message: string; status?: number; code?: string }): MessageErrorKind {+ if (opts.code === 'credits_exhausted') return 'credits'+ if (opts.code === 'signed_out' || opts.status === 401) return 'session'+ if (opts.status === 429) return 'limit'+ if (/Failed to fetch|NetworkError|net::ERR|ECONNREFUSED|Connection refused/i.test(opts.message)) return 'network'+ if (opts.status && opts.status >= 500) return 'engine'+ return 'generic'+}