fix(app): inline Tauri detection in EditorView

IS_TAURI is evaluated at module load time and may be false if
__TAURI_INTERNALS__ isn't injected yet. This prevented the
automation WebSocket from connecting on Windows and some Linux
configurations.
This commit is contained in:
Danila Poyarkov 2026-04-23 14:37:33 +03:00
parent 8c643298f3
commit 1bf19fff59

View file

@ -11,7 +11,7 @@ import { useMenu } from '@/composables/use-menu'
import { useCollab, COLLAB_KEY } from '@/composables/use-collab'
import { connectAutomation } from '@/automation/server'
import { spawnMCPIfNeeded } from '@/automation/spawn-mcp'
import { IS_TAURI } from '@/constants'
import { IS_BROWSER } from '@open-pencil/core'
import { createDemoShapes } from '@/demo'
import { useEditorStore } from '@/stores/editor'
import { createTab, activeTab, getActiveStore } from '@/stores/tabs'
@ -61,12 +61,13 @@ onMounted(async () => {
try {
const mcp = await spawnMCPIfNeeded()
mcpCleanup.value = mcp?.disconnect ?? null
if (import.meta.env.DEV || IS_TAURI) {
const isTauri = IS_BROWSER && '__TAURI_INTERNALS__' in window
if (import.meta.env.DEV || isTauri) {
automationCleanup.value = connectAutomation(getActiveStore, mcp?.authToken ?? null).disconnect
}
} catch (e) {
console.warn('[MCP]', e)
if (IS_TAURI) {
if (IS_BROWSER && '__TAURI_INTERNALS__' in window) {
const { toast } = await import('@/utils/toast')
toast.warning('MCP server failed to start. Install with: npm i -g @open-pencil/mcp')
}