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
fix(chat): eine fehlgeschlagene Suche im Dokument wird gesagt, nicht verschluckt
purple4c6fce98bf04
diff --git a/src/components/chat/RetrievalErrorBar.tsx b/src/components/chat/RetrievalErrorBar.tsxnew file mode 100644index 00000000..fa051b6b--- /dev/null+++ b/src/components/chat/RetrievalErrorBar.tsx@@ -0,0 +1,31 @@+/**+ * "Your documents were not searched for that message."+ *+ * Review S4: retrieval failures were logged and nothing else. The user kept a+ * green Docs badge, got an answer, and had no way to know the answer had never+ * seen the PDF. This is the composer-side half of the statement; the RAG panel+ * carries the same sentence for whoever has it open.+ */+import { AlertTriangle, X } from 'lucide-react'+import { useRAGStore } from '../../stores/ragStore'++export function RetrievalErrorBar() {+ const message = useRAGStore((s) => s.retrievalError)+ if (!message) return null+ return (+ <div+ data-testid="retrieval-error-bar"+ className="mx-3 mb-1.5 flex items-start gap-2 px-2 py-1 rounded-md bg-amber-500/10 border border-amber-500/20 text-[0.62rem] text-amber-700 dark:text-amber-300"+ >+ <AlertTriangle size={11} className="shrink-0 mt-0.5" />+ <span className="flex-1 leading-snug">{message}</span>+ <button+ onClick={() => useRAGStore.getState().setRetrievalError(null)}+ className="shrink-0 text-amber-600/70 hover:text-amber-700 dark:text-amber-400/70 dark:hover:text-amber-300"+ aria-label="Dismiss"+ >+ <X size={11} />+ </button>+ </div>+ )+}diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex c45fbeab..96692a2b 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -24,7 +24,7 @@ import { useModelStore } from '../stores/modelStore'import { useSettingsStore } from '../stores/settingsStore'import { useRAGStore } from '../stores/ragStore'import { retrieveContext } from '../api/rag'-import { buildRagSuffix } from '../lib/rag-prompt'+import { buildRagSuffix, RETRIEVAL_FAILED_MESSAGE } from '../lib/rag-prompt'import { toolRegistry } from '../api/mcp'import { usePermissionStore } from '../stores/permissionStore'import { CODEX_CONFIRM_TOOLS, codexConfirmEnabled } from './codexShellGate'@@ -439,8 +439,13 @@ export function useAgentChat() {// at offset 0 it cost the upstream prefix cache the whole prompt// (plan A5).ragSuffix = buildRagSuffix(ragContext.chunks)+ ragState.setRetrievalError(null)} catch (err) {log.error('RAG retrieval failed', { err })+ // Same statement plain chat makes (review S4). An agent run that+ // quietly lost its documents is worse, not better: it goes on to act+ // on what it did not read.+ ragState.setRetrievalError(RETRIEVAL_FAILED_MESSAGE)}}}diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.tsindex a8152834..79baaeeb 100644--- a/src/hooks/useChat.ts+++ b/src/hooks/useChat.ts@@ -8,7 +8,7 @@ import { useMemoryStore } from "../stores/memoryStore"import { useVoiceStore } from "../stores/voiceStore"import { autoSpeak } from "../lib/ttsBridge"import { retrieveContext } from "../api/rag"-import { buildRagSuffix } from "../lib/rag-prompt"+import { buildRagSuffix, RETRIEVAL_FAILED_MESSAGE } from "../lib/rag-prompt"import { getModelMaxTokens, capMessageCount } from "../lib/context-compaction"import { applyChatSendBudget, chatBudgetApplies } from "../lib/chat-send-budget"import { isTooManyMessagesError, halveHistory, TOO_MANY_MESSAGES_MAX_HALVINGS } from "../lib/too-many-messages"@@ -485,8 +485,14 @@ export function useChat() {// The result is appended to the system prompt below, which is what// makes Document Chat work on a cloud model as well as a local one.ragSuffix = buildRagSuffix(ragContext.chunks)+ // A clean turn clears any previous complaint.+ ragState.setRetrievalError(null)} catch (err) {log.error("RAG retrieval failed, continuing without context", { err })+ // Silence here was the defect (review S4): the model answered from+ // nothing while the user watched a green Docs badge and believed the+ // PDF had been read. The panel and the composer both show this.+ ragState.setRetrievalError(RETRIEVAL_FAILED_MESSAGE)}}}diff --git a/src/lib/rag-prompt.ts b/src/lib/rag-prompt.tsindex f1bf3dc8..8961f485 100644--- a/src/lib/rag-prompt.ts+++ b/src/lib/rag-prompt.ts@@ -36,3 +36,11 @@ export function buildRagSuffix(chunks: { content: string }[]): string {.join('\n\n')return `\n\n${RAG_INSTRUCTION}\n\n---\n${contextBlock}\n---`}++/**+ * Shown when retrieval threw and the turn went out without the documents+ * (review S4). English, like every other error surface in the app.+ */+export const RETRIEVAL_FAILED_MESSAGE =+ 'Your documents could not be searched for this message, so the answer was written without them. ' ++ 'Check that the embedding engine is running, then send again.'diff --git a/src/stores/ragStore.ts b/src/stores/ragStore.tsindex 2edaa751..f74c303f 100644--- a/src/stores/ragStore.ts+++ b/src/stores/ragStore.ts@@ -13,6 +13,11 @@ interface RAGState {indexingProgress: { current: number; total: number } | nulllastRetrievedChunks: { chunk: TextChunk; score: number }[]contextWarning: string | null+ /** Retrieval failed on the last send, so the answer was written WITHOUT the+ * documents (review S4). The old code only logged it, which meant the model+ * answered from nothing while the user watched a green Docs badge and+ * believed their PDF had been read. Cleared on the next successful turn. */+ retrievalError: string | nullpullingEmbeddingModel: boolean/** Bytes-level progress for the embedding-model pull (Bug F45-followup,* upgrade-path UX). Populated by useRAG.pullEmbeddingModel from each@@ -40,6 +45,7 @@ interface RAGState {clearConversationDocs: (conversationId: string) => voidsetLastRetrievedChunks: (chunks: { chunk: TextChunk; score: number }[]) => voidsetContextWarning: (warning: string | null) => void+ setRetrievalError: (message: string | null) => voidsetPullingEmbeddingModel: (pulling: boolean) => voidsetEmbeddingPullProgress: (p: { completed: number; total: number; status: string } | null) => voidsetEmbeddingInstallPrompt: (prompt: boolean) => void@@ -58,6 +64,7 @@ export const useRAGStore = create<RAGState>()(indexingProgress: null,lastRetrievedChunks: [],contextWarning: null,+ retrievalError: null,pullingEmbeddingModel: false,embeddingPullProgress: null,embeddingQueuedFiles: [],@@ -177,6 +184,8 @@ export const useRAGStore = create<RAGState>()(setContextWarning: (warning) => set({ contextWarning: warning }),+ setRetrievalError: (message) => set({ retrievalError: message }),+setPullingEmbeddingModel: (pulling) => set({ pullingEmbeddingModel: pulling }),setEmbeddingPullProgress: (p) => set({ embeddingPullProgress: p }),