Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

docs: README + landing page updated for v2.3.3 release

PurpleDoubleDe100e2c2a61e
diff --git a/README.md b/README.md
index cd4b6742..13b1ce73 100644
--- a/README.md
+++ b/README.md
@@ -34,28 +34,40 @@ No cloud. No data collection. No API keys. Auto-detects 12 local backends. Your
---
-## v2.3.2 — Current Release
-
-**GLM-4.7-Flash, Model Loading Fix, Agent Badge Audit, 75+ Downloadable Models**
-
-- **GLM-4.7-Flash** — ZhipuAI's strongest 30B class model. 11 variants across uncensored (Heretic) and mainstream, IQ2 to Q8. Fits 12GB VRAM (IQ2_M). Native tool calling.
-- **GLM 5.1 754B MoE** — Frontier agentic engineering model listed as cloud-available via Ollama.
-- **Model Loading Fix** — Fixed 3 bugs causing "0 models loaded" in ComfyUI Create View (race condition at startup, broken auto-retry logic, stale cache after download). Models now load reliably within seconds.
-- **Agent Badge Audit** — Consistent agent flags across all 75+ models. Models with native tool calling are correctly marked.
-- **Removed HOT Badges** — Cleaner UI, only AGENT badges shown for tool-calling models.
-
-### v2.3.0 Features (included)
-
-- **ComfyUI Plug & Play** — Auto-detect, one-click install, auto-start. Zero config image and video generation.
-- **20 Model Bundles** — 8 image + 12 video bundles with one-click download.
-- **Z-Image Turbo/Base** — Uncensored image model. 8-15 seconds per image. No safety filters.
-- **FLUX 2 Klein** — Next-gen FLUX architecture with Qwen 3 text encoder.
-- **Image-to-Image (I2I)** — Upload a source image, adjust denoise strength, transform with any image model.
-- **Image-to-Video (I2V)** — FramePack F1, CogVideoX, SVD with drag & drop image upload.
-- **Dynamic Workflow Builder** — 14 strategies. Auto-detects installed nodes.
-- **Unified Download Manager** — Track all downloads with progress, speed, retry.
-- **Think Mode in Chat Input** — Toggle thinking mode directly from the message input area.
-- **Process Cleanup** — ComfyUI auto-terminates when app is closed (Windows Job Object).
+## v2.3.3 — Current Release
+
+**Remote Access, Codex Streaming, Qwen 3.6 Day-0, ERNIE-Image, 2105 Tests**
+
+### Remote Access + Mobile Web App
+- **Access your AI from your phone** — Dispatch via LAN or Cloudflare Tunnel (Internet)
+- **Full mobile web app** — Hamburger drawer, chat list, Codex mode, file attach, thinking toggle, Plugins (Caveman + Personas)
+- **Mobile Agent Mode** — 13 tools with Thought/Action/Observation cards
+- **Security hardened** — 6-digit passcodes, rate limiting, JWT auth, permissions enforced, CSP headers
+
+### Codex Coding Agent — Major Upgrade
+- **Live streaming** between tool calls — see tokens as they generate
+- **Continue capability** — tool-call history persisted, model remembers previous actions
+- **AUTONOMY CONTRACT** — model completes ALL steps without premature stopping
+- **Fallback answer** — never shows empty bubble after tool calls
+
+### Agent Mode — 13-Phase Rewrite
+- **Parallel tool execution** with side-effect grouping
+- **Budget system** — max 50 tool calls / 25 iterations per task
+- **Sub-agent delegation** — `delegate_task` spawns isolated sub-agents
+- **MCP integration** — external tools via ToolRegistry
+- **Filesystem awareness** — agent uses file_list/system_info before acting
+
+### New Models + Image Gen
+- **Qwen 3.6** (day-0) — 35B MoE, vision + agentic coding + thinking. One-click download
+- **ERNIE-Image** (Baidu) — Turbo (8 steps) + Base (50 steps). Plug & play, no custom nodes
+- **Image-to-Image** — Upload source, adjust denoise, transform with any model
+- **75+ downloadable models** — all URLs verified
+
+### UI/UX
+- **AE-style text header** — clean typography for better discoverability
+- **Plugins dropdown** — Caveman Mode + Personas in one menu
+- **Thinking mode** — tri-state, auto-retry, universal tag stripper
+- **2105 tests** — comprehensive smoke tests covering the entire app
---
@@ -65,7 +77,7 @@ No cloud. No data collection. No API keys. Auto-detects 12 local backends. Your
|---------|:-:|:-:|:-:|:-:|
| AI Chat | **Yes** | Yes | Yes | Yes |
| **Coding Agent (Codex)** | **Yes** | No | No | No |
-| **13 MCP Agent Tools** | **Yes** | No | No | No |
+| **14 Agent Tools + MCP** | **Yes** | No | No | No |
| **Plug & Play Setup** | **12 Backends** | No | Built-in | No |
| **Multi-Provider** (20+ Presets) | **Yes** | Yes | Yes | No |
| **A/B Model Compare** | **Yes** | No | No | No |
@@ -82,6 +94,9 @@ No cloud. No data collection. No API keys. Auto-detects 12 local backends. Your
| Agent Workflows | **Yes** | No | No | No |
| Document Chat (RAG) | **Yes** | Yes | No | No |
| Voice (STT + TTS) | **Yes** | Partial | No | No |
+| **Remote Access (Phone)** | **Yes** | No | No | No |
+| **Plugins (Caveman + Personas)** | **Yes** | No | No | Yes |
+| **Auto-Update** | **Yes** | No | Yes | No |
| Open Source | **AGPL-3.0** | MIT | No | AGPL |
| No Docker | **Yes** | No | Yes | Yes |
@@ -93,8 +108,9 @@ No cloud. No data collection. No API keys. Auto-detects 12 local backends. Your
- **Plug & Play Setup** — First-launch wizard auto-detects 12 local backends. Nothing installed? One-click in-app Ollama download and install with progress bar. ComfyUI one-click install with step-by-step progress. Configurable ComfyUI port and path in Settings. Zero config needed.
- **Uncensored AI Chat** — Abliterated models with zero restrictions. Streaming + thinking display.
- **Multi-Provider** — 20+ presets. Local: Ollama, LM Studio, vLLM, KoboldCpp, llama.cpp, LocalAI, Jan, TabbyAPI, GPT4All, Aphrodite, SGLang, TGI. Cloud: OpenAI, Anthropic, OpenRouter, Groq, Together, DeepSeek, Mistral. Switch per conversation.
-- **Codex Coding Agent** — Reads codebase, writes code, runs shell commands. File tree with native folder picker. Up to 20 tool iterations.
-- **Agent Mode** — 13 MCP tools: web search, file I/O, shell, code execution, screenshots, system info. Native + Hermes XML fallback.
+- **Codex Coding Agent** — Live streaming between tool calls, continue capability, AUTONOMY CONTRACT. File tree, folder picker, up to 50 iterations.
+- **Agent Mode** — 14 tools + MCP: web search/fetch, file I/O, shell, code execution, screenshots, system info, time. Parallel execution, sub-agents, budget system.
+- **Remote Access** — Access your AI from your phone via LAN or Cloudflare Tunnel. Full mobile web app with Agent Mode, Codex, plugins, file attach.
- **Image Generation** — FLUX 2 Klein, FLUX.1 (schnell/dev), Z-Image Turbo/Base, Juggernaut XL, RealVisXL, DreamShaper XL via ComfyUI. Full parameter control, no content filter.
- **Image-to-Image** — Upload a source image, adjust denoise strength, transform with any image model.
- **Video Generation** — Wan 2.1, HunyuanVideo 1.5, LTX 2.3, AnimateDiff Lightning, CogVideoX, FramePack F1 on your GPU.
@@ -116,12 +132,15 @@ No cloud. No data collection. No API keys. Auto-detects 12 local backends. Your
- **20+ Personas** — Pre-built characters. Switch without prompt engineering.
- **Chat Export** — Markdown or JSON. Token counter. Keyboard shortcuts.
+### Customization
+- **Plugins Dropdown** — Caveman Mode (Off/Lite/Full/Ultra for terse responses) + 20+ Personas in one menu. Per-chat. Works in Chat, Agent, Codex.
+- **Auto-Update** — Signed NSIS installer. In-app download with progress bar. User-controlled restart (no forced updates). Settings survive updates.
+
### Polish
- **Standalone Desktop App** — Tauri v2 Rust backend. Download .exe, run it.
-- **Model Load/Unload** — Power icons in header. Load into VRAM, unload when done.
-- **Custom Dark Titlebar** — Frameless window, no native chrome.
-- **Linear/Arc UI** — Compact, monochrome. 15% larger for readability.
-- **Privacy First** — Zero tracking, all API calls proxied locally.
+- **Model Load/Unload** — iOS-style toggle in header. Load into VRAM, unload when done.
+- **AE-Style Header** — Clean typography navigation. Models, Settings, Downloads at a glance.
+- **Privacy First** — Zero tracking, all API calls proxied locally. ComfyUI process auto-killed on app close.
## Tech Stack
@@ -181,11 +200,11 @@ Open the **Create** tab. ComfyUI is auto-detected or one-click installed. Models
| Model | VRAM | Best For |
|-------|------|----------|
+| **Qwen 3.6 35B MoE** | 24 GB | Vision + agentic coding + thinking. Brand new. |
| **GLM-4.7-Flash IQ2** | 12 GB | Strongest 30B class. Tool calling. 198K context. |
| **Gemma 4 E4B** | 4 GB | Lightweight, fast, great for small GPUs. |
-| **Qwen 3.5 9B** | 8 GB | Strongest reasoning + coding at 9B. |
-| **Gemma 4 31B** | 16 GB | Frontier dense model, native tools + vision. |
| **Qwen 3.5 35B MoE** | 16 GB | Best agentic, 256K context. SWE-bench leader. |
+| **Gemma 4 31B** | 16 GB | Frontier dense model, native tools + vision. |
| Hermes 3 8B | 6 GB | Agent Mode. Uncensored + tool calling. |
| DeepSeek R1 (8B-70B) | 6-48 GB | Chain-of-thought reasoning. |
@@ -195,6 +214,7 @@ Open the **Create** tab. ComfyUI is auto-detected or one-click installed. Models
|-------|------|-------|
| FLUX.1 Schnell / Dev | 8-10 GB | Best text-to-image. Fast (schnell) or quality (dev). |
| FLUX 2 Klein 4B | 8-10 GB | Next-gen, fastest FLUX model. |
+| ERNIE-Image Turbo | 24 GB | Baidu DiT, 8 steps, 1024x1024. New. |
| Z-Image Turbo | 10-16 GB | Uncensored, 8-15 sec per image. |
| Juggernaut XL V9 | 6 GB | Best photorealistic SDXL. |
@@ -229,13 +249,19 @@ Open the **Create** tab. ComfyUI is auto-detected or one-click installed. Models
- [x] 20 Image + Video Model Bundles
- [x] Image-to-Image (I2I)
- [x] Image-to-Video (I2V) — FramePack, CogVideoX, SVD
-- [x] Z-Image + FLUX 2 support
-- [x] Dynamic Workflow Builder (14 strategies)
+- [x] Z-Image + FLUX 2 + ERNIE-Image support
+- [x] Dynamic Workflow Builder (15 strategies)
- [x] VRAM-Aware Model Filtering
- [x] Think Mode in Chat Input
+- [x] Remote Access (LAN + Cloudflare Tunnel)
+- [x] Mobile Web App (Agent, Codex, Plugins, Thinking)
+- [x] Codex Streaming + Continue + Autonomy Contract
+- [x] Agent 13-Phase Rewrite (parallel, budget, sub-agents, MCP)
+- [x] Auto-Update (signed NSIS installer)
+- [x] Qwen 3.6 Day-0 Support
+- [x] Plugins Dropdown (Caveman + Personas)
- [ ] Voice Mode (Qwen Omni live voice)
- [ ] Upscale + Inpainting
-- [ ] Plugin System
---
diff --git a/docs/index.html b/docs/index.html
index 06e20361..f76afb6e 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -24,7 +24,7 @@
<meta name="theme-color" content="#0a0a0a">
<link rel="icon" href="./favicon.png">
<script type="application/ld+json">
-{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Locally Uncensored","applicationCategory":"DeveloperApplication","applicationSubCategory":"Artificial Intelligence","operatingSystem":"Windows","description":"Generate anything — text, images, video. Locally. Uncensored. The only desktop app that combines AI chat, image generation, and video creation in one. No cloud, no API keys, no data collection. Free and open source.","url":"https://locallyuncensored.com/","downloadUrl":"https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.2/Locally.Uncensored_2.3.2_x64-setup.exe","softwareVersion":"2.3.0","license":"https://www.gnu.org/licenses/agpl-3.0.html","author":{"@type":"Person","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD"},"offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"featureList":["Plug & Play Setup with 12 Local Backend Auto-Detection","Uncensored AI Chat with 20+ Provider Presets","Codex Coding Agent with 13 MCP Tools","Multi-Provider: Ollama, LM Studio, vLLM, KoboldCpp, llama.cpp, LocalAI, Jan, OpenAI, Anthropic, OpenRouter, Groq, and more","Image Generation via ComfyUI (FLUX 2, Z-Image, SDXL)","Image-to-Image with Denoise Control","Video Generation (Wan 2.1, HunyuanVideo, LTX, AnimateDiff, FramePack)","Image-to-Video (FramePack F1, CogVideoX, SVD)","Granular Permission System","File Upload with Vision Support","Thinking Mode","A/B Model Compare","100% Offline and Private"],"screenshot":"https://raw.githubusercontent.com/PurpleDoubleD/locally-uncensored/master/docs/social-preview.png","softwareRequirements":"Any OpenAI-compatible backend (Ollama, LM Studio, vLLM, KoboldCpp, etc.) or cloud API key","memoryRequirements":"8 GB RAM minimum","storageRequirements":"6 GB for default model"}
+{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Locally Uncensored","applicationCategory":"DeveloperApplication","applicationSubCategory":"Artificial Intelligence","operatingSystem":"Windows","description":"Generate anything — text, images, video. Locally. Uncensored. The only desktop app that combines AI chat, image generation, and video creation in one. No cloud, no API keys, no data collection. Free and open source.","url":"https://locallyuncensored.com/","downloadUrl":"https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.3/Locally.Uncensored_2.3.3_x64-setup.exe","softwareVersion":"2.3.3","license":"https://www.gnu.org/licenses/agpl-3.0.html","author":{"@type":"Person","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD"},"offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"featureList":["Plug & Play Setup with 12 Local Backend Auto-Detection","Uncensored AI Chat with 20+ Provider Presets","Codex Coding Agent with Live Streaming and Continue Capability","14 Agent Tools + MCP Integration with Parallel Execution","Remote Access from Phone via LAN or Cloudflare Tunnel","Multi-Provider: Ollama, LM Studio, vLLM, KoboldCpp, llama.cpp, LocalAI, Jan, OpenAI, Anthropic, OpenRouter, Groq, and more","Image Generation via ComfyUI (FLUX 2, ERNIE-Image, Z-Image, SDXL)","Image-to-Image with Denoise Control","Video Generation (Wan 2.1, HunyuanVideo, LTX, AnimateDiff, FramePack)","Image-to-Video (FramePack F1, CogVideoX, SVD)","Qwen 3.6 Day-0 Support with Vision and Agentic Coding","Granular Permission System","File Upload with Vision Support","Thinking Mode with Universal Tag Stripping","A/B Model Compare","100% Offline and Private"],"screenshot":"https://raw.githubusercontent.com/PurpleDoubleD/locally-uncensored/master/docs/social-preview.png","softwareRequirements":"Any OpenAI-compatible backend (Ollama, LM Studio, vLLM, KoboldCpp, etc.) or cloud API key","memoryRequirements":"8 GB RAM minimum","storageRequirements":"6 GB for default model"}
</script>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"Organization","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD","sameAs":["https://github.com/PurpleDoubleD","https://reddit.com/user/GroundbreakingMall54"]}
@@ -206,12 +206,12 @@ html,body{overflow-x:hidden}
</nav>
<section class="hero">
- <div class="hero-badge">v2.3.2 / Open Source / AGPL-3.0</div>
+ <div class="hero-badge">v2.3.3 / Open Source / AGPL-3.0</div>
<h1>Your AI. Your machine.<br>No limits.</h1>
- <p>Chat, code, generate images, create videos — all running locally. Plug & Play with 12 local backends. 13 built-in tools, coding agent. No cloud, no accounts.</p>
+ <p>Chat, code, generate images, create videos — all running locally. Remote access from your phone. 14 agent tools, coding agent with live streaming. Plug & Play with 12 backends.</p>
<p style="margin-top:8px"><a href="./guide/" style="color:#a78bfa;font-size:0.9rem">Getting Started Guide</a></p>
<div class="hero-cta">
- <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.2/Locally.Uncensored_2.3.2_x64-setup.exe" class="btn btn-primary" download>Download for Windows</a>
+ <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.3/Locally.Uncensored_2.3.3_x64-setup.exe" class="btn btn-primary" download>Download for Windows</a>
<a href="https://github.com/PurpleDoubleD/locally-uncensored" class="btn" target="_blank">
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
View Source
@@ -226,10 +226,10 @@ html,body{overflow-x:hidden}
</section>
<section class="install reveal" id="install">
- <p style="margin-bottom:1.5rem;font-size:1.1rem;color:#ededed;font-weight:600">Download v2.3.2</p>
+ <p style="margin-bottom:1.5rem;font-size:1.1rem;color:#ededed;font-weight:600">Download v2.3.3</p>
<div style="display:flex;gap:1rem;justify-content:center;margin-bottom:2rem;flex-wrap:wrap">
- <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.2/Locally.Uncensored_2.3.2_x64-setup.exe" class="btn btn-primary" style="font-size:.9rem;padding:.6rem 1.5rem" download>Windows (.exe)</a>
- <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/tag/v2.3.2" class="btn" style="font-size:.9rem;padding:.6rem 1.5rem">All Downloads</a>
+ <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.3/Locally.Uncensored_2.3.3_x64-setup.exe" class="btn btn-primary" style="font-size:.9rem;padding:.6rem 1.5rem" download>Windows (.exe)</a>
+ <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/tag/v2.3.3" class="btn" style="font-size:.9rem;padding:.6rem 1.5rem">All Downloads</a>
</div>
<p style="color:var(--text-tertiary);font-size:.8rem">Plug & Play — choose from 20+ providers. The setup wizard auto-detects 12 local backends (Ollama, LM Studio, vLLM, KoboldCpp, Jan, GPT4All, llama.cpp, and more) or configure cloud APIs in Settings. Other platforms: <a href="https://github.com/PurpleDoubleD/locally-uncensored#-quick-start" style="color:var(--text-secondary);border-bottom:1px solid var(--border)">build from source</a>.</p>
</section>
@@ -244,15 +244,15 @@ html,body{overflow-x:hidden}
<div class="feature-icon" style="color:#8b5cf6">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a4 4 0 0 1 4 4v1a2 2 0 0 1 2 2v1a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3V9a2 2 0 0 1 2-2V6a4 4 0 0 1 4-4z"/><path d="M8 14v2a4 4 0 0 0 8 0v-2"/></svg>
</div>
- <h3>Agent Mode — 13 MCP Tools</h3>
- <p>Web search, file I/O, shell commands, code execution, screenshots, system info. Granular permissions per category. Native + Hermes fallback for any model.</p>
+ <h3>Agent Mode — 14 Tools + MCP</h3>
+ <p>Parallel tool execution, sub-agent delegation, budget system. Web search/fetch, file I/O, shell, code, screenshots, system info. MCP integration for external tools.</p>
</div>
<div class="feature-cell" style="border-color:rgba(59,130,246,0.3);background:rgba(59,130,246,0.03)">
<div class="feature-icon" style="color:#3b82f6;background:rgba(59,130,246,0.08)">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
</div>
<h3>Codex Coding Agent</h3>
- <p>Dedicated coding mode. Reads your codebase, writes code, runs commands. File tree browser, native folder picker, working directory. Up to 20 iterations per task.</p>
+ <p>Live streaming between tool calls. Continue capability across turns. AUTONOMY CONTRACT ensures multi-step completion. File tree, folder picker, up to 50 iterations.</p>
</div>
<div class="feature-cell">
<div class="feature-icon">
@@ -266,7 +266,7 @@ html,body{overflow-x:hidden}
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
</div>
<h3>Image Generation</h3>
- <p>FLUX 2 Klein, FLUX.1, Z-Image Turbo, Juggernaut XL via ComfyUI. Text-to-Image and Image-to-Image. No content filter. One-click setup.</p>
+ <p>FLUX 2, ERNIE-Image, Z-Image, Juggernaut XL via ComfyUI. Text-to-Image and Image-to-Image. 8 image bundles, no content filter. One-click setup.</p>
</div>
<div class="feature-cell">
<div class="feature-icon">
@@ -326,7 +326,7 @@ html,body{overflow-x:hidden}
</section>
<section class="agent-section reveal" id="whats-new">
- <div class="section-label">New in v2.3.2</div>
+ <div class="section-label">New in v2.3.3</div>
<h2 class="section-heading">GLM-4.7-Flash. 75+ Models. ComfyUI Plug & Play.</h2>
<div class="section-desc">GLM-4.7-Flash in 11 variants. 75+ downloadable models with agent badges. Model loading fix. 20 image + video bundles. Z-Image uncensored. FramePack I2V. Image-to-Image.</div>
@@ -509,7 +509,7 @@ html,body{overflow-x:hidden}
<h2>Run your own AI stack. No limits.</h2>
<p>Free, open source, and yours to keep.</p>
<div class="cta-buttons">
- <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.2/Locally.Uncensored_2.3.2_x64-setup.exe" class="btn btn-primary" download>Download for Windows</a>
+ <a href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.3.3/Locally.Uncensored_2.3.3_x64-setup.exe" class="btn btn-primary" download>Download for Windows</a>
<a href="https://github.com/PurpleDoubleD/locally-uncensored" class="btn" target="_blank">View on GitHub</a>
</div>
</section>
diff --git a/src/api/agent-context.ts b/src/api/agent-context.ts
new file mode 100644
index 00000000..43c32484
--- /dev/null
+++ b/src/api/agent-context.ts
@@ -0,0 +1,34 @@
+/**
+ * Per-agent-run chat context — maps the currently executing agent loop
+ * back to the conversation it belongs to. Lets the built-in tool
+ * executors (`file_read`, `file_write`, `execute_code`, `shell_execute`)
+ * thread a `chatId` through to the Rust side WITHOUT changing their
+ * public args shape or polluting the tool JSON schema the model sees.
+ *
+ * How it flows:
+ * 1. useAgentChat / useCodex / useClaudeCode → setActiveChatId(convId)
+ * at the start of their agent loop.
+ * 2. Tool executors in `src/api/mcp/builtin-tools.ts` → backendCall
+ * includes `{ chatId: getActiveChatId() }` in the request body.
+ * 3. Rust tool commands resolve relative paths against
+ * `~/agent-workspace/<chatId>/`, so every chat gets its own
+ * isolated workspace folder, created lazily on first write.
+ *
+ * When unset (standalone tool calls outside an agent loop), Rust falls
+ * back to `~/agent-workspace/default/` so nothing ever lands in the
+ * legacy shared folder.
+ */
+
+let activeChatId: string | null = null
+
+export function setActiveChatId(id: string | null | undefined): void {
+ activeChatId = id ? String(id) : null
+}
+
+export function getActiveChatId(): string | null {
+ return activeChatId
+}
+
+export function clearActiveChatId(): void {
+ activeChatId = null
+}
diff --git a/src/components/chat/HtmlPreviewModal.tsx b/src/components/chat/HtmlPreviewModal.tsx
new file mode 100644
index 00000000..bd68d533
--- /dev/null
+++ b/src/components/chat/HtmlPreviewModal.tsx
@@ -0,0 +1,193 @@
+import { useEffect, useMemo, useRef, useState } from 'react'
+import { motion, AnimatePresence } from 'framer-motion'
+import { X, ExternalLink, Smartphone, Tablet, Monitor, RotateCw } from 'lucide-react'
+import { openExternal } from '../../api/backend'
+
+interface Props {
+ code: string
+ language?: string
+ onClose: () => void
+}
+
+type Viewport = 'mobile' | 'tablet' | 'desktop'
+
+const VIEWPORTS: Record<Viewport, { width: number; height: number }> = {
+ mobile: { width: 375, height: 667 },
+ tablet: { width: 768, height: 1024 },
+ desktop: { width: 1280, height: 800 },
+}
+
+/**
+ * Wrap an HTML / SVG snippet so the iframe always has a sane shell.
+ * - Bare SVG → centred dark page that hugs the artwork.
+ * - Snippet HTML (no <html>/<doctype>) → minimal doc with utf-8 + body padding.
+ * - Full document → passed through untouched.
+ *
+ * The iframe runs with `sandbox="allow-scripts"` (no allow-same-origin), so
+ * any user JS lives in an opaque origin and can't reach our app.
+ */
+function buildDocument(code: string, language?: string): string {
+ const lang = (language || '').toLowerCase()
+ const trimmed = code.trim()
+ const lower = trimmed.toLowerCase()
+
+ // Bare SVG.
+ if (lang === 'svg' || (lower.startsWith('<svg') && lower.includes('xmlns'))) {
+ return [
+ '<!doctype html><html><head><meta charset="utf-8"><title>SVG Preview</title>',
+ '<style>html,body{margin:0;padding:0;background:#0e0e0e;color:#fff;height:100%;display:flex;align-items:center;justify-content:center;font-family:system-ui,sans-serif}svg{max-width:100%;max-height:100%}</style>',
+ '</head><body>',
+ code,
+ '</body></html>',
+ ].join('')
+ }
+
+ // Already a full document.
+ if (lower.startsWith('<!doctype') || lower.startsWith('<html')) {
+ return code
+ }
+
+ // Snippet — wrap.
+ return [
+ '<!doctype html><html><head><meta charset="utf-8"><title>HTML Preview</title>',
+ '<style>body{margin:0;padding:16px;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;line-height:1.5;background:#ffffff;color:#111}</style>',
+ '</head><body>',
+ code,
+ '</body></html>',
+ ].join('')
+}
+
+export function HtmlPreviewModal({ code, language, onClose }: Props) {
+ const [viewport, setViewport] = useState<Viewport>('desktop')
+ const [reloadKey, setReloadKey] = useState(0)
+ const iframeRef = useRef<HTMLIFrameElement>(null)
+ const doc = useMemo(() => buildDocument(code, language), [code, language])
+
+ // Esc closes — matches every other overlay in the app.
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') onClose()
+ }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [onClose])
+
+ const dims = VIEWPORTS[viewport]
+
+ const openInBrowser = () => {
+ // Hand the data URL to the host browser. data: URLs work in modern
+ // browsers; users can then save / share / inspect with full devtools.
+ const dataUrl = `data:text/html;charset=utf-8;base64,${btoa(unescape(encodeURIComponent(doc)))}`
+ openExternal(dataUrl)
+ }
+
+ return (
+ <AnimatePresence>
+ <motion.div
+ className="fixed inset-0 z-[200] flex items-center justify-center bg-black/70 backdrop-blur-sm p-4"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.15 }}
+ onClick={(e) => { if (e.target === e.currentTarget) onClose() }}
+ >
+ <motion.div
+ className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-white/10 rounded-lg shadow-2xl flex flex-col overflow-hidden w-full max-w-[95vw] h-[90vh] max-h-[900px]"
+ initial={{ scale: 0.96, opacity: 0 }}
+ animate={{ scale: 1, opacity: 1 }}
+ exit={{ scale: 0.96, opacity: 0 }}
+ transition={{ duration: 0.15 }}
+ >
+ {/* Header */}
+ <div className="flex items-center justify-between gap-3 px-4 py-2.5 border-b border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02]">
+ <div className="flex items-center gap-2">
+ <span className="text-xs font-semibold tracking-wider uppercase text-gray-500 dark:text-gray-400">
+ HTML Preview
+ </span>
+ <span className="text-[0.6rem] text-gray-400 dark:text-gray-500 font-mono">
+ {language || 'html'}
+ </span>
+ </div>
+
+ {/* Viewport switcher */}
+ <div className="flex items-center gap-0.5 bg-gray-100 dark:bg-white/[0.04] rounded-md p-0.5">
+ <ViewportBtn icon={Smartphone} active={viewport === 'mobile'} onClick={() => setViewport('mobile')} label="Mobile" />
+ <ViewportBtn icon={Tablet} active={viewport === 'tablet'} onClick={() => setViewport('tablet')} label="Tablet" />
+ <ViewportBtn icon={Monitor} active={viewport === 'desktop'} onClick={() => setViewport('desktop')} label="Desktop" />
+ </div>
+
+ <div className="flex items-center gap-1">
+ <button
+ onClick={() => setReloadKey((k) => k + 1)}
+ className="p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-white/[0.06] hover:text-gray-700 dark:hover:text-white transition-colors"
+ aria-label="Reload preview"
+ title="Reload preview"
+ >
+ <RotateCw size={14} />
+ </button>
+ <button
+ onClick={openInBrowser}
+ className="p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-white/[0.06] hover:text-gray-700 dark:hover:text-white transition-colors"
+ aria-label="Open in browser"
+ title="Open in browser"
+ >
+ <ExternalLink size={14} />
+ </button>
+ <button
+ onClick={onClose}
+ className="p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-white/[0.06] hover:text-gray-700 dark:hover:text-white transition-colors"
+ aria-label="Close"
+ title="Close (Esc)"
+ >
+ <X size={14} />
+ </button>
+ </div>
+ </div>
+
+ {/* Frame area — checkered background to make the rendered surface obvious */}
+ <div className="flex-1 overflow-auto bg-[length:24px_24px] bg-[linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,12px_12px] dark:bg-[length:24px_24px] dark:bg-[linear-gradient(45deg,rgba(255,255,255,0.03)_25%,transparent_25%,transparent_75%,rgba(255,255,255,0.03)_75%),linear-gradient(45deg,rgba(255,255,255,0.03)_25%,transparent_25%,transparent_75%,rgba(255,255,255,0.03)_75%)] flex items-center justify-center p-4">
+ <iframe
+ key={reloadKey}
+ ref={iframeRef}
+ srcDoc={doc}
+ sandbox="allow-scripts"
+ referrerPolicy="no-referrer"
+ title="HTML Preview"
+ className="bg-white border border-gray-200 dark:border-white/10 shadow-lg rounded transition-all"
+ style={{
+ width: viewport === 'desktop' ? '100%' : `${dims.width}px`,
+ height: viewport === 'desktop' ? '100%' : `${dims.height}px`,
+ maxWidth: '100%',
+ maxHeight: '100%',
+ }}
+ />
+ </div>
+ </motion.div>
+ </motion.div>
+ </AnimatePresence>
+ )
+}
+
+interface ViewportBtnProps {
+ icon: typeof Smartphone
+ active: boolean
+ onClick: () => void
+ label: string
+}
+function ViewportBtn({ icon: Icon, active, onClick, label }: ViewportBtnProps) {
+ return (
+ <button
+ onClick={onClick}
+ className={
+ 'flex items-center justify-center w-7 h-7 rounded transition-colors ' +
+ (active
+ ? 'bg-white dark:bg-white/10 text-gray-900 dark:text-white shadow-sm'
+ : 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-white')
+ }
+ aria-label={label}
+ title={label}
+ >
+ <Icon size={13} />
+ </button>
+ )
+}
diff --git a/src/components/chat/__tests__ b/src/components/chat/__tests__
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/components/chat/__tests__/CodeBlock.test.ts b/src/components/chat/__tests__/CodeBlock.test.ts
new file mode 100644
index 00000000..1d88e652
--- /dev/null
+++ b/src/components/chat/__tests__/CodeBlock.test.ts
@@ -0,0 +1,92 @@
+/**
+ * CodeBlock / HtmlPreviewModal Tests
+ *
+ * Tests the HTML-snippet detector used by the Preview chip. Every
+ * positive case must be something we'd safely render in a sandboxed
+ * iframe; every negative case must NOT trigger Preview (otherwise
+ * we'd render random JS/CSS as HTML, which is confusing).
+ *
+ * Run: npx vitest run src/components/chat/__tests__/CodeBlock.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { isHtmlSnippet } from '../CodeBlock'
+
+describe('isHtmlSnippet', () => {
+ describe('by language tag (fenced code block lang)', () => {
+ it('detects html', () => {
+ expect(isHtmlSnippet('<div>x</div>', 'html')).toBe(true)
+ })
+ it('detects htm', () => {
+ expect(isHtmlSnippet('<p>hello</p>', 'htm')).toBe(true)
+ })
+ it('detects xhtml', () => {
+ expect(isHtmlSnippet('<p/>', 'xhtml')).toBe(true)
+ })
+ it('detects svg', () => {
+ expect(isHtmlSnippet('<svg></svg>', 'svg')).toBe(true)
+ })
+ it('is case-insensitive on language', () => {
+ expect(isHtmlSnippet('<p>x</p>', 'HTML')).toBe(true)
+ expect(isHtmlSnippet('<p>x</p>', 'Html')).toBe(true)
+ })
+ it('does NOT trigger on js/ts/python/css', () => {
+ expect(isHtmlSnippet('const x = 1', 'js')).toBe(false)
+ expect(isHtmlSnippet('const x: number = 1', 'ts')).toBe(false)
+ expect(isHtmlSnippet('print(1)', 'python')).toBe(false)
+ expect(isHtmlSnippet('body { color: red }', 'css')).toBe(false)
+ })
+ })
+
+ describe('by content (no language tag)', () => {
+ it('detects a full <!DOCTYPE html> document', () => {
+ const code = '<!DOCTYPE html>\n<html><body>x</body></html>'
+ expect(isHtmlSnippet(code)).toBe(true)
+ })
+ it('detects lowercased <!doctype html>', () => {
+ const code = '<!doctype html>\n<html></html>'
+ expect(isHtmlSnippet(code)).toBe(true)
+ })
+ it('detects a document starting with <html', () => {
+ expect(isHtmlSnippet('<html><body>x</body></html>')).toBe(true)
+ })
+ it('detects <svg xmlns=...>', () => {
+ const code = '<svg xmlns="http://www.w3.org/2000/svg"><circle r="5"/></svg>'
+ expect(isHtmlSnippet(code)).toBe(true)
+ })
+ it('tolerates leading whitespace before the marker', () => {
+ const code = ' \n <!DOCTYPE html>\n<html></html>'
+ expect(isHtmlSnippet(code)).toBe(true)
+ const code2 = '\n\t<html></html>'
+ expect(isHtmlSnippet(code2)).toBe(true)
+ })
+ })
+
+ describe('negative cases', () => {
+ it('empty string → false', () => {
+ expect(isHtmlSnippet('')).toBe(false)
+ expect(isHtmlSnippet(' \n ')).toBe(false)
+ })
+ it('plain text → false', () => {
+ expect(isHtmlSnippet('Hello world')).toBe(false)
+ })
+ it('SVG without xmlns → false (too fragile to auto-detect)', () => {
+ // Bare <svg> without xmlns is technically valid but most code-block
+ // dumps are just fragments → don't auto-preview.
+ expect(isHtmlSnippet('<svg><circle r="5"/></svg>')).toBe(false)
+ })
+ it('fragment <div> without lang tag → false', () => {
+ // This is on purpose: `<div>foo</div>` by itself could be anything
+ // (JSX, Vue template, Angular, …). We only preview when we're sure.
+ expect(isHtmlSnippet('<div>foo</div>')).toBe(false)
+ })
+ it('JSON that starts with < → false', () => {
+ expect(isHtmlSnippet('<not-html>')).toBe(false)
+ })
+ it('JavaScript using document.createElement → false', () => {
+ expect(isHtmlSnippet('document.createElement("div")')).toBe(false)
+ })
+ it('CSS selector starting with html → false (content does not start with <html)', () => {
+ expect(isHtmlSnippet('html { margin: 0 }')).toBe(false)
+ })
+ })
+})
diff --git a/src/components/create/CreateTopControls.tsx b/src/components/create/CreateTopControls.tsx
new file mode 100644
index 00000000..fd60f5a9
--- /dev/null
+++ b/src/components/create/CreateTopControls.tsx
@@ -0,0 +1,232 @@
+import { useEffect, useRef, useState } from 'react'
+import { Image as ImageIcon, Film, Loader2, Power, ChevronDown, Check } from 'lucide-react'
+import { useCreateStore } from '../../stores/createStore'
+import { backendCall } from '../../api/backend'
+import { classifyModel, checkComfyConnection } from '../../api/comfyui'
+
+/**
+ * Create view's top controls (lives inside the app Header when the
+ * user is on the Create tab). Pattern mirrors the chat header:
+ * - Model picker — the active image OR video model, driven by
+ * `useCreateStore.mode`. Dropdown picks from the lists discovered
+ * by useCreate() (`imageModelList` / `videoModelList`).
+ * - Lichtschalter — green when ComfyUI is running, red when not,
+ * amber-with-spinner while transitioning. Click flips it.
+ *
+ * The mode switcher (Image ↔ Video) is exposed here too so the user can
+ * flip without scrolling down into the ParamPanel.
+ */
+export function CreateTopControls() {
+ const {
+ mode, setMode,
+ imageModel, setImageModel,
+ videoModel, setVideoModel,
+ imageModelList, videoModelList,
+ comfyRunning, setComfyRunning,
+ } = useCreateStore()
+
+ const [open, setOpen] = useState(false)
+ const [comfyBusy, setComfyBusy] = useState<'starting' | 'stopping' | null>(null)
+ const startPollRef = useRef<number | null>(null)
+
+ // Close the dropdown when the user clicks somewhere else.
+ useEffect(() => {
+ if (!open) return
+ const onDoc = (e: MouseEvent) => {
+ const target = e.target as HTMLElement | null
+ if (!target || !target.closest('[data-create-top-picker]')) setOpen(false)
+ }
+ document.addEventListener('mousedown', onDoc)
+ return () => document.removeEventListener('mousedown', onDoc)
+ }, [open])
+
+ // Heartbeat poll whenever the toggle lives in the header (independent of
+ // whether the full CreateView is mounted). Keeps the Lichtschalter in
+ // sync when the user starts/stops ComfyUI from another place (Settings,
+ // OS tray, etc.) without mounting the heavy useCreate hook.
+ useEffect(() => {
+ let cancelled = false
+ const tick = async () => {
+ if (cancelled) return
+ try {
+ const alive = await checkComfyConnection()
+ if (!cancelled) setComfyRunning(alive)
+ } catch { /* keep previous state */ }
+ }
+ tick() // fire once on mount
+ const id = window.setInterval(tick, 5000)
+ return () => { cancelled = true; clearInterval(id) }
+ }, [setComfyRunning])
+
+ // Always clean up the start-polling interval on unmount.
+ useEffect(() => () => {
+ if (startPollRef.current != null) {
+ clearInterval(startPollRef.current)
+ startPollRef.current = null
+ }
+ }, [])
+
+ const activeList = mode === 'image' ? imageModelList : videoModelList
+ const activeModel = mode === 'image' ? imageModel : videoModel
+ const onPickModel = (name: string) => {
+ if (mode === 'image') {
+ const type = classifyModel(name)
+ setImageModel(name, type)
+ } else {
+ setVideoModel(name)
+ }
+ setOpen(false)
+ }
+
+ const onToggleComfy = async () => {
+ if (comfyBusy) return
+ if (comfyRunning) {
+ setComfyBusy('stopping')
+ try { await backendCall('stop_comfyui') } catch {}
+ setComfyRunning(false)
+ setComfyBusy(null)
+ return
+ }
+
+ // START path — ComfyUI's first boot takes 5–15 s (Python startup,
+ // model index build, etc.). The old 800 ms optimistic reset fell
+ // back to "red/off" before the server was ready, which the user
+ // correctly reported as broken. Instead: keep the amber spinner
+ // UNTIL checkComfyConnection() returns 200, or give up after ~60 s.
+ setComfyBusy('starting')
+ try { await backendCall('start_comfyui') } catch { /* surfaced via poll */ }
+
+ // Stop any previous poll (in case the user mashed the button).
+ if (startPollRef.current != null) {
+ clearInterval(startPollRef.current)
+ startPollRef.current = null
+ }
+
+ const startedAt = Date.now()
+ const MAX_WAIT_MS = 60_000
+ startPollRef.current = window.setInterval(async () => {
+ const alive = await checkComfyConnection()
+ if (alive) {
+ if (startPollRef.current != null) {
+ clearInterval(startPollRef.current)
+ startPollRef.current = null
+ }
+ setComfyRunning(true)
+ setComfyBusy(null)
+ } else if (Date.now() - startedAt > MAX_WAIT_MS) {
+ // Giving up — surface a clear red state. The user can retry.
+ if (startPollRef.current != null) {
+ clearInterval(startPollRef.current)
+ startPollRef.current = null
+ }
+ setComfyRunning(false)
+ setComfyBusy(null)
+ }
+ }, 1500)
+ }
+
+ const toggleTitle = comfyBusy
+ ? (comfyBusy === 'starting' ? 'Starting ComfyUI…' : 'Stopping ComfyUI…')
+ : (comfyRunning ? 'ComfyUI running — click to stop' : 'ComfyUI stopped — click to start')
+
+ return (
+ <div className="flex items-center gap-1" data-create-top-picker>
+ {/* Image / Video mode switch */}
+ <div className="flex items-center rounded-md border border-gray-200 dark:border-white/10 overflow-hidden">
+ <button
+ onClick={() => setMode('image')}
+ className={`px-2 h-[22px] flex items-center gap-1 text-[0.6rem] font-medium transition-colors ${
+ mode === 'image'
+ ? 'bg-gray-200 dark:bg-white/10 text-gray-900 dark:text-white'
+ : 'text-gray-500 hover:text-gray-800 dark:hover:text-gray-200'
+ }`}
+ title="Image mode"
+ >
+ <ImageIcon size={11} />
+ Image
+ </button>
+ <button
+ onClick={() => setMode('video')}
+ className={`px-2 h-[22px] flex items-center gap-1 text-[0.6rem] font-medium transition-colors ${
+ mode === 'video'
+ ? 'bg-gray-200 dark:bg-white/10 text-gray-900 dark:text-white'
+ : 'text-gray-500 hover:text-gray-800 dark:hover:text-gray-200'
+ }`}
+ title="Video mode"
+ >
+ <Film size={11} />
+ Video
+ </button>
+ </div>
+
+ {/* Model picker */}
+ <div className="relative">
+ <button
+ onClick={() => setOpen((v) => !v)}
+ className="flex items-center gap-1 h-[22px] px-2 rounded-md text-[0.65rem] text-gray-700 dark:text-gray-200 bg-gray-100 dark:bg-white/5 hover:bg-gray-200 dark:hover:bg-white/10 transition-colors max-w-[220px]"
+ title={activeModel || `Select ${mode} model`}
+ >
+ <span className="truncate">{activeModel || `No ${mode} model`}</span>
+ <ChevronDown size={10} className={open ? 'rotate-180 transition-transform' : 'transition-transform'} />
+ </button>
+
+ {open && (
+ <div className="absolute top-[26px] right-0 min-w-[240px] max-h-[340px] overflow-y-auto rounded-md border border-gray-200 dark:border-white/10 bg-white dark:bg-[#151515] shadow-lg z-50">
+ {activeList.length === 0 ? (
+ <div className="px-3 py-2 text-[0.65rem] text-gray-500">
+ {comfyRunning ? `No ${mode} models installed yet` : 'Start ComfyUI to load models'}
+ </div>
+ ) : (
+ activeList.map((m) => (
+ <button
+ key={m.name}
+ onClick={() => onPickModel(m.name)}
+ className={`w-full text-left px-3 py-1.5 text-[0.65rem] flex items-center justify-between gap-2 transition-colors ${
+ activeModel === m.name
+ ? 'bg-gray-100 dark:bg-white/10 text-gray-900 dark:text-white'
+ : 'text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/5'
+ }`}
+ >
+ <span className="truncate">{m.name}</span>
+ {activeModel === m.name && <Check size={11} />}
+ </button>
+ ))
+ )}
+ </div>
+ )}
+ </div>
+
+ {/* ComfyUI power toggle (Lichtschalter) — same shape as the chat
+ header's Ollama toggle so the two look identical. */}
+ <button
+ onClick={onToggleComfy}
+ disabled={!!comfyBusy}
+ title={toggleTitle}
+ aria-label={toggleTitle}
+ className={`relative flex items-center h-[18px] w-[34px] rounded-full transition-colors duration-200 ${
+ comfyBusy
+ ? 'bg-amber-500/25 border border-amber-400/40'
+ : comfyRunning
+ ? 'bg-green-500/25 border border-green-400/50'
+ : 'bg-red-500/20 border border-red-400/40 hover:bg-red-500/30'
+ }`}
+ >
+ <span
+ className={`absolute top-[1px] flex items-center justify-center w-[14px] h-[14px] rounded-full shadow-sm transition-all duration-200 ${
+ comfyBusy
+ ? 'left-[9px] bg-amber-400'
+ : comfyRunning
+ ? 'left-[18px] bg-green-400'
+ : 'left-[1px] bg-red-400'
+ }`}
+ >
+ {comfyBusy ? (
+ <Loader2 size={9} className="animate-spin text-gray-900" />
+ ) : (
+ <Power size={9} className="text-gray-900" />
+ )}
+ </span>
+ </button>
+ </div>
+ )
+}
diff --git a/src/lib/__tests__/model-compatibility-planner.test.ts b/src/lib/__tests__/model-compatibility-planner.test.ts
new file mode 100644
index 00000000..7afce187
--- /dev/null
+++ b/src/lib/__tests__/model-compatibility-planner.test.ts
@@ -0,0 +1,106 @@
+/**
+ * isPlainTextPlanner Tests (Bug #80 + Mobile parity)
+ *
+ * Gemma 3/4 with `think: false` drops into plain-text structured planning
+ * ("Plan:", "Constraint Checklist:", "Confidence Score:") instead of
+ * emitting strippable tags. `isPlainTextPlanner` identifies those models
+ * so callers can pass `thinking: undefined` (Ollama default = tagged
+ * thinking) as a bypass.
+ *
+ * The mobile (remote.rs) JS code uses an identical algorithm.
+ *
+ * Run: npx vitest run src/lib/__tests__/model-compatibility-planner.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { isPlainTextPlanner } from '../model-compatibility'
+
+describe('isPlainTextPlanner', () => {
+ describe('positive matches — Gemma 3/4 variants', () => {
+ it('matches gemma3', () => {
+ expect(isPlainTextPlanner('gemma3')).toBe(true)
+ })
+ it('matches gemma3:27b', () => {
+ expect(isPlainTextPlanner('gemma3:27b')).toBe(true)
+ })
+ it('matches gemma3:12b-instruct', () => {
+ expect(isPlainTextPlanner('gemma3:12b-instruct')).toBe(true)
+ })
+ it('matches gemma4', () => {
+ expect(isPlainTextPlanner('gemma4')).toBe(true)
+ })
+ it('matches gemma4:31b', () => {
+ expect(isPlainTextPlanner('gemma4:31b')).toBe(true)
+ })
+ it('matches gemma4-abliterated variants', () => {
+ expect(isPlainTextPlanner('gemma4-abliterated')).toBe(true)
+ expect(isPlainTextPlanner('gemma4-abliterated:8b')).toBe(true)
+ })
+ it('matches gemma4-uncensored variants', () => {
+ expect(isPlainTextPlanner('gemma4-uncensored')).toBe(true)
+ })
+ it('is case-insensitive', () => {
+ expect(isPlainTextPlanner('Gemma4')).toBe(true)
+ expect(isPlainTextPlanner('GEMMA3:27B')).toBe(true)
+ })
+ it('strips single-segment org prefix', () => {
+ // The algorithm strips exactly ONE leading slash-terminated segment
+ // (`org/model` → `model`). Multi-slash HF paths (`hf.co/org/model`)
+ // leave an intermediate "org" in front so they do NOT match — this
+ // is intentional since we control the identifier format at the
+ // provider layer.
+ expect(isPlainTextPlanner('library/gemma4:31b')).toBe(true)
+ expect(isPlainTextPlanner('ollama/gemma3:27b')).toBe(true)
+ })
+ })
+
+ describe('negative matches — other models do NOT trigger bypass', () => {
+ it('gemma2 → false (not affected)', () => {
+ expect(isPlainTextPlanner('gemma2')).toBe(false)
+ expect(isPlainTextPlanner('gemma2:9b')).toBe(false)
+ })
+ it('qwen3 → false (uses <think> tags, stripper works fine)', () => {
+ expect(isPlainTextPlanner('qwen3')).toBe(false)
+ expect(isPlainTextPlanner('qwen3:32b')).toBe(false)
+ })
+ it('deepseek-r1 → false', () => {
+ expect(isPlainTextPlanner('deepseek-r1')).toBe(false)
+ })
+ it('qwq → false', () => {
+ expect(isPlainTextPlanner('qwq')).toBe(false)
+ })
+ it('llama3 → false (no thinking at all)', () => {
+ expect(isPlainTextPlanner('llama3')).toBe(false)
+ })
+ it('hermes3 → false', () => {
+ expect(isPlainTextPlanner('hermes3')).toBe(false)
+ })
+ it('empty / null → false', () => {
+ expect(isPlainTextPlanner(null)).toBe(false)
+ expect(isPlainTextPlanner('')).toBe(false)
+ })
+ })
+
+ describe('edge cases', () => {
+ it('gemma (no version suffix) → false — too ambiguous', () => {
+ expect(isPlainTextPlanner('gemma')).toBe(false)
+ expect(isPlainTextPlanner('gemma:latest')).toBe(false)
+ })
+ it('a substring match inside a different name → false', () => {
+ // e.g. a hypothetical model named "stuff-gemma3-X". Since our logic
+ // strips the org prefix then checks startsWith, this only triggers
+ // if the base name (after / and before :) starts with gemma3/4.
+ expect(isPlainTextPlanner('stuff-gemma3-mix')).toBe(false)
+ })
+ it('gemma3 inside a single-segment org namespace triggers correctly', () => {
+ expect(isPlainTextPlanner('mradermacher/gemma3-27b-it-GGUF')).toBe(true)
+ })
+ it('multi-segment HF path like "hf.co/bart/gemma4-X" → false (by design)', () => {
+ // Known limitation — see the single-segment test above for the
+ // rationale. Documenting so regressions don't accidentally "fix"
+ // this case and shift model-matching semantics.
+ expect(
+ isPlainTextPlanner('hf.co/bartowski/gemma4-27B-it-GGUF:Q4_K_M')
+ ).toBe(false)
+ })
+ })
+})
diff --git a/src/lib/__tests__/thinking-stripper.test.ts b/src/lib/__tests__/thinking-stripper.test.ts
new file mode 100644
index 00000000..91f5e9b4
--- /dev/null
+++ b/src/lib/__tests__/thinking-stripper.test.ts
@@ -0,0 +1,187 @@
+/**
+ * Thinking-Stripper Tests
+ *
+ * Validates the universal stripper that runs during streaming to ensure
+ * raw reasoning markup never reaches the user bubble regardless of what
+ * the model emits. The mobile (remote.rs) JS code mirrors this exact
+ * algorithm — passing these tests means the mobile helper is also correct.
+ *
+ * Covers:
+ * - stripAllThinkingTags (full strip — used when Thinking OFF)
+ * - stripNonCanonicalTags (strip non-<think> only — used inside state-machine)
+ * - finalStripThinkingTags (end-of-stream safety pass)
+ *
+ * Bug history in scope:
+ * - #79b: non-canonical tag stripper (Gemma <|channel|>thought)
+ * - #80: Gemma plain-text planner bypass (separate fix, but related)
+ *
+ * Run: npx vitest run src/lib/__tests__/thinking-stripper.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import {
+ stripAllThinkingTags,
+ stripNonCanonicalTags,
+ finalStripThinkingTags,
+} from '../thinking-stripper'
+
+describe('thinking-stripper', () => {
+ describe('stripAllThinkingTags — full strip', () => {
+ it('empty content passes through', () => {
+ expect(stripAllThinkingTags('')).toBe('')
+ })
+
+ it('content with no thinking tags passes through', () => {
+ expect(stripAllThinkingTags('Hello, here is the answer.')).toBe(
+ 'Hello, here is the answer.'
+ )
+ })
+
+ it('removes a full <thought>…</thought> block', () => {
+ const input = 'Before <thought>internal reasoning</thought> After'
+ expect(stripAllThinkingTags(input)).toBe('Before After')
+ })
+
+ it('removes a full <reasoning>…</reasoning> block', () => {
+ const input = '<reasoning>step 1\nstep 2</reasoning>Answer!'
+ expect(stripAllThinkingTags(input)).toBe('Answer!')
+ })
+
+ it('removes <reflect>…</reflect>', () => {
+ expect(stripAllThinkingTags('x<reflect>hmm</reflect>y')).toBe('xy')
+ })
+
+ it('removes <deepthink>…</deepthink>', () => {
+ expect(stripAllThinkingTags('x<deepthink>deep</deepthink>y')).toBe('xy')
+ })
+
+ it('removes multiple blocks in one buffer', () => {
+ const input = '<thought>a</thought>mid<reasoning>b</reasoning>end'
+ expect(stripAllThinkingTags(input)).toBe('midend')
+ })
+
+ it('removes Gemma <|channel|>thought … </channel|> block', () => {
+ // Real closing form the stripper supports: `</channel>` with optional
+ // trailing pipe (BLOCK_PATTERN: `<\/\|?channel\|?>`).
+ const input =
+ 'prefix <|channel|>thought\nPlan step\n</channel|> answer'
+ const out = stripAllThinkingTags(input)
+ expect(out).not.toContain('<|channel|>')
+ expect(out).not.toContain('</channel|>')
+ expect(out).toContain('prefix')
+ expect(out).toContain('answer')
+ })
+
+ it('also handles </channel> (no trailing pipe)', () => {
+ const input = 'x <|channel|>thought\nplan\n</channel> y'
+ const out = stripAllThinkingTags(input)
+ expect(out).not.toContain('<|channel|>')
+ expect(out).not.toContain('</channel>')
+ })
+
+ it('removes orphan opening channel tag (no close yet in stream)', () => {
+ // Mid-stream the close hasn't arrived; the opener must still be
+ // stripped so the UI never shows the "thought" marker.
+ const input = 'Before <|channel|>thought more text'
+ const out = stripAllThinkingTags(input)
+ expect(out).not.toContain('<|channel|>')
+ expect(out).not.toContain('thought')
+ expect(out).toContain('Before')
+ })
+
+ it('is case-insensitive on tag name', () => {
+ const input = '<THOUGHT>x</THOUGHT>answer'
+ expect(stripAllThinkingTags(input)).toBe('answer')
+ })
+
+ it('handles multi-line tag content', () => {
+ const input = '<thought>\nline 1\nline 2\nline 3\n</thought>\nDone.'
+ expect(stripAllThinkingTags(input)).toBe('\nDone.')
+ })
+ })
+
+ describe('stripNonCanonicalTags — leaves <think> alone', () => {
+ it('preserves canonical <think>…</think> block', () => {
+ // This one is handled by the char-state-machine; the stripper must
+ // NOT remove it or the machine will never see the open marker.
+ const input = '<think>pondering</think>Answer'
+ expect(stripNonCanonicalTags(input)).toBe(input)
+ })
+
+ it('still removes <thought>…</thought>', () => {
+ expect(stripNonCanonicalTags('<thought>x</thought>y')).toBe('y')
+ })
+
+ it('removes Gemma channel tags but preserves <think>', () => {
+ const input = '<think>a</think> <|channel|>thought extra'
+ const out = stripNonCanonicalTags(input)
+ expect(out).toContain('<think>a</think>')
+ expect(out).not.toContain('<|channel|>')
+ })
+ })
+
+ describe('finalStripThinkingTags — end-of-stream safety', () => {
+ it('removes everything including canonical <think> by default', () => {
+ const input = '<think>x</think><thought>y</thought>answer'
+ expect(finalStripThinkingTags(input)).toBe('answer')
+ })
+
+ it('keeps canonical <think> when keepCanonicalThink=true', () => {
+ const input = '<think>x</think><thought>y</thought>answer'
+ const out = finalStripThinkingTags(input, true)
+ expect(out).toContain('<think>x</think>')
+ expect(out).not.toContain('<thought>')
+ expect(out).toContain('answer')
+ })
+
+ it('removes orphan </think> closer', () => {
+ expect(finalStripThinkingTags('middle</think>tail')).toBe('middletail')
+ })
+
+ it('removes orphan <think> opener', () => {
+ expect(finalStripThinkingTags('head<think>tail')).toBe('headtail')
+ })
+
+ it('trims the final result', () => {
+ expect(finalStripThinkingTags(' answer ')).toBe('answer')
+ expect(finalStripThinkingTags('<thought>a</thought>\n answer \n')).toBe(
+ 'answer'
+ )
+ })
+
+ it('pure-answer content passes through (trimmed)', () => {
+ expect(finalStripThinkingTags('Hello world')).toBe('Hello world')
+ })
+ })
+
+ describe('edge cases / regression guards', () => {
+ it('does not eat content that merely contains the word "thought"', () => {
+ // False-positive guard: we match <thought> as a TAG, not the word.
+ const input = 'I thought about it.'
+ expect(stripAllThinkingTags(input)).toBe('I thought about it.')
+ })
+
+ it('handles nested markup gracefully (simple non-greedy match)', () => {
+ // A <thought> inside HTML content shouldn't over-match across a later
+ // unrelated </thought>. The non-greedy regex limits the span to the
+ // next close tag.
+ const input =
+ '<thought>a</thought>between<thought>b</thought>after'
+ expect(stripAllThinkingTags(input)).toBe('betweenafter')
+ })
+
+ it('stripping is idempotent (applying twice yields same result)', () => {
+ const input = '<thought>a</thought>clean<reasoning>b</reasoning>'
+ const once = stripAllThinkingTags(input)
+ const twice = stripAllThinkingTags(once)
+ expect(twice).toBe(once)
+ })
+
+ it('typical Gemma 4 streaming snapshot (mid-generation)', () => {
+ const streamSnap =
+ 'Sure! <|channel|>thought\nLet me plan:\n1. parse input\n2.'
+ const out = stripAllThinkingTags(streamSnap)
+ expect(out).not.toContain('channel')
+ expect(out).toContain('Sure!')
+ })
+ })
+})