Skip to content

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

Move AI chat to Design/AI tab in properties panel

Danila Poyarkovbf5c905134e8
diff --git a/components.d.ts b/components.d.ts
index 2df71cea2..379c03658 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -13,6 +13,7 @@ declare module 'vue' {
export interface GlobalComponents {
AppearanceSection: typeof import('./src/components/properties/AppearanceSection.vue')['default']
CanvasContextMenu: typeof import('./src/components/CanvasContextMenu.vue')['default']
+ ChatPanel: typeof import('./src/components/ChatPanel.vue')['default']
ColorInput: typeof import('./src/components/ColorInput.vue')['default']
ColorPicker: typeof import('./src/components/ColorPicker.vue')['default']
EditorCanvas: typeof import('./src/components/EditorCanvas.vue')['default']
@@ -47,15 +48,22 @@ declare module 'vue' {
IconLucideHash: typeof import('~icons/lucide/hash')['default']
IconLucideImage: typeof import('~icons/lucide/image')['default']
IconLucideItalic: typeof import('~icons/lucide/italic')['default']
+ IconLucideKeyRound: typeof import('~icons/lucide/key-round')['default']
IconLucideLink: typeof import('~icons/lucide/link')['default']
+ IconLucideLoaderCircle: typeof import('~icons/lucide/loader-circle')['default']
+ IconLucideMessageCircle: typeof import('~icons/lucide/message-circle')['default']
IconLucidePlus: typeof import('~icons/lucide/plus')['default']
IconLucideRadius: typeof import('~icons/lucide/radius')['default']
IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw')['default']
IconLucideRotateCw: typeof import('~icons/lucide/rotate-cw')['default']
IconLucideSearch: typeof import('~icons/lucide/search')['default']
+ IconLucideSend: typeof import('~icons/lucide/send')['default']
IconLucideSettings2: typeof import('~icons/lucide/settings2')['default']
+ IconLucideSparkles: typeof import('~icons/lucide/sparkles')['default']
+ IconLucideSquare: typeof import('~icons/lucide/square')['default']
IconLucideStrikethrough: typeof import('~icons/lucide/strikethrough')['default']
IconLucideToggleLeft: typeof import('~icons/lucide/toggle-left')['default']
+ IconLucideTriangleAlert: typeof import('~icons/lucide/triangle-alert')['default']
IconLucideType: typeof import('~icons/lucide/type')['default']
IconLucideUnderline: typeof import('~icons/lucide/underline')['default']
IconLucideUnlink: typeof import('~icons/lucide/unlink')['default']
diff --git a/src/App.vue b/src/App.vue
index 0d77d3582..5abf627c3 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -2,13 +2,11 @@
import { useEventListener, useUrlSearchParams } from '@vueuse/core'
import { SplitterGroup, SplitterPanel, SplitterResizeHandle } from 'reka-ui'
-import { useAIChat } from './composables/use-chat'
import { useKeyboard } from './composables/use-keyboard'
import { useMenu } from './composables/use-menu'
import { createDemoShapes } from './demo'
import { provideEditorStore } from './stores/editor'
-import ChatPanel from './components/ChatPanel.vue'
import EditorCanvas from './components/EditorCanvas.vue'
import LayersPanel from './components/LayersPanel.vue'
import PropertiesPanel from './components/PropertiesPanel.vue'
@@ -19,8 +17,6 @@ useKeyboard(store)
useMenu(store)
;(window as Window & { __OPEN_PENCIL_STORE__?: typeof store }).__OPEN_PENCIL_STORE__ = store
-const { chatPanelOpen } = useAIChat()
-
useEventListener(
document,
'wheel',
@@ -61,8 +57,7 @@ if (!('test' in params)) {
<div class="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2" />
</SplitterResizeHandle>
<SplitterPanel :default-size="15" :min-size="10" :max-size="30" class="flex">
- <ChatPanel v-if="chatPanelOpen" />
- <PropertiesPanel v-else />
+ <PropertiesPanel />
</SplitterPanel>
</SplitterGroup>
<div v-else class="flex flex-1 overflow-hidden">
diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vue
index 2812b8640..bc3aa7445 100644
--- a/src/components/ChatPanel.vue
+++ b/src/components/ChatPanel.vue
@@ -96,17 +96,7 @@ function toolState(part: ToolPart): 'pending' | 'done' | 'error' {
</script>
<template>
- <aside
- class="flex min-w-0 flex-1 flex-col overflow-hidden border-l border-border bg-panel"
- style="contain: paint layout style"
- >
- <!-- Header -->
- <div class="flex h-10 shrink-0 items-center gap-2 border-b border-border px-3">
- <icon-lucide-sparkles class="size-4 text-accent" />
- <span class="text-xs font-semibold">AI Chat</span>
- <span v-if="isStreaming" class="ml-auto text-[10px] text-muted"> streaming… </span>
- </div>
-
+ <div class="flex min-w-0 flex-1 flex-col overflow-hidden">
<!-- API key setup -->
<div v-if="!isConfigured" class="flex flex-1 flex-col items-center justify-center gap-4 px-4">
<icon-lucide-key-round class="size-8 text-muted" />
@@ -276,5 +266,5 @@ function toolState(part: ToolPart): 'pending' | 'done' | 'error' {
</form>
</div>
</template>
- </aside>
+ </div>
</template>
diff --git a/src/components/PropertiesPanel.vue b/src/components/PropertiesPanel.vue
index 881af1595..72f347d8b 100644
--- a/src/components/PropertiesPanel.vue
+++ b/src/components/PropertiesPanel.vue
@@ -1,8 +1,10 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
+import { useAIChat } from '@/composables/use-chat'
import { useEditorStore } from '@/stores/editor'
+import ChatPanel from './ChatPanel.vue'
import VariablesDialog from './VariablesDialog.vue'
import AppearanceSection from './properties/AppearanceSection.vue'
import EffectsSection from './properties/EffectsSection.vue'
@@ -16,6 +18,7 @@ import TypographySection from './properties/TypographySection.vue'
import VariablesSection from './properties/VariablesSection.vue'
const store = useEditorStore()
+const { activeTab } = useAIChat()
const variablesOpen = ref(false)
const node = computed(() => store.selectedNode.value)
@@ -33,69 +36,91 @@ const isComponentType = computed(() => {
>
<!-- Tabs -->
<div class="flex h-10 shrink-0 items-center gap-1 border-b border-border px-2">
- <button class="rounded px-2.5 py-1 text-xs font-semibold text-surface">Design</button>
- <button class="rounded px-2.5 py-1 text-xs text-muted">Prototype</button>
+ <button
+ class="rounded px-2.5 py-1 text-xs"
+ :class="
+ activeTab === 'design' ? 'font-semibold text-surface' : 'text-muted hover:text-surface'
+ "
+ @click="activeTab = 'design'"
+ >
+ Design
+ </button>
+ <button
+ class="flex items-center gap-1 rounded px-2.5 py-1 text-xs"
+ :class="activeTab === 'ai' ? 'font-semibold text-surface' : 'text-muted hover:text-surface'"
+ @click="activeTab = 'ai'"
+ >
+ <icon-lucide-sparkles class="size-3" />
+ AI
+ </button>
<span
+ v-if="activeTab === 'design'"
class="ml-auto cursor-pointer rounded px-1.5 py-0.5 text-[11px] text-muted hover:bg-hover"
>
{{ Math.round(store.state.zoom * 100) }}%
</span>
</div>
- <!-- Multi-select summary -->
- <div v-if="multiCount > 1" class="flex-1 overflow-y-auto pb-4">
- <div class="flex items-center gap-1.5 border-b border-border px-3 py-2">
- <span class="text-[11px] text-muted">Mixed</span>
- <span class="text-xs font-semibold">{{ multiCount }} layers</span>
- </div>
- <AppearanceSection />
- </div>
+ <!-- AI Chat tab -->
+ <ChatPanel v-if="activeTab === 'ai'" />
- <!-- Single selection -->
- <div v-else-if="node" class="flex-1 overflow-y-auto pb-4">
- <!-- Node header -->
- <div class="flex items-center gap-1.5 border-b border-border px-3 py-2">
- <span class="text-[11px]" :class="isComponentType ? 'text-[#9747ff]' : 'text-muted'">{{
- node.type
- }}</span>
- <span class="text-xs font-semibold">{{ node.name }}</span>
+ <!-- Design tab -->
+ <template v-else>
+ <!-- Multi-select summary -->
+ <div v-if="multiCount > 1" class="flex-1 overflow-y-auto pb-4">
+ <div class="flex items-center gap-1.5 border-b border-border px-3 py-2">
+ <span class="text-[11px] text-muted">Mixed</span>
+ <span class="text-xs font-semibold">{{ multiCount }} layers</span>
+ </div>
+ <AppearanceSection />
</div>
- <!-- Component actions -->
- <div
- v-if="node.type === 'INSTANCE'"
- class="flex flex-col gap-1 border-b border-border px-3 py-2"
- >
- <button
- class="rounded bg-[#9747ff]/10 px-2 py-1 text-left text-[11px] text-[#9747ff] hover:bg-[#9747ff]/20"
- @click="store.goToMainComponent()"
- >
- Go to Main Component
- </button>
- <button
- class="rounded px-2 py-1 text-left text-[11px] text-muted hover:bg-hover"
- @click="store.detachInstance()"
+ <!-- Single selection -->
+ <div v-else-if="node" class="flex-1 overflow-y-auto pb-4">
+ <!-- Node header -->
+ <div class="flex items-center gap-1.5 border-b border-border px-3 py-2">
+ <span class="text-[11px]" :class="isComponentType ? 'text-[#9747ff]' : 'text-muted'">{{
+ node.type
+ }}</span>
+ <span class="text-xs font-semibold">{{ node.name }}</span>
+ </div>
+
+ <!-- Component actions -->
+ <div
+ v-if="node.type === 'INSTANCE'"
+ class="flex flex-col gap-1 border-b border-border px-3 py-2"
>
- Detach Instance
- </button>
- </div>
+ <button
+ class="rounded bg-[#9747ff]/10 px-2 py-1 text-left text-[11px] text-[#9747ff] hover:bg-[#9747ff]/20"
+ @click="store.goToMainComponent()"
+ >
+ Go to Main Component
+ </button>
+ <button
+ class="rounded px-2 py-1 text-left text-[11px] text-muted hover:bg-hover"
+ @click="store.detachInstance()"
+ >
+ Detach Instance
+ </button>
+ </div>
- <PositionSection />
- <LayoutSection />
- <AppearanceSection />
- <TypographySection v-if="node.type === 'TEXT'" />
- <FillSection />
- <StrokeSection />
- <EffectsSection />
+ <PositionSection />
+ <LayoutSection />
+ <AppearanceSection />
+ <TypographySection v-if="node.type === 'TEXT'" />
+ <FillSection />
+ <StrokeSection />
+ <EffectsSection />
- <ExportSection />
- </div>
+ <ExportSection />
+ </div>
- <div v-else class="flex-1 overflow-y-auto pb-4">
- <PageSection />
- <VariablesSection @open-dialog="variablesOpen = true" />
- </div>
+ <div v-else class="flex-1 overflow-y-auto pb-4">
+ <PageSection />
+ <VariablesSection @open-dialog="variablesOpen = true" />
+ </div>
- <VariablesDialog v-model:open="variablesOpen" />
+ <VariablesDialog v-model:open="variablesOpen" />
+ </template>
</aside>
</template>
diff --git a/src/composables/use-chat.ts b/src/composables/use-chat.ts
index 81b80c99a..b0fd29755 100644
--- a/src/composables/use-chat.ts
+++ b/src/composables/use-chat.ts
@@ -8,7 +8,7 @@ import type { InferAgentUIMessage } from 'ai'
const API_KEY_STORAGE = 'open-pencil:openrouter-api-key'
const apiKey = ref(localStorage.getItem(API_KEY_STORAGE) ?? '')
-const chatPanelOpen = ref(false)
+const activeTab = ref<'design' | 'ai'>('design')
watch(apiKey, (key) => {
if (key) {
@@ -47,7 +47,7 @@ function createChat() {
export function useAIChat() {
return {
apiKey,
- chatPanelOpen,
+ activeTab,
isConfigured,
createChat
}
diff --git a/src/composables/use-keyboard.ts b/src/composables/use-keyboard.ts
index 8e2c7dacc..b77a2ee74 100644
--- a/src/composables/use-keyboard.ts
+++ b/src/composables/use-keyboard.ts
@@ -12,7 +12,7 @@ function isEditing(e: Event) {
}
export function useKeyboard(store: EditorStore) {
- const { chatPanelOpen } = useAIChat()
+ const { activeTab } = useAIChat()
useEventListener(window, 'copy', (e: ClipboardEvent) => {
if (isEditing(e)) return
e.preventDefault()
@@ -83,7 +83,7 @@ export function useKeyboard(store: EditorStore) {
if (e.metaKey || e.ctrlKey) {
if (e.code === 'KeyJ') {
e.preventDefault()
- chatPanelOpen.value = !chatPanelOpen.value
+ activeTab.value = activeTab.value === 'ai' ? 'design' : 'ai'
return
}
if (e.key === 'z' && !e.shiftKey) {