Skip to content

feat: comment tool with canvas annotations and collab sync#26

Merged
trmquang93 merged 4 commits intomainfrom
fix/comment-tool-cursor
Apr 6, 2026
Merged

feat: comment tool with canvas annotations and collab sync#26
trmquang93 merged 4 commits intomainfrom
fix/comment-tool-cursor

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a Comment tool (C key) for placing anchored comment pins on screens, hotspots, and connections directly on the canvas
  • Comments sync in real-time via Supabase Realtime broadcast alongside the existing collab session
  • Includes a Comments panel (side drawer) with open/resolved filtering, permission-aware actions, and canvas navigation on click
  • Adds 7 MCP server tools for programmatic comment management (list_comments, create_comment, update_comment, resolve_comment, delete_comment, and cascade-aware delete on entity removal)
  • File format bumped to v14 with full backward-compat import

Key files

Area File
State + CRUD src/hooks/useCommentManager.js
Canvas pin src/components/CommentPin.jsx
Inline composer src/components/CommentComposer.jsx
Side panel src/components/CommentsPanel.jsx
MCP tools mcp-server/src/tools/comment-tools.js
Utilities src/utils/commentUtils.js

Test plan

  • Place a comment in comment mode (C) on a screen — pin appears at click position
  • Place a comment on a hotspot and on a connection
  • Resolve a comment from the pin popover and from the Comments panel
  • Reviewer (non-moderator) can resolve and reopen their own comments but cannot reopen others'
  • Delete a screen — its comments are gone from the panel and the saved file
  • Delete a hotspot — its comments are gone
  • Open CommentComposer near the bottom edge of the viewport — composer stays on screen
  • Collab: two sessions — comment added in one appears in the other without reload
  • MCP: create_comment, list_comments, resolve_comment, delete_comment all work against a live .drawd file
  • npm test passes

Add a custom SVG speech bubble cursor (accent blue) that appears whenever
the comment tool is selected. The cursor persists over all child elements
including screen nodes, hotspots, and resize handles. Space+drag panning
still overrides to grab/grabbing as expected.
Introduces a full comment system: pin-based annotations on screens, hotspots, and connections; CommentComposer, CommentPin, and CommentsPanel UI components; useCommentManager CRUD hook with role-based permissions (host/editor/reviewer/viewer); collab broadcast sync for real-time comment updates; MCP server comment tools; and file format support (importFlow/exportFlow). Keyboard shortcut C activates the comment tool. User guide updated.
- Extract timeAgo/targetLabel from CommentsPanel into commentUtils.js
  and add 16 tests covering all branches and boundary conditions
- Add 25 tests for useCommentManager covering CRUD, resolve/unresolve,
  and all cascade delete helpers with cross-type safety checks
- Add 28 tests for FlowState comment operations (mcp-server/state.js),
  including listComments filters and getSummary counts
- Add 15 tests for handleCommentTool dispatch layer using mock state
- Extend buildPayload tests with comments passthrough + buildCollabPayload
- Extend importFlow tests with backward compat for missing comments field
- Cascade-delete comments in MCP state.js when screen/hotspot/connection
  is deleted, matching the React-side commentCallbacksRef behaviour
- Fix CommentPin popover position stale on first open: move
  getBoundingClientRect call into useLayoutEffect instead of render
- Guard update_comment / resolve_comment return values in comment-tools.js
  against undefined (contracts diverged between FlowState and React hook)
- Allow reviewers to reopen their own resolved comments in CommentsPanel
  (was gated on canModerate only, inconsistent with resolve permission)
- Clamp CommentComposer vertically to prevent overflow at bottom of viewport
@trmquang93 trmquang93 merged commit 66af164 into main Apr 6, 2026
1 check passed
@github-actions github-actions bot deleted the fix/comment-tool-cursor branch April 6, 2026 04:39
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