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: file upload, thinking toggle, compact UI, clean tool output
PurpleDoubleD28122f04d459
diff --git a/readme.txt b/readme.txtnew file mode 100644index 00000000..9a86ebe3--- /dev/null+++ b/readme.txt@@ -0,0 +1,355 @@+<div align="center">++<img src="logos/LU-monogram-bw.png" alt="Locally Uncensored" width="80">++# Locally Uncensored++**The only local AI app that does Chat + Agent Mode + Images + Video — all in one.**++No cloud. No censorship. No data collection. Your AI, your rules.++[](https://opensource.org/licenses/MIT)+[](https://github.com/PurpleDoubleD/locally-uncensored/stargazers)+[](https://github.com/PurpleDoubleD/locally-uncensored/commits)+[](https://github.com/PurpleDoubleD/locally-uncensored/discussions)+[](https://locallyuncensored.com)++<img src="docs/demo.gif" alt="Locally Uncensored Demo" width="700">++*Chat with AI personas, generate images, create videos — all running locally on your machine.*++[Getting Started](#-quick-start) · [Portable Download](#-portable--no-install) · [Features](#-features) · [Why This App?](#-why-locally-uncensored) · [Roadmap](#-roadmap) · [Contributing](CONTRIBUTING.md)++</div>++---++### 📸 Screenshots++| Chat with Personas | Image / Video Generation |+|:---:|:---:|+|  |  |+| **Model Manager** | **Create View with Parameters** |+|  |  |++---++## v2.2 — Latest Release++**New:** Custom dark titlebar (no more Windows chrome), branded NSIS installer, Qwen3-Coder integration, Download Manager with multi-pull + pause/resume, auto-unload on model switch, redesigned Model Selector, Update Checker++See the full [Release Notes](https://github.com/PurpleDoubleD/locally-uncensored/releases/tag/v2.2.0).++---++## ❓ Why Locally Uncensored?++Tired of switching between Ollama for chat, ComfyUI for images, and another tool for video? Frustrated with bloated UIs that need Docker and a PhD to set up?++**Locally Uncensored** is the all-in-one solution. One app. One setup. Everything local.++### How it compares++| Feature | Locally Uncensored | Open WebUI | LM Studio | SillyTavern |+|---------|:-:|:-:|:-:|:-:|+| AI Chat | ✅ | ✅ | ✅ | ✅ |+| **Multi-Provider** (Ollama + Cloud) | **✅** | ✅ | ✅ | ❌ |+| **Agent Mode (Tool Calling)** | **✅** | ❌ | ❌ | ❌ |+| **Model A/B Compare** | **✅** | ❌ | ❌ | ❌ |+| **Local Benchmark** | **✅** | ❌ | ❌ | ❌ |+| Image Generation | ✅ | ❌ | ❌ | ❌ |+| Video Generation | ✅ | ❌ | ❌ | ❌ |+| Uncensored by Default | ✅ | ❌ | ❌ | ⚠️ |+| Memory System | ✅ | ⚠️ (plugin) | ❌ | ❌ |+| **Agent Workflows** | **✅** | ❌ | ❌ | ❌ |+| LaTeX / Math Rendering | ✅ | ✅ | ❌ | ❌ |+| One-Click Setup | ✅ | ❌ (Docker) | ✅ | ❌ (Node.js) |+| 25+ Built-in Personas | ✅ | ❌ | ❌ | ⚠️ (manual) |+| RAG / Document Chat | ✅ | ✅ | ❌ | ❌ |+| Voice (STT + TTS) | ✅ | ⚠️ | ❌ | ❌ |+| Open Source | ✅ | ✅ | ❌ | ✅ |+| 100% Offline | ✅ | ✅ | ✅ | ✅ |++---++## ✨ Features++- **Uncensored AI Chat** — Run abliterated models locally with zero restrictions+- **Multi-Provider Support** — Ollama (local), OpenAI-compatible (OpenRouter, Groq, LMStudio, vLLM), Anthropic (Claude). Switch providers per conversation.+- **Agent Mode (Beta)** — Give your AI tools: web search, web fetch, file I/O, code execution, image generation. It chains tools autonomously to answer questions with real data. Best with [Hermes 3](https://ollama.com/library/hermes3).+- **Model A/B Compare** — Send the same prompt to two models side by side. Compare speed, quality, and token usage in real-time with parallel streaming.+- **Local Benchmark** — One-click benchmark any model on your hardware. Measures tokens/sec, time-to-first-token. Leaderboard across all tested models.+- **Memory System** — The AI remembers you across conversations. Context-aware injection scales with model size. Auto-extraction learns from every exchange. Export/import as .md or .json.+- **Agent Workflows** — Reusable multi-step agent chains. 3 built-in workflows (Research Topic, Summarize URL, Code Review). Visual builder for custom workflows with prompt, tool, condition, and loop steps.+- **Image Generation** — Text-to-image via ComfyUI with full parameter control+- **Video Generation** — Text-to-video with Wan 2.1/2.2, HunyuanVideo, LTX support+- **Document Chat (RAG)** — Upload PDFs, DOCX, or TXT files and chat with your documents+- **Voice Chat** — Talk to your AI with push-to-talk and hear responses with TTS+- **LaTeX / Math Rendering** — Full KaTeX support for inline and block math equations+- **Chat Export** — Export conversations as Markdown or JSON with one click+- **Token Counter** — Live token usage display with color-coded progress bar+- **Keyboard Shortcuts** — Ctrl+N (new chat), Ctrl+E (export), Ctrl+L (focus input), Ctrl+/ (shortcuts)+- **Search Providers** — Agent web search via SearXNG, Brave Search, Tavily, or DuckDuckGo. Configurable in settings.+- **25+ Personas** — From Helpful Assistant to Roast Master, switchable via dropdown+- **Model Manager** — Browse uncensored + mainstream models. HOT/AGENT badges. Variant selector for multi-size downloads.+- **Thinking Display** — See the AI's reasoning in collapsible blocks+- **Custom Dark Titlebar** — No native Windows chrome. Sleek frameless window with drag region, matching the app's luxury dark aesthetic.+- **Branded Installer** — Dark-themed NSIS installer with custom header and sidebar images. Premium from first click.+- **Linear/Arc UI** — Compact, monochrome, collapsible settings. Premium feel.+- **Privacy First** — Zero tracking. All API calls proxied locally. No analytics.+- **100% Local** — Everything runs on your machine (cloud providers optional)+- **Standalone Desktop App** — Tauri v2 Rust backend. Download the .exe, run it.++## Tech Stack++- **Desktop**: Tauri v2 (Rust backend, standalone .exe — no Node.js required)+- **Frontend**: React 19, TypeScript, Tailwind CSS 4, Framer Motion+- **State**: Zustand with localStorage persistence+- **AI Backend**: Ollama (local text), OpenAI-compat (cloud/local), Anthropic (cloud), ComfyUI (images/video), faster-whisper (voice)+- **Build**: Vite 8 (dev), Tauri CLI (production)++---++## 🚀 Quick Start++### Windows++```bash+git clone https://github.com/PurpleDoubleD/locally-uncensored.git+cd locally-uncensored+setup.bat+```++### Linux / macOS++```bash+git clone https://github.com/PurpleDoubleD/locally-uncensored.git+cd locally-uncensored+chmod +x setup.sh+./setup.sh+```++The setup script automatically:+1. Checks for Node.js 18+, Git, and Ollama+2. Installs missing dependencies+3. Downloads a recommended uncensored AI model (~5.7 GB)+4. Starts the app in your browser++### Manual Installation++**Prerequisites:** [Node.js](https://nodejs.org/) 18+, [Ollama](https://ollama.com/)++```bash+git clone https://github.com/PurpleDoubleD/locally-uncensored.git+cd locally-uncensored+npm install+npm run dev+```++Open **http://localhost:5173** — the app recommends models on first launch.++### Image & Video Generation++No separate installation needed! When you open the **Create** tab:++1. The app checks for ComfyUI automatically+2. If not found, click **"Install ComfyUI Automatically"** — it clones, installs dependencies, and sets up CUDA in one click+3. Go to **Model Manager → Discover → Image/Video** and click **Install All** on any model bundle+4. Generate images and videos — everything is ready++The entire setup happens inside the app. No terminal commands, no manual config files.++### One-Click Start (Windows)++```batch+start.bat+```++Launches Ollama + ComfyUI + the app in one go.++---++## 📦 Portable / No-Install++**Don't want to install anything?** Download the portable version — just extract and run. No admin rights, no installer, no registry entries.++### Windows (Portable)+1. Go to [Releases](https://github.com/PurpleDoubleD/locally-uncensored/releases)+2. Download the `.exe` installer+3. When the installer opens, select **"Install for current user only (portable)"**+4. Choose any folder (e.g., a USB drive) — done!++Alternatively, download the `.msi` for a traditional system-wide install.++### Linux (Portable)+1. Download the `.AppImage` from [Releases](https://github.com/PurpleDoubleD/locally-uncensored/releases)+2. `chmod +x Locally-Uncensored_*.AppImage`+3. `./Locally-Uncensored_*.AppImage`++No installation needed — AppImage is portable by design.++### macOS (Portable)+1. Download the `.dmg` from [Releases](https://github.com/PurpleDoubleD/locally-uncensored/releases)+2. Drag to any folder (doesn't have to be Applications)+3. Right-click → Open (first time only, to bypass Gatekeeper)++> **Note:** You still need [Ollama](https://ollama.com/) installed for AI chat. The app will guide you through setup on first launch.++---++## 🧠 Model Auto-Detection++The app automatically detects all installed models across all backends — no manual configuration needed:++- **Text models** — Auto-detected from Ollama. On first launch, the app scans your hardware and recommends the best uncensored models for your system.+- **Image models** — Auto-detected from ComfyUI's `models/checkpoints` folder. Drop any checkpoint in there and it shows up instantly.+- **Video models** — Auto-detected from ComfyUI. The app identifies your video backend (Wan 2.1/2.2 or AnimateDiff) and lists available models automatically.++Just install models in the standard locations and the app picks them up.++## 🎭 Recommended Models++### Text (Ollama) — scales to your hardware++| Model | Size | VRAM | Best For |+|-------|------|------|----------|+| **Hermes 3 8B** | 4.3 GB | 6 GB | **Agent Mode** — uncensored + native tool calling |+| **Hermes 3 70B** | 42 GB | 48 GB | **Best Agent** — maximum power |+| **Gemma 4 26B MoE** | 18 GB | 8 GB | 26B brain, runs like 4B. Vision + tools. Apache 2.0 |+| Gemma 4 E4B | 9.6 GB | 6 GB | Vision + native tools. 128K context |+| **Qwen3-Coder 30B** | 18 GB | 16 GB | **Best coding agent** — 256K context, native tool calling |+| Qwen 3.5 Abliterated | 5–18 GB | 6–16 GB | Best overall intelligence |+| Qwen 3 8B Abliterated | 5.2 GB | 6 GB | Fast, great for coding |+| DeepSeek R1 (8B–70B) | 5–42 GB | 6–48 GB | Chain-of-thought reasoning |+| GLM 4.6 9B Abliterated | 6 GB | 8 GB | Strong coding |+| Llama 3.1 8B Abliterated | 5.7 GB | 6 GB | Fastest all-rounder |+| Llama 3.3 70B Abliterated | 42 GB | 48 GB | Maximum intelligence |++### Image (ComfyUI)++| Model | VRAM | Notes |+|-------|------|-------|+| FLUX 2 Klein 4B | 8 GB | Next-gen, fastest FLUX |+| FLUX.1 Dev / Schnell | 8–10 GB | Best text-to-image |+| Juggernaut XL V9 | 6 GB | Best photorealistic SDXL |+| Pony Diffusion V6 XL | 6 GB | Anime/stylized |++### Video (ComfyUI)++| Model | VRAM | Output | Notes |+|-------|------|--------|-------|+| Wan 2.1 T2V 1.3B | 8–10 GB | 480p | Best entry point, fast |+| Wan 2.1 T2V 14B FP8 | 12+ GB | 720p | High quality |+| HunyuanVideo 1.5 FP8 | 12+ GB | 480p | Excellent temporal consistency |+| LTX Video 2.3 22B FP8 | 16+ GB | 480p+ | Latest, fast inference |++---++## ⚙️ Configuration++### Environment Variables++Create a `.env` file (see `.env.example`):++```env+# Path to your ComfyUI installation (optional)+COMFYUI_PATH=/path/to/your/ComfyUI+```++### In-App Settings++- **Temperature** — Controls randomness (0 = deterministic, 1 = creative)+- **Top P / Top K** — Fine-tune token sampling+- **Max Tokens** — Limit response length (0 = unlimited)+- **Theme** — Dark or Light mode++---++## 🗺️ Roadmap++- [x] **RAG / Document Chat** — Upload PDFs and chat with your documents+- [x] **Agent Mode (Beta)** — Tool calling with web search, file I/O, code execution+- [x] **Memory System** — Persistent agent memory with export/import+- [x] **Voice Chat** — STT + TTS with local Whisper+- [x] **Multi-Provider** — Ollama + OpenAI-compatible + Anthropic+- [x] **Model A/B Compare** — Side-by-side model comparison with parallel streaming+- [x] **Local Benchmark** — One-click benchmark with leaderboard+- [x] **LaTeX Rendering** — KaTeX for math equations+- [x] **Token Counter** — Live context window usage+- [x] **Chat Export** — Markdown and JSON export+- [x] **Keyboard Shortcuts** — Power-user shortcuts (Ctrl+N, Ctrl+E, Ctrl+/)+- [x] **Search Providers** — Brave Search, Tavily, SearXNG, DuckDuckGo+- [x] **Regenerate / Edit** — Edit user messages, regenerate AI responses+- [x] **Memory Debug** — See which memories are injected into prompts+- [ ] **MCP Support** — Model Context Protocol for extensible tool calling+- [ ] **Create Modes** — img2img, upscale, inpainting, background removal+- [x] **Agent Workflows** — Multi-step workflow chains with visual builder+- [ ] **Plugin System** — Extend the app with community plugins+- [ ] **Mobile UI** — Responsive layout for phone/tablet access++Have an idea? [Open a discussion](https://github.com/PurpleDoubleD/locally-uncensored/discussions)!++---++## 📁 Project Structure++```+src/+ api/ # Backend clients (Ollama, ComfyUI, providers, RAG, voice, agents)+ providers/ # Multi-provider system (Ollama, OpenAI-compat, Anthropic)+ components/ # React components+ chat/ # Chat UI, A/B Compare, Token Counter, Export+ create/ # Image/Video generation UI+ models/ # Model management, Benchmark, Discovery+ personas/ # Persona selection+ settings/ # App settings, Provider config, Search provider+ layout/ # App shell, Sidebar, Header, Shortcuts modal+ ui/ # Reusable UI components+ hooks/ # useChat, useABCompare, useBenchmark, useKeyboardShortcuts+ stores/ # Zustand stores (chat, model, settings, provider, compare, benchmark)+ types/ # TypeScript definitions+ lib/ # Utilities, benchmark prompts, chat export, model compatibility+```++---++## 🖥️ Platform Support++| Platform | Status | Download |+|----------|--------|----------|+| **Windows** (10/11) | ✅ Fully tested | `.exe` / `.msi` |+| **Linux** (Ubuntu 22.04+, Debian, Fedora) | ✅ Fully tested | `.AppImage` / `.deb` |+| **macOS** | 🚧 Community testing | Build from source |++> **Note:** We actively test and support Windows and Linux. macOS builds are provided on a best-effort basis — we don't have Mac hardware for testing. macOS users can build from source (see below) and we welcome community feedback and PRs for Mac-specific issues.++### Build from source (all platforms)+```bash+git clone https://github.com/PurpleDoubleD/locally-uncensored.git+cd locally-uncensored+npm install+npm run dev # Development+npm run tauri build # Production binary+```++## Contributing++We welcome contributions! Check out the [Contributing Guide](CONTRIBUTING.md) for details on how to get started.++See our [open issues](https://github.com/PurpleDoubleD/locally-uncensored/issues) or the [Roadmap](#-roadmap) for areas where help is needed.++## License++This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.++---++<div align="center">++**Built with privacy in mind. Your data stays on your machine.** 🔒++If you find this useful, consider giving it a ⭐++[Website](https://locallyuncensored.com) · [Report Bug](https://github.com/PurpleDoubleD/locally-uncensored/issues/new?template=bug_report.yml) · [Request Feature](https://github.com/PurpleDoubleD/locally-uncensored/issues/new?template=feature_request.yml) · [Join Discussion](https://github.com/PurpleDoubleD/locally-uncensored/discussions)++</div>diff --git a/src/api/agents.ts b/src/api/agents.tsindex 8931b19e..562b5ded 100644--- a/src/api/agents.ts+++ b/src/api/agents.ts@@ -265,7 +265,10 @@ export async function executeTool(code: args.code,timeout: 30000,});- return `Exit code: ${data.exitCode ?? 0}\nStdout:\n${data.stdout || ""}\nStderr:\n${data.stderr || ""}`;+ const output = data.stdout || "";+ const err = data.stderr || "";+ if (data.exitCode && data.exitCode !== 0) return `Error (${data.exitCode}):\n${err || output}`;+ return output || (err ? `stderr: ${err}` : "Done.");}case "file_read": {diff --git a/src/api/mcp/builtin-tools.ts b/src/api/mcp/builtin-tools.tsindex ffccaafd..2e5ccfae 100644--- a/src/api/mcp/builtin-tools.ts+++ b/src/api/mcp/builtin-tools.ts@@ -271,12 +271,20 @@ async function executeShellExecute(args: Record<string, any>): Promise<string> {timeout: args.timeout || 120000,shell: args.shell || null,})- return `Exit code: ${data.exitCode ?? 0}\nStdout:\n${data.stdout || ''}\nStderr:\n${data.stderr || ''}`+ const output = data.stdout || ''+ const err = data.stderr || ''+ if (data.timedOut) return `Timed out.\n${err}`+ if (data.exitCode && data.exitCode !== 0) return `Error (${data.exitCode}):\n${err || output}`+ return output || (err ? `stderr: ${err}` : 'Done.')}async function executeCodeExecute(args: Record<string, any>): Promise<string> {const data = await backendCall('execute_code', { code: args.code, timeout: 30000 })- return `Exit code: ${data.exitCode ?? 0}\nStdout:\n${data.stdout || ''}\nStderr:\n${data.stderr || ''}`+ const output = data.stdout || ''+ const err = data.stderr || ''+ if (data.timedOut) return `Timed out.\n${err}`+ if (data.exitCode && data.exitCode !== 0) return `Error (${data.exitCode}):\n${err || output}`+ return output || (err ? `stderr: ${err}` : 'Done.')}async function executeSystemInfo(): Promise<string> {diff --git a/src/api/providers/anthropic-provider.ts b/src/api/providers/anthropic-provider.tsindex b20c123c..57e1c6b2 100644--- a/src/api/providers/anthropic-provider.ts+++ b/src/api/providers/anthropic-provider.ts@@ -280,8 +280,20 @@ export class AnthropicProvider implements ProviderClient {continue}- // Regular user/assistant message- anthropicMessages.push({ role: msg.role, content: msg.content })+ // Regular user/assistant message — with optional images+ if (msg.images?.length && msg.role === 'user') {+ const content: any[] = []+ for (const img of msg.images) {+ content.push({+ type: 'image',+ source: { type: 'base64', media_type: img.mimeType, data: img.data },+ })+ }+ content.push({ type: 'text', text: msg.content })+ anthropicMessages.push({ role: 'user', content })+ } else {+ anthropicMessages.push({ role: msg.role, content: msg.content })+ }}// Anthropic requires messages to alternate user/assistant.diff --git a/src/api/providers/ollama-provider.ts b/src/api/providers/ollama-provider.tsindex 127b5dd9..b1c5b041 100644--- a/src/api/providers/ollama-provider.ts+++ b/src/api/providers/ollama-provider.ts@@ -16,7 +16,7 @@ import { parseNDJSONStream } from '../stream'// ── Ollama-specific types ──────────────────────────────────────interface OllamaChatChunk {- message?: { content: string; tool_calls?: { function: { name: string; arguments: Record<string, any> } }[] }+ message?: { content: string; thinking?: string; tool_calls?: { function: { name: string; arguments: Record<string, any> } }[] }done?: boolean}@@ -58,7 +58,11 @@ export class OllamaProvider implements ProviderClient {messages: ChatMessage[],options?: ChatOptions,): AsyncGenerator<ChatStreamChunk> {- const ollamaMessages = messages.map(m => ({ role: m.role, content: m.content }))+ const ollamaMessages = messages.map(m => {+ const msg: Record<string, any> = { role: m.role, content: m.content }+ if (m.images?.length) msg.images = m.images.map(img => img.data)+ return msg+ })const body: Record<string, any> = {model,@@ -72,6 +76,7 @@ export class OllamaProvider implements ProviderClient {if (options?.topK !== undefined) ollamaOptions.top_k = options.topKif (options?.maxTokens) ollamaOptions.num_predict = options.maxTokensbody.options = ollamaOptions+ body.think = options?.thinking === trueconst res = await localFetchStream(this.apiUrl('/chat'), {method: 'POST',@@ -95,6 +100,7 @@ export class OllamaProvider implements ProviderClient {yield {content: chunk.message?.content || '',+ thinking: chunk.message?.thinking || undefined,toolCalls: toolCalls?.length ? toolCalls : undefined,done: chunk.done || false,}@@ -110,6 +116,7 @@ export class OllamaProvider implements ProviderClient {const ollamaMessages = messages.map(m => {const msg: Record<string, any> = { role: m.role, content: m.content }if (m.tool_calls) msg.tool_calls = m.tool_calls+ if (m.images?.length) msg.images = m.images.map(img => img.data)return msg})@@ -126,6 +133,7 @@ export class OllamaProvider implements ProviderClient {if (options?.topK !== undefined) ollamaOptions.top_k = options.topKif (options?.maxTokens) ollamaOptions.num_predict = options.maxTokensbody.options = ollamaOptions+ body.think = options?.thinking === trueconst fetchOptions: any = {method: 'POST',@@ -150,6 +158,7 @@ export class OllamaProvider implements ProviderClient {return {content: data.message?.content || '',+ thinking: data.message?.thinking || '',toolCalls,}}diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex f6cc9a80..d2391fe2 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -262,7 +262,17 @@ export class OpenAIProvider implements ProviderClient {// ── Message conversion ───────────────────────────────────────private toOpenAIMessage(msg: ChatMessage): Record<string, any> {- const m: Record<string, any> = { role: msg.role, content: msg.content }+ // If message has images, use content array format+ let content: any = msg.content+ if (msg.images?.length && msg.role === 'user') {+ const parts: any[] = []+ for (const img of msg.images) {+ parts.push({ type: 'image_url', image_url: { url: `data:${img.mimeType};base64,${img.data}` } })+ }+ parts.push({ type: 'text', text: msg.content })+ content = parts+ }+ const m: Record<string, any> = { role: msg.role, content }if (msg.tool_calls) {m.tool_calls = msg.tool_calls.map(tc => ({diff --git a/src/api/providers/types.ts b/src/api/providers/types.tsindex bbe2e670..5f213b23 100644--- a/src/api/providers/types.ts+++ b/src/api/providers/types.ts@@ -77,6 +77,7 @@ export interface ProviderModel {export interface ChatMessage {role: 'system' | 'user' | 'assistant' | 'tool'content: string+ images?: { data: string; mimeType: string }[] // base64 image attachmentstool_calls?: ToolCall[]tool_call_id?: string // Required for OpenAI tool results}@@ -96,6 +97,7 @@ export interface ChatOptions {topP?: numbertopK?: number // Ollama/Anthropic support this, OpenAI doesn'tmaxTokens?: number+ thinking?: boolean // Enable model thinking/reasoning modesignal?: AbortSignal}@@ -103,6 +105,7 @@ export interface ChatOptions {export interface ChatStreamChunk {content: string+ thinking?: string // Model reasoning (Ollama thinking field, <think> tags)toolCalls?: ToolCall[]done: boolean}diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsxindex f0067924..ac08d194 100644--- a/src/components/chat/ChatInput.tsx+++ b/src/components/chat/ChatInput.tsx@@ -1,13 +1,14 @@-import { useState, useRef, useEffect } from 'react'+import { useState, useRef, useEffect, useCallback } from 'react'import { motion } from 'framer-motion'-import { Send, Square } from 'lucide-react'+import { Send, Square, Paperclip, X } from 'lucide-react'import { VoiceButton } from './VoiceButton'import { ApprovalDialog } from './ApprovalDialog'import { useVoiceStore } from '../../stores/voiceStore'import type { AgentToolCall } from '../../types/agent-mode'+import type { ImageAttachment } from '../../types/chat'interface Props {- onSend: (content: string) => void+ onSend: (content: string, images?: ImageAttachment[]) => voidonStop: () => voidisGenerating: booleanpendingApproval?: AgentToolCall | null@@ -15,11 +16,28 @@ interface Props {onReject?: () => void}+function fileToImageAttachment(file: File): Promise<ImageAttachment> {+ return new Promise((resolve, reject) => {+ const reader = new FileReader()+ reader.onload = () => {+ const dataUrl = reader.result as string+ const base64 = dataUrl.split(',')[1]+ resolve({ data: base64, mimeType: file.type || 'image/png', name: file.name })+ }+ reader.onerror = reject+ reader.readAsDataURL(file)+ })+}+export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApprove, onReject }: Props) {const [input, setInput] = useState('')+ const [images, setImages] = useState<ImageAttachment[]>([])+ const [isDragOver, setIsDragOver] = useState(false)const [isVoiceRecording, setIsVoiceRecording] = useState(false)const textareaRef = useRef<HTMLTextAreaElement>(null)+ const fileInputRef = useRef<HTMLInputElement>(null)const isTranscribing = useVoiceStore((s) => s.isTranscribing)+useEffect(() => {if (textareaRef.current) {textareaRef.current.style.height = 'auto'@@ -27,11 +45,23 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp}}, [input])+ const addFiles = useCallback(async (files: FileList | File[]) => {+ const imageFiles = Array.from(files).filter(f => f.type.startsWith('image/'))+ if (imageFiles.length === 0) return+ const newImages = await Promise.all(imageFiles.map(fileToImageAttachment))+ setImages(prev => [...prev, ...newImages].slice(0, 5)) // max 5 images+ }, [])++ const removeImage = (index: number) => {+ setImages(prev => prev.filter((_, i) => i !== index))+ }+const handleSend = () => {const trimmed = input.trim()- if (!trimmed || isGenerating) return- onSend(trimmed)+ if ((!trimmed && images.length === 0) || isGenerating) return+ onSend(trimmed || '(image)', images.length > 0 ? images : undefined)setInput('')+ setImages([])if (textareaRef.current) textareaRef.current.style.height = 'auto'}@@ -43,6 +73,39 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp}}+ // Paste handler for clipboard images (Ctrl+V screenshots)+ const handlePaste = useCallback((e: React.ClipboardEvent) => {+ const items = e.clipboardData?.items+ if (!items) return+ const imageItems = Array.from(items).filter(item => item.type.startsWith('image/'))+ if (imageItems.length === 0) return+ e.preventDefault()+ const files = imageItems.map(item => item.getAsFile()).filter(Boolean) as File[]+ addFiles(files)+ }, [addFiles])++ // Drag & Drop handlers+ const handleDragOver = useCallback((e: React.DragEvent) => {+ e.preventDefault()+ e.stopPropagation()+ setIsDragOver(true)+ }, [])++ const handleDragLeave = useCallback((e: React.DragEvent) => {+ e.preventDefault()+ e.stopPropagation()+ setIsDragOver(false)+ }, [])++ const handleDrop = useCallback((e: React.DragEvent) => {+ e.preventDefault()+ e.stopPropagation()+ setIsDragOver(false)+ if (e.dataTransfer?.files?.length) {+ addFiles(e.dataTransfer.files)+ }+ }, [addFiles])+return (<div className="px-3 pb-2 pt-1">{/* Approval dialog */}@@ -50,43 +113,98 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp<ApprovalDialog toolCall={pendingApproval} onApprove={onApprove} onReject={onReject} />)}- <div className="flex items-end gap-2 rounded-lg bg-white/[0.03] border border-white/[0.06] px-2.5 py-2">- <VoiceButton- onTranscript={(text) => { setInput(text); requestAnimationFrame(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = Math.min(textareaRef.current.scrollHeight, 200) + 'px' } }) }}- onRecordingChange={(r) => setIsVoiceRecording(r)}- disabled={isGenerating}- />-- <textarea- ref={textareaRef}- value={input}- onChange={(e) => setInput(e.target.value)}- onKeyDown={handleKeyDown}- placeholder={isTranscribing ? "Transcribing..." : isVoiceRecording ? "Recording..." : "Message..."}- rows={1}- className="flex-1 bg-transparent resize-none text-gray-200 placeholder-gray-600 focus:outline-none text-[0.75rem] leading-relaxed max-h-[200px]"- />-- {isGenerating ? (- <motion.button- onClick={onStop}- className="p-1.5 rounded-md bg-red-500/15 text-red-400 hover:bg-red-500/25 transition-all shrink-0"- whileTap={{ scale: 0.9 }}- aria-label="Stop generation"- >- <Square size={13} />- </motion.button>- ) : (- <motion.button- onClick={handleSend}- disabled={!input.trim() || isTranscribing}- className="p-1.5 rounded-md bg-white/8 text-gray-300 hover:bg-white/12 disabled:opacity-20 disabled:cursor-not-allowed transition-all shrink-0"- whileTap={{ scale: 0.9 }}- aria-label="Send message"- >- <Send size={13} />- </motion.button>+ <div+ className={`flex flex-col rounded-lg border px-2.5 py-2 transition-colors ${+ isDragOver+ ? 'bg-blue-500/5 border-blue-500/30'+ : 'bg-white/[0.03] border-white/[0.06]'+ }`}+ onDragOver={handleDragOver}+ onDragLeave={handleDragLeave}+ onDrop={handleDrop}+ >+ {/* Image previews */}+ {images.length > 0 && (+ <div className="flex gap-1.5 mb-1.5 flex-wrap">+ {images.map((img, i) => (+ <div key={i} className="relative group">+ <img+ src={`data:${img.mimeType};base64,${img.data}`}+ alt={img.name}+ className="w-14 h-14 object-cover rounded-lg border border-white/10"+ />+ <button+ onClick={() => removeImage(i)}+ className="absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"+ >+ <X size={8} />+ </button>+ <span className="absolute bottom-0 left-0 right-0 bg-black/60 text-[0.4rem] text-gray-300 text-center rounded-b-lg truncate px-0.5">+ {img.name}+ </span>+ </div>+ ))}+ </div>)}++ {/* Input row */}+ <div className="flex items-end gap-2">+ {/* Clip button */}+ <button+ onClick={() => fileInputRef.current?.click()}+ disabled={isGenerating}+ className="p-1.5 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 disabled:opacity-20 transition-all shrink-0"+ title="Attach images"+ >+ <Paperclip size={14} />+ </button>+ <input+ ref={fileInputRef}+ type="file"+ accept="image/*"+ multiple+ className="hidden"+ onChange={(e) => { if (e.target.files) addFiles(e.target.files); e.target.value = '' }}+ />++ <VoiceButton+ onTranscript={(text) => { setInput(text); requestAnimationFrame(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = Math.min(textareaRef.current.scrollHeight, 200) + 'px' } }) }}+ onRecordingChange={(r) => setIsVoiceRecording(r)}+ disabled={isGenerating}+ />++ <textarea+ ref={textareaRef}+ value={input}+ onChange={(e) => setInput(e.target.value)}+ onKeyDown={handleKeyDown}+ onPaste={handlePaste}+ placeholder={isDragOver ? "Drop images here..." : isTranscribing ? "Transcribing..." : isVoiceRecording ? "Recording..." : "Message..."}+ rows={1}+ className="flex-1 bg-transparent resize-none text-gray-200 placeholder-gray-600 focus:outline-none text-[0.75rem] leading-relaxed max-h-[200px]"+ />++ {isGenerating ? (+ <motion.button+ onClick={onStop}+ className="p-1.5 rounded-md bg-red-500/15 text-red-400 hover:bg-red-500/25 transition-all shrink-0"+ whileTap={{ scale: 0.9 }}+ aria-label="Stop generation"+ >+ <Square size={13} />+ </motion.button>+ ) : (+ <motion.button+ onClick={handleSend}+ disabled={(!input.trim() && images.length === 0) || isTranscribing}+ className="p-1.5 rounded-md bg-white/8 text-gray-300 hover:bg-white/12 disabled:opacity-20 disabled:cursor-not-allowed transition-all shrink-0"+ whileTap={{ scale: 0.9 }}+ aria-label="Send message"+ >+ <Send size={13} />+ </motion.button>+ )}+ </div></div></div>)diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsxindex d59d134e..a8aa5bde 100644--- a/src/components/chat/ChatView.tsx+++ b/src/components/chat/ChatView.tsx@@ -14,7 +14,7 @@ import { ErrorBoundary } from '../ui/ErrorBoundary'import { useSettingsStore } from '../../stores/settingsStore'import { FEATURE_FLAGS } from '../../lib/constants'import { isAgentCompatible } from '../../lib/model-compatibility'-import { FileText, Bot, User, ChevronDown, Download } from 'lucide-react'+import { FileText, Bot, User, ChevronDown, Download, Brain, Wrench } from 'lucide-react'import { TokenCounter } from './TokenCounter'import { MemoryDebugToggle } from './MemoryDebugPanel'import { ABCompare } from './ABCompare'@@ -31,9 +31,12 @@ export function ChatView() {const [ragPanelOpen, setRagPanelOpen] = useState(false)const [personaOpen, setPersonaOpen] = useState(false)const [exportOpen, setExportOpen] = useState(false)+ const [toolsDropdownOpen, setToolsDropdownOpen] = useState(false)const { getActivePersona, setActivePersona } = useSettingsStore()const activePersona = getActivePersona()const allPersonas = useSettingsStore((s) => s.personas)+ const thinkingEnabled = useSettingsStore((s) => s.settings.thinkingEnabled)+ const updateSettings = useSettingsStore((s) => s.updateSettings)const docCount = useRAGStore((s) =>activeConversationId ? (s.documents[activeConversationId] || []).length : 0@@ -83,8 +86,47 @@ export function ChatView() {transition={{ duration: 0.25, ease: 'easeOut' }}><div className="flex-1 flex flex-col min-w-0">- {/* Top bar: Token Counter + Documents + Agent Mode */}- <div className="flex items-center justify-end gap-2 px-3 pt-1">+ {/* Top bar — compact */}+ <div className="flex items-center gap-1.5 px-2 pt-0.5">+ {/* Left: Tools Active dropdown (only when agent is active) */}+ {isAgentActive && (+ <div className="relative">+ <button+ onClick={() => setToolsDropdownOpen(!toolsDropdownOpen)}+ className="flex items-center gap-1 px-2 py-0.5 rounded border border-white/[0.06] text-gray-500 hover:border-white/15 transition-colors text-[0.55rem]"+ >+ <Wrench size={9} className="text-green-400" />+ <span>Tools</span>+ <ChevronDown size={8} className={`transition-transform ${toolsDropdownOpen ? 'rotate-180' : ''}`} />+ </button>+ {toolsDropdownOpen && (+ <>+ <div className="fixed inset-0 z-40" onClick={() => setToolsDropdownOpen(false)} />+ <div className="absolute left-0 top-full mt-0.5 z-50 w-28 rounded-md bg-[#1a1a1a] border border-white/10 shadow-xl py-0.5 px-0.5">+ <PermissionOverrideBar />+ </div>+ </>+ )}+ </div>+ )}++ {/* Thinking toggle */}+ <button+ onClick={() => updateSettings({ thinkingEnabled: !thinkingEnabled })}+ className={`flex items-center gap-1 px-2 py-0.5 rounded border transition-colors text-[0.55rem] ${+ thinkingEnabled+ ? 'border-blue-500/30 text-blue-400'+ : 'border-white/[0.06] text-gray-600'+ }`}+ title="Toggle thinking mode — model reasons before answering"+ >+ <Brain size={9} />+ <span>Think</span>+ </button>++ {/* Spacer */}+ <div className="flex-1" />+{/* Token Counter */}<TokenCounter />@@ -95,15 +137,15 @@ export function ChatView() {<div className="relative"><buttononClick={() => setExportOpen(!exportOpen)}- className="flex items-center gap-1.5 px-3 py-1 rounded-full border border-gray-300 dark:border-white/15 hover:border-gray-400 dark:hover:border-white/25 text-gray-500 dark:text-gray-400 transition-colors text-xs"+ className="flex items-center gap-1 px-2 py-0.5 rounded border border-white/[0.06] hover:border-white/15 text-gray-500 transition-colors text-[0.55rem]"title="Export chat">- <Download size={13} />+ <Download size={10} /></button>{exportOpen && (<><div className="fixed inset-0 z-40" onClick={() => setExportOpen(false)} />- <div className="absolute right-0 top-full mt-1 z-50 w-36 rounded-lg bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 shadow-xl py-1">+ <div className="absolute right-0 top-full mt-1 z-50 w-32 rounded-lg bg-[#1a1a1a] border border-white/10 shadow-xl py-1">{(['markdown', 'json'] as const).map(fmt => (<buttonkey={fmt}@@ -112,9 +154,9 @@ export function ChatView() {if (conv) exportConversation(conv, fmt)setExportOpen(false)}}- className="w-full text-left px-3 py-1.5 text-[0.65rem] text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-gray-200 transition-colors"+ className="w-full text-left px-3 py-1 text-[0.55rem] text-gray-400 hover:bg-white/5 hover:text-gray-200 transition-colors">- Export as .{fmt === 'markdown' ? 'md' : fmt}+ .{fmt === 'markdown' ? 'md' : fmt}</button>))}</div>@@ -126,31 +168,29 @@ export function ChatView() {<div className="relative"><buttononClick={() => setPersonaOpen(!personaOpen)}- className="flex items-center gap-1.5 px-3 py-1 rounded-full border border-gray-300 dark:border-white/15 hover:border-gray-400 dark:hover:border-white/25 text-gray-500 dark:text-gray-400 transition-colors text-xs"+ className="flex items-center gap-1 px-2 py-0.5 rounded border border-white/[0.06] hover:border-white/15 text-gray-500 transition-colors text-[0.55rem]">- <User size={13} />- <span className="font-medium max-w-[80px] truncate">{activePersona?.name || 'No Persona'}</span>- <ChevronDown size={10} className={`transition-transform ${personaOpen ? 'rotate-180' : ''}`} />+ <User size={10} />+ <span className="max-w-[60px] truncate">{activePersona?.name || 'No Filter'}</span>+ <ChevronDown size={8} className={`transition-transform ${personaOpen ? 'rotate-180' : ''}`} /></button>{personaOpen && (<><div className="fixed inset-0 z-40" onClick={() => setPersonaOpen(false)} />- <div className="absolute right-0 top-full mt-1 z-50 w-48 max-h-[250px] overflow-y-auto scrollbar-thin rounded-lg bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 shadow-xl py-1">- {/* Active persona pinned at top */}+ <div className="absolute right-0 top-full mt-1 z-50 w-44 max-h-[220px] overflow-y-auto scrollbar-thin rounded-lg bg-[#1a1a1a] border border-white/10 shadow-xl py-1">{activePersona && (<div className="px-2 pb-1 mb-1 border-b border-white/[0.06]">- <div className="px-2 py-1.5 rounded-md bg-white/[0.06] border border-white/10 text-[0.65rem] text-white font-medium flex items-center gap-1.5">+ <div className="px-2 py-1 rounded-md bg-white/[0.06] border border-white/10 text-[0.55rem] text-white font-medium flex items-center gap-1.5"><div className="w-1 h-1 rounded-full bg-green-400 shrink-0" />{activePersona.name}</div></div>)}- {/* Other personas */}{allPersonas.filter(p => p.id !== activePersona?.id).map(p => (<buttonkey={p.id}onClick={() => { setActivePersona(p.id); setPersonaOpen(false) }}- className="w-full text-left px-3 py-1.5 text-[0.65rem] text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-gray-200 transition-colors"+ className="w-full text-left px-3 py-1 text-[0.55rem] text-gray-400 hover:bg-white/5 hover:text-gray-200 transition-colors">{p.name}</button>@@ -164,19 +204,19 @@ export function ChatView() {<buttononClick={() => setRagPanelOpen(!ragPanelOpen)}className={- 'flex items-center gap-1.5 px-3 py-1 rounded-full border transition-colors text-xs ' ++ 'flex items-center gap-1 px-2 py-0.5 rounded border transition-colors text-[0.55rem] ' +(ragPanelOpen || ragEnabled- ? 'border-green-400 dark:border-green-500/40 text-green-600 dark:text-green-300'- : 'border-gray-300 dark:border-white/15 hover:border-gray-400 dark:hover:border-white/25 text-gray-500 dark:text-gray-400')+ ? 'border-green-500/30 text-green-400'+ : 'border-white/[0.06] hover:border-white/15 text-gray-500')}title="Document Chat (RAG)">- <FileText size={13} />- <span className="font-medium">Documents</span>+ <FileText size={10} />+ <span>Docs</span>{docCount > 0 && (<span className={- 'min-w-[16px] h-[16px] flex items-center justify-center rounded-full text-[0.55rem] font-bold ' +- (ragEnabled ? 'bg-green-500 text-white' : 'bg-gray-200 dark:bg-white/15 text-gray-600 dark:text-gray-300')+ '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>@@ -186,26 +226,23 @@ export function ChatView() {{/* Agent Mode (Beta) */}{FEATURE_FLAGS.AGENT_MODE && (<div className={- 'flex items-center gap-1.5 px-3 py-1 rounded-full border transition-colors text-xs ' ++ 'flex items-center gap-1 px-2 py-0.5 rounded border transition-colors text-[0.55rem] ' +(isAgentActive- ? 'border-green-400 dark:border-green-500/40 text-green-600 dark:text-green-300'+ ? 'border-green-500/30 text-green-400': activeModel && !isAgentCompatible(activeModel)- ? 'border-gray-300/50 dark:border-white/8 text-gray-400 dark:text-gray-600 opacity-50'- : 'border-gray-300 dark:border-white/15 text-gray-500 dark:text-gray-400')+ ? 'border-white/[0.04] text-gray-600 opacity-50'+ : 'border-white/[0.06] text-gray-500')}>- <Bot size={13} />+ <Bot size={10} /><div className="flex flex-col items-start leading-none">- <span className="text-[0.45rem] text-amber-400 font-bold uppercase tracking-widest">Beta</span>- <span className="font-medium">Agent</span>+ <span className="text-[0.35rem] text-amber-400 font-bold uppercase tracking-widest">Beta</span>+ <span>Agent</span></div><AgentModeToggle /></div>)}</div>- {/* Permission Override Bar — shown when agent mode is active */}- {isAgentActive && <PermissionOverrideBar />}-<MessageListisGenerating={isGenerating}isLoadingModel={isLoadingModel}diff --git a/src/components/chat/MessageBubble.tsx b/src/components/chat/MessageBubble.tsxindex 94d5a14f..cc657863 100644--- a/src/components/chat/MessageBubble.tsx+++ b/src/components/chat/MessageBubble.tsx@@ -53,24 +53,25 @@ export function MessageBubble({ message, onRegenerate, onEdit }: Props) {return (<motion.div- className={'flex gap-2.5 px-3 py-2 group ' + (isUser ? 'flex-row-reverse' : '')}- initial={{ opacity: 0, y: 10 }}+ className={'flex gap-2 px-3 py-1 group ' + (isUser ? 'flex-row-reverse' : '')}+ initial={{ opacity: 0, y: 6 }}animate={{ opacity: 1, y: 0 }}- transition={{ duration: 0.2 }}+ transition={{ duration: 0.15 }}>+ {/* Avatar */}<divclassName={- 'w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ' ++ 'w-6 h-6 rounded-md flex items-center justify-center shrink-0 ' +(isUser- ? 'bg-gray-200 dark:bg-white/10 border border-gray-300 dark:border-white/15'- : 'bg-gray-100 dark:bg-[#2f2f2f] border border-gray-200 dark:border-white/10')+ ? 'bg-white/8 border border-white/10'+ : 'bg-white/5 border border-white/[0.06]')}>- {isUser ? <User size={13} className="text-gray-600 dark:text-gray-300" /> : <Bot size={13} className="text-gray-500 dark:text-gray-400" />}+ {isUser ? <User size={11} className="text-gray-400" /> : <Bot size={11} className="text-gray-500" />}</div>- <div className="max-w-[80%] space-y-1.5">- {/* Thinking block (collapsible, lighter blue, italic, smaller) */}+ <div className="max-w-[80%] space-y-0.5">+ {/* Thinking block */}{!isUser && message.thinking && (<ThinkingBlock thinking={message.thinking} />)}@@ -86,17 +87,37 @@ export function MessageBubble({ message, onRegenerate, onEdit }: Props) {</>)}- {/* Main answer bubble */}+ {/* Image attachments */}+ {message.images && message.images.length > 0 && (+ <div className="flex gap-1 flex-wrap">+ {message.images.map((img, i) => (+ <a+ key={i}+ href={`data:${img.mimeType};base64,${img.data}`}+ target="_blank"+ rel="noopener noreferrer"+ >+ <img+ src={`data:${img.mimeType};base64,${img.data}`}+ alt={img.name}+ className="max-w-[180px] max-h-[120px] object-cover rounded-md border border-white/10 hover:border-white/25 transition-colors cursor-pointer"+ />+ </a>+ ))}+ </div>+ )}++ {/* Main content */}<divclassName={- 'rounded-xl px-3 py-2 relative ' ++ 'rounded-lg px-2.5 py-1.5 relative ' +(isUser- ? 'bg-gray-100 dark:bg-[#2f2f2f] border border-gray-200 dark:border-white/10'- : 'bg-white dark:bg-[#2a2a2a] border border-gray-200 dark:border-white/5')+ ? 'bg-white/[0.06] border border-white/[0.08]'+ : 'bg-white/[0.03] border border-white/[0.04]')}>{isUser && isEditing ? (- <div className="space-y-1.5">+ <div className="space-y-1"><textarearef={editRef}value={editContent}@@ -109,65 +130,43 @@ export function MessageBubble({ message, onRegenerate, onEdit }: Props) {if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); confirmEdit() }if (e.key === 'Escape') cancelEdit()}}- className="w-full bg-transparent text-[0.8rem] leading-relaxed text-gray-800 dark:text-gray-200 resize-none focus:outline-none"+ className="w-full bg-transparent text-[0.78rem] leading-relaxed text-gray-200 resize-none focus:outline-none"/><div className="flex items-center gap-1 justify-end">- <button onClick={confirmEdit} className="p-0.5 rounded hover:bg-green-500/20 text-green-500 transition-colors" title="Save & resend">- <Check size={12} />- </button>- <button onClick={cancelEdit} className="p-0.5 rounded hover:bg-red-500/20 text-red-400 transition-colors" title="Cancel">- <X size={12} />- </button>+ <button onClick={confirmEdit} className="p-0.5 rounded hover:bg-green-500/20 text-green-500 transition-colors"><Check size={11} /></button>+ <button onClick={cancelEdit} className="p-0.5 rounded hover:bg-red-500/20 text-red-400 transition-colors"><X size={11} /></button></div></div>) : isUser ? (- <p className="text-[0.8rem] leading-relaxed text-gray-800 dark:text-gray-200 whitespace-pre-wrap">{message.content}</p>+ <p className="text-[0.78rem] leading-relaxed text-gray-200 whitespace-pre-wrap">{message.content}</p>) : (- <div className="text-[0.8rem] leading-relaxed">+ <div className="text-[0.78rem] leading-relaxed"><MarkdownRenderer content={message.content} /></div>)}{!isEditing && (- <div className="absolute top-1.5 right-1.5 flex items-center gap-0.5">- {/* Edit (user messages only) */}+ <div className="absolute top-1 right-1 flex items-center gap-0.5">{isUser && onEdit && (- <button- onClick={startEdit}- className="p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-white/10 text-gray-400 hover:text-gray-700 dark:hover:text-white transition-all"- aria-label="Edit message"- >- <Pencil size={12} />- </button>+ <button onClick={startEdit} className="p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-white/10 text-gray-500 hover:text-white transition-all" aria-label="Edit message"><Pencil size={10} /></button>)}- {/* Regenerate (assistant messages only) */}{!isUser && onRegenerate && (- <button- onClick={onRegenerate}- className="p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-white/10 text-gray-400 hover:text-gray-700 dark:hover:text-white transition-all"- aria-label="Regenerate response"- >- <RefreshCw size={12} />- </button>+ <button onClick={onRegenerate} className="p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-white/10 text-gray-500 hover:text-white transition-all" aria-label="Regenerate response"><RefreshCw size={10} /></button>)}- <button- onClick={handleCopy}- className="p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-white/10 text-gray-400 hover:text-gray-700 dark:hover:text-white transition-all"- aria-label="Copy message"- >- {copied ? <Check size={12} /> : <Copy size={12} />}+ <button onClick={handleCopy} className="p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-white/10 text-gray-500 hover:text-white transition-all" aria-label="Copy message">+ {copied ? <Check size={10} /> : <Copy size={10} />}</button>{!isUser && <SpeakerButton text={message.content} />}</div>)}</div>- {/* Sources section for RAG citations */}+ {/* RAG sources */}{!isUser && message.sources && message.sources.length > 0 && (- <div className="mt-2 pt-2 border-t border-gray-100 dark:border-white/5">- <p className="text-[0.6rem] text-gray-400 mb-1">Sources:</p>+ <div className="pt-1 border-t border-white/[0.04]">+ <p className="text-[0.5rem] text-gray-500 mb-0.5">Sources:</p>{message.sources.map((s, i) => (- <p key={i} className="text-[0.6rem] text-gray-500 dark:text-gray-400 truncate">+ <p key={i} className="text-[0.5rem] text-gray-600 truncate">[{i + 1}] {s.documentName} — {s.preview.slice(0, 60)}...</p>))}diff --git a/src/components/chat/PermissionOverrideBar.tsx b/src/components/chat/PermissionOverrideBar.tsxindex ee51266a..784796c5 100644--- a/src/components/chat/PermissionOverrideBar.tsx+++ b/src/components/chat/PermissionOverrideBar.tsx@@ -1,69 +1,66 @@import { usePermissionStore } from '../../stores/permissionStore'import { useChatStore } from '../../stores/chatStore'-import type { ToolCategory, PermissionLevel } from '../../api/mcp/types'-import { FolderOpen, Terminal, Monitor, Globe, Cpu, Image, GitBranch } from 'lucide-react'+import type { ToolCategory } from '../../api/mcp/types'+import { FolderOpen, Terminal, Monitor, Globe, Cpu, Image, GitBranch, Lock } from 'lucide-react'-const CATEGORY_META: Record<ToolCategory, { icon: typeof Globe; short: string }> = {- web: { icon: Globe, short: 'Web' },- system: { icon: Cpu, short: 'Sys' },- filesystem: { icon: FolderOpen, short: 'Files' },- terminal: { icon: Terminal, short: 'Shell' },- desktop: { icon: Monitor, short: 'Screen' },- image: { icon: Image, short: 'Image' },- workflow: { icon: GitBranch, short: 'Flow' },-}--const ICON_COLORS: Record<PermissionLevel, string> = {- blocked: 'text-red-400',- confirm: 'text-amber-400',- auto: 'text-green-400',-}+const LOCKED: Set<ToolCategory> = new Set(['image'])-const NEXT_LEVEL: Record<PermissionLevel, PermissionLevel> = {- blocked: 'confirm',- confirm: 'auto',- auto: 'blocked',-}+const CATEGORIES: { key: ToolCategory; icon: typeof Globe; label: string }[] = [+ { key: 'web', icon: Globe, label: 'Web' },+ { key: 'system', icon: Cpu, label: 'System' },+ { key: 'filesystem', icon: FolderOpen, label: 'Files' },+ { key: 'terminal', icon: Terminal, label: 'Shell' },+ { key: 'desktop', icon: Monitor, label: 'Screenshot' },+ { key: 'image', icon: Image, label: 'Image' },+ { key: 'workflow', icon: GitBranch, label: 'Workflows' },+]export function PermissionOverrideBar() {const activeConversationId = useChatStore((s) => s.activeConversationId)- const { getEffectivePermissions, setConversationOverride, clearConversationOverrides, conversationOverrides } = usePermissionStore()+ const { getEffectivePermissions, setConversationOverride } = usePermissionStore()if (!activeConversationId) return nullconst permissions = getEffectivePermissions(activeConversationId)- const hasOverrides = !!conversationOverrides[activeConversationId]- const handleClick = (category: ToolCategory) => {- const current = permissions[category]- setConversationOverride(activeConversationId, category, NEXT_LEVEL[current])+ const toggleTool = (cat: ToolCategory) => {+ if (LOCKED.has(cat)) return+ const current = permissions[cat]+ setConversationOverride(activeConversationId, cat, current === 'blocked' ? 'auto' : 'blocked')}return (- <div className="flex items-center gap-1 px-2 py-0.5 flex-wrap">- {(Object.keys(CATEGORY_META) as ToolCategory[]).map((cat) => {- const { icon: Icon, short } = CATEGORY_META[cat]- const level = permissions[cat]+ <div>+ {CATEGORIES.map(({ key, icon: Icon, label }) => {+ const isLocked = LOCKED.has(key)+ const isOn = !isLocked && permissions[key] !== 'blocked'return (<button- key={cat}- onClick={() => handleClick(cat)}- className="flex items-center gap-1 px-1.5 py-0.5 rounded border border-white/[0.06] text-[0.5rem] font-medium text-gray-500 hover:border-white/15 transition-all"- title={`${short}: ${level} — click to cycle`}+ key={key}+ onClick={() => toggleTool(key)}+ disabled={isLocked}+ className={`flex items-center gap-1.5 w-full px-1.5 py-[3px] text-[0.5rem] transition-colors ${+ isLocked+ ? 'text-gray-700 cursor-default'+ : isOn+ ? 'text-gray-300 hover:bg-white/5'+ : 'text-gray-600 hover:bg-white/5'+ }`}>- <Icon size={9} className={ICON_COLORS[level]} />- <span>{short}</span>+ {isLocked ? (+ <Lock size={7} className="text-gray-700" />+ ) : (+ <Icon size={8} className={isOn ? 'text-green-400' : 'text-gray-600'} />+ )}+ <span className="flex-1 text-left">{label}</span>+ {isLocked ? (+ <span className="text-[0.4rem] text-gray-700">soon</span>+ ) : (+ <div className={`w-1 h-1 rounded-full ${isOn ? 'bg-green-400' : 'bg-gray-700'}`} />+ )}</button>)})}- {hasOverrides && (- <button- onClick={() => clearConversationOverrides(activeConversationId)}- className="text-[0.5rem] text-gray-600 hover:text-gray-400 transition-colors ml-1"- >- reset- </button>- )}</div>)}diff --git a/src/components/chat/ThinkingBlock.tsx b/src/components/chat/ThinkingBlock.tsxindex ef75caf9..a2d2ad97 100644--- a/src/components/chat/ThinkingBlock.tsx+++ b/src/components/chat/ThinkingBlock.tsx@@ -13,48 +13,37 @@ export function ThinkingBlock({ thinking }: Props) {if (!thinking) return nullreturn (- <motion.div- className="mb-2"- initial={{ opacity: 0, y: 6 }}- animate={{ opacity: 1, y: 0 }}- transition={{ duration: 0.2 }}- >- <div className="rounded-xl bg-blue-50 dark:bg-blue-500/8 border border-blue-200/50 dark:border-blue-400/15 overflow-hidden">- {/* Toggle header */}- <button- onClick={() => setOpen(!open)}- className="w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-blue-100/50 dark:hover:bg-blue-500/10 transition-colors"- aria-label="Toggle thinking details"- >- <Brain size={13} className="text-blue-400 dark:text-blue-300/70 shrink-0" />- <span className="text-[0.7rem] font-medium text-blue-500 dark:text-blue-300/80 tracking-wide">- Thinking- </span>- <ChevronDown- size={12}- className={`text-blue-400 dark:text-blue-300/60 ml-auto transition-transform duration-200 ${open ? 'rotate-180' : ''}`}- />- </button>+ <div className="mb-0.5">+ <button+ onClick={() => setOpen(!open)}+ className="flex items-center gap-1.5 py-0.5 text-left hover:opacity-80 transition-opacity"+ aria-label="Toggle thinking details"+ >+ <Brain size={10} className="text-blue-400/70 shrink-0" />+ <span className="text-[0.6rem] text-blue-400/70">Thinking</span>+ <ChevronDown+ size={9}+ className={`text-blue-400/50 transition-transform duration-200 ${open ? 'rotate-180' : ''}`}+ />+ </button>- {/* Collapsible content */}- <AnimatePresence>- {open && (- <motion.div- initial={{ height: 0, opacity: 0 }}- animate={{ height: 'auto', opacity: 1 }}- exit={{ height: 0, opacity: 0 }}- transition={{ duration: 0.2 }}- className="overflow-hidden"- >- <div className="px-3 pb-3 pt-1">- <div className="text-[0.72rem] leading-relaxed italic text-blue-600/70 dark:text-blue-200/50 font-light">- <MarkdownRenderer content={thinking} />- </div>+ <AnimatePresence>+ {open && (+ <motion.div+ initial={{ height: 0, opacity: 0 }}+ animate={{ height: 'auto', opacity: 1 }}+ exit={{ height: 0, opacity: 0 }}+ transition={{ duration: 0.15 }}+ className="overflow-hidden"+ >+ <div className="pl-4 pb-1 pt-0.5">+ <div className="text-[0.65rem] leading-relaxed italic text-blue-200/40">+ <MarkdownRenderer content={thinking} /></div>- </motion.div>- )}- </AnimatePresence>- </div>- </motion.div>+ </div>+ </motion.div>+ )}+ </AnimatePresence>+ </div>)}diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex 5655896f..90cd0d1b 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -112,7 +112,7 @@ export function useAgentChat() {// ── Main agent message handler ────────────────────────────- const sendAgentMessage = useCallback(async (userContent: string) => {+ const sendAgentMessage = useCallback(async (userContent: string, userImages?: import('../types/chat').ImageAttachment[]) => {const { activeModel } = useModelStore.getState()const { settings } = useSettingsStore.getState()const store = useChatStore.getState()@@ -219,6 +219,7 @@ export function useAgentChat() {id: uuid(),role: 'user' as const,content: userContent,+ images: userImages,timestamp: Date.now(),}useChatStore.getState().addMessage(convId, userMessage)@@ -286,7 +287,11 @@ export function useAgentChat() {...(agentSystemPrompt ? [{ role: 'system' as const, content: agentSystemPrompt }] : []),...conv.messages.filter((m) => m.role !== 'system' && m.content.trim() !== '')- .map((m) => ({ role: m.role as 'user' | 'assistant' | 'tool', content: m.content })),+ .map((m) => ({+ role: m.role as 'user' | 'assistant' | 'tool',+ content: m.content,+ ...(m.images?.length ? { images: m.images.map(img => ({ data: img.data, mimeType: img.mimeType })) } : {}),+ })),]// Setup@@ -327,6 +332,7 @@ export function useAgentChat() {topP: settings.topP,topK: settings.topK,maxTokens: settings.maxTokens || undefined,+ thinking: settings.thinkingEnabled === true ? true : false,signal: abort.signal,}@@ -344,6 +350,8 @@ export function useAgentChat() {toolCalls = turn.toolCallsturnContent = turn.content || ''+ // Native thinking field from Ollama+ if ((turn as any).thinking) turnThinking = (turn as any).thinking} else {// ── Hermes XML prompt-based tool calling (Ollama fallback) ──diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.tsindex 7fdc1b8d..d3f60fb1 100644--- a/src/hooks/useChat.ts+++ b/src/hooks/useChat.ts@@ -14,6 +14,7 @@ import { useMemory } from "./useMemory"import { useAgentModeStore } from "../stores/agentModeStore"import { getProviderForModel } from "../api/providers"import type { ChatStreamChunk } from "../api/providers/types"+import type { ImageAttachment } from "../types/chat"export function useChat() {const [isGenerating, setIsGenerating] = useState(false)@@ -27,7 +28,7 @@ export function useChat() {const agentChat = useAgentChat()const { extractAndSave } = useMemory()- const sendMessage = useCallback(async (content: string) => {+ const sendMessage = useCallback(async (content: string, images?: ImageAttachment[]) => {const { activeModel } = useModelStore.getState()const { settings } = useSettingsStore.getState()const store = useChatStore.getState()@@ -35,7 +36,7 @@ export function useChat() {// Agent mode delegation: if active for this conversation, use agent chatif (store.activeConversationId && useAgentModeStore.getState().isActive(store.activeConversationId)) {- return agentChat.sendAgentMessage(content)+ return agentChat.sendAgentMessage(content, images)}if (!activeModel) return@@ -49,6 +50,7 @@ export function useChat() {id: uuid(),role: "user" as const,content,+ images,timestamp: Date.now(),}useChatStore.getState().addMessage(convId, userMessage)@@ -114,7 +116,11 @@ export function useChat() {...(systemPrompt ? [{ role: "system" as const, content: systemPrompt }] : []),...conv.messages.filter((m) => m.content.trim() !== '')- .map((m) => ({ role: m.role as 'user' | 'assistant' | 'system' | 'tool', content: m.content })),+ .map((m) => ({+ role: m.role as 'user' | 'assistant' | 'system' | 'tool',+ content: m.content,+ ...(m.images?.length ? { images: m.images.map(img => ({ data: img.data, mimeType: img.mimeType })) } : {}),+ })),]const abort = new AbortController()@@ -138,6 +144,7 @@ export function useChat() {topP: settings.topP,topK: settings.topK,maxTokens: settings.maxTokens || undefined,+ thinking: settings.thinkingEnabled === true ? true : false,signal: abort.signal,},)@@ -152,6 +159,11 @@ export function useChat() {useModelStore.getState().setIsModelLoading(false)}+ // Ollama native thinking field (Gemma 4, Qwen 3.5, etc.)+ if (chunk.thinking) {+ thinkingRef.current += chunk.thinking+ }+if (chunk.content) {const text = chunk.contentdiff --git a/src/lib/constants.ts b/src/lib/constants.tsindex 0b39381d..525425c0 100644--- a/src/lib/constants.ts+++ b/src/lib/constants.ts@@ -14,6 +14,7 @@ export const DEFAULT_SETTINGS: Settings = {maxTokens: 0,theme: 'dark',onboardingDone: false,+ thinkingEnabled: true,searchProvider: 'auto',braveApiKey: '',tavilyApiKey: '',diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.tsindex 47120911..e6f00d43 100644--- a/src/stores/settingsStore.ts+++ b/src/stores/settingsStore.ts@@ -3,7 +3,7 @@ import { persist } from 'zustand/middleware'import type { Settings, Persona } from '../types/settings'import { DEFAULT_SETTINGS, BUILT_IN_PERSONAS } from '../lib/constants'-const STORE_VERSION = 2+const STORE_VERSION = 3interface SettingsState {settings: Settings@@ -58,10 +58,11 @@ export const useSettingsStore = create<SettingsState>()(version: STORE_VERSION,migrate: (persisted: any, version: number) => {if (version < STORE_VERSION) {- // Keep user's custom personas, replace built-in onesconst customPersonas = (persisted.personas || []).filter((p: Persona) => !p.isBuiltIn)return {...persisted,+ // Merge new default settings into existing (fills missing fields like thinkingEnabled)+ settings: { ...DEFAULT_SETTINGS, ...(persisted.settings || {}) },personas: [...BUILT_IN_PERSONAS, ...customPersonas],activePersonaId: persisted.activePersonaId || 'unrestricted',_version: STORE_VERSION,diff --git a/src/types/chat.ts b/src/types/chat.tsindex 50fead6a..fc1c7f17 100644--- a/src/types/chat.ts+++ b/src/types/chat.ts@@ -2,12 +2,19 @@ import type { AgentBlock } from './agent-mode'export type Role = 'user' | 'assistant' | 'system' | 'tool'+export interface ImageAttachment {+ data: string // base64 encoded+ mimeType: string // e.g. 'image/png', 'image/jpeg'+ name: string // filename+}+export interface Message {id: stringrole: Rolecontent: stringthinking?: stringtimestamp: number+ images?: ImageAttachment[]sources?: { documentName: string; chunkIndex: number; preview: string }[]// Agent Mode fieldsagentBlocks?: AgentBlock[]diff --git a/src/types/settings.ts b/src/types/settings.tsindex a9aa800f..e9630225 100644--- a/src/types/settings.ts+++ b/src/types/settings.ts@@ -8,6 +8,7 @@ export interface Settings {maxTokens: numbertheme: 'light' | 'dark'onboardingDone: boolean+ thinkingEnabled: booleansearchProvider: SearchProviderbraveApiKey: stringtavilyApiKey: string