Canvas Comments
Storybook addon for inline UI feedback on the canvas — click to annotate, compare stories on a board, review in a panel, and hand structured context to coding agents via a filesystem dom-map.
storybook-addon-canvas-comments
A Storybook addon for leaving inline UI feedback comments directly on the canvas. It is designed so that coding agents (AI assistants) can pick up the feedback and act on it.
Click any element in a story and type a note. The comment is anchored to the element's role and accessible name in the accessibility tree. A CSS selector and pointer coordinates are saved too, as fallbacks. A DOM snapshot of the target element is saved with it too. A companion CLI lets an agent block until you finish reviewing. The agent then receives all open comments as structured JSON.
A board page lays several stories side by side, like a design canvas.
You can duplicate a frame, set its props, drag elements to where they should go, mark elements for removal, and leave notes.
You can also drop components from your design system onto a frame.
The board writes those instructions as Markdown for a coding agent.
Send to agent hands them to an agent waiting with the wait-board CLI.
The agent fixes the code, clears the instructions it applied from the board, and waits for the next round.
The loop runs against a local Storybook dev server, or against a pull request's preview Storybook.
Demo

| Leave a comment | Read the thread on a pin | Review in the panel |
|---|---|---|
![]() |
![]() |
![]() |
- Turn on UI feedback in the toolbar and click an element on the canvas. Type a note in the popover and save it.
- Each comment becomes a pin. Hover a pin to read the note and its replies, such as one a coding agent posted with the
replyCLI. - The UI Feedback panel lists every comment with its accessibility anchor and selector. Complete review signals a waiting agent.
The demo runs the example Storybook in examples/react-vite.
The Board section has a demo of the board page.
Features
| Feature | What it does |
|---|---|
| Inline commenting | Toggle "UI Feedback" in the toolbar, click an element on the canvas, and type a note in the popover. |
| Comment pins | Saved comments are shown as pins on the canvas. Hover or focus a pin to read the note and its replies, and resolve it in place. A pin with replies shows the reply count. Toggle pin visibility from the toolbar (eye icon) or the panel header. |
| Addon panel | A "UI Feedback" panel lists all comments with their selector and metadata. It supports reopen / resolve / delete, and deleting every resolved comment at once. |
| Replies | Each comment has a reply thread. Reviewers reply from the panel. Coding agents reply with the reply CLI to explain what they changed. The thread is shown in the panel and in the pin tooltip. |
| Review-completion signal | A "Complete review" button in the panel flips a review status flag. A waiting coding agent can detect it. "Reopen review" flips it back. |
| Agent-friendly output | The dom-map and wait-comments CLIs pair each comment with its saved DOM snapshot. They emit JSON built for LLM consumption. |
| Board | A board page (/?path=/board/) lays stories out as frames to compare variants. Drag elements in a frame to leave move instructions, mark them for removal, comment on them, and put notes on the board. Drag components from a design system onto a frame to show what to add. The instructions are written as Markdown for coding agents. Works on a phone too. See Board. |
| Board agent loop | Send to agent signals a coding agent waiting with the wait-board CLI. The agent applies the instructions, clears them with board-resolve, and waits again. It works with a local dev server or a pull request's preview Storybook, and the Claude Code plugin's board-fix and board-fix-remote skills run it. See Sending the board to a coding agent. |
Requirements
- Storybook with the Vite builder. Webpack builders are not supported.
The addon preset registers a Vite dev-server middleware via
viteFinal. - React-based manager UI (standard Storybook 8+).
Installation
Install the package from npm as a dev dependency:
pnpm add -D storybook-addon-canvas-comments
# or
npm install -D storybook-addon-canvas-comments
# or
yarn add -D storybook-addon-canvas-comments
To try it without installing, see temporary mode.
The release workflow builds dist/ and ships it in the npm package.
The package has no install-time scripts (preinstall, install, postinstall, or prepare).
So pnpm needs no allowBuilds entry for it.
Setup
Register the addon in .storybook/main.ts:
import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
addons: ["storybook-addon-canvas-comments"],
};
export default config;
Trying it without installing (temporary mode)
To try the addon on a project, or to review a project once, run your Storybook with it straight from npx.
Nothing is added to package.json or .storybook/main.*:
npx storybook-addon-canvas-comments dev
# or
pnpm dlx storybook-addon-canvas-comments dev
Run it where you run Storybook.
It installs only the addon and its one small dependency, not Storybook, Vite or React: it uses the project's own.
So pnpm dlx does not ask whether to run esbuild's install script.
It writes a config directory next to yours, .storybook-canvas-comments/, that loads your main config and adds the addon to its addons.
It then runs your project's own storybook dev with that directory, and deletes the directory when Storybook exits.
The directory has its own .gitignore, so git ignores it while it exists.
- Every other option goes to Storybook, such as
-p 6006or--no-open. -c, --config-dir <dir>— your config directory, if it is not.storybook.--addon-options <json|file>— the addon's preset options, as JSON such as'{"board":false}', or the path of a JSON file that holds them. They are the same options as inmain.ts:board,frameSize,designSystemsandapiUrl.npx storybook-addon-canvas-comments buildrunsstorybook buildthe same way.
The board's design system components work too.
Put the designSystems option in a JSON file, and pass its path:
{
"designSystems": [
{ "name": "Example UI", "importPath": "@example/ui", "titlePrefix": "UI/" },
{ "name": "@acme/ui", "components": ["Alert", "Badge"], "args": { "Alert": { "title": "Saved" } } }
]
}
npx storybook-addon-canvas-comments dev --addon-options canvas-comments.json
All three kinds work as with the addon installed:
titlePrefixlists stories in your Storybook.reflists the stories of a Storybook in therefsof your main config.componentswrites stories for a library without stories."auto"needs TypeScript installed in the project, as without the temporary mode.
Comments and boards are saved to .storybook/canvas-comments/, as with the addon installed.
Run the CLIs below with npx -p storybook-addon-canvas-comments, or with pnpm, pnpx --package=storybook-addon-canvas-comments, for example:
npx -p storybook-addon-canvas-comments canvas-comments-wait-comments
npx -p storybook-addon-canvas-comments canvas-comments-wait-board --format json
npx -p storybook-addon-canvas-comments canvas-comments-board-resolve --ids <id1>,<id2>
# or
pnpx --package=storybook-addon-canvas-comments canvas-comments-wait-comments
pnpx --package=storybook-addon-canvas-comments canvas-comments-wait-board --format json
pnpx --package=storybook-addon-canvas-comments canvas-comments-board-resolve --ids <id1>,<id2>
pnpx is short for pnpm dlx, so pnpm dlx --package=storybook-addon-canvas-comments <cli> works too.
The temporary mode needs the same setup as the addon: Storybook with the Vite builder, installed in the project. If your main config already lists the addon, it adds nothing and warns.
Usage
- Turn on UI Feedback in the Storybook toolbar.
- Click the target UI element on the canvas.
- Type your note in the popover (
Cmd/Ctrl+Enterto save,Escapeto cancel). - The comment appears in the UI Feedback addon panel.
Use the eye icon in the toolbar to show or hide the saved-comment pins on the canvas.
The Pins checkbox in the panel header does the same.
Hovering or focusing a pin shows the note as a tooltip with a resolve button.
The tooltip also lists the comment's replies, oldest first, with their author and date.
A long thread scrolls inside the tooltip, and the tooltip stays within the canvas.
A pin with replies shows the reply count as a badge.
Replies from the reply CLI appear after the story reloads.
Comments are stored under the directory where the Storybook dev server runs:
.storybook/canvas-comments/comments.json
Resolved comments stay in this file until you delete them. The Delete resolved (N) button in the panel header deletes all resolved comments in every story. Their replies are deleted too. Open comments are kept.
Treat this file as local feedback data. A coding agent can read the JSON directly, or use the CLIs below for DOM-mapped output.
Add the directory to .gitignore, because the board saves its files next to it:
**/.storybook/canvas-comments/
Review completion (coding-agent integration)
This workflow lets a coding agent that started Storybook detect when your review is finished. The agent then moves on to follow-up work (fixes, filing issues, and so on).
- Leave comments on the canvas.
- When you are done, click the Complete review button in the panel header.
- The review status becomes
completed, signaling any waiting agent.
Adding a new comment automatically flips the status back to reviewing.
So the fix → re-review loop works repeatedly.
While the review is completed, the button reads Reopen review.
Click it to set the status back to reviewing without adding a comment.
Click Complete review again to signal a waiting agent once more.
The review status is stored in the same file as the comments, under review:
{
"comments": [],
"review": {
"status": "reviewing",
"updatedAt": "2026-06-27T00:00:00.000Z"
}
}
An agent can block until the review completes with the wait-comments CLI. On completion it prints the dom-map JSON of the open comments to stdout and exits:
pnpm exec canvas-comments-wait-comments \
--comments-file path/to/.storybook/canvas-comments/comments.json \
--include-dom-tree
On startup the CLI resets the review status to reviewing before polling.
So a stale completed from a previous round does not return immediately.
Pass --no-reset to skip the reset. Other options:
--timeout-ms <ms>— give up after this long (exit code 1);0waits indefinitely (default).--poll-interval-ms <ms>— polling interval (default2000).--status <open|resolved|all>/--story-id <id>— filter which comments are included in the output.
Board
The board compares stories side by side and collects fix instructions across them.
Open it at /?path=/board/, or press + Board in the toolbar of a story to add that story and open the board.

The demo adds two SignupForm stories and duplicates one of them.
In the copy, it sets the title prop in the side panel, moves the Sign up button, marks the Cancel button for removal, and comments on the heading.
It then leaves a note and clicks Send to agent.
An agent waiting with wait-board receives the instructions as Markdown and changes the component's code, and the frames reload with the fix.
It clears the instructions it applied with board-resolve and waits for the next round.
The terminal shows the real CLI output; see Sending the board to a coding agent.
| Action | How |
|---|---|
| Add a frame | Type in Add a story… at the top and press Enter, or press + Board on a story. |
| Duplicate a frame | Duplicate in the frame header. Its instructions are copied too, so the copy can branch off as another variant. |
| Move and resize | Drag a frame by its header, or anywhere on it in Select mode. Drag the bottom-right corner to resize, or pick Mobile / Tablet / Desktop in the side panel. |
| Override args | Set the story's props in the side panel. Each prop gets an input for its type (a checkbox, a select of its options, a number or text field) with its type and default. Reset goes back to the story's value. Raw args takes Storybook's URL format, such as label:Save;disabled:!true, for what the inputs do not cover. |
| Pan and zoom | Drag the background or scroll to pan. Ctrl / Cmd + scroll zooms. Fit shows every frame. |
| Several boards | Pick a board in the toolbar, or use New, Rename and Delete. |
The board has four modes. Switch them in the toolbar or with a key:
| Mode | Key | What it does |
|---|---|---|
| Select | V |
Select, move and resize frames. |
| Interact | I |
Use the stories as usual, for example to open a menu before you comment. |
| Element | E |
Click an element in a frame to comment on it or mark it for removal. Drag it to leave a move instruction. |
| Note | N |
Click the board to put a note. A note placed on a frame belongs to that frame. |
In Element mode, pressing an element picks its closest interactive ancestor (button, a, [role], [tabindex] and so on).
So pressing the text inside a button picks the button.
Hold Alt to pick one level further out.
Each instruction gets a numbered pin, and moves are previewed inside the frame with a CSS translate.
To delete an element, click it and press Remove element on its instruction in the side panel.
The element is faded out in the frame and its pin turns red; press Keep element to undo.
The story code does not change; a coding agent or a person makes the real fix.
See Sending the board to a coding agent.
The board works on a phone, for example to review a pull request's preview. Below 900px wide, the toolbar fits in two rows, and the Components panel and the side panel (Details) open as bottom sheets over the canvas. Selecting an instruction or a component opens Details. Two fingers pan and pinch-zoom the board, and ← Stories goes back to the stories.
Design system components
The board can list the components of a design system, such as a @acme/ui package in your monorepo.
Drag one onto a frame to show where it should go.
The board renders the component's story in place, and writes an instruction to add it, with its import, to the Markdown for coding agents.

The demo searches the Components panel of the example design system and drags an Alert above the sign-up form.
It drops a Checkbox on the form, sets its label and defaultChecked props in the side panel, and gives it a note.
It then moves the Alert and shows the Markdown the board writes for a coding agent.
List the design systems in the preset options. Each one is a set of stories: the stories under a title prefix in this Storybook, or the stories of a composed Storybook. A library without stories works too; see Libraries without stories.
// .storybook/main.ts
const config: StorybookConfig = {
addons: [
{
name: "storybook-addon-canvas-comments",
options: {
designSystems: [
// Stories in this Storybook whose title starts with "UI/"
{ name: "Example UI", importPath: "@example/ui", titlePrefix: "UI/" },
// Every story of the Storybook composed as `refs.ui`
{ name: "@acme/ui", ref: "ui" },
],
},
},
],
refs: {
ui: { title: "@acme/ui", url: "http://localhost:6008" },
},
};
| Option | Description |
|---|---|
name |
Shown in the Components panel. |
importPath |
The module written into the instructions, as in import { Alert } from "@example/ui". Defaults to name. |
titlePrefix |
Only stories whose title starts with this. Leave it out to list every story. |
ref |
The id of a composed Storybook in refs. Leave it out for stories in this Storybook. |
With a design system set, the board toolbar has a Components button that shows or hides the panel. The panel groups the stories by component, and each story is a variant you can drag:
- Drag a story onto a frame. The frame is highlighted while the pointer is over it.
The component goes where you drop it, and takes the height of its rendered story.
A story whose content is all positioned (
position: absolute), such as a floating action button, fills the box like a screen instead. - Click a story, or focus it and press
Enter, to add it to the top-left of the selected frame (or of the first frame). - Drag a placed component to move it, and drag its bottom-right corner to resize it.
- Select it to set its props in the side panel, with the same inputs as a frame's (or type Raw args in Storybook's URL format, such as
title:Saved), and describe how to use it.
The component name comes from the last part of the story title.
UI/Alert gives Alert, and an auto title such as buttons/primary-button gives PrimaryButton.
When the component is dropped on an element of the story, the board records that element too, like an element instruction.
Stories of a composed Storybook render from its URL. When that URL is on another origin, the board cannot read the rendered story. So the component keeps the default 320×64 box and Storybook's own padding; resize it by hand. The composed Storybook also has to allow the manager's origin with CORS, as for any composed Storybook.
Libraries without stories
A component library does not need stories of its own to be on the board.
Set components, and the preset writes a story for each component, which renders it with the args you give it on the board.
// .storybook/main.ts
const config: StorybookConfig = {
addons: [
{
name: "storybook-addon-canvas-comments",
options: {
designSystems: [
{
name: "@acme/ui",
// Every component the module exports
components: "auto",
// Exports to leave out of "auto"
exclude: ["ThemeProvider"],
// Args for the props a component cannot render without
args: { Alert: { title: "Saved" } },
},
],
},
},
],
};
| Option | Description |
|---|---|
components |
"auto" lists the components that importPath exports. An array, such as ["Alert", "Badge"], names them. |
exclude |
With "auto", exports to leave out. |
args |
The args of a component's story, by component name. Each component has one story, Default. |
"auto" reads the module with TypeScript: its source, or its type declarations for a built package.
It lists the exports with a capitalized name that can be called or constructed, such as function components, forwardRef and memo components, and classes.
TypeScript has to be installed in the project; otherwise list the components.
ref and titlePrefix are ignored with components.
The stories are written under node_modules/.cache/storybook-addon-canvas-comments/library/ in the directory where Storybook runs, each time Storybook starts.
They are tagged canvas-comments-library, so they are hidden from the sidebar, from docs pages and from the test runner, and the board's story search leaves them out.
They are still in index.json; leave them out of any tool that reads it, such as a visual regression test, by that tag.
They render in this Storybook with its decorators, such as a theme provider, and the board reads their props for the side panel when Storybook's docgen can read the component.
Board instructions for coding agents
With the dev server, the board saves two files under the directory where Storybook runs:
.storybook/canvas-comments/board.json # the boards, frames, instructions and notes
.storybook/canvas-comments/board-instructions.md # the instructions as Markdown
board-instructions.md is rewritten on every save, so an agent can read it as-is.
Copy as Markdown in the side panel copies the same Markdown for the current board.
Each element is identified by its role and accessible name, and by a CSS selector.
A frame's args follow its story id.
Moves, and the positions of components to add, are in the story's rendered CSS px:
## Board 1
### Example/SignupForm / Default (copy)
- story: `example-signupform--default` / args: `title:Join the beta`
- size: 390×720
1. button "Sign up" (`#storybook-root > form > div:nth-of-type(3) > button:nth-of-type(2)`): move left 106px, move down 92px / Put Sign up on its own row, full width
2. button "Cancel" (`#storybook-root > form > div:nth-of-type(3) > button:nth-of-type(1)`): remove this element
3. heading "Join the beta" (`#storybook-root > form > h2`): Keep the title to one line
Components to add:
- Add `Checkbox` (`import { Checkbox } from "@example/ui"`, as in story `ui-checkbox--unchecked`, args `label:I agree to the Terms;defaultChecked:!true`) at x 62px, y 447px, 320×17, over form "Sign up" (`#storybook-root > form`) / Required before Sign up
### Board notes
- Ship the copy with the full-width button
A statically built Storybook has no dev-server API.
There the board saves to the browser's localStorage, so only that browser sees it.
Use Copy as Markdown to hand the instructions over.
With the preset option apiUrl, a static build saves the board through the hosted API instead, next to the comments.
See Hosted mode.
Sending the board to a coding agent
A coding agent can wait for the board, apply its instructions, and hand it back, round after round. You stay on the board, and the agent stays in its terminal:
- The agent runs
canvas-comments-wait-boardand waits. The Agent section of the side panel shows Editing. - You collect instructions on the board: moves, removals, comments, components to add, and notes, on any of your boards.
- You click Send to agent. Pending edits are saved first, and the status turns to Sent to agent. The button is disabled while no board has an instruction.
wait-boardprints the instructions of every board and exits. The agent changes the code.- The agent clears the instructions it applied with
canvas-comments-board-resolve. The board page picks the change up within a few seconds, and the instructions disappear from it. Frames stay, so you can check the fixes in them. Instructions you added while the agent worked stay too, for the next round. - The agent runs
wait-boardagain, which sets the status back to Editing, and the next round starts.
Until the agent picks the board up, Reopen takes it back so you can keep editing. An instruction the agent cannot apply, because it is unclear or conflicts with the code, is left on the board; the agent should say why.
The loop runs in two places:
| Local dev server | Pull request preview | |
|---|---|---|
| Where the board is saved | .storybook/canvas-comments/board.json |
<app>/board.json in R2, through the hosted API |
| How the agent waits | wait-board |
wait-board --api-url <url> |
| When the frames show the fixes | Storybook reloads them as soon as the code changes | Once the agent pushes and the preview is redeployed; reload the board then |
| Claude Code skill | board-fix |
board-fix-remote, which also commits and pushes to the PR branch |
The Agent section is shown with the dev server, and in a static build that uses the hosted API. A static build without it keeps the board in the browser and has no API to signal through; use Copy as Markdown there.
With the Claude Code plugin installed, a round looks like this:
# Local: start Storybook, then in Claude Code
/canvas-comments:board-fix
# Pull request preview: in Claude Code, on the PR branch or anywhere that can reach the preview
/canvas-comments:board-fix-remote pr=123
Claude tells you when it is waiting. Click Send to agent whenever a round of instructions is ready, on a laptop or a phone. Claude reports what it changed and what it left on the board, then waits for the next round.
The status is stored in board.json under review, in the same shape as the comments' review status:
{
"boards": [],
"version": 1,
"review": {
"status": "completed",
"updatedAt": "2026-11-16T00:00:00.000Z"
}
}
wait-board resets the status to reviewing and polls board.json until it is completed.
It then prints the instructions Markdown, the same as board-instructions.md:
pnpm exec canvas-comments-wait-board \
--board-file path/to/.storybook/canvas-comments/board.json
--format json— print{ boardFile, instructions, items }instead.itemslists each edit, component and note with itsid,kindand board, forboard-resolve.--timeout-ms <ms>— give up after this long, with exit code2.0waits indefinitely (default).--poll-interval-ms <ms>— polling interval (default2000).--no-reset— do not reset the status first, e.g. when waiting again after a timeout.--board-file <path>— override the default path.--api-url <url>— wait on the hosted board API instead ofboard.json.
board-resolve removes applied instructions — element edits, components to add, and notes — and keeps the frames.
It prints the removed items as JSON:
pnpm exec canvas-comments-board-resolve --ids 3f2a...,9c1d...
--ids <id,id,...>— the items to remove, fromwait-board --format json. Instructions added since stay on the board.--all— remove every instruction on every board.--board-file <path>— override the default path.--api-url <url>— remove them through the hosted board API.
The board reads each frame's DOM directly, so the manager and the preview must be served from the same origin.
That is the default for storybook dev and storybook build.
Every frame is a separate iframe, so keep a board to the stories you want to compare.
Keep the Storybook sidebar shown while you use the board.
With the sidebar hidden, Storybook places addon pages (and its own settings pages) in the wrong part of the window.
New frames are 390×720, a phone, by default.
For a desktop or tablet service, set the size of the frames added to the board with the preset option frameSize:
const config: StorybookConfig = {
addons: [
{
name: "storybook-addon-canvas-comments",
options: { frameSize: "desktop" },
},
],
};
frameSize |
Size of a new frame |
|---|---|
"mobile" |
390×844 |
"tablet" |
768×1024 |
"desktop" |
1280×800 |
{ width: 1440, height: 900 } |
Any size in px. It is at least 200×120, the smallest a frame can be resized to. |
It sets only the size of new frames: frames already on a board keep theirs, and Mobile / Tablet / Desktop in the side panel still resize a frame. An unknown value is ignored with a warning when Storybook starts.
To leave out the board page and the + Board button, turn the board off in the preset options:
const config: StorybookConfig = {
addons: [
{
name: "storybook-addon-canvas-comments",
options: { board: false },
},
],
};
Accessibility-tree anchor
On click, the addon walks up to the nearest element with a role and an accessible name.
An example is button "Save".
It stores that element as domContext.a11yAnchor:
role/name— the element's ARIA role and accessible name.ancestors— up to three named ancestors, outermost first, such asgroup "Milk". They tell same-named elements apart.index— position among elements that still match role, name, and ancestors.offset— the click position inside the element's box, as a 0–1 ratio.
Roles and names come from dom-accessibility-api.
Testing Library's getByRole uses the same library.
Pins on the canvas re-resolve the anchor whenever the story's layout or DOM changes.
So they follow the element when it moves or resizes.
Pins resolve their position in this order:
- The accessibility-tree anchor.
- The stored
selector, only when it is an attribute or id selector. Positional path selectors are skipped. - The stored pointer, scaled from the original viewport.
The anchor is missing when no element up to #storybook-root has both a role and a name.
It no longer resolves after the element's accessible name changes.
In both cases the next fallback is used.
Anchors get more reliable when interactive elements and landmarks have a role and a label.
The same labels also help Testing Library queries.
Selector strategy
Canvas Comments locates DOM elements using this priority:
data-ai-source— source file path (most precise, enables agent-to-source tracing)data-testid— test ID attributeid— element ID- Path selector — structural CSS selector (least stable)
The clicked element is first widened to the closest ancestor carrying one of those attributes. So comments attach to meaningful components rather than leaf nodes.
The data-ai-source and data-ai-component attributes are the primary signals for AI agents.
Agents use them to locate source files from a comment.
As a starting convention, the addon exports a Vite plugin.
The plugin marks component files with metadata comments:
// .storybook/main.ts — viteFinal hook
import { canvasCommentsPlugin } from "storybook-addon-canvas-comments";
export const viteFinal = async (config) =>
mergeConfig(config, {
plugins: [canvasCommentsPlugin()],
});
Note: The bundled plugin currently provides metadata annotation as a foundation. For full JSX attribute injection (adding
data-ai-source/data-ai-componentto DOM elements at build time), integrate a Babel plugin or custom SWC transform. You can also add these attributes manually to component root elements.
The selector priority is fixed for now. Preset-level customization of the priority list may be added based on user feedback.
HTTP API
With the Vite builder, the addon preset adds a middleware to the Storybook dev server:
GET /__canvas-comments/comments
POST /__canvas-comments/comments
DELETE /__canvas-comments/comments?status=resolved
PATCH /__canvas-comments/comments/:id
DELETE /__canvas-comments/comments/:id
POST /__canvas-comments/comments/:id/replies
GET /__canvas-comments/review
POST /__canvas-comments/review
GET /__canvas-comments/board
PUT /__canvas-comments/board
GET /__canvas-comments/board/review
POST /__canvas-comments/board/review
PATCH updates a comment's status to open or resolved:
{
"status": "resolved"
}
DELETE removes the comment from comments.json and returns the deleted comment.
DELETE /__canvas-comments/comments?status=resolved removes every resolved comment.
It returns the deleted comments as an array.
Only status=resolved is accepted, and any other query returns 400.
So open comments are never bulk-deleted.
POST /__canvas-comments/comments/:id/replies appends a reply and returns the updated comment.
author is reviewer or agent, and body must not be blank:
{
"author": "agent",
"body": "Increased the padding to 16px"
}
A reply does not change the comment's status.
A reviewer reply resets the review status to reviewing, the same as a new comment.
An agent reply leaves the review status alone.
GET /__canvas-comments/review returns the current review state.
POST sets status to reviewing or completed:
{
"status": "completed"
}
GET /__canvas-comments/board returns the saved boards as { "version": 1, "boards": [...] }.
PUT replaces them, writes board.json, and rewrites board-instructions.md.
It keeps the board's review status.
GET /__canvas-comments/board/review returns the board's review state.
POST sets status to reviewing or completed, with the same body as /__canvas-comments/review.
Requests from the addon are sent with Accept: msw/passthrough.
So stories using msw-storybook-addon do not log unhandled-request warnings.
The requests pass straight through to the dev-server middleware.
dom-map CLI
You can emit JSON for the saved comments with the dom-map CLI.
It reads comments.json from disk, or the hosted API with --api-url.
It pairs each comment with the DOM snapshot saved when the comment was created.
It needs neither a browser nor a running Storybook:
pnpm exec canvas-comments-dom-map \
--comments-file path/to/.storybook/canvas-comments/comments.json \
--story-id example-button--primary
Omitting --story-id processes every story that has comments. Only open comments are included by default.
pnpm exec canvas-comments-dom-map \
--status all \
--include-dom-tree
The output includes the stored anchor and coordinates.
It also includes the target element's tag / attributes / rect / text / ancestors.
Such comments get matchType: "snapshot".
A comment without a snapshot gets matchType: "none" and an error.
With --include-dom-tree the subtree rooted at each comment target is also included.
That keeps the context small for AI agents.
Pass --storybook-url to fill the story URLs in the output.
reply CLI
A coding agent can reply to a comment with the reply CLI to explain in plain words what it changed.
It writes to comments.json directly, so Storybook does not need to be running.
It prints the updated comment as JSON:
pnpm exec canvas-comments-reply \
--comment-id 42f3dcbf-4e8d-49e4-86c4-7a61a62b7e70 \
--body "Increased the padding to 16px" \
--resolve
--author <agent|reviewer>— who wrote the reply. Defaults toagent.--resolve— also mark the commentresolved. Without it, the status is unchanged.--comments-file <path>— override the default storage path.--api-url <url>— reply through the hosted API instead of a local file.
The dom-map and wait-comments output includes each comment's replies.
So the agent can read the earlier thread before it acts on a comment.
JSON schema
Comments and the review status are stored in one JSON object, designed to be read by AI agents. A file that only holds a comment array, from older versions, is still read:
{
"comments": [
{
"id": "42f3dcbf-4e8d-49e4-86c4-7a61a62b7e70",
"storyId": "example-button--primary",
"storyTitle": "Example/Button",
"storyName": "Primary",
"note": "Increase the padding around this button",
"selector": "[data-ai-source=\"src/components/Button.tsx:42\"]",
"dataTestId": "submit-button",
"dataAiComponent": "SubmitButton",
"dataAiSource": "src/components/Button.tsx:42",
"rect": {
"x": 24,
"y": 120,
"width": 160,
"height": 44
},
"pointer": {
"x": 84,
"y": 138
},
"viewport": {
"width": 390,
"height": 844
},
"createdAt": "2026-06-12T00:00:00.000Z",
"status": "open"
}
],
"review": {
"status": "reviewing",
"updatedAt": null
}
}
Each comment may also carry a domContext object.
It is a snapshot of the target element and a bounded DOM tree captured at comment time.
It also holds the a11yAnchor described in Accessibility-tree anchor.
A comment with replies also carries replies, oldest first.
Each reply has id, author (reviewer or agent), body, and createdAt.
The stored selector is built with the priority described in Selector strategy.
Hosted mode (Cloudflare Pages + R2)
By default comments are stored on the local filesystem via the dev-server middleware.
A statically built Storybook may be deployed to Cloudflare Pages.
For that case, the src/cloudflare/ directory provides Pages Functions.
They store comments in a Cloudflare R2 bucket instead:
src/cloudflare/functions/api/canvas-comments/[app]/— Pages Functions implementing these routesGET/POST /api/canvas-comments/<app>/commentsDELETE /api/canvas-comments/<app>/comments?status=resolvedPATCH/DELETE /api/canvas-comments/<app>/comments/:idPOST /api/canvas-comments/<app>/comments/:id/repliesGET/POST /api/canvas-comments/<app>/reviewGET/PUT /api/canvas-comments/<app>/boardGET/POST /api/canvas-comments/<app>/board/reviewPOST /api/canvas-comments/<app>/board/resolve
src/cloudflare/wrangler.example.toml— example Pages configuration- Bind an R2 bucket as
CANVAS_COMMENTS_BUCKET
- Bind an R2 bucket as
The Functions import files from outside src/cloudflare/.
They are src/board/board-items.ts, src/board/board-schema.ts, src/comment-schema.ts, src/constants.ts, src/review-schema.ts, src/types.ts and src/storage/*.
The installed package ships all of them under node_modules/storybook-addon-canvas-comments/src/.
Copy that whole src/ tree to a working directory and run wrangler pages deploy from its src/cloudflare.
Copying only src/cloudflare/ is not enough.
Each app is stored as one R2 object, <app>/comments.json.
It has the same { "comments": [...], "review": {...} } format as the local file.
Writes are conditional on the object's etag.
If another writer changed the object in the meantime, the function re-reads it and retries.
So concurrent writes do not lose comments.
The board is stored in the same bucket, as <app>/board.json.
It has the same format as the dev server's board.json, with the board's review status in it.
So the board page, Send to agent, and the wait-board and board-resolve CLIs work in hosted mode too.
The board API sits next to the comments API: apiUrl .../<app>/comments gives .../<app>/board.
GETreturns{ "version": 1, "boards": [...] }, andPUTreplaces the boards and keeps the review status. A body without aboardsarray is rejected with400, so a bad request cannot wipe the boards.GET/POST .../board/reviewreads and sets the board's review status, like/__canvas-comments/board/review.POST .../board/resolveremoves applied instructions and returns them as{ "resolved": [...] }. The body is{ "ids": ["..."] }, or{ "all": true }for every instruction. It runs as one conditional write, so instructions the board page saved meanwhile are kept.
One Pages project can serve several apps, such as separate Storybooks for different apps.
Pick the app with the <app> path segment.
It may only contain letters, digits, - and _.
Point the addon at the hosted API via the preset options:
const config: StorybookConfig = {
addons: [
{
name: "storybook-addon-canvas-comments",
options: { apiUrl: "/api/canvas-comments/<app>/comments" },
},
],
};
The API has no authentication of its own. Anyone who can reach it can read, write, and delete comments. Put the Pages project behind Cloudflare Access so only reviewers can use it.
The review status API works in hosted mode with the same JSON shape as the dev server.
The dom-map, reply, and wait-comments CLIs take --api-url.
It makes them use the hosted API instead of a local file:
pnpm exec canvas-comments-wait-comments \
--api-url https://your-storybook.pages.dev/api/canvas-comments/<app>/comments
If Cloudflare Access protects the site, give the CLI a service token.
Add an Access policy with the Service Auth action that includes the token.
Then set CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET before running the CLI.
Every --api-url request then sends them as the Access headers.
They are CF-Access-Client-Id and CF-Access-Client-Secret.
Set both variables, or neither. Without them, the CLI sends no credentials.
CF_ACCESS_CLIENT_ID=<client id> CF_ACCESS_CLIENT_SECRET=<client secret> \
pnpm exec canvas-comments-dom-map \
--api-url https://your-storybook.pages.dev/api/canvas-comments/<app>/comments
wait-board and board-resolve take the same --api-url, the comments URL, and use the board API next to it.
A URL ending in /board works too:
pnpm exec canvas-comments-wait-board --format json \
--api-url https://your-storybook.pages.dev/api/canvas-comments/<app>/comments
pnpm exec canvas-comments-board-resolve --ids 3f2a...,9c1d... \
--api-url https://your-storybook.pages.dev/api/canvas-comments/<app>/comments
Pull request previews
Cloudflare Pages deploys every branch to a preview URL, such as https://<branch>.<project>.pages.dev.
The R2 binding in wrangler.toml applies to preview deployments too, so the previews share the bucket with production.
To give each pull request its own comments and board, put the branch in the <app> name.
Cloudflare Pages sets CF_PAGES_BRANCH while it builds; in GitHub Actions, use GITHUB_HEAD_REF:
// .storybook/main.ts
const branch = (process.env.CF_PAGES_BRANCH ?? process.env.GITHUB_HEAD_REF ?? "local")
.toLowerCase()
.replace(/[^a-z0-9_-]+/g, "-");
const config: StorybookConfig = {
addons: [
{
name: "storybook-addon-canvas-comments",
options: { apiUrl: `/api/canvas-comments/my-app-${branch}/comments` },
},
],
};
Use the branch rather than the commit, so new pushes keep the same comments and board.
A reviewer then works on https://<branch>.<project>.pages.dev/?path=/board/ and clicks Send to agent.
A coding agent anywhere that can reach the preview, such as Claude Code on the web, waits with wait-board --api-url, pushes the fixes to the branch, and clears the instructions with board-resolve --api-url.
The board-fix-remote skill runs this loop.
Claude Code plugin
This repository is also a Claude Code plugin marketplace.
The canvas-comments plugin ships three skills:
canvas-issuesreads the open comments with thedom-mapCLI and finds the component each one points at. It then files one GitHub issue per feature, labeleddesign. It needs the GitHub CLI (gh), signed in to the repository.board-fixwaits for Send to agent on the board with thewait-boardCLI. It applies the instructions to the code, clears them withboard-resolve, and waits for the next round.board-fix-remotedoes the same for a pull request's preview Storybook, through the hosted board API. It finds the PR and its preview, applies the instructions on the PR branch, pushes, and then clears them. It needs no local Storybook, so it works in Claude Code on the web.
Install it in Claude Code:
/plugin marketplace add ksugawara61/storybook-addon-canvas-comments
/plugin install canvas-comments@storybook-addon-canvas-comments
To turn it on for everyone working in a project, add it to the project's .claude/settings.json:
{
"extraKnownMarketplaces": {
"storybook-addon-canvas-comments": {
"source": {
"source": "github",
"repo": "ksugawara61/storybook-addon-canvas-comments"
}
}
},
"enabledPlugins": {
"canvas-comments@storybook-addon-canvas-comments": true
}
}
Then ask Claude to "turn the canvas comments into issues", or run /canvas-comments:canvas-issues.
Pass dry-run to write the planned issues to canvas-issues-dry-run/ instead of filing them.
Pass api-url=<url> to read hosted comments.
The skill works without any setup in a project with one Storybook.
For anything project-specific, add .claude/canvas-issues.md at the repository root.
Examples are where each app's Storybook lives, the hosted API URL, where shared UI primitives are, and the issue template.
The skill reads that file first and follows it.
To have Claude fix what you send from the board, start Storybook and ask Claude to "watch the board and fix it", or run /canvas-comments:board-fix.
Claude waits in the background; click Send to agent on the board whenever a round of instructions is ready.
Pass once to stop after one round.
For project-specific steps, such as which checks to run after a fix, add .claude/board-fix.md at the repository root.
To have Claude fix what a reviewer sends from a pull request's preview, ask it to "watch the board on the PR preview and fix it", or run /canvas-comments:board-fix-remote.
Pass pr=<number> to pick the PR, and api-url=<url> or storybook-url=<url> when Claude cannot find the preview by itself.
The machine Claude runs on must reach the preview host, and needs CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET when Cloudflare Access protects it.
Add .claude/board-fix-remote.md at the repository root for the preview URL and <app> name of a branch, the checks to run, and how to commit:
- Storybook: packages/web (`pnpm --filter web exec ...`)
- Preview: https://<branch alias>.my-storybook.pages.dev, where the alias is the branch name in lowercase with other characters as `-`
- API: <preview>/api/canvas-comments/web-<branch alias>/comments
- Checks: `pnpm --filter web typecheck` and `pnpm --filter web test`
- Commit messages: `fix(ui): <what changed> (board)`
Development
pnpm install
pnpm typecheck
pnpm test
pnpm build
To try a change in Storybook, run the example in examples/react-vite:
pnpm build
cd examples/react-vite
pnpm install
pnpm storybook
Try a local change in another project with a link: or file: dependency on your checkout.
Run pnpm build after each change, because the consumer loads dist/.
Releasing
CI publishes to npm with Trusted Publishing (OIDC), so the repository holds no npm token.
-
Add the changes to the
Unreleasedsection ofCHANGELOG.mdin the PRs that make them. -
Run the Release workflow (
.github/workflows/release.yaml) onmainfrom the Actions tab and pickpatch,minor, ormajor. It runs in thenpmenvironment. It bumpspackage.json, moves theUnreleasednotes inCHANGELOG.mdunder the new version, and runs the checks. Then it pushes achore: release vX.Y.Zcommit and thevX.Y.Ztag tomain, stages the package on npm with provenance (npm stage publish), and creates the GitHub Release. The release notes are the version'sCHANGELOG.mdsection followed by the notes GitHub generates from the merged PRs. If a commit lands onmainwhile it runs, the push fails before anything is published. Run it again. Re-running a failed run after the push resumes from the tag and skips what is already done. -
Approve the staged version with 2FA. Until then it is not public. On npmjs.com, open the Staged Packages tab in your account settings, review the version, and click Approve. Or use the CLI (npm 11.15.0 or later):
npm stage list storybook-addon-canvas-comments npm stage approve <stage-id>
One-time setup
- GitHub: the workflow pushes to
mainwithGITHUB_TOKEN. If a branch protection rule or ruleset onmainrequires pull requests, the push is rejected, so let the release bypass it (for example, push with a GitHub App token that is on the ruleset's bypass list). - GitHub (optional): add required reviewers to the
npmenvironment under Settings → Environments to approve every publish by hand. Protectmainwith "Require review from Code Owners" so changes to.github/workflows/need the owner's review (see.github/CODEOWNERS). - npm: a package must exist on npm before it can have a Trusted Publisher.
For the first release, publish a placeholder once, for example with
npx setup-npm-trusted-publish storybook-addon-canvas-comments. - npm: under the package's Settings → Trusted Publisher, choose GitHub Actions and enter:
- Organization or user:
ksugawara61 - Repository:
storybook-addon-canvas-comments - Workflow filename:
release.yaml - Environment name:
npm - Allowed actions: leave both "Allow npm publish" and "Allow npm dist-tag" unchecked, so CI can only stage new versions.
- Organization or user:
- npm: set Publishing access to "Require two-factor authentication and disallow tokens".
If publishing fails with 422 Unprocessable Entity, check the Trusted Publisher settings and that repository.url in package.json matches this repository.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ksugawara61/storybook-addon-canvas-comments.


