Whiteboard: read-only viewers can drag comment markers and the move persists #181
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#181
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
/board/{id}/view(and the/s/{token}share link) — readonly mode — comment markers remain draggable. A viewer can grab a marker, drag it to a new position, and thedragendhandler atcomments.js:317-339firesrpcCall("comment.update", { id, x, y }). The server accepts it; the move persists; everyone editing the board sees the marker move next time they refresh.Root cause
Two things conspire:
comments.js:248creates every marker withdraggable: trueunconditionally.makeAllReadonly()(app.js:299-308) iteratesWhiteboardObjects.getAllObjects()to disable dragging — but comment markers live inWhiteboardComments._comments, not inWhiteboardObjects. They are never touched.The popover Reply / Resolve / Delete buttons are NOT a problem here —
WhiteboardComments.init()is skipped in readonly so the popover container is never created andshowCommentPopoverbails at line 413-414. Drag is the only UI-level mutation path.Expected
In readonly mode:
comment.updateRPC is not fired by the viewer.Edit mode is unchanged.
Acceptance
/board/{id}/viewfor a board with comments shows the markers but they cannot be dragged./s/{token}shared link with comments: same as above.comment.updateRPC fires from a readonly client.init()running).Out of scope
Server-side authorisation gap — a determined viewer with devtools can still call
WhiteboardComments.deleteComment(id)directly, and the server has no token-scoped authz oncomment.*RPCs. That is a separate backend issue (file individually if needed); it is not a UI fix.Implementation Spec for Issue #181
Objective
In readonly mode (
/board/{id}/viewand/s/{token}), comment markers must render but be undraggable.Approach
Smallest, contained change to
comments.js+ a one-liner fromapp.js:_readonlyflag incomments.js.setReadonly(value)that flips the flag AND walks all currently-rendered markers to toggle their Konvadraggable()accordingly.addCommentMarker, create the marker withdraggable: !_readonly.app.js, callWhiteboardComments.setReadonly(readonlyMode)BEFORE theloadCommentscall so newly-created markers respect the flag, and any pre-existing ones from a re-render are also flipped.No need to change
makeAllReadonly(it has its own concern: real objects).Files to Modify
crates/hero_whiteboard_admin/static/web/js/whiteboard/comments.jscrates/hero_whiteboard_admin/static/web/js/whiteboard/app.jsImplementation Plan
Step 1: Add
_readonlyflag +setReadonlyin comments.jsAt the top of the module (after the existing
var _escHandler), add:In the IIFE return at the bottom, expose:
And define the function near
init:Dependencies: none.
Step 2: Honor
_readonlyinaddCommentMarkerFile:
comments.js, change line ~248 from:to:
Dependencies: Step 1.
Step 3: Wire from app.js
File:
app.js, before line 264 (await WhiteboardComments.loadComments(boardId);), add:This handles both the readonly and editable initial path. For
refreshFromServerpolling in readonly mode (line 154-157), it does not re-create markers vialoadComments— it goes throughapplySyncUpdatefor objects only. Comments aren't included in that path, so a singlesetReadonlycall at init suffices for the readonly viewer lifecycle.Dependencies: Step 1 + 2.
Acceptance Criteria
/board/{id}/viewshows comment markers; clicking does nothing visible (popover container does not exist — pre-existing behavior); dragging a marker does NOT move it and does NOT firecomment.update./s/{token}shared link: same as above./board/{id}) drag still works and still pushes history (#179).Notes
setReadonlyis idempotent and safe to call multiple times.WhiteboardObjects.makeAllReadonly()— it's its own scope.comment.*RPCs from readonly clients) is explicitly out of scope per the issue text.Test Results + Final Summary
Changes
static/web/js/whiteboard/comments.js:_readonlyflag.setReadonly(value)— sets the flag and walks all existing markers, toggling.draggable(!_readonly). Exported in the IIFE return.addCommentMarkernow creates markers withdraggable: !_readonly.static/web/js/whiteboard/app.js:WhiteboardComments.setReadonly(readonlyMode)immediately beforeloadComments. Handles both first-load and any future re-render path.Behaviour after fix
/board/{id}/viewand/s/{token}: markers visible; cursor is the pan-hand fromsetupReadonlyPan; dragging a marker does nothing and nocomment.updateRPC fires./board/{id}: drag still works, history is still pushed (#179), broadcasts still go out.Gates
node -c comments.js/node -c app.js— JS syntax OKcargo fmt --check— passcargo clippy --workspace --all-targets -- -D warnings— passcargo test --workspace --lib— 0 tests, 0 failuresAcceptance Criteria
comment.update.Out of scope (per the issue)
Server-side auth on
comment.*for share-link clients. A determined readonly viewer can still callWhiteboardComments.deleteComment(id)from devtools. File a backend issue if you want that closed.Manual verification still required
Rebuild + restart
hero_whiteboard_admin, hard-reload/board/{id}(edit) and/board/{id}/view(readonly), attempt to drag a comment marker in each.