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.

fix(v2.5.2): ComfyUI UTF-8 stdout, robust ChatGPT import, proxy-independent inline image

purple82cac3d7e55a
diff --git a/docs/index.html b/docs/index.html
index 8216c03c..b30571c9 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -33,7 +33,7 @@
<link rel="icon" href="https://locallyuncensored.com/favicon.png">
<link rel="apple-touch-icon" href="https://locallyuncensored.com/favicon.png">
<script type="application/ld+json">
-{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Locally Uncensored","alternateName":["LU","Locally Uncensored Desktop App"],"applicationCategory":"DeveloperApplication","applicationSubCategory":"Artificial Intelligence","operatingSystem":"Windows 10, Windows 11, Linux","description":"Open-source desktop app for running AI locally. Chat with 20+ providers, generate images and video via ComfyUI, and code with a built-in AI agent — all on your own hardware. Auto-detects 12 local backends. No cloud, no telemetry.","url":"https://locallyuncensored.com/","downloadUrl":"https://github.com/PurpleDoubleD/locally-uncensored/releases/latest","softwareVersion":"2.5.1","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","availability":"https://schema.org/InStock"},"featureList":["Plug & Play Setup with 12 Local Backend Auto-Detection (Ollama, LM Studio, vLLM, KoboldCpp, Jan, llama.cpp, LocalAI, GPT4All, TabbyAPI, Aphrodite, SGLang, TGI)","20+ Provider Presets (local + cloud)","Qwen 3.6 Day-0 Support (35B MoE, Vision, Agentic Coding, 256K context)","GPT-OSS Compatible (120B, 20B via Ollama)","GLM-4.7 Flash Integration","DeepSeek R1 and DeepSeek V3 Support","Llama 4 and Llama 3.3 Ready","Gemma 4 E4B and 27B (Native Vision)","Mistral Small 3 and Phi 4 Support","Qwen 3 Coder and Qwen 2.5 Coder","Abliterated Model Variants","Codex Coding Agent with Live Streaming and Apply-Patch","Claude Code CLI Integration","Agent Mode with 14 Tools, Parallel Execution, MCP, Sub-Agent Delegation","Remote Access from Phone via LAN or Cloudflare Tunnel (6-digit Passcode, QR Setup)","Mobile Web App (Chat, Codex, Tools, Plugins)","Image Generation via ComfyUI (FLUX 2 Klein, FLUX.1, Juggernaut XL, Z-Image Turbo, ERNIE-Image, SDXL, SD 3.5)","Video Generation (Wan 2.1, Wan 2.2, HunyuanVideo 1.5, LTX 2.3, FramePack F1, AnimateDiff, CogVideoX)","Image-to-Image with Denoise Control","Image-to-Video (FramePack F1, CogVideoX, SVD)","Granular Permission System (7 Tool Categories)","File Upload with Vision Support","Thinking Mode with Universal Tag Stripping","A/B Model Compare","Local Benchmark","Memory System and Document RAG","Voice (STT / TTS)","Auto-Update over Signed NSIS Channel","75+ One-Click Model Downloads","Hardware-Aware Model Recommendations","100% Offline and Private (No Telemetry)","AGPL-3.0 Open Source"],"screenshot":"https://raw.githubusercontent.com/PurpleDoubleD/locally-uncensored/master/docs/social-preview.png","softwareRequirements":"Any OpenAI-compatible local backend (Ollama, LM Studio, vLLM, KoboldCpp, etc.) or cloud API key","memoryRequirements":"8 GB RAM minimum; 8-16 GB VRAM for image/video generation","storageRequirements":"6 GB for default model"}
+{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Locally Uncensored","alternateName":["LU","Locally Uncensored Desktop App"],"applicationCategory":"DeveloperApplication","applicationSubCategory":"Artificial Intelligence","operatingSystem":"Windows 10, Windows 11, Linux","description":"Open-source desktop app for running AI locally. Chat with 20+ providers, generate images and video via ComfyUI, and code with a built-in AI agent — all on your own hardware. Auto-detects 12 local backends. No cloud, no telemetry.","url":"https://locallyuncensored.com/","downloadUrl":"https://github.com/PurpleDoubleD/locally-uncensored/releases/latest","softwareVersion":"2.5.2","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","availability":"https://schema.org/InStock"},"featureList":["Plug & Play Setup with 12 Local Backend Auto-Detection (Ollama, LM Studio, vLLM, KoboldCpp, Jan, llama.cpp, LocalAI, GPT4All, TabbyAPI, Aphrodite, SGLang, TGI)","20+ Provider Presets (local + cloud)","Qwen 3.6 Day-0 Support (35B MoE, Vision, Agentic Coding, 256K context)","GPT-OSS Compatible (120B, 20B via Ollama)","GLM-4.7 Flash Integration","DeepSeek R1 and DeepSeek V3 Support","Llama 4 and Llama 3.3 Ready","Gemma 4 E4B and 27B (Native Vision)","Mistral Small 3 and Phi 4 Support","Qwen 3 Coder and Qwen 2.5 Coder","Abliterated Model Variants","Codex Coding Agent with Live Streaming and Apply-Patch","Claude Code CLI Integration","Agent Mode with 14 Tools, Parallel Execution, MCP, Sub-Agent Delegation","Remote Access from Phone via LAN or Cloudflare Tunnel (6-digit Passcode, QR Setup)","Mobile Web App (Chat, Codex, Tools, Plugins)","Image Generation via ComfyUI (FLUX 2 Klein, FLUX.1, Juggernaut XL, Z-Image Turbo, ERNIE-Image, SDXL, SD 3.5)","Video Generation (Wan 2.1, Wan 2.2, HunyuanVideo 1.5, LTX 2.3, FramePack F1, AnimateDiff, CogVideoX)","Image-to-Image with Denoise Control","Image-to-Video (FramePack F1, CogVideoX, SVD)","Granular Permission System (7 Tool Categories)","File Upload with Vision Support","Thinking Mode with Universal Tag Stripping","A/B Model Compare","Local Benchmark","Memory System and Document RAG","Voice (STT / TTS)","Auto-Update over Signed NSIS Channel","75+ One-Click Model Downloads","Hardware-Aware Model Recommendations","100% Offline and Private (No Telemetry)","AGPL-3.0 Open Source"],"screenshot":"https://raw.githubusercontent.com/PurpleDoubleD/locally-uncensored/master/docs/social-preview.png","softwareRequirements":"Any OpenAI-compatible local backend (Ollama, LM Studio, vLLM, KoboldCpp, etc.) or cloud API key","memoryRequirements":"8 GB RAM minimum; 8-16 GB VRAM for image/video generation","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","logo":"https://locallyuncensored.com/logos/LU-monogram-bw-transparent.png","sameAs":["https://github.com/PurpleDoubleD","https://github.com/PurpleDoubleD/locally-uncensored","https://reddit.com/user/GroundbreakingMall54","https://locallyuncensored.com"]}
@@ -827,7 +827,7 @@ footer a:hover{color:var(--fg)}
<!-- Top meta strip -->
<div class="mast-strip">
- <span class="numero">v 2.5.1</span>
+ <span class="numero">v 2.5.2</span>
<span class="sep">·</span>
<span>AGPL-3.0</span>
<span class="sep">·</span>
@@ -868,10 +868,10 @@ footer a:hover{color:var(--fg)}
<div class="container">
<div class="dl-card">
<div class="dl-info">
- <h3>Locally Uncensored <em>&mdash; 2.5.1</em></h3>
+ <h3>Locally Uncensored <em>&mdash; 2.5.2</em></h3>
<p>WINDOWS &middot; ~7 MB installer &middot; AGPL-3.0</p>
</div>
- <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.5.1/Locally.Uncensored_2.5.1_x64-setup.exe" download>
+ <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.5.2/Locally.Uncensored_2.5.2_x64-setup.exe" download>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
Download .exe
</a>
@@ -1169,10 +1169,10 @@ footer a:hover{color:var(--fg)}
<div class="narrow">
<div class="dl-card">
<div class="dl-info">
- <h3>Locally Uncensored <em>&mdash; 2.5.1</em></h3>
+ <h3>Locally Uncensored <em>&mdash; 2.5.2</em></h3>
<p>WINDOWS &middot; ~7 MB installer &middot; AGPL-3.0</p>
</div>
- <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.5.1/Locally.Uncensored_2.5.1_x64-setup.exe" download>
+ <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.5.2/Locally.Uncensored_2.5.2_x64-setup.exe" download>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
Download .exe
</a>
diff --git a/package.json b/package.json
index 16916e1d..17746a42 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "locally-uncensored",
- "version": "2.5.1",
+ "version": "2.5.2",
"private": false,
"description": "Generate anything — text, images, video. Locally. Uncensored.",
"license": "AGPL-3.0",
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index eb134561..13fa171f 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2514,7 +2514,7 @@ dependencies = [
[[package]]
name = "locally-uncensored"
-version = "2.5.1"
+version = "2.5.2"
dependencies = [
"axum",
"base64 0.22.1",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index f5576d49..dda833b5 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "locally-uncensored"
-version = "2.5.1"
+version = "2.5.2"
description = "Private, local AI chat & image/video generation"
authors = ["purpledoubled"]
edition = "2021"
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index e6bee13d..31795b53 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -799,6 +799,17 @@ pub fn start_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, St
.current_dir(&comfy_path)
.env("TQDM_DISABLE", "1")
.env("PYTHONUNBUFFERED", "1")
+ // Windows fix (plum133, Discord 2026-06-07): ComfyUI / its nodes print
+ // Unicode progress glyphs (e.g. '▍' U+258D) to stdout. On a non-UTF-8
+ // Windows console codepage (cp1252) Python's *piped* stdout defaults to
+ // the locale codec and raises UnicodeEncodeError ("'charmap' codec
+ // can't encode character '▍' …"), which propagates out of the
+ // KSampler progress callback and aborts generation ("Generation
+ // failed: … (KSampler)"). Force UTF-8 I/O so any Unicode output is
+ // encodable on every locale — also keeps the Rust-side line reader's
+ // UTF-8 assumption valid.
+ .env("PYTHONIOENCODING", "utf-8")
+ .env("PYTHONUTF8", "1")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
@@ -1319,6 +1330,11 @@ pub fn auto_start_comfyui(state: &AppState) {
.current_dir(&path)
.env("TQDM_DISABLE", "1")
.env("PYTHONUNBUFFERED", "1")
+ // Windows UTF-8 fix — see start_comfyui (plum133 2026-06-07):
+ // prevents the cp1252 'charmap' UnicodeEncodeError crash when
+ // ComfyUI prints Unicode progress glyphs to the piped stdout.
+ .env("PYTHONIOENCODING", "utf-8")
+ .env("PYTHONUTF8", "1")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 8081a2e4..01b468b3 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
"productName": "Locally Uncensored",
- "version": "2.5.1",
+ "version": "2.5.2",
"identifier": "com.purpledoubled.locally-uncensored",
"build": {
"beforeBuildCommand": "npm run build",
diff --git a/src/components/chat/ToolCallBlock.tsx b/src/components/chat/ToolCallBlock.tsx
index b8e29f2f..04e83fc6 100644
--- a/src/components/chat/ToolCallBlock.tsx
+++ b/src/components/chat/ToolCallBlock.tsx
@@ -2,7 +2,7 @@ import { useState } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { Search, Globe, FileText, FileEdit, Terminal, Image, Film, Loader2, Check, X, Clock, AlertCircle, FolderOpen, Cpu, Monitor, GitBranch, Database } from 'lucide-react'
import type { AgentToolCall } from '../../types/agent-mode'
-import { getComfyHost } from '../../api/backend'
+import { getComfyHost, getComfyPort } from '../../api/backend'
// F1 (konata3602 commitment 2026-05-23) + render fix (konata3602 bug 2026-06-07)
// — when image_generate / video_generate / screenshot produce a ComfyUI output,
@@ -98,6 +98,24 @@ export function ToolCallBlock({ toolCall, onApprove, onReject }: Props) {
// without the user having to expand the block — konata's "and no image".
const previewUrl = comfyViewUrlFromResult(toolCall.result)
+ // Proxy-independent loading (konata 2026-06-08). In browser/dev the tool
+ // result carries the RELATIVE `/comfyui/view?…` Vite-proxy path, which loads
+ // fine under `npm run dev` (verified E2E). But a built frontend served
+ // WITHOUT that dev proxy (e.g. `vite preview` or a static host) would 404 the
+ // relative path → no image. If the primary src errors, retry with an ABSOLUTE
+ // URL straight to the ComfyUI host: <img>/<video> display is not CORS-gated,
+ // so it loads with no server-side proxy. Tauri results are already absolute
+ // (they never start with '/') and are unaffected.
+ const [imgFailed, setImgFailed] = useState(false)
+ const effectivePreviewUrl = (() => {
+ if (!previewUrl) return null
+ if (imgFailed && previewUrl.startsWith('/')) {
+ const path = previewUrl.startsWith('/comfyui/') ? previewUrl.slice('/comfyui'.length) : previewUrl
+ return `http://${getComfyHost()}:${getComfyPort()}${path}`
+ }
+ return previewUrl
+ })()
+
return (
<div className="mb-0.5">
{/* Header line — monochrome, only status icon has subtle color */}
@@ -127,20 +145,22 @@ export function ToolCallBlock({ toolCall, onApprove, onReject }: Props) {
and no picture. A .mp4/.webm output renders in a <video>; everything
else — including animated .webp — in an <img>. URL is bounded to OUR
ComfyUI by comfyViewUrlFromResult (never auto-loads arbitrary URLs). */}
- {previewUrl && (
+ {previewUrl && effectivePreviewUrl && (
<div className="pl-5 pt-0.5">
- {isInlineVideoUrl(previewUrl) ? (
+ {isInlineVideoUrl(effectivePreviewUrl) ? (
<video
- src={previewUrl}
+ src={effectivePreviewUrl}
controls
loop
+ onError={() => { if (!imgFailed) setImgFailed(true) }}
className="block max-w-full max-h-[320px] rounded border border-gray-200 dark:border-white/[0.06]"
/>
) : (
- <a href={previewUrl} target="_blank" rel="noopener noreferrer" className="block">
+ <a href={effectivePreviewUrl} target="_blank" rel="noopener noreferrer" className="block">
<img
- src={previewUrl}
+ src={effectivePreviewUrl}
alt="Generated image"
+ onError={() => { if (!imgFailed) setImgFailed(true) }}
className="max-w-full max-h-[320px] rounded border border-gray-200 dark:border-white/[0.06]"
loading="lazy"
/>
diff --git a/src/lib/__tests__/chatbot-export.test.ts b/src/lib/__tests__/chatbot-export.test.ts
index a815739d..70363cd8 100644
--- a/src/lib/__tests__/chatbot-export.test.ts
+++ b/src/lib/__tests__/chatbot-export.test.ts
@@ -3,7 +3,8 @@
// session) trimmed to one or two messages so the tests stay readable.
import { describe, it, expect } from 'vitest'
-import { parseJsonText, detectPlatform } from '../parsers/chatbot-export'
+import JSZip from 'jszip'
+import { parseJsonText, parseExportFile, detectPlatform } from '../parsers/chatbot-export'
const chatgptFixture = JSON.stringify([
{
@@ -144,3 +145,123 @@ describe('parseJsonText — robustness', () => {
expect(r.conversations).toHaveLength(0)
})
})
+
+// ── Regression: real-world ChatGPT export shapes (mikes_pp, Discord 2026-06-07)
+// The old parser used "first parent==null node, then children[0] forever",
+// which lands on the abandoned branch after a regenerate/edit and frequently
+// produced 0 messages → the whole import failed with "no conversation file
+// found". These fixtures exercise the visible-thread selection + content
+// shapes that broke it.
+
+// A regenerated answer: the user SAW a2 (current_node), a1 is the abandoned
+// original. The walk must follow current_node, not children[0].
+const chatgptBranchedFixture = JSON.stringify([
+ {
+ title: 'Branched chat',
+ create_time: 1700000000.0,
+ update_time: 1700000100.0,
+ current_node: 'a2',
+ mapping: {
+ root: { id: 'root', message: null, parent: null, children: ['u1'] },
+ u1: { id: 'u1', message: { id: 'u1', author: { role: 'user' }, content: { content_type: 'text', parts: ['What is 2+2?'] } }, parent: 'root', children: ['a1', 'a2'] },
+ a1: { id: 'a1', message: { id: 'a1', author: { role: 'assistant' }, content: { content_type: 'text', parts: ['OLD abandoned answer'] } }, parent: 'u1', children: [] },
+ a2: { id: 'a2', message: { id: 'a2', author: { role: 'assistant' }, content: { content_type: 'text', parts: ['NEW visible answer: four'] } }, parent: 'u1', children: [] },
+ },
+ },
+])
+
+// Multimodal user turn: parts = [image_asset_pointer object, text string].
+// The image pointer carries no readable text and must be skipped, not crash.
+const chatgptMultimodalFixture = JSON.stringify([
+ {
+ title: 'Image chat',
+ create_time: 1700000000.0,
+ current_node: 'a1',
+ mapping: {
+ root: { id: 'root', message: null, parent: null, children: ['u1'] },
+ u1: { id: 'u1', message: { id: 'u1', author: { role: 'user' }, content: { content_type: 'multimodal_text', parts: [{ content_type: 'image_asset_pointer', asset_pointer: 'file-service://abc' }, 'Describe this image'] } }, parent: 'root', children: ['a1'] },
+ a1: { id: 'a1', message: { id: 'a1', author: { role: 'assistant' }, content: { content_type: 'code', text: 'It is a sunset over the sea.' } }, parent: 'u1', children: [] },
+ },
+ },
+])
+
+// No current_node + a regenerate: the newest (last) child is the visible one.
+const chatgptNoCurrentNodeFixture = JSON.stringify([
+ {
+ title: 'Regenerated no current_node',
+ create_time: 1700000000.0,
+ mapping: {
+ root: { id: 'root', message: null, parent: null, children: ['u1'] },
+ u1: { id: 'u1', message: { id: 'u1', author: { role: 'user' }, content: { content_type: 'text', parts: ['Hi'] } }, parent: 'root', children: ['a1', 'a2'] },
+ a1: { id: 'a1', message: { id: 'a1', author: { role: 'assistant' }, content: { content_type: 'text', parts: ['first older'] } }, parent: 'u1', children: [] },
+ a2: { id: 'a2', message: { id: 'a2', author: { role: 'assistant' }, content: { content_type: 'text', parts: ['second newest'] } }, parent: 'u1', children: [] },
+ },
+ },
+])
+
+describe('parseJsonText — ChatGPT real-world mapping', () => {
+ it('follows current_node to the regenerated (visible) branch, not children[0]', () => {
+ const r = parseJsonText(chatgptBranchedFixture)
+ expect(r.conversations).toHaveLength(1)
+ const c = r.conversations[0]
+ expect(c.messageCount).toBe(2)
+ expect(c.markdown).toContain('What is 2+2?')
+ expect(c.markdown).toContain('NEW visible answer: four')
+ expect(c.markdown).not.toContain('OLD abandoned answer')
+ })
+ it('extracts text from multimodal parts (skips image pointers) and code content', () => {
+ const r = parseJsonText(chatgptMultimodalFixture)
+ expect(r.conversations).toHaveLength(1)
+ const c = r.conversations[0]
+ expect(c.messageCount).toBe(2)
+ expect(c.markdown).toContain('Describe this image')
+ expect(c.markdown).toContain('It is a sunset over the sea.')
+ expect(c.markdown).not.toContain('asset_pointer')
+ })
+ it('falls back to the newest (last) child when current_node is absent', () => {
+ const r = parseJsonText(chatgptNoCurrentNodeFixture)
+ expect(r.conversations).toHaveLength(1)
+ const c = r.conversations[0]
+ expect(c.messageCount).toBe(2)
+ expect(c.markdown).toContain('second newest')
+ expect(c.markdown).not.toContain('first older')
+ })
+})
+
+describe('parseExportFile — ChatGPT .zip with dated top-level folder', () => {
+ // Build a zip shaped like a current OpenAI export: everything nested under a
+ // dated folder, with sibling metadata files the old "largest .json" / exact
+ // path lookup would trip on. Use a uint8array payload tagged with .name so
+ // the test needs neither File/Blob nor FileReader (vitest env: node).
+ async function makeZipFile(files: Record<string, string>, name: string): Promise<File> {
+ const zip = new JSZip()
+ for (const [path, content] of Object.entries(files)) zip.file(path, content)
+ const buf = await zip.generateAsync({ type: 'uint8array' })
+ return Object.assign(buf, { name }) as unknown as File
+ }
+
+ it('finds conversations.json nested under a dated folder, ignoring sibling json', async () => {
+ const folder = '1716800000-ab12cd34ef56'
+ const file = await makeZipFile({
+ [`${folder}/conversations.json`]: chatgptFixture,
+ [`${folder}/message_feedback.json`]: JSON.stringify([{ id: 'fb1', rating: 'thumbsUp' }]),
+ [`${folder}/user.json`]: JSON.stringify({ id: 'user-1', email: '[email protected]' }),
+ [`${folder}/chat.html`]: '<html><body>export</body></html>',
+ }, 'chatgpt-export.zip')
+ const res = await parseExportFile(file)
+ expect(res.detectedPlatform).toBe('chatgpt')
+ expect(res.conversations).toHaveLength(1)
+ expect(res.conversations[0].title).toBe('Recipes for pasta')
+ expect(res.conversations[0].messageCount).toBe(2)
+ })
+
+ it('still finds a root-level conversations.json (older export layout)', async () => {
+ const file = await makeZipFile({
+ 'conversations.json': chatgptFixture,
+ 'user.json': JSON.stringify({ id: 'user-1' }),
+ }, 'old-export.zip')
+ const res = await parseExportFile(file)
+ expect(res.conversations).toHaveLength(1)
+ expect(res.conversations[0].platform).toBe('chatgpt')
+ })
+})
diff --git a/src/lib/parsers/chatbot-export.ts b/src/lib/parsers/chatbot-export.ts
index 75d64ed2..4379f264 100644
--- a/src/lib/parsers/chatbot-export.ts
+++ b/src/lib/parsers/chatbot-export.ts
@@ -92,6 +92,48 @@ function slugify(s: string, fallback: string): string {
// }
// }
// ]
+// Pull readable text out of a ChatGPT message `content` object. Real exports
+// use several content_type shapes:
+// { content_type: 'text', parts: ['...'] }
+// { content_type: 'multimodal_text', parts: ['...', { content_type:'image_asset_pointer', ... }] }
+// { content_type: 'code' | 'execution_output', text: '...' }
+// { content_type: 'tether_*' , result: '...' }
+// Strings in `parts` are kept; non-text parts (image/audio pointers) are
+// skipped gracefully; falls back to `content.text` / `content.result`.
+function extractChatGptText(content: any): string {
+ if (!content || typeof content !== 'object') return ''
+ const chunks: string[] = []
+ if (Array.isArray(content.parts)) {
+ for (const p of content.parts) {
+ if (typeof p === 'string') { if (p.trim()) chunks.push(p) }
+ else if (p && typeof p === 'object' && typeof p.text === 'string') { if (p.text.trim()) chunks.push(p.text) }
+ // image_asset_pointer / audio_asset_pointer / etc. carry no readable text → skip
+ }
+ }
+ if (chunks.length === 0 && typeof content.text === 'string' && content.text.trim()) chunks.push(content.text)
+ if (chunks.length === 0 && typeof content.result === 'string' && content.result.trim()) chunks.push(content.result)
+ return chunks.join('\n').trim()
+}
+
+// Turn an ordered list of mapping nodes (root → leaf) into markdown lines.
+function linearizeChatGptNodes(nodes: any[]): { lines: string[]; count: number } {
+ const lines: string[] = []
+ let count = 0
+ for (const node of nodes) {
+ const msg = node?.message
+ if (msg && msg.author && msg.content) {
+ const role = String(msg.author.role || 'unknown')
+ const text = extractChatGptText(msg.content)
+ if (text && role !== 'tool' && role !== 'system') {
+ const heading = role === 'user' ? '**You**' : (role === 'assistant' ? '**Assistant**' : `**${role}**`)
+ lines.push(heading, '', text, '')
+ count++
+ }
+ }
+ }
+ return { lines, count }
+}
+
function parseChatGpt(raw: unknown): NormalisedConversation[] {
if (!Array.isArray(raw)) return []
const out: NormalisedConversation[] = []
@@ -105,41 +147,72 @@ function parseChatGpt(raw: unknown): NormalisedConversation[] {
const isoTimestamp = timestamp ? new Date(timestamp * 1000).toISOString() : null
const mapping = c.mapping as Record<string, any> | undefined
- if (!mapping) continue
+ if (!mapping || typeof mapping !== 'object') continue
- // Linearise the message tree by walking from root following the first
- // child each time. That matches what the user actually saw in the UI
- // (alternative branches were never visible in the rendered conversation).
- const root = Object.values(mapping).find(n => n && n.parent == null) as any
- if (!root) continue
- const lines: string[] = [`# ${title}`, '']
- if (isoTimestamp) lines.push(`_Created: ${isoTimestamp}_`, '')
- let node = root
- let messageCount = 0
- while (node) {
- const msg = node.message
- if (msg && msg.author && msg.content) {
- const role = String(msg.author.role || 'unknown')
- const parts = Array.isArray(msg.content.parts) ? msg.content.parts : []
- const text = parts.map((p: any) => typeof p === 'string' ? p : (p?.text || '')).join('\n').trim()
- if (text && role !== 'tool' && role !== 'system') {
- const heading = role === 'user' ? '**You**' : (role === 'assistant' ? '**Assistant**' : `**${role}**`)
- lines.push(heading, '', text, '')
- messageCount++
- }
+ // Linearise the message tree into the single thread the user actually saw.
+ // Real exports have a synthetic root (message == null) and, after edits or
+ // regenerations, multiple sibling branches — the old "first node with
+ // parent==null, then children[0] forever" walk lands on the ORIGINAL
+ // (often abandoned) branch and frequently dead-ends at 0 messages, which
+ // is why mikes_pp's import produced "no conversations". Two strategies,
+ // best first:
+ // 1. `current_node` is the leaf of the visible thread — walk PARENT
+ // links up to the root and reverse. Exactly what the user saw.
+ // 2. Fallback: from each parent-less node walk forward following the
+ // LAST (newest) child; keep whichever walk yields the most messages.
+ const collectUp = (leafId: string): any[] => {
+ const chain: any[] = []
+ const seen = new Set<string>()
+ let node: any = mapping[leafId]
+ while (node && node.id && !seen.has(node.id)) {
+ seen.add(node.id)
+ chain.push(node)
+ node = (node.parent != null) ? mapping[node.parent] : null
}
- const children = Array.isArray(node.children) ? node.children : []
- const next = children[0]
- node = next ? mapping[next] : null
+ chain.reverse()
+ return chain
}
- if (messageCount === 0) continue
+ const collectDown = (rootId: string): any[] => {
+ const chain: any[] = []
+ const seen = new Set<string>()
+ let node: any = mapping[rootId]
+ while (node && node.id && !seen.has(node.id)) {
+ seen.add(node.id)
+ chain.push(node)
+ const children = Array.isArray(node.children) ? node.children : []
+ const nextId = children.length > 0 ? children[children.length - 1] : null
+ node = nextId ? mapping[nextId] : null
+ }
+ return chain
+ }
+
+ let best: { lines: string[]; count: number } | null = null
+ const currentNodeId = typeof c.current_node === 'string' ? c.current_node : null
+ if (currentNodeId && mapping[currentNodeId]) {
+ best = linearizeChatGptNodes(collectUp(currentNodeId))
+ }
+ if (!best || best.count === 0) {
+ const rootIds = Object.values(mapping)
+ .filter((n: any) => n && n.parent == null && n.id)
+ .map((n: any) => n.id as string)
+ const candidates = rootIds.length > 0 ? rootIds : Object.keys(mapping)
+ for (const rid of candidates) {
+ const r = linearizeChatGptNodes(collectDown(rid))
+ if (!best || r.count > best.count) best = r
+ }
+ }
+ if (!best || best.count === 0) continue
+
+ const lines: string[] = [`# ${title}`, '']
+ if (isoTimestamp) lines.push(`_Created: ${isoTimestamp}_`, '')
+ lines.push(...best.lines)
out.push({
id: slugify(title, `chatgpt_${createTime || out.length}`),
title,
markdown: lines.join('\n').trim(),
platform: 'chatgpt',
timestamp: isoTimestamp,
- messageCount,
+ messageCount: best.count,
})
}
return out
@@ -283,30 +356,38 @@ export async function parseExportFile(file: File): Promise<ParseResult> {
const name = file.name.toLowerCase()
if (name.endsWith('.zip')) {
const zip = await JSZip.loadAsync(file)
- // Try common filenames in priority order.
- const candidates = ['conversations.json', 'data/conversations.json']
- for (const path of candidates) {
- const entry = zip.file(path)
- if (entry) {
- const text = await entry.async('string')
- return parseJsonText(text)
- }
+ // Collect every file entry. Depth-independent on purpose: current ChatGPT
+ // exports nest everything under a dated top-level folder, e.g.
+ // "1716800000-ab12cd…/conversations.json", so the old exact-path lookup of
+ // "conversations.json" / "data/conversations.json" missed entirely and the
+ // user saw "no conversation file found" (mikes_pp, Discord 2026-06-07).
+ const entries: Array<{ path: string; entry: JSZip.JSZipObject }> = []
+ zip.forEach((path, entry) => { if (!entry.dir) entries.push({ path, entry }) })
+ const basename = (p: string) => (p.split('/').pop() || '').toLowerCase()
+ const isJson = (p: string) => p.toLowerCase().endsWith('.json')
+
+ // 1) Prefer any file whose basename is exactly conversations.json, wherever
+ // it sits in the tree (handles the dated-folder nesting). Return the
+ // first that yields at least one conversation.
+ for (const e of entries.filter(e => basename(e.path) === 'conversations.json')) {
+ const text = await e.entry.async('string')
+ const res = parseJsonText(text)
+ if (res.conversations.length > 0) return res
}
- // Fallback: pick the largest .json file inside the zip.
- let best: { path: string; size: number } | null = null
- zip.forEach((path, entry) => {
- if (!entry.dir && path.toLowerCase().endsWith('.json')) {
- const size = (entry as any)._data?.uncompressedSize || 0
- if (!best || size > best.size) best = { path, size }
- }
- })
- if (best) {
- const e = zip.file((best as { path: string; size: number }).path)
- if (e) {
- const text = await e.async('string')
- return parseJsonText(text)
+ // 2) Parse-and-pick: try every JSON file and keep whichever produces the
+ // most conversations. We deliberately do NOT rank by file size via
+ // JSZip's private `_data.uncompressedSize` — it is 0/undefined for many
+ // entries, which previously made the fallback grab user.json /
+ // message_feedback.json (→ 0 conversations) instead of the real export.
+ let best: ParseResult | null = null
+ for (const e of entries.filter(e => isJson(e.path))) {
+ const text = await e.entry.async('string')
+ const res = parseJsonText(text)
+ if (res.conversations.length > 0 && (!best || res.conversations.length > best.conversations.length)) {
+ best = res
}
}
+ if (best) return best
return { conversations: [], skipped: 0, detectedPlatform: 'unknown' }
}
// JSON path
diff --git a/vite.config.ts b/vite.config.ts
index 36447395..95345f22 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -248,6 +248,10 @@ function comfyLauncher(): Plugin {
stdio: ['ignore', 'pipe', 'pipe'],
shell: false,
windowsHide: true,
+ // Mirror the Rust launcher (process.rs): force UTF-8 I/O so ComfyUI's
+ // Unicode progress glyphs don't crash on a non-UTF-8 Windows codepage
+ // (plum133 'charmap' codec UnicodeEncodeError, Discord 2026-06-07).
+ env: { ...process.env, PYTHONIOENCODING: 'utf-8', PYTHONUTF8: '1' },
})
comfyProcess.stdout?.on('data', (d) => {