Skip to content

feat(canvas): action registry with ⌘K palette, main menu and editor shortcuts - #448

Merged
kgoedecke merged 16 commits into
mainfrom
kgoedecke/feat-cmd-k-action
Nov 9, 2026
Merged

kgoedecke merged 16 commits into
mainfrom
kgoedecke/feat-cmd-k-action

Conversation

@kgoedecke

Copy link
Copy Markdown
Collaborator

What

One registry of canvas commands (src/lib/actions/registry.ts) now drives four surfaces, so a command, its name and its key binding are written once:

  • Keyboard: dispatchActionKey, called first by the canvas page's keydown handler. ⌫, Esc, ↩/Tab and the arrow nudge keep their own handler.
  • ⌘K action palette (CommandPalette.tsx, on cmdk): searchable commands grouped by menu, each with its chord. Text that matches no command can go to the agent's composer as a prompt.
  • Main menu off the Doop mark in the top bar (MainMenu.tsx): File, Edit, View, Object, Text, Arrange, Help, with checks on toggles and greyed-out items when there's nothing to act on.
  • Shortcuts sheet on ⌃⇧? (ShortcutsSheet.tsx), searchable.

The agent composer moves from ⌘K to ⌘/ (works from inside fields) and to bare / outside fields.

New commands

  • Arrange: align (⌥A/H/D/W/V/S), tidy up (⌃⌥T), pack, distribute spacing (⌃⌥H/V) and distribute by edge. They work on frames and on layers inside a frame, one undo step each.
  • Object:
    • Group ⌘G, frame selection ⌥⌘G, ungroup ⇧⌘G / ⌘⌫ (wrap layers in a div and unwrap).
    • Add auto layout ⇧A: the space between layers becomes the flex gap and their margins along the flow are dropped, so nothing moves. Remove auto layout ⌥⇧A.
    • Flip ⇧H/⇧V, rotate 90°/180°, hide other layers, collapse layers ⌥L, remove fill ⌥/, bare ] / [ for front/back.
  • Edit:
    • Find ⌘F and find & replace ⌥⌘F across the page's frames (text nodes only; replace all is one undo step).
    • Copy/paste properties ⌥⌘C/⌥⌘V, paste over selection ⇧⌘V, paste to replace ⇧⌘R.
    • Select inverse ⇧⌘A, select matching layers ⌥⌘A, eyedropper ⌃C (Mac).
  • View: comment pins ⇧C, multiplayer cursors ⌥⌘, outline mode ⌘Y (Mac; a display-only stylesheet in each frame that never reaches saves or exports), ⌘\ for Hide UI, next/previous frame N/⇧N and Home/End, previous/next page PgUp/PgDn.
  • Text: create link ⇧⌘U, alignment ⌥⌘L/T/R/J, font size ⇧⌘. / ⇧⌘,, case changes.
  • File: place image ⇧⌘K, export ⇧⌘E, export to PDF, version history, new / duplicate canvas.

Notes

  • ⌘Y is outlines on a Mac and stays redo (Ctrl+Y) elsewhere. actionRegistry.test.ts fails if any binding is used twice on either platform, or clashes with a tool key.
  • A key whose command is disabled, or finds nothing to act on, is left to the browser.
  • Not included: keys pressed while focus is inside a frame are not passed to the registry, and the native desktop menus beyond View are unchanged.

Testing

  • New tests: actionRegistry, actionChords, arrange, groupLayers, findText. Full suite passes locally.
  • Driven in the browser against a dev server: ⌘K, main menu, align plus undo/redo, tidy up, find and replace all plus undo, ⌘Y, ⌘G / ⇧A / ⇧⌘G, ⌘/, N, ⌃⇧?.

🤖 Generated with Claude Code

…hortcuts

One registry of canvas commands drives the keyboard, the ⌘K action
palette, the main menu off the Doop mark and the ⌃⇧? shortcuts sheet.
Adds arrange (align, distribute, tidy up, pack), group / ungroup, auto
layout, flip and rotate, copy and paste properties, paste over / replace,
find and replace across frames, links, text alignment, case and size,
outline mode, comment pin and cursor toggles, and frame and page stepping.
The agent composer moves from ⌘K to ⌘/ (and / outside fields).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes reach the canvas editor's main command and editing workflows.

Fix grouping for direct body children before merging; it can rearrange the selected layers.

Findings

  1. P1 Grouping moves body children ▶
  2. P2 Extra frames escape Undo ▶

Summary

The PR puts canvas commands in one registry for keyboard shortcuts, the action palette, menus, and the shortcuts sheet.

  • Canvas commands now share one registry across the keyboard, menus, and shortcut list.
  • Canvas users can group, style, link, and reshape selected layers.
  • Selected frames and layers can line up and spread out across the canvas.
  • Canvas users can find and replace text across page frames.
  • Canvas users can switch views and move between frames and pages with commands.
  • The macOS menu bar now mirrors the canvas commands and their current state.
  • Keyboard shortcut hints now have a font for symbols missing from the regular web fonts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Registry[Action registry] --> Keyboard[Keyboard shortcuts]
  Registry --> Palette[Action palette]
  Registry --> MainMenu[Canvas main menu]
  Registry --> NativeMenu[macOS menu bar]
  Registry --> Sheet[Shortcuts sheet]
  Keyboard --> Commands[Canvas commands]
  Palette --> Commands
  MainMenu --> Commands
  NativeMenu --> Commands
  Commands --> Frames[Frame API and undo history]
  Commands --> Layers[Layer edits and frame runtime]
Loading

Reviews (12) · Last reviewed commit: "fix(canvas): find a layer's parent on th..." · Reviewed by Greptile

Comment thread src/lib/actions/edits.ts Resolved
Comment thread src/lib/frameClipboard.ts Resolved
Comment thread src/lib/frameClipboard.ts Resolved
Comment thread src/lib/layers.ts Resolved
Comment thread src/lib/actions/edits.ts Resolved
Comment thread src/lib/actions/findText.ts Resolved
Comment thread src/lib/actions/edits.ts Resolved
- Arranged layers move to the computed frame-space spots (`move` takes
  frame px, not parent-relative).
- Paste to replace keeps a frame until all its replacements land, takes
  back partial ones, and records create + delete as one ordered undo step.
- Grouping carries a flex parent's flow onto the wrapper; grid children
  are refused rather than rearranged.
- Remove auto layout writes an explicit block display, so class-supplied
  flex or grid goes too.
- Find and replace leaves text in locked layers alone, numbering intact.
- Select inverse of everything clears the selection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/history.ts Resolved
Comment thread src/lib/actions/edits.ts Resolved
Comment thread src/lib/frameClipboard.ts Resolved
…st edits

- Each replacement is recorded as a transfer (creates, then the delete):
  undo restores the original before removing its replacement and stops,
  retryable, if that fails.
- Copies a failed replacement could not take back stay in the undo step.
- Grouping and auto layout refuse to write when the frame changed while
  its layout was being read, since positional layer paths may have moved.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Record the whole replacement as one transfer (every create, then every
delete), so undo restores all originals before removing any replacement
and keeps the rest on the stack when a restore fails.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Adopts main's persistent view options (pixel grid, cursors, comment pins)
in place of this branch's session toggles: their chords (⇧', ⇧C, ⌘⌥\)
now live in the action registry, with a Pixel grid action in View, and
Stage's own key handler is gone. Stage-only test fixtures install the
registry's key dispatch through tests/fixtures/actionKeys.ts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/actions/edits.ts Resolved
Comment thread src/lib/actions/findText.ts Resolved
Comment thread src/lib/frameClipboard.ts Resolved
Comment thread src/lib/layers.ts Resolved
…le replacements

- Auto layout on a box clears only the margins between its children; the
  first child's leading and the last one's trailing margin stay.
- Create link wraps an image (or SVG and other contentless elements) in
  the link instead of appending an empty link inside it, and unlinks it.
- Find and replace matches with a case-insensitive regular expression on
  the original text, so offsets hold where lower-casing changes length.
- A paste to replace that lands after the canvas or history changed takes
  its replacements back instead of entering another canvas's history.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/actions/edits.ts Resolved
…by identity

- Off a Mac, either Ctrl or the Meta key is the mod key, as the canvas
  always read it; the strict Ctrl match broke ⌘-driven keys on Linux CI.
- Create link resolves every picked element before changing the document
  and returns their final paths, so wrapping one image cannot move the
  link onto an unpicked sibling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/layers.ts Resolved
Elements are linked outermost first; a picked child already inside its
parent's new link retargets that link instead of adding its own, and a
content wrap lifts the links it would otherwise enclose.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/layers.ts Resolved
…linked

A link wrapped around a box's content turns the links inside it into spans
that keep every attribute but the link-only ones, and a picked inner link
is followed to its span.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/layers.ts Resolved
A link inside SVG artwork becomes a `g` with its attributes, not an HTML
span the parser would move out of the SVG. Also pins a drawing-move test
assertion to the old scope's quoted value, so a random fresh scope that
happens to contain "old" cannot fail it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

kgoedecke and others added 3 commits November 9, 2026 13:52
Google's Inter and Geist Mono drop ⌘ ⌥ ⇧ ⌃, so mono shortcut hints fell
back to SF Mono's undersized glyphs. A 5 KB subset of the full Inter
('Doop Keys') now supplies the key symbols in every font stack, and the
main menu's hints use the UI font like the zoom menu. Menu separators get
6px either side, matching the menu padding.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The page sends File, Edit, View, Object, Text, Arrange and Help (labels in
its language, chords as key equivalents) and keeps enabled/checked state in
step; the shell keeps the app menu, Close Tab, the system edit items, Full
Screen and Window. Picks come back as app-menu events and keys keep the
canvas keyboard's rules. Older shells keep their fixed View menu.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…action

# Conflicts:
#	.context/RELEASE.md
#	desktop/src-tauri-chromium/Cargo.lock
#	desktop/src-tauri/Cargo.lock
#	desktop/src-tauri/src/main.rs
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/actions/edits.ts Resolved
Comment thread src/lib/history.ts Resolved
Comment thread src/lib/actions/registry.ts Resolved
… on replace, keep ⌘A claimed

Hide other layers, select inverse and grouping read a layer's parent off
its path, which stops at an #id, so a nested layer like #title counted as
a root: hiding hid the containers holding it. They now walk the layer tree.

Paste to replace rechecks each target once its replacements exist: one a
teammate edited meanwhile stays (its copies go), one deleted meanwhile
leaves plain copies, and the delete carries the checked updatedAt so the
server refuses a stale one, which then drops out of the undo step.

⌘A with everything already selected no longer falls through to the
browser's select-all.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke

Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/lib/actions/edits.ts Outdated
Comment on lines +323 to +324
const parent = placeOf(buildLayerTree(p.frame.html), p.selectors[0]!)?.parent
const style = await inheritedLayout(p.frame.id, parent?.selector ?? null)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Grouping moves body children

groupKeepingLayout now misses the real parent of layers directly inside body. buildLayerTree starts at the body's children, so placeOf returns no parent and inheritedLayout skips the layout read.

Grouping two direct children of a flex row puts them in an unstyled div, stacking them instead of keeping them side by side. Grid children also bypass the refusal. Use the actual body as the parent for these layout checks.

Comment thread src/lib/frameClipboard.ts Outdated
const now = live.get(target.id)
if (!now) leftovers.push(...created)
else if (now.updatedAt === target.updatedAt) done.push({ target: now, created })
else for (const f of created) api.deleteFrame(f.id).catch(console.error)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Extra frames escape Undo

When a teammate edits the target while copies are being created, this new branch deletes those copies with only catch(console.error) and leaves them out of done and leftovers. If a cleanup delete fails, the extra frames stay but Undo cannot remove them. The user must find and delete them by hand.

Await cleanup and add failed deletions to leftovers, as the partial-creation branch already does.

kgoedecke and others added 2 commits November 9, 2026 14:55
…cleanups undoable

Grouping layers directly inside body read no parent once parents came from
the layer tree, so a flex body's row was lost and grid bodies skipped the
refusal; the body is now their parent. Copies of a target a teammate edited
are now deleted before the undo step is recorded, and any that cannot be
stay in it, so Undo still removes them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
As a separate file, the font was one more request a page's load event
waited on once a hint drew a ⌘, and drawing browser tests timed out in
page.goto. A 5 KB woff2 rides in styles.css as a data URL instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kgoedecke
kgoedecke merged commit 1970798 into main Nov 9, 2026
19 of 22 checks passed
kitravee added a commit to kitravee/doop that referenced this pull request Nov 9, 2026
Resolves the conflicts with the action registry (doop-design#448): ⌘X stays with the
native cut event, which the registry does not bind, and copy keeps going
through copySelection in elementClipboard.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant