The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(remote): clear dev-mode message instead of HTTP 404 + JSON.parse
PurpleDoubleD0b03796dced6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 06a31bea..5fa05b6e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,14 @@All notable changes to Locally Uncensored are documented here.+## [Unreleased]++### Fixed+- **Remote Access in `npm run dev` now surfaces a clear actionable message instead of a cryptic 404 + JSON.parse stacktrace** — reported on Discord in `#bug-reports` by @phantomderp on v2.4.2: clicking the LAN button printed `POST http://localhost:5173/local-api/start-remote-server [HTTP/1.1 404 Not Found]` and clicking Internet showed an `Error: HTTP 404` toast plus `Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data`. Root cause: Remote Access is a Tauri-only feature (a Rust axum server, JWT auth, Cloudflare tunnel binary management, mobile-UI static serve — ~3700 lines in `src-tauri/src/commands/remote.rs`). When v2.4.2 added the corresponding `/local-api/*` paths to `src/api/backend.ts`'s endpoint map, no matching middleware was added to `vite.config.ts`, so dev-mode clicks fell through to vite's default 404 HTML page, which the frontend then tried to JSON.parse. End-user impact: zero — the installed `.exe` routes through Tauri's `invoke()` and works as designed. Developer impact: a confusing dead-end when iterating on the UI from `npm run dev`. Mirroring the entire feature in Node middleware would be a maintenance trap, so we keep dev lean and instead: (1) `Sidebar.handleDispatch` and the `remoteStore.startServer` / `restart` / `startTunnel` actions all check `isTauri()` first and short-circuit with `REMOTE_DEV_MODE_ERROR` — a single source-of-truth string that points at `npm run tauri:dev` (Tauri-aware dev mode where Remote works fully) or the installed app; (2) all 12 Remote-related vite middlewares are stubbed to return `HTTP 501 + { error, devModeOnly: true }` as a backstop in case any future caller bypasses the store guards.++### Tests+- 5 new regression cases in `remoteStore.test.ts` covering the dev-mode short-circuit: `startServer` / `restart` / `startTunnel` all throw `REMOTE_DEV_MODE_ERROR` when `isTauri()` is false, `backendCall` is never reached, and the error message itself contains the actionable `npm run tauri:dev` hint plus a "desktop app" reference.+## [2.4.2] - 2026-04-26### Fixeddiff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsxindex d1d00206..21d2f165 100644--- a/src/components/layout/Sidebar.tsx+++ b/src/components/layout/Sidebar.tsx@@ -6,8 +6,8 @@ import { useUIStore } from '../../stores/uiStore'import { useModelStore } from '../../stores/modelStore'import { useSettingsStore } from '../../stores/settingsStore'import { useCodexStore } from '../../stores/codexStore'-import { useRemoteStore } from '../../stores/remoteStore'-import { backendCall } from '../../api/backend'+import { useRemoteStore, REMOTE_DEV_MODE_ERROR } from '../../stores/remoteStore'+import { backendCall, isTauri } from '../../api/backend'import { formatDate, truncate } from '../../lib/formatters'import type { ChatMode } from '../../types/codex'@@ -69,6 +69,19 @@ export function Sidebar() {setDispatchPicker(false)if (!activeModel) return+ // Reported by @phantomderp on v2.4.2: clicking LAN/Internet from+ // `npm run dev` produced an HTTP 404 + cryptic JSON.parse error+ // because the dev server can't host the Rust HTTP server / JWT auth /+ // Cloudflare tunnel that Remote needs. Bail early with a clear,+ // actionable banner before we burn user time on the folder picker+ // and create a doomed conversation row. The store's startServer()+ // also throws REMOTE_DEV_MODE_ERROR for any future caller that+ // bypasses this guard.+ if (!isTauri()) {+ useRemoteStore.setState({ error: REMOTE_DEV_MODE_ERROR })+ return+ }+// #29 follow-up: ask the user where the agent should write files for// this remote session BEFORE starting the server. Cancel = bail, no// orphan conv. Skip = keep `~/agent-workspace/<slug>/` default. Thediff --git a/src/stores/__tests__/remoteStore-v2.test.ts b/src/stores/__tests__/remoteStore-v2.test.tsindex d91bdacd..6fe72e7a 100644--- a/src/stores/__tests__/remoteStore-v2.test.ts+++ b/src/stores/__tests__/remoteStore-v2.test.ts@@ -12,6 +12,10 @@ import { useMemoryStore } from '../memoryStore'// ─── Mocks ───vi.mock('../../api/backend', () => ({backendCall: vi.fn().mockResolvedValue({}),+ // isTauri is consulted at the top of startServer/startTunnel/restart to+ // short-circuit dev-mode callers (REMOTE_DEV_MODE_ERROR). Tests in this+ // file exercise the happy path so we always return true.+ isTauri: vi.fn(() => true),}))import { backendCall } from '../../api/backend'const mockBackend = backendCall as unknown as ReturnType<typeof vi.fn>diff --git a/src/stores/__tests__/remoteStore.test.ts b/src/stores/__tests__/remoteStore.test.tsindex ae4ae80d..6ae145ff 100644--- a/src/stores/__tests__/remoteStore.test.ts+++ b/src/stores/__tests__/remoteStore.test.ts@@ -1,15 +1,19 @@import { describe, it, expect, vi, beforeEach } from 'vitest'const mockBackendCall = vi.fn()+const mockIsTauri = vi.fn(() => true)vi.mock('../../api/backend', () => ({backendCall: (...args: unknown[]) => mockBackendCall(...args),+ isTauri: () => mockIsTauri(),}))-import { useRemoteStore } from '../remoteStore'+import { useRemoteStore, REMOTE_DEV_MODE_ERROR } from '../remoteStore'describe('remoteStore', () => {beforeEach(() => {mockBackendCall.mockReset()+ mockIsTauri.mockReset()+ mockIsTauri.mockReturnValue(true) // default: assume Tauri is availableuseRemoteStore.setState({enabled: false,port: 11435,@@ -85,6 +89,48 @@ describe('remoteStore', () => {expect(state.error).toContain('Connection refused')expect(state.enabled).toBe(false)})++ // Reported by @phantomderp on v2.4.2 — clicking LAN/Internet from+ // `npm run dev` produced an HTTP 404 + JSON.parse SyntaxError because+ // the dev server can't host the Rust backend Remote needs. The store+ // short-circuits with REMOTE_DEV_MODE_ERROR; backendCall is never+ // reached.+ describe('dev-mode short-circuit', () => {+ it('throws REMOTE_DEV_MODE_ERROR when isTauri() is false', async () => {+ mockIsTauri.mockReturnValue(false)+ await expect(useRemoteStore.getState().startServer()).rejects.toThrow(REMOTE_DEV_MODE_ERROR)+ })++ it('sets the dev-mode error on state without calling backendCall', async () => {+ mockIsTauri.mockReturnValue(false)+ try { await useRemoteStore.getState().startServer() } catch { /* expected */ }+ expect(mockBackendCall).not.toHaveBeenCalled()+ expect(useRemoteStore.getState().error).toBe(REMOTE_DEV_MODE_ERROR)+ expect(useRemoteStore.getState().loading).toBe(false)+ expect(useRemoteStore.getState().enabled).toBe(false)+ })++ it('restart() also short-circuits in dev mode', async () => {+ mockIsTauri.mockReturnValue(false)+ await expect(useRemoteStore.getState().restart()).rejects.toThrow(REMOTE_DEV_MODE_ERROR)+ expect(mockBackendCall).not.toHaveBeenCalled()+ })++ it('startTunnel() also short-circuits in dev mode', async () => {+ mockIsTauri.mockReturnValue(false)+ await expect(useRemoteStore.getState().startTunnel()).rejects.toThrow(REMOTE_DEV_MODE_ERROR)+ expect(mockBackendCall).not.toHaveBeenCalled()+ expect(useRemoteStore.getState().tunnelLoading).toBe(false)+ })++ it('REMOTE_DEV_MODE_ERROR mentions the actionable path (`npm run tauri:dev`)', () => {+ // If the message ever loses the developer-actionable hint, this+ // catches it. The whole point of the short-circuit is to point+ // people at the right command.+ expect(REMOTE_DEV_MODE_ERROR).toMatch(/npm run tauri:dev/)+ expect(REMOTE_DEV_MODE_ERROR.toLowerCase()).toContain('desktop app')+ })+ })})// ── stopServer ─────────────────────────────────────────────diff --git a/src/stores/remoteStore.ts b/src/stores/remoteStore.tsindex 255126f9..a08a0fdf 100644--- a/src/stores/remoteStore.ts+++ b/src/stores/remoteStore.ts@@ -1,7 +1,25 @@import { create } from 'zustand'-import { backendCall } from '../api/backend'+import { backendCall, isTauri } from '../api/backend'import { useMemoryStore } from './memoryStore'+/**+ * Reported on Discord by @phantomderp on v2.4.2 — clicking LAN/Internet+ * while running from source via plain `npm run dev` produced an HTTP 404+ * + cryptic `JSON.parse: unexpected character` stacktrace. Remote Access+ * is fundamentally a Tauri-only feature: a Rust axum server, JWT auth,+ * Cloudflare tunnel binary management, mobile-UI static serve. None of+ * that exists in the vite dev process. Mirroring it would mean+ * reimplementing ~3700 lines of Rust in Node middleware, plus a forever+ * maintenance burden every time the Rust side moves.+ *+ * Instead: detect dev-mode at the store entry points and surface a clear+ * actionable message — pick the .exe or `npm run tauri:dev`. The same+ * message is also returned by the catch-all vite middleware as a 501 in+ * case any future caller bypasses the store.+ */+export const REMOTE_DEV_MODE_ERROR =+ "Remote Access requires the installed desktop app. The plain `npm run dev` server can't host the Rust backend Remote needs (built-in HTTP server, secure passcodes, Cloudflare tunnel). For full Remote in development, use `npm run tauri:dev` instead — it brings the Rust side in and Remote works there too."+/*** Enrich a system prompt with the user's memory context so Remote chats* share the same cross-conversation memory as desktop chats.@@ -96,6 +114,14 @@ export const useRemoteStore = create<RemoteState>()((set, get) => ({qrVisible: false,startServer: async (model?: string, systemPrompt?: string) => {+ if (!isTauri()) {+ // Defense in depth: Sidebar.handleDispatch already short-circuits+ // before this point, but any other caller (tests, future components,+ // mobile bridge) lands here too. Throw so dispatch()/restart() catch+ // it and surface the message in `error` like any other failure.+ set({ loading: false, enabled: false, error: REMOTE_DEV_MODE_ERROR })+ throw new Error(REMOTE_DEV_MODE_ERROR)+ }set({ loading: true, error: null })try {const args: Record<string, unknown> = {}@@ -238,6 +264,10 @@ export const useRemoteStore = create<RemoteState>()((set, get) => ({},startTunnel: async () => {+ if (!isTauri()) {+ set({ tunnelLoading: false, error: REMOTE_DEV_MODE_ERROR })+ throw new Error(REMOTE_DEV_MODE_ERROR)+ }set({ tunnelLoading: true, error: null })try {const url = await backendCall<string>('start_tunnel')@@ -298,6 +328,10 @@ export const useRemoteStore = create<RemoteState>()((set, get) => ({},restart: async (model?: string, systemPrompt?: string) => {+ if (!isTauri()) {+ set({ loading: false, enabled: false, error: REMOTE_DEV_MODE_ERROR })+ throw new Error(REMOTE_DEV_MODE_ERROR)+ }set({ loading: true, error: null })try {const args: Record<string, unknown> = {}diff --git a/vite.config.ts b/vite.config.tsindex fabfe247..48daf07b 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -317,6 +317,48 @@ function comfyLauncher(): Plugin {fetchUrl(url)})+ // ─── Remote Access stubs (dev mode) ───────────────────────────+ // Reported by @phantomderp on v2.4.2: clicking LAN/Internet from+ // `npm run dev` returned an HTML 404 page that the frontend then+ // tried to JSON.parse, producing a cryptic+ // "SyntaxError: unexpected character at line 1 column 1" stacktrace.+ //+ // Remote Access is fundamentally a Tauri-only feature: a Rust axum+ // server, JWT auth, Cloudflare tunnel binary management,+ // mobile-UI static serve. None of that exists in the vite dev+ // process. Mirroring it here would mean reimplementing ~3700 lines+ // of Rust in Node middleware plus a forever maintenance burden.+ //+ // Instead: respond with HTTP 501 + a structured JSON body so the+ // frontend can surface a clear actionable error. The Sidebar ++ // remoteStore already short-circuit before fetch() in dev mode+ // (REMOTE_DEV_MODE_ERROR); these stubs are the backstop for any+ // future caller that bypasses those guards.+ const REMOTE_DEV_MODE_BODY = JSON.stringify({+ error: "Remote Access requires the installed desktop app. Use `npm run tauri:dev` for full Remote in development — the plain vite dev server can't host the Rust backend Remote needs.",+ devModeOnly: true,+ })+ const remoteStubPaths = [+ '/local-api/start-remote-server',+ '/local-api/stop-remote-server',+ '/local-api/restart-remote-server',+ '/local-api/remote-server-status',+ '/local-api/regenerate-remote-token',+ '/local-api/remote-qr-code',+ '/local-api/remote-connected-devices',+ '/local-api/disconnect-remote-device',+ '/local-api/set-remote-permissions',+ '/local-api/start-tunnel',+ '/local-api/stop-tunnel',+ '/local-api/tunnel-status',+ ]+ for (const path of remoteStubPaths) {+ server.middlewares.use(path, (_req, res) => {+ res.writeHead(501, { 'Content-Type': 'application/json' })+ res.end(REMOTE_DEV_MODE_BODY)+ })+ }+// API: Manual startserver.middlewares.use('/local-api/start-comfyui', async (_req, res) => {const alreadyRunning = await isComfyRunning()