Whiteboard: ungroup is not undoable #186
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#186
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
WhiteboardGroups.ungroup(static/web/js/whiteboard/groups.js:167-178) destroys the group container and callsWhiteboardSync.onDelete(id)directly, with noWhiteboardHistory.push({ type: "delete", id, state }). After ungrouping a 30-object group there is no Ctrl+Z to bring the group back.Approach
Mirror the pattern used by
WhiteboardObjects.deleteObject(objects.js:1384): snapshot the group viaWhiteboardSync.serializeForServer(groupNode)BEFORE destroying, then push{ type: "delete", id, state }once the local destroy + objects-registry cleanup are done, and letWhiteboardSync.onDelete(id)persist the server-side delete as today.Undo path is already wired:
history.js:171callsrecreateObject(action.state)fortype === "delete", which goes throughWhiteboardApp.renderSingleObject(state)→createGroupFromData(obj, data)(app.js:530). The serialized payload already includes_groupState.nameand_groupState.children, so the group reappears with the same children references and the same name.Acceptance
object.deleted/object.created) still fires for both ungroup and the undo re-create.Out of scope
z-order chevrons (#14), comment marker rotate/scale (#25).
Implementation Spec for Issue #186
Objective
Make
ungroupundoable: Ctrl+Z restores the group container around the same children.Approach
Mirror
WhiteboardObjects.deleteObject(objects.js:1384): snapshot the group viaWhiteboardSync.serializeForServer(groupNode)before destroying it, then push{ type: 'delete', id, state }. ExistingrecreateObjectpath (history.js:119) →WhiteboardApp.renderSingleObject→createGroupFromDatahandles the undo recreate.File to Modify
crates/hero_whiteboard_admin/static/web/js/whiteboard/groups.jsImplementation Plan
Step 1: Snapshot + history push in
ungroupReplace the function body (
groups.js:167-178) with:Acceptance Criteria
object.deleted/object.createdbroadcasts fire for the original ungroup and the undo recreate.Notes
serializeForServeralready captures_groupState.name+_groupState.childrenvia thegrouptype branch (sync.js:331-335).createGroupFromData(app.js:530) handles the recreation: it rebuilds the visual chrome and rebinds the child ids list.snapshotguard (if (snapshot)) is defensive —serializeForServershould always return a payload for an existing group, but fail-soft on missing dependency.Test Results + Final Summary
Changes
static/web/js/whiteboard/groups.js—ungroupnow snapshots the group viaWhiteboardSync.serializeForServer(groupNode)before destroy and pushes{ type: 'delete', id, state: snapshot }on the history stack.WhiteboardSync.onDelete(id)continues to fire after, unchanged.Behaviour after fix
object.deleted(the ungroup) and oneobject.created(the undo).Gates
node -c groups.js— JS syntax OKcargo fmt --check— passcargo clippy --workspace --all-targets -- -D warnings— passManual verification still required
Rebuild + restart
hero_whiteboard_admin, hard-reload. Group a few objects (Ctrl+G), Ungroup via the selection-toolbar or shortcut, press Ctrl+Z — verify the group container is restored with its name and child references.