Description
The packages/desktop README documents a web-only development mode that doesn't actually work. The code calls Tauri APIs unconditionally without checking if running in a Tauri context, causing immediate crashes when running in a browser.
Documentation Claims
From packages/desktop/README.md (lines 16-20):
If you only want the web dev server (no native shell):
\`\`\`bash
bun run --cwd packages/desktop dev
\`\`\`
This suggests the desktop package supports browser-only development for quick iteration without the native shell overhead.
Actual Behavior
Running bun run --cwd packages/desktop dev and opening http://localhost:1420 in a browser results in multiple crashes:
Error 1: OS Type Detection
TypeError: Cannot read properties of undefined (reading 'os_type')
at type (@tauri-apps_plugin-os.js:20:47)
at index.tsx:47:18
Location: src/index.tsx:47 - calls ostype() unconditionally in createPlatform()
Error 2: Menu Creation
TypeError: Cannot read properties of undefined (reading 'os_type')
at type (@tauri-apps_plugin-os.js:20:47)
at createMenu (menu.ts:10:7)
Location: src/menu.ts:10 - calls ostype() without checking Tauri context
Error 3: WebView Zoom
TypeError: Cannot read properties of undefined (reading 'os_type')
at type (@tauri-apps_plugin-os.js:20:47)
at webview-zoom.ts:8:17
Location: src/webview-zoom.ts:8 - calls ostype() at module initialization
Error 4: Server Readiness Check
TypeError: Cannot read properties of undefined (reading 'invoke')
at invoke (chunk-IT22SQDD.js:107:37)
at ServerGate (index.tsx:324:45)
Location: src/index.tsx:324 - calls invoke("ensure_server_ready") unconditionally
Root Cause
The code assumes it's always running in a Tauri context and calls Tauri APIs directly without checking "__TAURI__" in window. This breaks the documented browser-only dev mode.
Files Affected
All these files call Tauri APIs unconditionally:
-
src/index.tsx
ostype() - line ~47
invoke("ensure_server_ready") - line ~324
invoke("kill_sidecar") - multiple locations
invoke("get_default_server_url") - line ~315
invoke("set_default_server_url") - line ~320
invoke("parse_markdown_command") - line ~324
open(), save() - file picker dialogs
check() - updater
tauriFetch() - HTTP requests
isPermissionGranted(), requestPermission() - notifications
relaunch() - restart functionality
-
src/menu.ts
-
src/webview-zoom.ts
ostype() - line 8
invoke("plugin:webview|set_webview_zoom") - line 27
Proposed Solutions
Option 1: Fix the Code (Recommended)
Add Tauri context detection and graceful fallbacks:
const isTauri = "__TAURI__" in window
// Example fixes:
const OS_NAME = isTauri ? ostype() : "unknown"
export async function createMenu() {
if (!isTauri || ostype() !== "macos") return
// ... rest of menu code
}
const [serverData] = createResource<ServerReadyData>(() => {
if (!isTauri) {
return Promise.resolve({ url: "http://127.0.0.1:4096", password: null })
}
return invoke("ensure_server_ready").then(...)
})
This would make the documented browser-only mode actually work.
Option 2: Update Documentation
If browser-only mode isn't intended to be supported, remove the misleading documentation:
- If you only want the web dev server (no native shell):
-
- ```bash
- bun run --cwd packages/desktop dev
- ```
And clarify that tauri dev is the only supported development mode.
Impact
This affects developers who:
- Don't have Tauri prerequisites installed
- Want quick UI iteration without native shell overhead
- Are following the documented workflow
Environment
- Platform: macOS (but affects all platforms)
- Node: v22.22.0
- Bun: v1.3.6
- Package: @opencode-ai/desktop v1.1.33
Additional Context
The web-only dev mode is a common pattern for Tauri/Electron apps to enable faster development iteration. The infrastructure (Vite dev server) is already in place - it just needs the Tauri API guards to make it work as documented.
Description
The
packages/desktopREADME documents a web-only development mode that doesn't actually work. The code calls Tauri APIs unconditionally without checking if running in a Tauri context, causing immediate crashes when running in a browser.Documentation Claims
From
packages/desktop/README.md(lines 16-20):This suggests the desktop package supports browser-only development for quick iteration without the native shell overhead.
Actual Behavior
Running
bun run --cwd packages/desktop devand opening http://localhost:1420 in a browser results in multiple crashes:Error 1: OS Type Detection
Location:
src/index.tsx:47- callsostype()unconditionally increatePlatform()Error 2: Menu Creation
Location:
src/menu.ts:10- callsostype()without checking Tauri contextError 3: WebView Zoom
Location:
src/webview-zoom.ts:8- callsostype()at module initializationError 4: Server Readiness Check
Location:
src/index.tsx:324- callsinvoke("ensure_server_ready")unconditionallyRoot Cause
The code assumes it's always running in a Tauri context and calls Tauri APIs directly without checking
"__TAURI__" in window. This breaks the documented browser-only dev mode.Files Affected
All these files call Tauri APIs unconditionally:
src/index.tsx
ostype()- line ~47invoke("ensure_server_ready")- line ~324invoke("kill_sidecar")- multiple locationsinvoke("get_default_server_url")- line ~315invoke("set_default_server_url")- line ~320invoke("parse_markdown_command")- line ~324open(),save()- file picker dialogscheck()- updatertauriFetch()- HTTP requestsisPermissionGranted(),requestPermission()- notificationsrelaunch()- restart functionalitysrc/menu.ts
ostype()- line 10src/webview-zoom.ts
ostype()- line 8invoke("plugin:webview|set_webview_zoom")- line 27Proposed Solutions
Option 1: Fix the Code (Recommended)
Add Tauri context detection and graceful fallbacks:
This would make the documented browser-only mode actually work.
Option 2: Update Documentation
If browser-only mode isn't intended to be supported, remove the misleading documentation:
And clarify that
tauri devis the only supported development mode.Impact
This affects developers who:
Environment
Additional Context
The web-only dev mode is a common pattern for Tauri/Electron apps to enable faster development iteration. The infrastructure (Vite dev server) is already in place - it just needs the Tauri API guards to make it work as documented.