Skip to content

feat(artifacts): infinite canvas — camera, gestures, frames - #5260

Closed
shepherdjerred wants to merge 1 commit into
artifacts-hardeningfrom
artifacts-canvas
Closed

shepherdjerred wants to merge 1 commit into
artifacts-hardeningfrom
artifacts-canvas

Conversation

@shepherdjerred

@shepherdjerred shepherdjerred commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Why

M2: the board opens as a free canvas an agent publish can land on. The grid was a placeholder body in BoardPage for exactly this. Client only: no server or contract change.

What

  • Hand-rolled DOM canvas modelled on Claude's design canvas (packages/artifacts/src/client/canvas/). World layer translate(x, y) scale(s), origin 0 0, s in [0.05, 4]; chips, selection ring, Exit chip, pins and 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: transform only while it moves.
  • Input: non-passive wheel (Ctrl/Meta zoom at cursor, else pan with deltaMode normalised), Safari gesture* and a two-pointer pinch arbitrated so one pinch is applied once, Space-/middle-/H pan, a pan blanket during drags, and wheel/gesture a live frame forwards over the bridge. 1 fit all, 2 fit selection, 0 100 %; camera stored per board (localStorage, try/catch).
  • Frames from the index at world pixels, in three tiers: one live frame (double-click or Enter, Exit chip, 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; eviction hysteresis, never on a zoom-only settle), 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 (existing AnchorAdapters, measured on settle and followed through the camera) on the overlay; the sidebar lists all board threads, with the frame named.
  • Accessibility: the outline link is the first tab stop; frame chips follow in reading order with aria-labels; Enter activates, Esc exits.
  • The grid is removed; ?view=canvas skips a launch redirect (the focused view and outline link to it).

Demo

Before (grid) and after (canvas), same board:

Before After
before after

Zoomed in on a selected frame with its pin, and the live frame (WebKit) with the Exit chip:

selected
live

Settled sharpness at 200 % (WebKit) and fit-all at 50 % on the seeded demo board (Chromium):

zoom 200
zoom 50

Recording of pan, zoom at the cursor, fit, select, activate and exit: canvas-tour.webm

Verification

  • bunx turbo run build typecheck test lint --filter=@shepherdjerred/artifacts: green (unit tests cover camera math, zoom-at-cursor invariant, clamps, gesture/pinch idempotence, tier selection with hysteresis, adaptive cap, the camera controller on a fake clock).
  • bun run test:e2e in packages/artifacts: green on desktop Chromium, mobile Chromium and WebKit. The canvas spec checks zoom at the cursor keeps a world point within 1 px, exact wheel pan, Space/hand-tool pan, fit keys, zero iframe document requests on select/live toggle/new frame via a live update, a ctrl-wheel forwarded from the live frame, board and frame pin placement and reload round trip, reduced motion (nothing animates), reading-order tabbing and axe.
  • Extended tier: bunx turbo run test:extended --filter=@shepherdjerred/artifacts green (6 files, 69 tests). The broad verify:extended -- --filter='...[origin/main...HEAD]' was not run to completion: it spans the whole lower stack and was cut short on a busy machine; this PR touches only the artifacts client.
  • Visual: rendered and inspected at 0.5, 1 and 2 zoom in Chromium and WebKit; text is sharp once the camera settles.
  • Not verified (needs Jerred): real trackpad and iPad gestures (synthetic events only), Safari sharpness on a retina display, Firefox (the lowered cap is chosen by user agent, not exercised).
  • Live acceptance, ArgoCD and runtime layers are not applicable: client-only change, nothing deployed.

🤖 Generated with Claude Code

https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT

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).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: 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:16
@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-26T19:19:41.312264Z 09992eb 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: 09992ebe47

ℹ️ 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 +241 to +243
function onWheel(event: WheelEvent): void {
event.preventDefault();
const camera = controller.get();

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 scrolling inside active document viewers

When a reviewer activates a Markdown or PDF frame, wheel events from its scroll container bubble to this handler, which unconditionally cancels native scrolling and pans the entire canvas instead. Both MarkdownViewer and PdfViewer rely on native scrolling, so activating them no longer lets the reviewer scroll through their contents with a mouse wheel or trackpad. Exempt ordinary wheel input inside active scrollable viewers while retaining canvas zoom gestures and explicit pan modifiers.

Useful? React with 👍 / 👎.

Comment on lines +196 to +198
revealed.current = selectedThreadId;
const frame = pin.frameId === null ? undefined : byId.get(pin.frameId);
if (frame !== undefined) reveal(frame.rect);

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 Reveal the selected thread's anchor inside its frame

When a sidebar thread points to a later PDF page, a scrolled document position, or a video timestamp other than the current one, this only brings the frame rectangle into view; it never calls the viewer adapter's reveal method. Those adapters return no visible pin for offscreen pages or unmatched video times, so selecting the comment leaves its referenced content and pin hidden. Invoke the frame adapter's anchor reveal once its preview is loaded, as the focused view already does, rather than treating camera movement alone as a completed reveal.

Useful? React with 👍 / 👎.

@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 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
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