Commit graph

871 commits

Author SHA1 Message Date
Anton A S 6d3e2d20cd Scope checklist: marquee in scope, layer panel sync, delete locked guard, undo/redo validation, tests 2026-03-16 14:26:52 +03:00
Anton A S 1b743bec94 Add selection scope: enter containers with dblclick, exit with Escape or click-outside 2026-03-16 14:26:52 +03:00
Anton A S 19d6e01960 Fix double-click enter: offset coords to group-local space 2026-03-16 14:26:52 +03:00
Anton A S 01235c0d84 Fix group selection: single click selects group, double click enters, locked groups block enter 2026-03-16 14:26:52 +03:00
Anton A S 116acb5cfa Make lock/visibility icons more visible 2026-03-16 14:26:52 +03:00
Anton A S 6596702389 Fix lock: block move/resize/rotate for locked nodes, skip locked in marquee, improve toggle icon visibility 2026-03-16 14:26:52 +03:00
Anton A S bc85d73cc8 Add lock and visibility toggles to layers panel 2026-03-16 14:26:52 +03:00
Danila Poyarkov 7572d3a54e Add roundtrip tests for COLOR variable alpha handling
Co-authored-by: Shai Rubinstein <rubinsh@gmail.com>
2026-03-16 14:23:19 +03:00
Danila Poyarkov 1b6a75bd67 Update CHANGELOG with all changes since 0.10.0 2026-03-16 14:19:32 +03:00
Danila Poyarkov 9391ac0112 Fix save crash when COLOR variable is missing alpha
Reuse safeColor() (which defaults a ?? 1) in the variable export
path. The Kiwi schema requires all Color struct fields — variables
created without explicit alpha caused 'Missing required field a'.

Fixes #128
2026-03-16 14:17:28 +03:00
Danila Poyarkov 8d7dd0a36b Add random.ts helpers, replace all raw crypto.getRandomValues calls
New module packages/core/src/random.ts with randomHex, randomInt,
randomIndex — centralizes all crypto-based randomness.

Replaces:
- Date.now() IDs in VariablesDialog (not unique, not random)
- Hand-rolled hex token in automation/server.ts
- Inline crypto.getRandomValues in clipboard.ts, use-collab.ts

Also adds --color-component Tailwind theme color (#9747ff) and
replaces all 6 hardcoded occurrences across DesignPanel, LayerTree,
NodeContextMenuContent, and menu.ts.
2026-03-16 14:13:36 +03:00
Danila Poyarkov 921d2d35c5 Export IS_BROWSER from core, replace all raw typeof window checks
- Add IS_BROWSER constant to core/constants.ts, rewrite IS_TAURI to use it
- Replace 9 raw 'typeof window' checks across canvaskit, fig-export,
  figma-api, fig-file, fonts, SafariBanner, use-chat
- Promote no-typeof-window-check lint rule from warn to error
- Extract array mutation helpers (updateArrayItem, removeArrayItem,
  toggleArrayVisibility) into useMultiProps — DRY up FillSection and
  StrokeSection (removes 20+ duplicated for-loops)
2026-03-16 14:05:24 +03:00
Danila Poyarkov c06ed32990 Harden linting: add eqeqeq, prefer-const, radix, no-console, no-typeof-window-check
New built-in rules:
- eqeqeq (null-safe) — prevent loose equality coercions
- prefer-const — catch unused let declarations
- radix — require parseInt radix parameter
- no-console — warn on console.log in app code (CLI/MCP exempted)

New custom rule:
- no-typeof-window-check — flag raw typeof window checks, prefer
  IS_BROWSER/IS_TAURI constants (warn-level, constants.ts + fonts.ts
  exempted)

Fix 4 violations caught by new rules.
2026-03-16 13:54:07 +03:00
Danila Poyarkov 283b836d50 Add unit tests for font helpers: isVariableFont, normalizeFontFamily, styleToVariant, fetchBundledFont
21 new tests covering:
- normalizeFontFamily: Variable suffix stripping, edge cases
- styleToVariant: all weight→Google variant mappings
- isVariableFont: fvar table detection with synthetic TTF buffers
- fetchBundledFont: headless asset resolution, TTF magic validation
2026-03-16 13:40:16 +03:00
Danila Poyarkov 15f80d6d62 Refactor font loading: DRY up local font lookup, fix headless fallback
- Merge loadLocalFont + tryLoadLocalFont into findLocalFont with
  optional style param — eliminates duplicated queryLocalFonts logic
  and adds consistent variable font filtering for CJK fallback
- Replace nested ternary font matching with a simple loop over
  family name candidates
- Extract fetchBundledFont helper for browser/Node font resolution
- Ship Inter-Regular.ttf in packages/core/assets so headless CLI
  can resolve the bundled fallback via import.meta.url instead of
  fetch('/') which fails in Node/Bun (fixes #121 scenario)
- Use IS_BROWSER constant instead of repeating typeof window checks
2026-03-16 13:38:16 +03:00
Danila Poyarkov 2cb83c5582 Simplify set_layout HUG default condition
When wasNone is true, args.direction is guaranteed truthy (we early-return
otherwise), so the extra args.direction check is redundant.
2026-03-16 13:28:17 +03:00
Danila Poyarkov b3d3c0a00b Use collab injection in MobileHud instead of prop drilling
MobileHud now uses useCollabInjected() directly — same pattern as
CollabPanel — and handles share/join/disconnect internally.

Removes broken event handlers that were never defined in EditorView.
2026-03-16 13:27:17 +03:00
Danila Poyarkov 6a40e4e3e3 Disable automation WebSocket in production web app
Only connect to the local automation bridge in Tauri desktop or
local dev, matching the existing spawnMCPIfNeeded guard.

Fixes #126
2026-03-16 13:27:17 +03:00
rubinsh a8fc8f1ea8
fix(set_layout): default to HUG sizing when enabling auto-layout (#125)
* fix(set_layout): default to HUG sizing when enabling auto-layout

When `set_layout` transitions a frame from `layoutMode: 'NONE'` to
auto-layout, it now sets `primaryAxisSizingMode` and
`counterAxisSizingMode` to `'AUTO'` (which maps to HUG internally).

Previously these remained at `'FIXED'`, causing the frame to keep its
original dimensions instead of shrinking/growing to fit children. This
made `h="hug"`, `justify="end"`, and `grow={1}` appear broken when
containers were created via the `set_layout` MCP tool (as opposed to
the JSX `render` path, which already defaulted to HUG).

The fix only applies when `direction` is provided and the frame was
previously in `layoutMode: 'NONE'` — updating spacing or alignment on
an existing auto-layout frame does not reset sizing modes.

* docs: add changelog entry for set_layout HUG sizing fix
2026-03-16 13:27:02 +03:00
Danila Poyarkov 63e204fc71 Fix CI: use npm vue-stream-markdown instead of local link 2026-03-15 19:37:31 +03:00
Danila Poyarkov f4c68f7f41 Release v0.10.0 2026-03-15 19:27:37 +03:00
Danila Poyarkov 21996096e8 Merge acp-research: ACP agent support, MCP server refactor 2026-03-15 18:46:46 +03:00
Danila Poyarkov 12d3b60e69 Clean up ACP branch: gate debug log, fix capitalizations, harden types
- Gate acpDebugLog behind import.meta.env.DEV (no logging in production)
- Remove saveAcpDebugLog (Desktop hardcode) — clipboard copy is sufficient
- Hide ACP log button unless in DEV mode with entries
- Fix textFromContent: proper type guards instead of unsafe casts
- Fix trailing empty line in server.ts handleBrowserMessage
- Rename Acp → ACP, Mcp → MCP in all identifiers:
  AcpPermissionDialog → ACPPermissionDialog (file + component)
  AcpDebugEntry → ACPDebugEntry
  spawnMcpIfNeeded → spawnMCPIfNeeded
  checkMcpHealth → checkMCPHealth
  McpContent/McpResult/McpTransport → MCPContent/MCPResult/MCPTransport
  createMcpSession → createMCPSession
2026-03-15 18:24:37 +03:00
Anton A S 63f3ef3755 Show agent name in model selector for ACP, fix model dropdown, update docs 2026-03-15 18:13:29 +03:00
Anton A S 55ba13b43b Use full system prompt for ACP agents instead of short context 2026-03-15 18:06:15 +03:00
Anton A S 6fcb29686d Save ACP debug log to Desktop, keep last 5 minutes 2026-03-15 17:47:32 +03:00
Anton A S 83f7c53fee Add ACP debug log with copy button in chat toolbar 2026-03-15 17:45:14 +03:00
Anton A S 206cb3742f Debug: log ACP session updates 2026-03-15 17:42:50 +03:00
Anton A S aaae074223 Fix ACP settings: show stock keys for all providers, always show Clear button 2026-03-15 17:42:01 +03:00
Anton A S a76d20b27b Fix ACP agent commands: claude-agent-acp, remove stale ts-expect-error 2026-03-15 17:06:57 +03:00
Anton A S 583b03eb3b Harden ACP transport, MCP server, and add permission dialog
- Extract mapUpdate to testable module, dynamic import for @tauri-apps/plugin-shell
- Add warnings for unhandled ACP content types and empty tool titles
- MCP server: session limit (max 10), fix null WS comparison, guard JSX preprocessing
- MCP server: read version from package.json instead of hardcoded 0.0.0
- MCP tests: use port 0 (OS-assigned) to prevent collision
- Connection error handling with user-friendly messages, stale session recovery
- Agent crash detection via close handler, destroying flag, buildCrashChunks
- Port collision: detect EADDRINUSE in vite-plugin stderr and log clear error
- Production Tauri: spawn openpencil-mcp via shell plugin, orphan reuse via health check
- Permission confirmation dialog (reka-ui AlertDialog) with queue, 60s auto-reject timeout
- Health check in ProviderSelect hides ACP agents when MCP server unavailable
- Move DESIGN_CONTEXT to app constants, add ACP_PERMISSION_TIMEOUT_MS
- 36 tests across 3 files (acp-transport, acp-permission, mcp-server)
- Update CHANGELOG, README, CONTRIBUTING, AGENTS.md
2026-03-15 16:49:43 +03:00
Danila Poyarkov dfb050538c Spawn MCP server as subprocess instead of SSR module
Replace ssrLoadModule hack with simple child_process.spawn.
Same approach as production (Tauri sidecar) — just run the MCP
server entry point directly. No re-evaluation on HMR, no
WebSocket reconnect storms, no globalThis guards.
2026-03-15 16:42:49 +03:00
Danila Poyarkov 2aa6d7f607 Fix bridge loading: use ssrLoadModule for workspace TS resolution 2026-03-15 16:42:48 +03:00
Danila Poyarkov 1092e6b9f5 Unify MCP server: always proxy to live editor via WebSocket
Remove headless SceneGraph mode — the MCP server now always proxies
tool calls to the browser via WebSocket. One server, one architecture:

  HTTP :7600 — /health, /rpc (CLI), /mcp (MCP Streamable HTTP)
  WS   :7601 — browser connects, executes tool calls against live editor

- Delete http.ts (merged into server.ts)
- Delete headless SceneGraph, open_file, save_file, new_document
- Delete canvaskit-wasm dependency (no headless rendering)
- Add ws dependency for WebSocket server
- Rewrite tests with mock browser over real HTTP+WebSocket
- Simplify bridge.ts to 6 lines (just imports and starts the server)
2026-03-15 16:42:46 +03:00
Danila Poyarkov 5641554ab7 Clean up automation bridge: direct imports, upgrade zod to v4
- Replace ssrLoadModule hacks with direct imports from @open-pencil/core
- Replace isBunRuntime() hack with @hono/node-server (works everywhere)
- Remove ViteServer type parameter from startAutomationBridge
- Upgrade @open-pencil/mcp zod dependency from v3 to v4
- Add @open-pencil/mcp as root devDependency for bridge imports
2026-03-15 16:40:41 +03:00
Danila Poyarkov fea1f4f95d Fix MCP bridge SSR module resolution
ssrLoadModule('@open-pencil/mcp') fails because Vite can't resolve
workspace TypeScript packages. Use relative path to source instead.
2026-03-15 16:40:39 +03:00
Danila Poyarkov 3d098b8a13 Remove shiki shim — handled by forked vue-stream-markdown
The fork inlines shiki stubs at build time, so consumers no longer
need to alias shiki to a shim.
2026-03-15 16:40:38 +03:00
Danila Poyarkov 4f0c11e275 Export shiki stubs from shim to prevent undefined destructuring
The shim must export everything vue-stream-markdown destructures
from import('shiki'): bundledThemesInfo, bundledLanguagesInfo,
createHighlighter. A throwing shim causes the import to succeed
but all named exports to be undefined.
2026-03-15 16:40:37 +03:00
Danila Poyarkov 758ddde8d8 Fix ACP stop button: close stream immediately on abort
The cancel request was sent to the agent but the stream stayed open
until prompt() resolved, leaving the UI in streaming state. Now the
stream closes immediately with a finish chunk, guarded against
double-close from the concurrent prompt resolution.
2026-03-15 16:40:36 +03:00
Danila Poyarkov ace8c26f2e Use forked vue-stream-markdown with shiki optional chaining fix
Replace npm vue-stream-markdown with open-pencil fork that guards
bundledThemesInfo/bundledLanguagesInfo with ?. to prevent TypeError
when shiki is not installed. Revert shiki shim and cdn-options hacks.
2026-03-15 16:40:35 +03:00
Danila Poyarkov 660bb3aab6 Fix shiki shim: export stubs instead of throwing
The throwing shim caused hasShikiModule() to return false, but
import('shiki') still resolved in some code paths where the module
was imported directly without the has-check, causing undefined
destructuring and the 'e.find' TypeError.
2026-03-15 16:40:33 +03:00
Danila Poyarkov 1a86f3fa16 Remove packages/acp and its tests
Redundant — the MCP server already provides external tool access.
The desktop app uses acp-transport.ts (ACP client) + automation
bridge MCP endpoint instead of the standalone ACP agent.
2026-03-15 16:40:32 +03:00
Danila Poyarkov 19505665f5 Add ACP transport unit tests for mapUpdate chunk mapping
Tests cover: text deltas (empty skip, start/continue), reasoning
chunks, tool call lifecycle (input/output/error), title fallback,
and unhandled update types.
2026-03-15 16:40:31 +03:00
Danila Poyarkov ba31fe7920 Add tests for MCP server makeFigma option
Test that external FigmaAPI skips file lifecycle tools and allows
tool execution without loading a document first.
2026-03-15 16:40:30 +03:00
Danila Poyarkov b71a3523d2 Inject design context into first ACP prompt
Without context, the agent uses its own file/terminal tools instead
of the MCP design tools. Prepend instructions on the first message
telling it to use open-pencil MCP tools to draw on the canvas.
2026-03-15 16:40:28 +03:00
Danila Poyarkov ff78d8d57b Bridge MCP server to live editor via automation WebSocket
ACP agents now get an MCP server at http://127.0.0.1:7600/mcp that
proxies tool calls through the automation WebSocket to the browser,
where they execute against the live editor store. No separate
subprocess, no stale npm package — tools operate on the open canvas.

- Add /mcp endpoint to automation bridge (Streamable HTTP transport)
- Each MCP tool call → sendToBrowser({command:'tool'}) → browser executes
- Strip mcp__open-pencil__ prefix from tool names in chat UI
- Export paramToZod from MCP package for bridge reuse
2026-03-15 16:40:27 +03:00
Danila Poyarkov e79fb5ac5d Connect ACP agents to OpenPencil MCP tools
Pass openpencil-mcp as a stdio MCP server to the ACP session so
agents get all design tools (create shapes, render JSX, export
images, etc.) instead of just plain conversation.

- Add makeFigma option to createServer for external FigmaAPI injection
- Skip file lifecycle tools (open/save/new) when using external FigmaAPI
- Pass MCP server config in ACP newSession mcpServers
- Add bun to Tauri shell scope for MCP server subprocess
2026-03-15 16:40:26 +03:00
Danila Poyarkov f02bd84aec Fix ACP transport: Uint8Array conversion, empty deltas, shiki error
- Convert Tauri shell stdout data (number[]) to Uint8Array for
  ndJsonStream compatibility
- Skip empty text deltas from agent_message_chunk
- Disable shiki CDN in Markdown component (not installed, caused
  'e.find' TypeError on inline code)
- Remove debug console.log statements
2026-03-15 16:40:24 +03:00
Danila Poyarkov 2109bd6605 Fix ACP shell scope config and surface connection errors
- Add scoped command definitions for claude-code-acp, codex-acp, gemini
  in Tauri shell plugin capabilities (required for Command.create)
- Show error banner in ChatPanel when transport initialization fails
  instead of silently swallowing the error
2026-03-15 16:40:23 +03:00
Danila Poyarkov 7adac1b270 Fix lint errors in ACP transport and merge master 2026-03-15 16:40:22 +03:00