AI-native design editor. Open-source Figma alternative.
fix(acp): show install errors for missing agent CLIs (#176)
Danila Poyarkov1c99e6a9c27f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0f4c3aad1..067af52c2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,7 @@### Fixes+- Show actionable ACP install errors in the chat panel when Claude Code, Codex, or Gemini CLI is selected but the required local CLI is missing- Fix inline layer rename so clearing the name falls back to the default node name, and Backspace/Delete inside rename inputs no longer delete the layer- Fix rotated frame hit testing, hover highlights, and selection overlays so child hover/click areas, frame title labels, and size pills stay aligned during rotation and live rotation previewdiff --git a/README.md b/README.mdindex c95615ec7..0b26733d9 100644--- a/README.md+++ b/README.md@@ -158,7 +158,7 @@ Use Claude Code, Codex, or Gemini CLI directly in the chat panel. The agent conn**Setup (Claude Code):**-1. Install the ACP adapter: `npm i -g @zed-industries/claude-agent-acp`+1. Install the ACP adapter: `npm i -g @agentclientprotocol/claude-agent-acp`2. Add MCP permission to `~/.claude/settings.json`:```json{diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.tsindex a10c58b35..e49291079 100644--- a/packages/core/src/constants.ts+++ b/packages/core/src/constants.ts@@ -98,12 +98,31 @@ export interface ACPAgentDef {name: stringcommand: stringargs: string[]+ installCommand?: string}export const ACP_AGENTS: ACPAgentDef[] = [- { id: 'claude-code', name: 'Claude Code', command: 'claude-agent-acp', args: [] },- { id: 'codex', name: 'Codex', command: 'codex-acp', args: [] },- { id: 'gemini-cli', name: 'Gemini CLI', command: 'gemini', args: ['--acp'] }+ {+ id: 'claude-code',+ name: 'Claude Code',+ command: 'claude-agent-acp',+ args: [],+ installCommand: 'npm i -g @agentclientprotocol/claude-agent-acp'+ },+ {+ id: 'codex',+ name: 'Codex',+ command: 'codex-acp',+ args: [],+ installCommand: 'npm i -g @zed-industries/codex-acp'+ },+ {+ id: 'gemini-cli',+ name: 'Gemini CLI',+ command: 'gemini',+ args: ['--acp'],+ installCommand: 'npm i -g @google/gemini-cli'+ }]export type AIProviderID =diff --git a/src/ai/acp-transport.ts b/src/ai/acp-transport.tsindex ebc02e478..61c7dca2d 100644--- a/src/ai/acp-transport.ts+++ b/src/ai/acp-transport.ts@@ -28,7 +28,20 @@ interface ACPSession {dead: boolean}-export function formatConnectionError(e: unknown): string {+function isMissingCommandError(message: string): boolean {+ const normalized = message.toLowerCase()+ return normalized.includes('enoent') || normalized.includes('program not found')+}++function missingCommandMessage(agentDef?: ACPAgentDef): string {+ if (!agentDef) return 'ACP agent CLI is not installed.'+ if (!agentDef.installCommand) {+ return `"${agentDef.command}" is not installed. Install it and restart OpenPencil.`+ }+ return `"${agentDef.command}" is not installed. Install it with: ${agentDef.installCommand}`+}++export function formatConnectionError(e: unknown, agentDef?: ACPAgentDef): string {const msg = e instanceof Error ? e.message : String(e)if (msg.includes('ECONNREFUSED') ||@@ -40,6 +53,9 @@ export function formatConnectionError(e: unknown): string {if (msg.includes('timeout') || msg.includes('Timeout') || msg.includes('ETIMEDOUT')) {return 'MCP server did not respond in time.'}+ if (isMissingCommandError(msg)) {+ return missingCommandMessage(agentDef)+ }return msg}@@ -180,7 +196,7 @@ export class ACPChatTransport implements ChatTransport<UIMessage> {finish(result.stopReason === 'end_turn' ? 'stop' : 'other')}).catch((e) => {- finish('error', formatConnectionError(e))+ finish('error', formatConnectionError(e, this.agentDef))})}})@@ -238,7 +254,12 @@ export class ACPChatTransport implements ChatTransport<UIMessage> {this.session = null})- const child = await command.spawn()+ let child: TauriChild+ try {+ child = await command.spawn()+ } catch (e) {+ throw new Error(formatConnectionError(e, this.agentDef))+ }const output = new ReadableStream<Uint8Array>({async pull(controller) {@@ -312,7 +333,7 @@ export class ACPChatTransport implements ChatTransport<UIMessage> {})} catch (e) {await child.kill()- throw new Error(formatConnectionError(e))+ throw new Error(formatConnectionError(e, this.agentDef))}const session: ACPSession = {diff --git a/src/components/CanvasMenu.vue b/src/components/CanvasMenu.vueindex ee776b2a8..2ec62fe6d 100644--- a/src/components/CanvasMenu.vue+++ b/src/components/CanvasMenu.vue@@ -33,25 +33,25 @@ function execCommand(cmd: 'copy' | 'cut' | 'paste') {console.warn(`Clipboard command ${cmd} failed`, error)}- toast.show('Clipboard access is blocked in this browser context', 'error')+ toast.error('Clipboard access is blocked in this browser context')}async function clipboardWrite(text: string | null, label: string) {if (!text) returncopy(text)- toast.show(`Copied as ${label}`)+ toast.info(`Copied as ${label}`)}async function copyAsPNG() {if (!navigator.clipboard?.write || typeof ClipboardItem === 'undefined') {- toast.show('PNG clipboard export is not available in this browser', 'error')+ toast.error('PNG clipboard export is not available in this browser')return}const data = await store.renderExportImage([...selectedIds.value], 2, 'PNG')if (!data) returnconst blob = new Blob([data], { type: 'image/png' })await navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })])- toast.show('Copied as PNG')+ toast.info('Copied as PNG')}const menuCls = useMenuUI({diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vueindex 4b2bb7e80..e21cfb370 100644--- a/src/components/ChatPanel.vue+++ b/src/components/ChatPanel.vue@@ -11,6 +11,7 @@ import ChatInput from '@/components/chat/ChatInput.vue'import ChatMessage from '@/components/chat/ChatMessage.vue'import ProviderSetup from '@/components/chat/ProviderSetup.vue'import { useAIChat } from '@/composables/use-chat'+import { toast } from '@/utils/toast'import { useI18n } from '@open-pencil/vue'import type { Chat } from '@ai-sdk/vue'@@ -29,7 +30,6 @@ ensureChat().then((c) => {const messagesEnd = ref<HTMLDivElement>()const debugCopied = ref(false)const acpLogCopied = ref(false)-const initError = ref<string | null>(null)const messages = computed(() => chat.value?.messages ?? [])const status = computed(() => chat.value?.status ?? 'ready')@@ -73,16 +73,16 @@ watch(async function handleSubmit(text: string) {if (status.value === 'streaming' || status.value === 'submitted') returntry {- initError.value = nullconst c = await ensureChat()if (c) chat.value = markRaw(c)} catch (e) {console.error('Failed to initialize chat:', e)- initError.value = e instanceof Error ? e.message : String(e)+ toast.error(e instanceof Error ? e.message : String(e))return}chat.value?.sendMessage({ text }).catch((e: unknown) => {console.error('Chat error:', e)+ toast.error(e instanceof Error ? e.message : String(e))})}@@ -211,18 +211,6 @@ function handleClearChat() {</button></div>- <!-- Connection error banner -->- <div- v-if="initError"- class="flex items-center gap-2 border-t border-red-500/20 bg-red-500/10 px-3 py-2 text-[11px] text-red-400"- >- <icon-lucide-circle-alert class="size-3.5 shrink-0" />- <span class="min-w-0 flex-1">{{ initError }}</span>- <button class="shrink-0 text-red-300 hover:text-red-200" @click="initError = null">- <icon-lucide-x class="size-3" />- </button>- </div>-<ChatInput :status="status" @submit="handleSubmit" @stop="handleStop" /><ACPPermissionDialog />diff --git a/src/components/CollabPanel.vue b/src/components/CollabPanel.vueindex 6cf0c76ca..5a9418773 100644--- a/src/components/CollabPanel.vue+++ b/src/components/CollabPanel.vue@@ -50,7 +50,7 @@ watch(function copyLink() {if (!shareUrl.value) returncopy(shareUrl.value)- toast.show('Link copied to clipboard')+ toast.info('Link copied to clipboard')}function onShare() {@@ -59,7 +59,7 @@ function onShare() {const roomId = collab.shareCurrentDoc()router.push(`/share/${roomId}`)copy(`${window.location.origin}/share/${roomId}`)- toast.show('Link copied to clipboard')+ toast.info('Link copied to clipboard')popoverOpen.value = false}diff --git a/src/components/MobileHud.vue b/src/components/MobileHud.vueindex 46cb5abd9..729b79b97 100644--- a/src/components/MobileHud.vue+++ b/src/components/MobileHud.vue@@ -49,7 +49,7 @@ function onShare() {const roomId = collab.shareCurrentDoc()router.push(`/share/${roomId}`)copy(`${window.location.origin}/share/${roomId}`)- toast.show('Link copied to clipboard')+ toast.info('Link copied to clipboard')}function onDisconnect() {diff --git a/src/components/chat/ProviderSetup.vue b/src/components/chat/ProviderSetup.vueindex 240b98184..287c95163 100644--- a/src/components/chat/ProviderSetup.vue+++ b/src/components/chat/ProviderSetup.vue@@ -86,11 +86,21 @@ function save() {<ProviderSelectField test-id="provider-selector" /><p class="text-center text-[10px] leading-relaxed text-muted">- Uses your existing {{ acpAgent?.name }} subscription. Make sure- <code class="rounded bg-input px-1 py-0.5 font-mono text-[9px]">{{- acpAgent?.command- }}</code>- is installed and authenticated.+ Uses your existing {{ acpAgent?.name }} subscription.+ <template v-if="acpAgent?.installCommand">+ Install it with+ <code class="rounded bg-input px-1 py-0.5 font-mono text-[9px]">{{+ acpAgent.installCommand+ }}</code>+ and sign in before sending your first message.+ </template>+ <template v-else>+ Make sure+ <code class="rounded bg-input px-1 py-0.5 font-mono text-[9px]">{{+ acpAgent?.command+ }}</code>+ is installed and authenticated.+ </template></p></div>diff --git a/src/stores/editor.ts b/src/stores/editor.tsindex 218a040ca..6a312439b 100644--- a/src/stores/editor.ts+++ b/src/stores/editor.ts@@ -889,7 +889,7 @@ export function createEditorStore(initialGraph?: SceneGraph) {editor.requestRender()} catch (e) {console.error('Failed to open .fig file:', e)- toast.show(`Failed to open file: ${e instanceof Error ? e.message : String(e)}`, 'error')+ toast.error(`Failed to open file: ${e instanceof Error ? e.message : String(e)}`)} finally {state.loading = false}diff --git a/src/utils/toast.ts b/src/utils/toast.tsindex 5e6ca8aca..a962aa7e3 100644--- a/src/utils/toast.ts+++ b/src/utils/toast.ts@@ -15,8 +15,16 @@ const toasts = ref<Toast[]>([])let nextId = 0let errorHandlersInitialized = false-function show(message: string, variant: ToastVariant = 'default') {- toasts.value.push({ id: ++nextId, message, variant })+function info(message: string) {+ toasts.value.push({ id: ++nextId, message, variant: 'default' })+}++function warning(message: string) {+ toasts.value.push({ id: ++nextId, message, variant: 'warning' })+}++function error(message: string) {+ toasts.value.push({ id: ++nextId, message, variant: 'error' })}function remove(id: number) {@@ -28,12 +36,12 @@ function setupGlobalErrorHandler() {errorHandlersInitialized = trueuseEventListener(window, 'error', (e) => {- show(e.message || 'An unexpected error occurred', 'error')+ error(e.message || 'An unexpected error occurred')})useEventListener(window, 'unhandledrejection', (e) => {const msg = e.reason instanceof Error ? e.reason.message : String(e.reason)- show(msg || 'An unexpected error occurred', 'error')+ error(msg || 'An unexpected error occurred')})}-export const toast = { show, remove, toasts, setupGlobalErrorHandler, TOAST_DURATION }+export const toast = { info, warning, error, remove, toasts, setupGlobalErrorHandler, TOAST_DURATION }diff --git a/tests/e2e/chat-panel.spec.ts b/tests/e2e/chat-panel.spec.tsindex 5c14427d2..7d77a6b92 100644--- a/tests/e2e/chat-panel.spec.ts+++ b/tests/e2e/chat-panel.spec.ts@@ -41,7 +41,14 @@ async function injectMockTransport(page: Page) {const lastUser = [...messages].reverse().find((m) => m.role === 'user')const text = lastUser?.parts?.find((p) => p.type === 'text')?.text ?? ''const msgId = `mock-msg-${++msgCounter}`- const wantsTool = text.toLowerCase().includes('frame') || text.toLowerCase().includes('rectangle')+ const lowerText = text.toLowerCase()+ const wantsTool = lowerText.includes('frame') || lowerText.includes('rectangle')++ if (lowerText.includes('missing agent')) {+ throw new Error(+ '"claude-agent-acp" is not installed. Install it with: npm i -g @agentclientprotocol/claude-agent-acp',+ )+ }return new ReadableStream({start(controller) {@@ -199,3 +206,14 @@ test('switching tabs preserves chat', async () => {await chatTab().click()await expect(page.getByText('Hello there', { exact: true })).toBeVisible()})++test('transport errors show an actionable toast', async () => {+ await chatInput().fill('Trigger missing agent error')+ await chatInput().press('Enter')++ await expect(+ page.getByText('Install it with: npm i -g @agentclientprotocol/claude-agent-acp', {+ exact: false,+ }),+ ).toBeVisible({ timeout: 5000 })+})diff --git a/tests/engine/acp-transport.test.ts b/tests/engine/acp-transport.test.tsindex 649eda53e..4a217d07a 100644--- a/tests/engine/acp-transport.test.ts+++ b/tests/engine/acp-transport.test.ts@@ -164,6 +164,14 @@ describe('mapUpdate', () => {})describe('formatConnectionError', () => {+ const claudeAgent = {+ id: 'claude-code',+ name: 'Claude Code',+ command: 'claude-agent-acp',+ args: [],+ installCommand: 'npm i -g @agentclientprotocol/claude-agent-acp'+ } as const+test('ECONNREFUSED maps to MCP not running', () => {const msg = formatConnectionError(new Error('connect ECONNREFUSED 127.0.0.1:7600'))expect(msg).toBe('MCP server is not running. Make sure the editor is open.')@@ -179,6 +187,13 @@ describe('formatConnectionError', () => {expect(msg).toBe('MCP server did not respond in time.')})+ test('ENOENT maps to install instructions', () => {+ const msg = formatConnectionError(new Error('spawn claude-agent-acp ENOENT'), claudeAgent)+ expect(msg).toBe(+ '"claude-agent-acp" is not installed. Install it with: npm i -g @agentclientprotocol/claude-agent-acp'+ )+ })+test('other errors pass through', () => {const msg = formatConnectionError(new Error('Something unexpected'))expect(msg).toBe('Something unexpected')