Skip to content

feat(artifacts): arrange frames on the canvas - #5273

Closed
shepherdjerred wants to merge 5 commits into
artifacts-canvasfrom
artifacts-canvas-arrange
Closed

shepherdjerred wants to merge 5 commits into
artifacts-canvasfrom
artifacts-canvas-arrange

Conversation

@shepherdjerred

@shepherdjerred shepherdjerred commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Why

M2 done-when: the layout survives a reload, and an agent publish during a drag loses neither change. Stacked on #5260 (the canvas camera, gestures and frames).

What

  • Select (click, Shift-click, marquee on empty canvas), drag (4 px threshold, pointer capture, edge auto-pan), eight resize handles (a fixed-viewport frame keeps its aspect; a responsive one resizes freely), 8 px grid snap (Alt disables), [ ] z-order ({ } to the ends), arrow nudge (Shift 10x), Delete from board behind a confirm (never the artifact), undo and redo (Mod+Z, Shift+Mod+Z), Esc cancels a drag.
  • The arrangement is a replicated document: the server's index plus an outbox of boards.applyOps ops; what is drawn is the index with the outbox applied on top. Saves are debounced 400 ms and flushed on pagehide with a keepalive request. A change from another actor merges by id, never moves the camera, and never disturbs a drag in progress (the draft is drawn over the document). A toast says "New frame: <title>" with a jump-to.
  • Undo entries record before and after for the touched frames and replay as ops against the board as it is now, so another actor's frames are left alone.
  • aria-live announcements for moves, resizes, order and removal.
  • Contract change (own commit, resize a frame through moveFrames): moveFrames entries take optional w and h. Nothing else could resize a frame after placement. Backward compatible; the domain merge, the e2e fake and their tests are updated. Approved by the manager. A server integration test (Postgres, extended tier) checks that a resize and a concurrent agent placeFrame both survive and that a move without a size keeps the resized size.
  • Speech-bubble comment mode (canvas and focused view): the cursor is a speech bubble whose tail tip is the hotspot (inline SVG data URI, crosshair fallback) on the canvas world and frames and on every viewer stage, including the overlay over an inert iframe; not over the toolbar, chips or sidebar. Pins are the same bubble with the tail tip on the anchor (lib/pin-shape.ts): filled for this version, hollow for another version, a clean dashed outline for an approximate position (replacing the serrated style), selected thicker with a glow; clustering is unchanged and the hit target is 26 x 30.
  • Toolbar restyled as Claude-style pills: tools (select V with a filled accent arrow, hand H, comment C) bottom centre; zoom, fit all and fit selection in a small pill bottom right. lucide icons, 20 px, 1.5 px stroke, 44 px targets on coarse pointers.
  • Cursor and pins are lucide's MessageCircle (path read from its icon data, so it cannot drift): cursor = the glyph with a white fill, accent stroke and white halo, hotspot on the tail tip, crosshair fallback; pins = the same silhouette at 28 px with the tail tip on the anchor (filled / hollow for another version / dashed for approximate).
  • Floating, collapsible comments (canvas and focused view): a card on the right, a bottom sheet on a phone; collapses to a pill with the icon, open count and a waiting dot; Shift+C toggles; remembered per viewer; a pin click, J/K or a new comment opens it on the thread; fit-all, fit-selection and reveal aim at what it leaves; aria-expanded/aria-controls, focus in and back, no animation.
  • Floating nav pill replaces the shell bar and page header on the canvas and focused view (full-bleed, ~90 px reclaimed): workspace switcher and Inbox as before, then title and actions (List view; or board > artifact, version select, Open raw), then keyboard and theme; a phone keeps the mark, title and an overflow menu. Inbox and outline keep the normal shell bar. No console-ui change was needed.
  • An open modal now owns Escape (the canvas/focused Escape binding used to stop a dialog from closing).
  • Visual nits from review: a selected frame has one ring (the chip is tinted, keyboard focus outlines the whole chip once).
  • Dialog: a native close event caused by its own close() no longer closes a dialog that was opened again in between (it made the delete confirm flaky).

Demo

Floating shell: canvas with the panel open, collapsed (full width again, the pill shows the count), the focused view, and a phone (pill above the tools, then the bottom sheet). For the before, compare the earlier shots below (full-width bars and a sidebar column):

canvas, panel open
canvas, panel collapsed
focused view
phone, collapsed
phone, bottom sheet

MessageCircle cursor (rendered at 4x) beside the pins and the toolbar icon it comes from:

cursor and pins

Toolbar (select, comment and hand active):

select
comment
hand

Speech-bubble cursor (Playwright cannot capture the OS cursor, so it is rendered at 4x) next to placed pins, then a recording of placing a pin in comment mode:

cursor and pins

comment-place.webm

Re-captured: fit-all with filled and dashed (approximate) pins, and the selected frame with one ring, plus keyboard focus on a chip:

pins
selected
chip focus

Marquee select, the selected frame with its eight handles, and an agent publish arriving mid-drag (the dragged frame stays under the pointer, a toast names the new frame, the camera does not move):

marquee
handles
mid-drag publish
after release

Recording of arranging a board, an agent publish arriving mid-drag, resize, undo, redo and z-order: arrange-tour.webm

Verification

  • bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts: green. Unit tests: snapping, marquee hit-testing and selection, the eight-handle resize with and without aspect, z-order steps, the undo stack (coalescing, redo clearing), history entries replayed against a board another actor changed, outbox coalescing, and merge-during-drag (an agent's frame arriving under a queued edit and a drag draft).
  • bun run test:e2e in packages/artifacts: green (185 tests) on desktop Chromium, mobile Chromium and WebKit. The comment spec checks the bubble's tail tip lands within 1.5 px of the click and that comment mode sets a url( cursor on the canvas and in the focused view and restores the normal one. The arrange spec covers drag with grid snap and Alt, reload persistence, fixed-aspect and free resize, an agent publish during a drag keeping both changes with the camera untouched, undo and redo, nudge as one undo, z-order without moving iframes, delete with confirm and undo, the pagehide flush, edge auto-pan, Esc cancel and axe.
  • Extended tier: bunx turbo run test:extended --filter=@shepherdjerred/artifacts green (70 tests, including the resize integration test); this PR touches src/domain and src/shared, which the Postgres suite does not exercise differently. The broad verify:extended over the whole lower stack was not run to completion.
  • Not verified (needs Jerred): real trackpad and iPad gestures (touch has no drag-to-arrange yet: one finger still pans), Firefox.
  • Live acceptance, ArgoCD and runtime layers: not applicable, nothing deployed.

🤖 Generated with Claude Code

https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

@greptile-apps

greptile-apps Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@shepherdjerred
shepherdjerred marked this pull request as ready for review November 26, 2026 19:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T21:53:01.369897Z 031d6f1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 470cbcd2cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +183 to +184
const merged = new Map(last.moves.map((move) => [move.artifactId, move]));
for (const move of op.moves) merged.set(move.artifactId, move);

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 Badge Preserve optional dimensions when coalescing frame moves

If a user resizes a frame and then nudges or moves it before the 400 ms save debounce expires, the later move replaces the entire earlier move record, dropping its w and h. Since useBoardLayout.apply also coalesces the local outbox, the frame immediately reverts to its original size and the resize is never saved. Merge the move fields while preserving earlier optional dimensions and page values when the later operation omits them.

Useful? React with 👍 / 👎.

Comment on lines +143 to +144
});
return ops;

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 Badge Restore the launch target when undoing its removal

On a board configured to launch a focused artifact, removing that frame through the canvas clears launch.artifactId in removeFrame. Undo restores the frame and order but never restores the launch target, because history records only frames and order. Thus removing the launch frame and immediately undoing still permanently changes how the board opens: subsequent visits show the canvas instead of the focused artifact. Capture the removal's launch change and restore it with a setLaunch operation during undo.

Useful? React with 👍 / 👎.

shepherdjerred and others added 3 commits November 26, 2026 11:58
Why
Resizing a frame on the canvas has no op: placeFrame sets the size once and
moveFrames only moves. A resize must merge under the row lock like a drag, so
an agent publish and a resize never refuse each other.

What
- `moveFrames` entries take optional `w` and `h`; omitted, the size is left
  alone, so existing callers are unchanged.
- The domain merge and the e2e fake apply them.

Verification
- bun test of src/domain and src/shared (new cases for the resize and for a
  zero width).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
Why
M2 done-when: layout survives a reload, and an agent publish during a drag
loses neither change.

What
- Select (click, Shift-click, marquee on empty canvas), drag with a 4 px
  threshold, pointer capture and edge auto-pan, eight resize handles (a
  fixed-viewport frame keeps its aspect, a responsive one resizes freely),
  8 px grid snap (Alt disables), `[` `]` z-order, arrow nudge (Shift 10x),
  Delete from board behind a confirm (never the artifact), undo and redo
  (Mod+Z, Shift+Mod+Z) over the applied ops. Esc cancels a drag.
- The arrangement is a replicated document: the server's index plus an outbox
  of `boards.applyOps` ops, drawn as the index with the outbox applied on
  top. Saves are debounced 400 ms and flushed on `pagehide` (a keepalive
  request). A change from another actor merges by id, never moves the camera
  and never disturbs a drag in progress (the draft is drawn over the
  document). A toast names a new frame, with a jump-to.
- Undo entries record before and after for the touched frames and replay as
  ops against the board as it is now, so another actor's frames are left alone.
- `aria-live` announcements for moves, resizes, order and removal.
- Dialog: a native `close` event from our own `close()` no longer closes a
  dialog reopened in between.

Verification
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts
- bunx turbo run test:extended --filter=@shepherdjerred/artifacts
- bun run test:e2e: desktop Chromium, mobile Chromium and WebKit, including
  the arrange spec (drag, snap, Alt, reload persistence, aspect and free
  resize, agent publish mid-drag, undo and redo, nudge, z-order, delete and
  undo, pagehide flush, edge auto-pan, Esc cancel, axe).
- Not run: real trackpad and iPad gestures.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
Why
Comment mode should look like commenting: the cursor is a speech bubble whose
tail tip is the hotspot, and the pin that lands is the same bubble with the
tail on the anchor. The serrated "approximate" pin and the doubled ring on a
selected frame's title bar read badly.

What
- `--ar-comment-cursor` (an inline SVG data URI, hotspot on the tail tip, with
  `crosshair` as the fallback) on the canvas world and frames, and on every
  `.ar-stage` in the focused view, including the overlay over an inert iframe.
  Not over the toolbar, chips or sidebar.
- `PinBubble` replaces the circular pin on the canvas and in the focused
  view: 26 x 30 bubble, thread number inside, tail tip on the anchor
  (`lib/pin-shape.ts`). Filled for this version, hollow for another version,
  a clean dashed outline for an approximate position, selected thicker with a
  glow. Clustering is unchanged.
- A selected frame's chip is tinted and the frame carries the one selection
  ring; keyboard focus outlines the whole chip once.
- E2E for comment-mode cursors moved with the pin specs into
  `comment.desktop.spec.ts` (helpers shared in `canvas-helpers.ts`).

Verification
- bunx turbo run build typecheck test lint test:extended --filter=@shepherdjerred/artifacts
- e2e on desktop Chromium and WebKit: canvas, comment (tail tip within 1.5 px
  of the click, computed cursor contains url( in comment mode on the canvas and
  in the focused view, normal when it ends), arrange and review specs.
- Not verified: the OS cursor itself (Playwright cannot capture it).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cd41cf57b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +24 to +27
{ key: "ArrowLeft", run: arrow(-1, 0) },
{ key: "ArrowRight", run: arrow(1, 0) },
{ key: "ArrowUp", run: arrow(0, -1) },
{ key: "ArrowDown", run: arrow(0, 1) },

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 Badge Suspend arrangement shortcuts while interacting with a live frame

When a video frame is activated, Canvas.activate keeps it selected and focuses its native <video controls> element, but these arrow bindings remain enabled. useShortcuts excludes only typing targets and open dialogs, so arrow keys on that video invoke nudge and persist unintended layout changes instead of remaining available for media interaction. Gate arrangement shortcuts while a frame is active, or exclude events originating within its interactive content, matching the active-frame exclusion already used for pointer arrangement.

Useful? React with 👍 / 👎.

Why
The toolbar should read like Claude's canvas toolbar: a white pill floating
at the bottom centre with large icon buttons, the active tool soft-tinted.

What
- Tool pill (bottom centre): select (MousePointer2, V; the arrow is filled in
  the accent colour while active), hand (H), then comment (MessageCircle, C),
  in groups separated by thin dividers. A group with no tools is not drawn,
  so the annotation tools can add theirs.
- Zoom out, percent, zoom in, fit all and fit selection move to a small
  second pill at the bottom right.
- lucide-react icons at 20 px and 1.5 px stroke, tooltips with the shortcut,
  `aria-pressed` on tool buttons, 40 px buttons and 44 px on coarse pointers.
- Tool state moves into `useToolModes`: select, hand and comment mode are
  exclusive, and `V` selects.

Verification
- bunx turbo run build typecheck test lint test:extended --filter=@shepherdjerred/artifacts
- bun run test:e2e: desktop Chromium, mobile Chromium and WebKit (155 tests)
  plus a new pill spec (V, H, C flip the pressed tool; zoom is in its own pill).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f96887e9e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +113 to +116
const ops = coalesceOps([...inflight.current, ...queued.current]);
if (ops.length === 0) return;
try {
await fetch(`${location.origin}/trpc/boards.applyOps`, {

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 Badge Preserve save ordering when flushing on page exit

If a save is still in flight when the user makes another edit and leaves the page, beacon() submits the newer operations concurrently with the original request. If the keepalive request reaches applyOpsLocked first, the original request can subsequently overwrite the final position with the older one. The server's row lock serializes arrival, not edit order, and absolute moves are idempotent but not commutative. Preserve ordering or add server-side sequencing so an older in-flight save cannot overwrite the exit flush.

Useful? React with 👍 / 👎.

function onKey(event: KeyboardEvent): void {
if (event.key === "Escape") finish(true);
}
globalThis.addEventListener("keydown", onKey);

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 Badge Cancel pointer sessions when their canvas unmounts

If the user presses F while dragging a selected frame, useCanvasKeys navigates to the focused view and unmounts the canvas before pointer release. Neither the attachGestures cleanup nor ResizeHandles ends its outstanding session, so finish() never stops this session's auto-pan loop or removes its global keydown listener. The animation loop continues after navigation, retaining the old canvas and potentially recomputing drafts every frame. End outstanding sessions with cancellation when their owning gesture layer or resize handles unmount.

Useful? React with 👍 / 👎.

@shepherdjerred
shepherdjerred marked this pull request as draft November 26, 2026 20:38
@shepherdjerred
shepherdjerred removed this pull request from stack #5283 November 26, 2026 21:13
…el and nav pill

Why
Comment mode should use the same glyph as the toolbar, the comments should not
take a column from the canvas, and the shell bar plus page header waste ~90 px
on the two views that need the space.

What
- Cursor and pins are lucide's `MessageCircle`, with the path read from its
  icon data (`lib/pin-shape.ts`, a test pins the path so a lucide update
  re-measures the tail tip). The cursor is the glyph with a white fill, an
  accent stroke and a white halo, installed as `--ar-comment-cursor` at
  startup, hotspot on the tail tip, `crosshair` fallback. Pins are the same
  silhouette at 28 px with the tail tip on the anchor: filled, hollow for
  another version, dashed for approximate.
- Comments are a floating card on the right (a bottom sheet on a phone) that
  collapses to a pill with the icon, the open count and a waiting dot. Shift+C
  toggles it (letters with Shift are now a different key in `shortcuts.ts`),
  the choice is remembered per viewer, and a pin click, J/K or a new comment
  opens it on the thread. While open, fit-all, fit-selection and reveal aim at
  what it leaves; the viewer narrows. `aria-expanded`, `aria-controls`, focus
  moves in and back, nothing animates.
- The canvas and the focused view are full-bleed. The shell bar and the page
  header are one floating pill at the top left (workspace switcher and Inbox,
  then the title and actions: List view, or board > artifact, the version
  select and Open raw, then keyboard and theme); a phone keeps the mark, the
  title and an overflow menu. Inbox and outline keep the shell bar. The focused
  view's comment-mode and viewport-width controls move to a bottom pill.
- An open modal now owns Escape (the global Escape binding used to prevent the
  dialog from closing on the canvas and focused routes).

Verification
- bunx turbo run build typecheck test lint test:extended --filter=@shepherdjerred/artifacts
- bun run test:e2e on desktop Chromium, mobile Chromium and WebKit, including a
  new shell spec (panel toggle by button and Shift+C with focus, pill count,
  persistence, pin click and new comment expand and scroll, fit-all clear of
  the panel, phone bottom sheet, no shell bar on canvas and focused routes,
  menus, axe) and updated specs (tail tip within 1.5 px, MessageCircle cursor).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
@shepherdjerred
shepherdjerred marked this pull request as ready for review November 26, 2026 21:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 031d6f1d41

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +46 to +48
if (collapsed)
return (
<button

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 Badge Preserve comment drafts when collapsing the panel

If a reviewer types a general comment or thread reply and clicks Hide comments to inspect the artifact, this early return unmounts the entire panel body. Composer stores its text in local state, so reopening the panel silently discards the draft; thread reply and edit state are also lost. Keep the panel contents mounted while collapsed, or lift their draft state outside the conditionally rendered subtree.

Useful? React with 👍 / 👎.

move({
s: camera.s,
x: sizeRef.current.width / 2 - (rect.x + rect.w / 2) * camera.s,
x: usable().width / 2 - (rect.x + rect.w / 2) * camera.s,

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 Badge Use the unobscured viewport for the reveal visibility check

With the desktop comments panel open, a frame or board pin can be inside the full viewport but hidden behind the panel. Although this change centers revealed targets within usable(), the preceding visibility check still calls visibleRect(camera, sizeRef.current) and returns early for those obscured targets. Consequently, selecting their threads or using Jump to does not bring them into view. Use the usable viewport dimensions for the visibility check as well as the destination.

Useful? React with 👍 / 👎.

@shepherdjerred
shepherdjerred marked this pull request as draft November 26, 2026 22:01
@shepherdjerred
shepherdjerred removed this pull request from stack #5291 November 26, 2026 23:54
@shepherdjerred

Copy link
Copy Markdown
Owner Author

Superseded by #5346 (canvas, arrangement and annotations replayed on top of #5331). The branch is kept for now.

shepherdjerred added a commit that referenced this pull request Nov 28, 2026
Why
M2 done-when: layout survives a reload, and an agent publish during a drag
loses neither change.

What
- Select (click, Shift-click, marquee on empty canvas), drag with a 4 px
  threshold, pointer capture and edge auto-pan, eight resize handles (a
  fixed-viewport frame keeps its aspect, a responsive one resizes freely),
  8 px grid snap (Alt disables), `[` `]` z-order, arrow nudge (Shift 10x),
  Delete from board behind a confirm (never the artifact), undo and redo
  (Mod+Z, Shift+Mod+Z) over the applied ops. Esc cancels a drag.
- The arrangement is a replicated document: the server's index plus an outbox
  of `boards.applyOps` ops, drawn as the index with the outbox applied on
  top. Saves are debounced 400 ms and flushed on `pagehide` (a keepalive
  request). A change from another actor merges by id, never moves the camera
  and never disturbs a drag in progress (the draft is drawn over the
  document). A toast names a new frame, with a jump-to.
- Undo entries record before and after for the touched frames and replay as
  ops against the board as it is now, so another actor's frames are left alone.
- `aria-live` announcements for moves, resizes, order and removal.
- Dialog: a native `close` event from our own `close()` no longer closes a
  dialog reopened in between.

Verification
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts
- bunx turbo run test:extended --filter=@shepherdjerred/artifacts
- bun run test:e2e: desktop Chromium, mobile Chromium and WebKit, including
  the arrange spec (drag, snap, Alt, reload persistence, aspect and free
  resize, agent publish mid-drag, undo and redo, nudge, z-order, delete and
  undo, pagehide flush, edge auto-pan, Esc cancel, axe).
- Not run: real trackpad and iPad gestures.

Folded in (from the same PR), each with its own Why/What/Verification in the
original history:
- feat(artifacts): resize a frame through moveFrames: `moveFrames` entries take
  optional `w` and `h` (omitted leaves the size alone); the domain merge and the
  e2e fake apply them, so a resize merges under the row lock like a drag.
- feat(artifacts): speech-bubble comment cursor and pins
- feat(artifacts): restyle the canvas toolbar as a floating pill (V, H, C tool
  pill; zoom in its own pill; `useToolModes`)
- feat(artifacts): MessageCircle cursor and pins, floating comments panel and
  nav pill (Shift+C panel, full-bleed canvas and focused view, floating nav pill)

Supersedes #5273.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
shepherdjerred added a commit that referenced this pull request Nov 28, 2026
* feat(artifacts): infinite canvas — camera, gestures, frames

Why
M2 needs the board to open as a free canvas an agent publish can land on.
The grid was a placeholder body in `BoardPage` for exactly this.

What
- Hand-rolled DOM canvas modelled on Claude's design canvas. The world layer
  is `translate(x, y) scale(s)` (origin 0 0, s 0.05 to 4); chips, the
  selection ring, the Exit chip, pins and the toolbar are an unscaled overlay
  that follows the camera. The camera is a plain object written once per rAF;
  React hears about it on settle (120 ms pan, 250 ms zoom). `will-change` is
  set only while the camera moves.
- Input: non-passive wheel (Ctrl/Meta zooms at the cursor), Safari gesture
  events and a two-pointer pinch arbitrated so one pinch applies once,
  Space-, middle- and H-drag pan, a pan blanket during drags, and wheel and
  gesture input a live frame forwards over the bridge. `1` fit all, `2` fit
  selection, `0` 100 %; the camera is stored per board.
- Frames come from the index at world pixels. Three tiers: one live frame
  (double-click or Enter, Exit chip and Esc), at most 8 inert previews (4 in
  Firefox, lowered by 2 when the rAF p95 over the last 2 s of motion is over
  25 ms, floor 3, with eviction hysteresis) and the typed placeholder.
  Stacking is CSS z-index from `order`; iframes are never moved or remounted.
- Board pins (`board{page,x,y}`) and frame pins (via the existing
  `AnchorAdapter`s) sit on the overlay. The sidebar lists all board threads.
- The outline stays the keyboard path; its link is the first tab stop and the
  frame chips follow in reading order.
- The grid is removed; `?view=canvas` skips a launch redirect.

Verification
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts
- bun run test:e2e in packages/artifacts: desktop Chromium, mobile Chromium
  and WebKit, including the canvas spec (zoom-at-cursor within 1 px, zero
  iframe document requests on select, live toggle and a new frame, pins, axe,
  reduced motion).
- Not run: real trackpad, iPad and Safari gestures (synthetic events only);
  Firefox (cap lowered by user agent, not exercised).

Supersedes #5260.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

* feat(artifacts): arrange frames on the canvas

Why
M2 done-when: layout survives a reload, and an agent publish during a drag
loses neither change.

What
- Select (click, Shift-click, marquee on empty canvas), drag with a 4 px
  threshold, pointer capture and edge auto-pan, eight resize handles (a
  fixed-viewport frame keeps its aspect, a responsive one resizes freely),
  8 px grid snap (Alt disables), `[` `]` z-order, arrow nudge (Shift 10x),
  Delete from board behind a confirm (never the artifact), undo and redo
  (Mod+Z, Shift+Mod+Z) over the applied ops. Esc cancels a drag.
- The arrangement is a replicated document: the server's index plus an outbox
  of `boards.applyOps` ops, drawn as the index with the outbox applied on
  top. Saves are debounced 400 ms and flushed on `pagehide` (a keepalive
  request). A change from another actor merges by id, never moves the camera
  and never disturbs a drag in progress (the draft is drawn over the
  document). A toast names a new frame, with a jump-to.
- Undo entries record before and after for the touched frames and replay as
  ops against the board as it is now, so another actor's frames are left alone.
- `aria-live` announcements for moves, resizes, order and removal.
- Dialog: a native `close` event from our own `close()` no longer closes a
  dialog reopened in between.

Verification
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts
- bunx turbo run test:extended --filter=@shepherdjerred/artifacts
- bun run test:e2e: desktop Chromium, mobile Chromium and WebKit, including
  the arrange spec (drag, snap, Alt, reload persistence, aspect and free
  resize, agent publish mid-drag, undo and redo, nudge, z-order, delete and
  undo, pagehide flush, edge auto-pan, Esc cancel, axe).
- Not run: real trackpad and iPad gestures.

Folded in (from the same PR), each with its own Why/What/Verification in the
original history:
- feat(artifacts): resize a frame through moveFrames: `moveFrames` entries take
  optional `w` and `h` (omitted leaves the size alone); the domain merge and the
  e2e fake apply them, so a resize merges under the row lock like a drag.
- feat(artifacts): speech-bubble comment cursor and pins
- feat(artifacts): restyle the canvas toolbar as a floating pill (V, H, C tool
  pill; zoom in its own pill; `useToolModes`)
- feat(artifacts): MessageCircle cursor and pins, floating comments panel and
  nav pill (Shift+C panel, full-bleed canvas and focused view, floating nav pill)

Supersedes #5273.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

* feat(artifacts): annotate the canvas

Why
M3: Jerred arranges and annotates; agents change content. Annotations persist
in the board index and agents read them back.

What
- Tool pill group 2: text (T), sticky (S), pen (P), box (B), arrow (A), line
  (L). A drag draws (a click makes a title or a default sticky), the tool
  reverts to select after one shape unless Shift is held, Shift snaps lines
  to 45 degrees.
- Notes render in the world layer (so they stay sharp; `will-change` only
  while the camera moves): a div for sticky, title and box, one `<svg>` per
  straight segment and one path per pen stroke. They never take a pointer;
  `shapes.ts` hit-tests geometry (a 12 screen-pixel stroke for lines, arrows
  and strokes, borders only for boxes) and the topmost of a note and a frame
  by `order` wins.
- Text is edited in an overlay `<textarea>` placed through the camera (Enter
  or double-click; Ctrl/Cmd+Enter saves, Esc abandons; an empty new note is
  dropped). A palette sets colours and a title's size.
- Pen strokes are simplified (Ramer-Douglas-Peucker, tolerance grown until the
  stroke fits the 500-point cap).
- Select, move, resize (box and sticky handles, line and arrow endpoint
  handles), z-order, delete and undo use the arrangement machinery: history
  entries now cover notes and replay as `putNote` and `deleteNote`; adjacent
  puts of one note coalesce.
- The outline lists the text of stickies and titles.
- Canvas split: the overlay is `CanvasOverlay`, tool modes `useToolModes`.
- The zoom pill moves above the tools in a narrow canvas (container query).

Verification
- bunx turbo run build typecheck test lint test:extended --filter=@shepherdjerred/artifacts
- bun run test:e2e: desktop Chromium, mobile Chromium and WebKit (177 tests),
  including the notes spec: every kind drawn, tool reverts, Shift lock,
  typed text and dropped empties, edit and undo, hit testing (6 px hit, 12 px
  miss, box middle ignored), move, resize and endpoint drag, delete and undo
  and redo, colour, z-order, reload persistence, an agent's putNote arriving
  live, sharpness (will-change auto at rest) and axe.

Folded in (from the same PR):
- feat(artifacts): a pen note on the board index: `NoteSchema` gains `pen`
  (origin, offset points, 2 to 500 points via `MAX_PEN_POINTS`, colour); the
  note schema and board primitives move into `notes.ts` and
  `board-primitives.ts` to keep `contract.ts` under the file-size limit.

Supersedes #5286.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

* fix(artifacts): keep the canvas lint-clean

Why
- The canvas adds a ThemeToggle use that console-ui deprecated and pushes
  FrameViewer over the cognitive-complexity limit.

What
- floating-nav uses ThemeButton, like the app header.
- FrameViewer reads which controls to draw from one small function.

Verification
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts: pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

* fix(artifacts): style the canvas with console-ui tokens

Why
- The console-ui conformance scan (#5438) now covers artifacts; the canvas
  styles added 1 inline-typography, 9 colour-literal and 1 shared-class-patch
  finding, and the allowlist may only shrink.

What
- Shadows use var(--ui-shadow-menu) instead of colour-mix on black.
- A title note passes its size as a --ar-title-font custom property.
- The narrow floating nav no longer restyles .ui-workspace-label, which
  already ellipsizes.

Verification
- vitest run src/client/conformance.test.ts: pass with no allowlist change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

---------

Co-authored-by: Claude Sonnet 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