* Add multi-provider AI support (Anthropic, OpenAI, Google AI, OpenAI-compatible)
- Add AI_PROVIDERS registry with per-provider model lists, key placeholders, and URLs
- Refactor use-chat composable: provider factory creates the right AI SDK model
- Per-provider API key storage in localStorage with automatic legacy migration
- New ProviderSetup.vue replaces APIKeySetup.vue with provider selector
- New ProviderSettings.vue popover accessible from gear icon in chat input
- OpenAI-compatible provider with custom base URL and model ID fields
- Install @ai-sdk/anthropic and @ai-sdk/google dependencies
- Update E2E tests for new provider setup flow
* Fix reactivity, key masking, missing model ID field, and chat reset on model change
- Use ref instead of computed for apiKey — computed getter over localStorage
wasn't triggering reactivity when the key was set
- Load stored key for new provider in providerId watcher
- Reset chat on modelId and customModelId change, not just provider switch
- Add custom model ID field to ProviderSetup.vue for OpenAI-compatible
- Simplify ProviderSettings key field — empty input with contextual placeholder
instead of fragile dot-masking that broke on partial edits
- Use data-test-id locator for model selector in E2E test
* Use useLocalStorage from vueuse instead of manual ref + watch + localStorage
Replaces 5 hand-rolled ref/watch/localStorage sync pairs with useLocalStorage.
API key uses a computed storage key that rebinds when the provider changes.
* Use useLocalStorage for collab name persistence
* Review fixes: changelog placement, remove dead class, cursor-pointer
* Extract ProviderSelect component and uiInput helper
- ProviderSelect.vue: shared select dropdown for AI providers
- ui/input.ts: shared input styling (sm/md sizes)
- Remove 7 duplicated input class strings across chat components
* Use uppercase acronyms: keyURL, customBaseURL, supportsCustomBaseURL
* Match select dropdown width to trigger via --reka-select-trigger-width
Move min-w-[var(--reka-select-trigger-width)] into selectContent base
style so all selects get it by default. Remove per-component overrides.
* Uppercase acronyms in variable names, improve setup form layout
- providerID, modelID, customModelID, setAPIKey, AIProviderID
- Keep apiKey lowercase at start (standard JS convention)
- Compact setup form: single column, full-width Connect button
- Fix grammar: 'a OpenRouter' → 'an OpenRouter'
- Shorter promo text
* Allow text selection in chat panel
* Fix chat E2E test: Save → Connect button text
* Disable mermaid in chat markdown renderer
Alias mermaid and beautiful-mermaid to empty shims in Vite config,
preventing vue-stream-markdown from attempting to load them.
* Interleave text and tool calls in chat messages
Render message parts in order instead of grouping all tool calls
first then all text. Use SDK's isToolUIPart/isTextUIPart/getToolName
instead of custom type guards. Fix error state: output-error, not error.
* Implement figma.viewport.scrollAndZoomIntoView()
Figma Plugin API method that centers the viewport on given nodes.
Reuses the same bounding box logic as the viewport_zoom_to_fit tool.
* Catch tool execution errors and return them to the AI
Instead of crashing with an unhandled exception, tool errors are
caught and returned as { error: message } so the AI can retry or
explain the failure. UI detects error outputs and shows them in red
with the error message when expanded.
* Replace esbuild with sucrase for JSX transform
Sucrase is a pure JS transform (201 KB / 46 KB gzip) that works in
both Node/Bun and the browser. Replaces esbuild (13 MB WASM) which
only worked in Node/Bun.
- buildComponent() and renderJSX() are now synchronous
- render tool works in browser AI chat (no more 'esbuild required')
- Handles full JS expressions (map, ternaries, Array.from, etc.)
* Update system prompt to prioritize render tool with JSX
Document available tags, props, layout, text, and sizing options.
Instruct the AI to use full JS expressions in JSX for complex layouts.
* Fix zoom shortcuts to match Figma
Cmd+0: Zoom to 100% (was incorrectly mapped to Zoom to fit)
Cmd+1: Zoom to fit
Cmd+2: Zoom to selection
Shift+1 / Shift+2: same as Cmd+1 / Cmd+2
Add zoomTo100() and zoomToSelection() to editor store.
Refactor zoomToFit() to use shared zoomToBounds() helper.
* Refactor keyboard shortcuts to useMagicKeys
Replace manual keydown handler with VueUse useMagicKeys + whenever
for declarative shortcut registration.
- mod() helper for cross-platform Meta/Control shortcuts
- plain() helper for modifier-free keys
- Proper modifier exclusion (⌘G vs ⌘⇧G no longer conflict)
- Add E2E tests: duplicate, zoom (⌘0/⌘1/⌘2/⇧1/⇧2), auto-layout (⇧A)
- All 26 keyboard shortcut tests pass
* Fix scrollAndZoomIntoView to actually zoom
Match Figma Plugin API behavior (equivalent to Shift-1): compute
zoom level that fits all nodes with padding, capped at 100%.
Previously only set center without adjusting zoom.
338 lines
9.2 KiB
TypeScript
338 lines
9.2 KiB
TypeScript
import { expect, test, type Page } from '@playwright/test'
|
|
|
|
import { CanvasHelper } from '../helpers/canvas'
|
|
|
|
let page: Page
|
|
let canvas: CanvasHelper
|
|
|
|
test.describe.configure({ mode: 'serial' })
|
|
|
|
test.beforeAll(async ({ browser }) => {
|
|
page = await browser.newPage()
|
|
await page.goto('/')
|
|
canvas = new CanvasHelper(page)
|
|
await canvas.waitForInit()
|
|
})
|
|
|
|
test.afterAll(async () => {
|
|
await page.close()
|
|
})
|
|
|
|
function getActiveTool() {
|
|
return page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.activeTool)
|
|
}
|
|
|
|
function getSelectedCount() {
|
|
return page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.selectedIds.size)
|
|
}
|
|
|
|
function getPageChildren() {
|
|
return page.evaluate(() => {
|
|
const store = window.__OPEN_PENCIL_STORE__!
|
|
return store.graph.getChildren(store.state.currentPageId).map((n) => ({
|
|
id: n.id,
|
|
type: n.type,
|
|
name: n.name,
|
|
childIds: n.childIds
|
|
}))
|
|
})
|
|
}
|
|
|
|
function getUIVisible() {
|
|
return page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.showUI)
|
|
}
|
|
|
|
test.describe('tool switching', () => {
|
|
test('V → SELECT', async () => {
|
|
await page.keyboard.press('v')
|
|
expect(await getActiveTool()).toBe('SELECT')
|
|
})
|
|
|
|
test('R → RECTANGLE', async () => {
|
|
await page.keyboard.press('r')
|
|
expect(await getActiveTool()).toBe('RECTANGLE')
|
|
})
|
|
|
|
test('O → ELLIPSE', async () => {
|
|
await page.keyboard.press('o')
|
|
expect(await getActiveTool()).toBe('ELLIPSE')
|
|
})
|
|
|
|
test('F → FRAME', async () => {
|
|
await page.keyboard.press('f')
|
|
expect(await getActiveTool()).toBe('FRAME')
|
|
})
|
|
|
|
test('T → TEXT', async () => {
|
|
await page.keyboard.press('t')
|
|
expect(await getActiveTool()).toBe('TEXT')
|
|
})
|
|
|
|
test('L → LINE', async () => {
|
|
await page.keyboard.press('l')
|
|
expect(await getActiveTool()).toBe('LINE')
|
|
})
|
|
|
|
test('P → PEN', async () => {
|
|
await page.keyboard.press('p')
|
|
expect(await getActiveTool()).toBe('PEN')
|
|
})
|
|
|
|
test('H → HAND', async () => {
|
|
await page.keyboard.press('h')
|
|
expect(await getActiveTool()).toBe('HAND')
|
|
})
|
|
|
|
test('S → SECTION', async () => {
|
|
await page.keyboard.press('s')
|
|
expect(await getActiveTool()).toBe('SECTION')
|
|
})
|
|
})
|
|
|
|
test.describe('selection shortcuts', () => {
|
|
test('⌘A selects all', async () => {
|
|
await page.keyboard.press('v')
|
|
await canvas.drawRect(100, 100, 60, 60)
|
|
await canvas.drawRect(200, 100, 60, 60)
|
|
|
|
await page.keyboard.press('Meta+a')
|
|
expect(await getSelectedCount()).toBe(2)
|
|
})
|
|
|
|
test('Escape clears selection and resets to SELECT tool', async () => {
|
|
await page.keyboard.press('Escape')
|
|
expect(await getSelectedCount()).toBe(0)
|
|
expect(await getActiveTool()).toBe('SELECT')
|
|
})
|
|
|
|
test('Backspace deletes selected', async () => {
|
|
await canvas.selectAll()
|
|
const beforeCount = await getSelectedCount()
|
|
expect(beforeCount).toBeGreaterThan(0)
|
|
|
|
await page.keyboard.press('Backspace')
|
|
await canvas.waitForRender()
|
|
|
|
const children = await getPageChildren()
|
|
expect(children).toHaveLength(0)
|
|
})
|
|
})
|
|
|
|
test.describe('z-order shortcuts', () => {
|
|
test('] brings to front', async () => {
|
|
await canvas.drawRect(100, 100, 60, 60)
|
|
await canvas.drawRect(100, 100, 60, 60)
|
|
|
|
const childrenBefore = await getPageChildren()
|
|
const firstId = childrenBefore[0].id
|
|
|
|
// Select the first (bottom) node
|
|
await page.evaluate((id) => {
|
|
window.__OPEN_PENCIL_STORE__!.select([id])
|
|
}, firstId)
|
|
await canvas.waitForRender()
|
|
|
|
await page.keyboard.press(']')
|
|
await canvas.waitForRender()
|
|
|
|
const childrenAfter = await getPageChildren()
|
|
expect(childrenAfter[childrenAfter.length - 1].id).toBe(firstId)
|
|
})
|
|
|
|
test('[ sends to back', async () => {
|
|
const children = await getPageChildren()
|
|
const lastId = children[children.length - 1].id
|
|
|
|
// Select the last (top) node
|
|
await page.evaluate((id) => {
|
|
window.__OPEN_PENCIL_STORE__!.select([id])
|
|
}, lastId)
|
|
await canvas.waitForRender()
|
|
|
|
await page.keyboard.press('[')
|
|
await canvas.waitForRender()
|
|
|
|
const after = await getPageChildren()
|
|
expect(after[0].id).toBe(lastId)
|
|
})
|
|
})
|
|
|
|
test.describe('group/ungroup shortcuts', () => {
|
|
test('⌘G groups selection', async () => {
|
|
await canvas.selectAll()
|
|
expect(await getSelectedCount()).toBeGreaterThanOrEqual(2)
|
|
|
|
await page.keyboard.press('Meta+g')
|
|
await canvas.waitForRender()
|
|
|
|
const children = await getPageChildren()
|
|
const group = children.find((c) => c.type === 'GROUP')
|
|
expect(group).toBeTruthy()
|
|
expect(group!.childIds.length).toBeGreaterThanOrEqual(2)
|
|
})
|
|
|
|
test('⌘⇧G ungroups', async () => {
|
|
await page.keyboard.press('Meta+Shift+g')
|
|
await canvas.waitForRender()
|
|
|
|
const children = await getPageChildren()
|
|
expect(children.every((c) => c.type !== 'GROUP')).toBe(true)
|
|
})
|
|
})
|
|
|
|
test.describe('UI toggles', () => {
|
|
test('⌘\\ toggles UI visibility', async () => {
|
|
const before = await getUIVisible()
|
|
|
|
await page.keyboard.press('Meta+\\')
|
|
await canvas.waitForRender()
|
|
|
|
const after = await getUIVisible()
|
|
expect(after).toBe(!before)
|
|
|
|
// Restore
|
|
await page.keyboard.press('Meta+\\')
|
|
await canvas.waitForRender()
|
|
expect(await getUIVisible()).toBe(before)
|
|
})
|
|
})
|
|
|
|
test.describe('duplicate', () => {
|
|
test('⌘D duplicates selection', async () => {
|
|
await canvas.clearCanvas()
|
|
await canvas.drawRect(100, 100, 60, 60)
|
|
await canvas.selectAll()
|
|
expect(await getSelectedCount()).toBe(1)
|
|
|
|
await page.keyboard.press('Meta+d')
|
|
await canvas.waitForRender()
|
|
|
|
const children = await getPageChildren()
|
|
expect(children).toHaveLength(2)
|
|
})
|
|
})
|
|
|
|
test.describe('zoom shortcuts', () => {
|
|
test('⌘0 zooms to 100%', async () => {
|
|
await canvas.clearCanvas()
|
|
await canvas.drawRect(100, 100, 60, 60)
|
|
|
|
// Set zoom to something other than 100%
|
|
await page.evaluate(() => {
|
|
const store = window.__OPEN_PENCIL_STORE__!
|
|
store.state.zoom = 2
|
|
})
|
|
await canvas.waitForRender()
|
|
|
|
await page.keyboard.press('Meta+0')
|
|
await canvas.waitForRender()
|
|
|
|
const zoomAfter = await page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.zoom)
|
|
expect(zoomAfter).toBe(1)
|
|
})
|
|
|
|
test('⌘1 zooms to fit', async () => {
|
|
await page.keyboard.press('Meta+1')
|
|
await canvas.waitForRender()
|
|
|
|
const zoom = await page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.zoom)
|
|
expect(zoom).toBeGreaterThan(0)
|
|
expect(zoom).toBeLessThanOrEqual(1)
|
|
})
|
|
|
|
test('⌘2 zooms to selection', async () => {
|
|
await canvas.selectAll()
|
|
|
|
await page.keyboard.press('Meta+2')
|
|
await canvas.waitForRender()
|
|
|
|
const zoom = await page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.zoom)
|
|
expect(zoom).toBeGreaterThan(0)
|
|
expect(zoom).toBeLessThanOrEqual(1)
|
|
})
|
|
|
|
test('⇧1 zooms to fit (same as ⌘1)', async () => {
|
|
await page.keyboard.press('Shift+1')
|
|
await canvas.waitForRender()
|
|
|
|
const zoom = await page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.zoom)
|
|
expect(zoom).toBeGreaterThan(0)
|
|
expect(zoom).toBeLessThanOrEqual(1)
|
|
})
|
|
|
|
test('⇧2 zooms to selection (same as ⌘2)', async () => {
|
|
await canvas.selectAll()
|
|
|
|
await page.keyboard.press('Shift+2')
|
|
await canvas.waitForRender()
|
|
|
|
const zoom = await page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.zoom)
|
|
expect(zoom).toBeGreaterThan(0)
|
|
expect(zoom).toBeLessThanOrEqual(1)
|
|
})
|
|
})
|
|
|
|
test.describe('undo/redo', () => {
|
|
test('⌘Z undoes last action', async () => {
|
|
await canvas.clearCanvas()
|
|
await canvas.drawRect(100, 100, 60, 60)
|
|
expect((await getPageChildren()).length).toBe(1)
|
|
|
|
await page.keyboard.press('Meta+z')
|
|
await canvas.waitForRender()
|
|
|
|
expect((await getPageChildren()).length).toBe(0)
|
|
})
|
|
|
|
test('⌘⇧Z redoes undone action', async () => {
|
|
await page.keyboard.press('Meta+Shift+z')
|
|
await canvas.waitForRender()
|
|
|
|
expect((await getPageChildren()).length).toBe(1)
|
|
})
|
|
})
|
|
|
|
test.describe('auto-layout shortcut', () => {
|
|
test('⇧A toggles auto-layout on frame', async () => {
|
|
await canvas.clearCanvas()
|
|
await canvas.drawRect(100, 100, 200, 200)
|
|
await canvas.selectAll()
|
|
|
|
// Change to frame type for auto-layout
|
|
await page.evaluate(() => {
|
|
const store = window.__OPEN_PENCIL_STORE__!
|
|
const nodes = [...store.state.selectedIds]
|
|
if (nodes[0]) store.updateNode(nodes[0], { type: 'FRAME' })
|
|
})
|
|
await canvas.waitForRender()
|
|
|
|
const layoutBefore = await page.evaluate(() => {
|
|
const store = window.__OPEN_PENCIL_STORE__!
|
|
const nodes = [...store.state.selectedIds]
|
|
return store.graph.getNode(nodes[0])?.layoutMode
|
|
})
|
|
expect(layoutBefore).toBe('NONE')
|
|
|
|
await page.keyboard.press('Shift+a')
|
|
await canvas.waitForRender()
|
|
|
|
const layoutAfter = await page.evaluate(() => {
|
|
const store = window.__OPEN_PENCIL_STORE__!
|
|
const nodes = [...store.state.selectedIds]
|
|
return store.graph.getNode(nodes[0])?.layoutMode
|
|
})
|
|
expect(layoutAfter).toBe('VERTICAL')
|
|
|
|
// Toggle off
|
|
await page.keyboard.press('Shift+a')
|
|
await canvas.waitForRender()
|
|
|
|
const layoutFinal = await page.evaluate(() => {
|
|
const store = window.__OPEN_PENCIL_STORE__!
|
|
const nodes = [...store.state.selectedIds]
|
|
return store.graph.getNode(nodes[0])?.layoutMode
|
|
})
|
|
expect(layoutFinal).toBe('NONE')
|
|
})
|
|
})
|