Skip to content

AI-native design editor. Open-source Figma alternative.

Merge origin/master into agent/mcp-automation-settings

Danila Poyarkov22c98e28c879
diff --cc src/views/WorkspaceView.vue
index 000000000,6b0e7db43..d5123871f
mode 000000,100644..100644
--- a/src/views/WorkspaceView.vue
+++ b/src/views/WorkspaceView.vue
@@@ -1,0 -1,116 +1,107 @@@
+ <script setup lang="ts">
+ import { onMounted, onUnmounted, provide, ref } from 'vue'
+ import { useEventListener, useUrlSearchParams } from '@vueuse/core'
+ import { useHead } from '@unhead/vue'
+ import { useRoute } from 'vue-router'
+
-import { connectAutomation } from '@/app/automation/bridge/server'
-import { spawnMCPIfNeeded } from '@/app/automation/mcp/spawn'
+ import { exposeCollaborationActions } from '@/app/browser-bridge'
++import { startMCPRuntime, stopMCPRuntime } from '@/app/automation/mcp/runtime'
+ import { COLLAB_KEY, useCollab } from '@/app/collab/use'
+ import { createDemoShapes } from '@/app/demo/document'
+ import { useKeyboard } from '@/app/shell/keyboard/use'
+ import { openFileFromPath, useEditorMenu } from '@/app/shell/menu/use'
+ import {
+ activeTab,
+ createDocumentInCurrentTab,
+ createHomeTab,
+ createTab,
+ getActiveStore,
+ tabCount
+ } from '@/app/tabs'
+ import { isTauri } from '@/app/tauri/env'
+ import FontStatusBanner from '@/components/font-status/FontStatusBanner.vue'
+ import RenameSelectionDialog from '@/components/selection/RenameSelectionDialog.vue'
+ import SafariBanner from '@/components/SafariBanner.vue'
+ import TabBar from '@/components/TabBar.vue'
+ import EditorWorkspace from '@/components/editor/EditorWorkspace.vue'
+ import HomeWorkspace from '@/components/home/HomeWorkspace.vue'
+
+ const route = useRoute()
+ const params = useUrlSearchParams('history')
+ const createdInitialTab = tabCount() === 0
+ const shouldCreateHome =
+ route.path === '/' &&
+ !('test' in params) &&
+ !route.meta.demo &&
+ (isTauri() || 'recent-files' in params)
+ let firstTab = activeTab.value
+ if (!firstTab) firstTab = shouldCreateHome ? createHomeTab() : createTab()
+
+ if (createdInitialTab && route.meta.demo && !('test' in params)) {
+ void createDemoShapes(firstTab.store)
+ }
+
+ useHead({ title: route.meta.demo ? 'Demo' : undefined })
+ useKeyboard()
+ useEditorMenu()
+
+ const collab = useCollab(getActiveStore)
+ provide(COLLAB_KEY, collab)
+ exposeCollaborationActions(collab)
+
+ useEventListener(
+ document,
+ 'wheel',
+ (event: WheelEvent) => {
+ if (event.ctrlKey || event.metaKey) event.preventDefault()
+ },
+ { passive: false }
+ )
+
-const automationCleanup = ref<(() => void) | null>(null)
-const mcpCleanup = ref<(() => void) | null>(null)
+ const fileAssociationCleanup = ref<(() => void) | null>(null)
+
+ interface PendingOpenFile {
+ path: string
+ }
+
+ async function openPendingAssociatedFiles(): Promise<void> {
+ const { invoke } = await import('@tauri-apps/api/core')
+ const files = await invoke<PendingOpenFile[]>('take_pending_open')
+ for (const file of files) await openFileFromPath(file.path)
+ }
+
+ async function bindAssociatedFileOpen(): Promise<void> {
+ if (!isTauri()) return
+ const { listen } = await import('@tauri-apps/api/event')
+ fileAssociationCleanup.value = await listen('open-associated-files', () => {
+ void openPendingAssociatedFiles().catch((error) => console.error('[Open With]', error))
+ })
+ await openPendingAssociatedFiles()
+ }
+
+ onMounted(async () => {
- const mcp = await spawnMCPIfNeeded()
- mcpCleanup.value = mcp?.disconnect ?? null
- const tauri = isTauri()
- if (import.meta.env.DEV || (tauri && mcp)) {
- automationCleanup.value = connectAutomation(getActiveStore, mcp?.authToken ?? null).disconnect
- }
++ await startMCPRuntime(getActiveStore)
+
+ try {
+ await bindAssociatedFileOpen()
+ } catch (error) {
+ console.error('[Open With]', error)
+ }
+ })
+
+ onUnmounted(() => {
- mcpCleanup.value?.()
- automationCleanup.value?.()
++ void stopMCPRuntime()
+ fileAssociationCleanup.value?.()
+ })
+ </script>
+
+ <template>
+ <div data-test-id="editor-root" class="flex h-screen w-screen flex-col">
+ <SafariBanner />
+ <FontStatusBanner />
+ <RenameSelectionDialog />
+ <TabBar />
+ <HomeWorkspace v-show="activeTab?.kind === 'home'" @new-document="createDocumentInCurrentTab" />
+ <EditorWorkspace v-if="activeTab?.kind !== 'home'" />
+ </div>
+ </template>