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): der Docs-Knopf ist auch im Cloud-Chat da
purplea52a54d0418d
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsxindex 566c7d96..923384b7 100644--- a/src/components/chat/ChatView.tsx+++ b/src/components/chat/ChatView.tsx@@ -8,11 +8,12 @@ import { useAgentModeStore } from '../../stores/agentModeStore'import { MessageList } from './MessageList'import { ChatInput } from './ChatInput'import { RAGPanel } from './RAGPanel'+import { DocsButton } from './DocsButton'+import { useDocsAvailability } from '../../hooks/useDocsAvailability'import { AgentModeToggle } from './AgentModeToggle'import { AgentWorkspaceBadge } from './AgentWorkspaceBadge'import { ErrorBoundary } from '../ui/ErrorBoundary'-import { useSettingsStore } from '../../stores/settingsStore'-import { FileText, ChevronDown, Download, Wrench, Radio, RefreshCw, X } from 'lucide-react'+import { ChevronDown, Download, Wrench, Radio, RefreshCw, X } from 'lucide-react'import { PluginsDropdown } from './PluginsDropdown'import { ModelSelector } from '../models/ModelSelector'import { useConversationModelHint } from './ConversationModelNote'@@ -68,11 +69,13 @@ export function ChatView() {const ragEnabled = useRAGStore((s) =>activeConversationId ? s.ragEnabled[activeConversationId] ?? false : false)- // Docs (RAG) needs a LOCAL embeddings backend (built-in llama-server or- // Ollama). In global Cloud mode there is none, so mirror the web app and- // hide the Docs button rather than offer an upload that fails with- // "Ollama is not running". Local mode keeps it (built-in engine embeds).- const appMode = useSettingsStore((s) => s.settings.appMode)+ // Docs (RAG) needs a LOCAL EMBEDDINGS backend, which is not the same thing as+ // a local CHAT backend. That mix-up is what hid the button in Cloud mode until+ // A9 (aldrich_ironhart, 2026-09-01). The embeddings sidecar on 127.0.0.1:8128+ // runs in Cloud mode too, and retrieval reaches the model through the system+ // prompt, which every provider takes. So the question is whether this machine+ // can embed, and that is what useDocsAvailability asks.+ const docs = useDocsAvailability()const isAgentActive = useAgentModeStore((s) =>activeConversationId ? s.agentModeActive[activeConversationId] ?? false : false)@@ -382,7 +385,7 @@ export function ChatView() {// Commands need the tool catalog to drive, which only Agent// mode has here. Plain chat leaves "/cmd" as ordinary text.slashCommands={isAgentActive}- onAttachDocs={appMode !== 'cloud' ? () => setRagPanelOpen(true) : undefined}+ onAttachDocs={docs.enabled ? () => setRagPanelOpen(true) : undefined}composerModel={/* What this chat's answers were written by rides on thepicker itself now, as a dot plus a tooltip, instead of a@@ -396,31 +399,16 @@ export function ChatView() {composerAbove={<><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /></>}composerActions={<>- {/* Documents (RAG) — local-embeddings only, so hide in- Cloud mode (web parity). */}- {appMode !== 'cloud' && (- <button- onClick={() => setRagPanelOpen(!ragPanelOpen)}- className={- 'flex items-center gap-1 px-2 py-1.5 rounded-md transition-all shrink-0 text-[0.6rem] font-medium ' +- (ragPanelOpen || ragEnabled- ? 'bg-green-500/15 text-green-400 border border-green-500/30'- : 'text-gray-500 hover:text-gray-300 hover:bg-white/5')- }- title="Document Chat (RAG)"- >- <FileText size={11} />- <span>Docs</span>- {docCount > 0 && (- <span className={- 'min-w-[12px] h-[12px] flex items-center justify-center rounded-full text-[0.45rem] font-bold ' +- (ragEnabled ? 'bg-green-500 text-white' : 'bg-white/15 text-gray-300')- }>- {docCount}- </span>- )}- </button>- )}+ {/* Documents (RAG), shown in both modes since A9. In+ Cloud mode without an embedding lane it stays visible+ and says what is missing. */}+ <DocsButton+ availability={docs}+ open={ragPanelOpen}+ ragEnabled={ragEnabled}+ docCount={docCount}+ onToggle={() => setRagPanelOpen(!ragPanelOpen)}+ />{/* Plugins (Chat Tools + Caveman + Personas) */}<PluginsDropdown openUpward />diff --git a/src/components/chat/DocsButton.tsx b/src/components/chat/DocsButton.tsxnew file mode 100644index 00000000..acbea151--- /dev/null+++ b/src/components/chat/DocsButton.tsx@@ -0,0 +1,56 @@+/**+ * The Docs button in the composer action row.+ *+ * Its own file since A9, because it now has three states instead of two and a+ * state you cannot render in a test is a state nobody has checked.+ */+import { FileText } from 'lucide-react'+import type { DocsAvailability } from '../../lib/docs-availability'++interface Props {+ availability: DocsAvailability+ /** The RAG panel is open. */+ open: boolean+ /** RAG is switched on for this conversation. */+ ragEnabled: boolean+ /** Documents indexed for this conversation. */+ docCount: number+ onToggle: () => void+}++export function DocsButton({ availability, open, ragEnabled, docCount, onToggle }: Props) {+ if (!availability.visible) return null+ const active = availability.enabled && (open || ragEnabled)+ return (+ <button+ data-testid="docs-toggle"+ onClick={availability.enabled ? onToggle : undefined}+ disabled={!availability.enabled}+ title={availability.title}+ className={+ 'flex items-center gap-1 px-2 py-1.5 rounded-md transition-all shrink-0 text-[0.6rem] font-medium ' ++ (active+ ? 'bg-green-500/15 text-green-400 border border-green-500/30'+ : availability.enabled+ ? 'text-gray-500 hover:text-gray-300 hover:bg-white/5'+ : // Present, readable, and plainly not pressable. Hiding it was the+ // bug; a button that looks alive and does nothing would be the+ // next one.+ 'text-gray-600 opacity-50 cursor-not-allowed')+ }+ >+ <FileText size={11} />+ <span>Docs</span>+ {docCount > 0 && (+ <span+ className={+ 'min-w-[12px] h-[12px] flex items-center justify-center rounded-full text-[0.45rem] font-bold ' ++ (ragEnabled ? 'bg-green-500 text-white' : 'bg-white/15 text-gray-300')+ }+ >+ {docCount}+ </span>+ )}+ </button>+ )+}diff --git a/src/components/chat/RAGPanel.tsx b/src/components/chat/RAGPanel.tsxindex 73a6a9a5..3f4b8dce 100644--- a/src/components/chat/RAGPanel.tsx+++ b/src/components/chat/RAGPanel.tsx@@ -20,6 +20,7 @@ import {import { useShallow } from 'zustand/react/shallow'import { useRAG } from '../../hooks/useRAG'import { useRAGStore } from '../../stores/ragStore'+import { useSettingsStore } from '../../stores/settingsStore'import { formatBytes } from '../../lib/formatters'interface Props {@@ -87,6 +88,7 @@ export function RAGPanel({ conversationId, onClose }: Props) {}function RAGPanelInner({ conversationId, onClose }: { conversationId: string; onClose?: () => void }) {+ const cloudMode = useSettingsStore((s) => s.settings.appMode) === 'cloud'const rag = useRAG(conversationId)const documents = rag.documents ?? []const isEnabled = rag.isEnabled ?? false@@ -268,6 +270,21 @@ function RAGPanelInner({ conversationId, onClose }: { conversationId: string; on)}</div>+ {/* Where the files stay, said in Cloud mode because in Cloud mode it is a+ fair question (A9). Indexing runs on this machine on 127.0.0.1:8128;+ only the passages that match the question travel with the prompt. */}+ {cloudMode && (+ <div className="px-3 pt-2">+ <p+ data-testid="rag-cloud-privacy"+ className="text-[0.6rem] leading-snug text-gray-500 dark:text-gray-400"+ >+ Your documents are indexed on this computer and stay here. Only the passages+ that match your question are sent to the cloud model as context.+ </p>+ </div>+ )}+{/* Context window warning */}<AnimatePresence>{contextWarning && (diff --git a/src/components/chat/__tests__/docs-in-cloud-chat.test.ts b/src/components/chat/__tests__/docs-in-cloud-chat.test.tsnew file mode 100644index 00000000..2975644c--- /dev/null+++ b/src/components/chat/__tests__/docs-in-cloud-chat.test.ts@@ -0,0 +1,151 @@+/**+ * @vitest-environment jsdom+ *+ * A9: "There's no document tab in cloud chat to add documents and audio clips"+ * (aldrich_ironhart, Discord #general, 2026-09-01).+ *+ * He was right. ChatView hid the Docs button on `appMode !== 'cloud'`, on the+ * belief that Document Chat needs a local backend. It needs a local EMBEDDING+ * backend, which is a different sidecar (127.0.0.1:8128), one the app resumes+ * in Cloud mode too, and the retrieved passages reach the model through the+ * system prompt, which every provider takes.+ *+ * So the rule is not about the mode any more, it is about the embedding lane.+ * Three states, each rendered for real, plus the negative controls that keep+ * the fix from turning into "always enabled, never honest":+ *+ * local -> visible, pressable, unchanged+ * cloud + embeddings present -> visible, pressable, tooltip says where the+ * files stay+ * cloud + no embeddings -> visible, NOT pressable, tooltip names the+ * missing part instead of hiding the feature+ *+ * Run: npx vitest run src/components/chat/__tests__/docs-in-cloud-chat.test.ts+ */+import { describe, it, expect, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, cleanup, fireEvent } from '@testing-library/react'+import { DocsButton } from '../DocsButton'+import {+ docsAvailability,+ DOCS_TITLE_PLAIN,+ DOCS_TITLE_CLOUD,+ DOCS_TITLE_NO_EMBEDDINGS,+} from '../../../lib/docs-availability'++afterEach(() => cleanup())++function show(appMode: 'local' | 'cloud', embedReady: boolean | null, onToggle = () => {}) {+ return render(+ createElement(DocsButton, {+ availability: docsAvailability(appMode, embedReady),+ open: false,+ ragEnabled: false,+ docCount: 0,+ onToggle,+ }),+ )+}++const docs = () => screen.queryByTestId('docs-toggle') as HTMLButtonElement | null++describe('the rule that decides the Docs button', () => {+ it('local mode is untouched: there, pressable, plain tooltip', () => {+ expect(docsAvailability('local', null)).toEqual({+ visible: true,+ enabled: true,+ title: DOCS_TITLE_PLAIN,+ })+ })++ it('local mode does not care what the embedding probe says, in either direction', () => {+ // Negative control for the probe: local mode never measured it before the+ // fix and must not start depending on it now.+ expect(docsAvailability('local', false).enabled).toBe(true)+ expect(docsAvailability('local', true).enabled).toBe(true)+ })++ it('cloud with an embedding lane: there and pressable, which is the whole bug report', () => {+ const a = docsAvailability('cloud', true)+ expect(a.visible).toBe(true)+ expect(a.enabled).toBe(true)+ expect(a.title).toBe(DOCS_TITLE_CLOUD)+ })++ it('cloud without one: still there, but off, and it says why', () => {+ expect(docsAvailability('cloud', false)).toEqual({+ visible: true,+ enabled: false,+ title: DOCS_TITLE_NO_EMBEDDINGS,+ })+ })++ it('cloud while the probe is still running keeps it pressable, not dead-then-alive', () => {+ // A button that starts disabled and wakes up a moment later reads as+ // broken. Unknown is not "no".+ expect(docsAvailability('cloud', null).enabled).toBe(true)+ })++ it('never hides the button again, in any state', () => {+ for (const mode of ['local', 'cloud'] as const) {+ for (const ready of [true, false, null]) {+ expect(docsAvailability(mode, ready).visible).toBe(true)+ }+ }+ })+})++describe('the button as it actually renders', () => {+ it('cloud with embeddings: present, enabled, and clicking opens the panel', () => {+ const onToggle = vi.fn()+ show('cloud', true, onToggle)+ const b = docs()+ expect(b).not.toBeNull()+ expect(b!.disabled).toBe(false)+ expect(b!.getAttribute('title')).toBe(DOCS_TITLE_CLOUD)+ expect(b!.getAttribute('title')).toContain('stay here')+ fireEvent.click(b!)+ expect(onToggle).toHaveBeenCalledTimes(1)+ })++ it('cloud without embeddings: present, disabled, tooltip names the engine, click does nothing', () => {+ const onToggle = vi.fn()+ show('cloud', false, onToggle)+ const b = docs()+ expect(b).not.toBeNull()+ expect(b!.disabled).toBe(true)+ expect(b!.getAttribute('title')).toBe('Documents need the local embeddings engine')+ fireEvent.click(b!)+ expect(onToggle).not.toHaveBeenCalled()+ })++ it('local: present and enabled, exactly as before the fix', () => {+ const onToggle = vi.fn()+ show('local', null, onToggle)+ const b = docs()+ expect(b).not.toBeNull()+ expect(b!.disabled).toBe(false)+ expect(b!.textContent).toContain('Docs')+ fireEvent.click(b!)+ expect(onToggle).toHaveBeenCalledTimes(1)+ })++ it('the document count still rides along, and a disabled button never looks active', () => {+ cleanup()+ render(+ createElement(DocsButton, {+ availability: docsAvailability('cloud', false),+ open: true,+ ragEnabled: true,+ docCount: 3,+ onToggle: () => {},+ }),+ )+ const b = docs()!+ expect(b.textContent).toContain('3')+ // Negative control on the styling: open + ragEnabled would normally paint+ // the button green. A button that cannot be pressed must not claim to be on.+ expect(b.className).not.toContain('bg-green-500/15')+ expect(b.className).toContain('cursor-not-allowed')+ })+})diff --git a/src/hooks/__tests__/docs-availability-asks-the-embed-lane.test.ts b/src/hooks/__tests__/docs-availability-asks-the-embed-lane.test.tsnew file mode 100644index 00000000..066462f6--- /dev/null+++ b/src/hooks/__tests__/docs-availability-asks-the-embed-lane.test.ts@@ -0,0 +1,84 @@+/**+ * @vitest-environment jsdom+ *+ * The rule in lib/docs-availability.ts is only worth anything if the composer+ * feeds it a real measurement. This file checks the wiring, which is the part a+ * pure-function test cannot see:+ *+ * local -> no probe at all, and the button is on+ * cloud -> exactly one probe, and its answer decides+ *+ * The probe itself (api/embed-availability.ts) is stubbed here on purpose. What+ * it asks the sidecar is covered by api/__tests__/embed-lane-readiness.test.ts;+ * what the composer does with the answer is covered here.+ *+ * Run: npx vitest run src/hooks/__tests__/docs-availability-asks-the-embed-lane.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, cleanup, waitFor } from '@testing-library/react'+import { useDocsAvailability } from '../useDocsAvailability'+import { useSettingsStore } from '../../stores/settingsStore'+import { DEFAULT_SETTINGS } from '../../lib/constants'+import { DOCS_TITLE_NO_EMBEDDINGS } from '../../lib/docs-availability'++const probe = vi.fn<() => Promise<boolean>>()+vi.mock('../../api/embed-availability', () => ({+ embeddingBackendReady: () => probe(),+ builtinEmbedReady: async () => false,+}))++function Probe() {+ const a = useDocsAvailability()+ return createElement('div', {+ 'data-testid': 'state',+ 'data-enabled': String(a.enabled),+ 'data-visible': String(a.visible),+ title: a.title,+ })+}++const state = () => screen.getByTestId('state')++beforeEach(() => {+ probe.mockReset()+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'local' } })+})+afterEach(() => cleanup())++describe('the composer asks the embedding lane, not the app mode', () => {+ it('local mode never probes and never turns the button off', async () => {+ probe.mockResolvedValue(false)+ render(createElement(Probe))+ await waitFor(() => expect(state().getAttribute('data-visible')).toBe('true'))+ expect(state().getAttribute('data-enabled')).toBe('true')+ // Negative control: a probe that would say no was never even asked.+ expect(probe).not.toHaveBeenCalled()+ })++ it('cloud mode with an embedding lane keeps the button on', async () => {+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'cloud' } })+ probe.mockResolvedValue(true)+ render(createElement(Probe))+ await waitFor(() => expect(probe).toHaveBeenCalledTimes(1))+ await waitFor(() => expect(state().getAttribute('data-enabled')).toBe('true'))+ expect(state().getAttribute('title')).toContain('stay here')+ })++ it('cloud mode without one shows it and says what is missing', async () => {+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'cloud' } })+ probe.mockResolvedValue(false)+ render(createElement(Probe))+ await waitFor(() => expect(state().getAttribute('data-enabled')).toBe('false'))+ expect(state().getAttribute('data-visible')).toBe('true')+ expect(state().getAttribute('title')).toBe(DOCS_TITLE_NO_EMBEDDINGS)+ })++ it('a probe that throws is reported as missing, not as working', async () => {+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'cloud' } })+ probe.mockRejectedValue(new Error('tauri bridge missing'))+ render(createElement(Probe))+ await waitFor(() => expect(state().getAttribute('data-enabled')).toBe('false'))+ expect(state().getAttribute('title')).toBe(DOCS_TITLE_NO_EMBEDDINGS)+ })+})diff --git a/src/hooks/useDocsAvailability.ts b/src/hooks/useDocsAvailability.tsnew file mode 100644index 00000000..3eaad521--- /dev/null+++ b/src/hooks/useDocsAvailability.ts@@ -0,0 +1,44 @@+/**+ * Docs-button state for the composer (A9).+ *+ * Local mode answers without asking anything, exactly as before. Cloud mode+ * probes the local embedding lane once per mount and reports what it found, so+ * the button can be there and say why it cannot run instead of being missing.+ */+import { useEffect, useState } from 'react'+import { useSettingsStore } from '../stores/settingsStore'+import { useRAGStore } from '../stores/ragStore'+import { embeddingBackendReady } from '../api/embed-availability'+import { docsAvailability, type DocsAvailability } from '../lib/docs-availability'++export function useDocsAvailability(): DocsAvailability {+ const appMode = useSettingsStore((s) => s.settings.appMode)+ // `null` = not measured yet. Local mode never measures: the rule ignores the+ // probe there, and a Tauri round trip per composer mount for an answer nobody+ // reads is a cost with no buyer.+ const [embedReady, setEmbedReady] = useState<boolean | null>(null)++ useEffect(() => {+ if (appMode !== 'cloud') {+ setEmbedReady(null)+ return+ }+ let cancelled = false+ ;(async () => {+ try {+ const ready = await embeddingBackendReady(useRAGStore.getState().embeddingModel)+ if (!cancelled) setEmbedReady(ready)+ } catch {+ // A probe that cannot run is not proof the lane is dead, but it is not+ // proof it lives either, and the honest report is the one the user can+ // act on: the tooltip names the missing part.+ if (!cancelled) setEmbedReady(false)+ }+ })()+ return () => {+ cancelled = true+ }+ }, [appMode])++ return docsAvailability(appMode, embedReady)+}diff --git a/src/lib/docs-availability.ts b/src/lib/docs-availability.tsnew file mode 100644index 00000000..ee353cb8--- /dev/null+++ b/src/lib/docs-availability.ts@@ -0,0 +1,65 @@+/**+ * Who gets the Docs button, and when it can be pressed.+ *+ * A9 (aldrich_ironhart, Discord #general 2026-09-01): "There's no document tab+ * in cloud chat to add documents and audio clips". He was right, and the+ * reason it was missing did not hold up. Document Chat needs an EMBEDDING+ * backend, not a chat backend, and the embedding backend is the bundled+ * llama-server on 127.0.0.1:8128, which the app starts and resumes without ever+ * asking what appMode says (useModels.resumeEmbedServer). Retrieval then puts+ * the matching passages into the system prompt (lib/rag-prompt.ts), and a+ * system prompt is the one thing every provider takes. So nothing about Cloud+ * mode stops Document Chat; the button was hidden on the wrong question.+ *+ * The rule below asks the right one. Local mode is untouched. Cloud mode shows+ * the button and lets the missing part, if any, say so in a tooltip instead of+ * hiding the feature and leaving the user to guess.+ */+import type { AppMode } from '../types/settings'++export interface DocsAvailability {+ /** Render the button at all. Always true now, which is the fix. */+ visible: boolean+ /** Clickable. False only in Cloud mode with no embedding backend on the box. */+ enabled: boolean+ /** The button's tooltip. Carries the reason when disabled, and the privacy+ * statement when Cloud mode is about to send passages upstream. */+ title: string+}++/** Local mode, and Cloud mode before the probe answers. */+export const DOCS_TITLE_PLAIN = 'Document Chat (RAG)'++/**+ * Cloud mode with a working embedding lane. It says where the files stay,+ * because in Cloud mode that is a fair question and the answer is good news:+ * indexing runs on this machine, and only the passages that match the question+ * travel with the prompt.+ */+export const DOCS_TITLE_CLOUD =+ 'Document Chat (RAG). Your files are indexed on this computer and stay here. ' ++ 'Only the passages that match your question are sent to the cloud model as context.'++/** Cloud mode with no embedding backend. The exact wording David asked for. */+export const DOCS_TITLE_NO_EMBEDDINGS = 'Documents need the local embeddings engine'++/**+ * @param appMode the global Local/Cloud switch+ * @param embedReady result of the embedding-lane probe, or `null` while it is+ * still running. Unknown counts as available on purpose: a button that starts+ * dead and comes alive a moment later reads as broken, and the RAG panel+ * carries its own install card for the case the probe then says no.+ */+export function docsAvailability(appMode: AppMode, embedReady: boolean | null): DocsAvailability {+ if (appMode !== 'cloud') {+ return { visible: true, enabled: true, title: DOCS_TITLE_PLAIN }+ }+ if (embedReady === false) {+ return { visible: true, enabled: false, title: DOCS_TITLE_NO_EMBEDDINGS }+ }+ return {+ visible: true,+ enabled: true,+ title: embedReady === true ? DOCS_TITLE_CLOUD : DOCS_TITLE_PLAIN,+ }+}