Repository navigation
feat(artifacts): board annotations - #5286
shepherdjerred wants to merge 2 commits into
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62400ebd89
ℹ️ 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".
| aria-label={note.type === "sticky" ? "Sticky text" : "Title text"} | ||
| defaultValue={note.text} | ||
| data-kind={note.type} |
There was a problem hiding this comment.
Enforce the note text limits before closing the editor
Typing or pasting more than 500 characters into a title, or 2,000 into a sticky, is allowed by this textarea, but NoteSchema rejects that text. Saving calls arrange.putNote, whose applyBoardOps synchronously parses the resulting board and throws. Because commitText already clears the editor, the entered text is lost without a useful validation message. Enforce the corresponding limit in the editor or validate before dismissing it.
Useful? React with 👍 / 👎.
| if (!dragged) return null; | ||
| const rect = rectBetween(from, to); | ||
| return { type: "box", page: 0, ...rect, color }; |
There was a problem hiding this comment.
Reject zero-area boxes before creating a note
A strictly horizontal or vertical drag longer than six world pixels passes dragged, but rectBetween produces a zero height or width. The returned box violates the positive Size fields in NoteSchema, so releasing the pointer triggers an uncaught validation error in arrange.putNote instead of completing or ignoring the drawing. Require positive dimensions or apply a minimum box size before returning this note.
Useful? React with 👍 / 👎.
| onFitAll={camera.fitAll} | ||
| onFitSelection={camera.fitSelection} |
There was a problem hiding this comment.
Include annotations in the camera fitting bounds
When an annotation is selected, the fit-selection control is enabled, but its callback does nothing: Canvas still constructs useCanvasCamera(slug, frames, selectedFrames), and fitSelection returns immediately when that frame-only selection is empty. Mixed selections also exclude annotation bounds, and fit-all ignores annotations entirely. Pass annotation rectangles into the camera fitting inputs so these controls include the newly selectable board content.
Useful? React with 👍 / 👎.
Why M3 annotations include freehand strokes, and the board index has no note for one. Strokes must be bounded so a board document stays small. What - `NoteSchema` gains `pen`: an origin (`x`, `y`), `points` as offsets from it (so a move changes only the origin), and a colour. A stroke has 2 to 500 points (`MAX_PEN_POINTS`); the client simplifies before it stores. - The note schema and the board primitives move out of `contract.ts` into `notes.ts` and `board-primitives.ts` to keep it under the file-size limit. - `putNote` and `deleteNote` already merge under the row lock; tests cover a pen through the schema, the domain merge and the real service (every note kind round-trips through `boards.get`, a 501-point stroke is a 400). Verification - bunx turbo run build typecheck test lint test:extended --filter=@shepherdjerred/artifacts Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
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. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT
62400eb to
c933081
Compare
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
* 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>
Why
M3: Jerred arranges and annotates; agents change content. Annotations persist in the board index and agents read them back. Stacked on #5273 (arrange, toolbar, MessageCircle cursor and pins, floating comments panel and nav pill); the screenshots show that floating shell.
What
NoteSchemagainspen: an origin,pointsas offsets from it (a move changes only the origin), a colour, 2 to 500 points (MAX_PEN_POINTS). The note schema and board primitives move out ofcontract.ts(notes.ts,board-primitives.ts) to keep it under the file-size limit.putNoteanddeleteNotealready merge under the row lock. Tests: schema, domain merge, and the real service (every kind round-trips throughboards.get; 501 points is a 400).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 when it finishes; Shift snaps lines and arrows to 45 degrees. Pen strokes are simplified (Ramer-Douglas-Peucker, tolerance grown until the stroke fits the cap).will-changeonly while the camera moves): a div for sticky, title and box, one<svg>per straight segment, one path per pen stroke. They never take a pointer: hit-testing is geometry (a 12 screen-pixel stroke for lines, arrows and strokes; box borders only, so an empty box does not block what is under it), and the topmost of a note and a frame byorderwins. Z-order is shared with frames throughorder. Arrows store plain coordinates and do not follow frames.<textarea>placed through the camera (Enter or double-click edits; Ctrl/Cmd+Enter saves; Esc abandons; an empty new note is dropped).putNoteanddeleteNoteagainst the current board; box and sticky get the eight handles, line and arrow get endpoint handles; delete of annotations needs no confirm (frames still do).CanvasOverlayand tool modes intouseToolModes; the zoom pill moves above the tools in a narrow canvas (container query).Agents read them back
boards.getreturnsindex.notesincluding the newpenkind.toolkit artifacts show --jsonalready printsnotes: board.index.notes(read.ts in #5214), so it needs no change: it parses through the contract, which now knowspen.Demo
A board with two concepts annotated: a title, a sticky with a colour, a box, an arrow, a pen stroke; the palette with the sticky selected; and an agent's
putNotearriving live:Recording: annotations-tour2.webm (draws each kind, edits text, moves, undoes and redoes, then an agent note appears).
Verification
bunx turbo run build typecheck test lint test:extended --filter=@shepherdjerred/artifacts: green. Unit tests: stroke simplification (ends kept, every dropped point within tolerance, cap), geometry (bounds, move and scale by rectangle, hit-testing at several zooms, topmost by z), drawing (defaults, 45 degree snap, ids), arrangement op builders, and history for notes (create, edit, delete restoring order, an agent's concurrent note untouched, coalescing). Extended tier (71 tests) includes every note kind through the real service.bun run test:e2e: green (205 tests) on desktop Chromium, mobile Chromium and WebKit. The notes spec covers: each kind drawn and the tool reverting, Shift lock, typed text and dropped empties, edit and undo, hit testing (5 px hits a line, 12 px misses, a box's empty middle is ignored), move, box resize and line endpoint drag, delete and undo and redo, colour, z-order, reload persistence, an agent'sputNotearriving live without moving the camera,will-change: autoat rest, the outline text list, and axe with the palette and an editor open.🤖 Generated with Claude Code
https://claude.ai/code/session_011u9pQkmfQzZFyzPbpimoiT