Skip to content

Real eraser: erasing splits or removes what it touches - #66

Merged
BPMData merged 2 commits into
mainfrom
claude/project-thread-380vka
Nov 24, 2026
Merged

BPMData merged 2 commits into
mainfrom
claude/project-thread-380vka

Conversation

@BPMData

@BPMData BPMData commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Before: the eraser saved a white "eraser stroke" that only hid ink at render time. Each swipe made a board heavier. Erased notes and strokes still existed, still showed up in lasso selection, and still counted in "N drawn".

After: when the pen lifts, the eraser stroke becomes real edits and no eraser stroke is stored.

  • Pen, highlighter, spray, straight lines and the shape brush: split into the pieces that are left. A cut shape-brush stroke ends in its tip shape, and each piece gets its own cached picture.
  • Fully covered ink, text notes and stamps: removed.
  • Rectangles and circles: these have no points to split. They are removed when fully covered. When only partly covered, a trimmed piece of the eraser is kept over just them.
  • Undo and other screens: one undo restores everything exactly, and other screens see the same result.

How:

  • src/lib/eraserEdits.ts works out the edits. It only touches the eraser's own author's ink drawn before the eraser, the same rule as before.
  • They are sent as order-keeping groups through a new elements-replace event (src/lib/elementGroups.ts). Each group removes ids and inserts the new elements where the first of them was, so stacking order never changes.
  • Undo is one groups history step. A fully removed element is put back right after the element that preceded it.
  • The server applies the same rules as batch add and remove: only your own ink (teachers: anyone's), the lock, the board cap and the one-name-stamp rule.
  • If an edit would pass the server's size limits, the eraser falls back to the old eraser stroke.
  • Old rooms' eraser strokes still render as before.

Tests:

  • tests/eraserEdits.test.ts covers splitting, long segments, full removal, other people's ink, shape-brush pieces, notes and stamps, the partial rectangle, and an exact undo/redo round trip. It also covers the server: sync to a second screen, a late joiner's view, undo, and refusing to remove other people's ink.
  • e2e/eraser.spec.ts covers a shape-brush stroke split, a second screen, undo and full erase. It couldn't run in my environment (no browser), so CI is its first run.

Closes the TODO.md item "A real eraser".


Generated by Claude Code

…ring an eraser stroke

- On pen-up an eraser stroke becomes edits (src/lib/eraserEdits.ts): pen, highlighter,
  spray, straight lines and shape-brush strokes are split into what's left; fully
  covered ink, notes and stamps are removed; no eraser element is stored. Rectangles
  and circles it only partly covers keep a trimmed piece of eraser over just them.
- New elements-replace event applies the edits in place (src/lib/elementGroups.ts), so
  stacking order never changes and one undo restores everything exactly.
- Tests: tests/eraserEdits.test.ts (geometry, order, undo, server sync and permissions)
  and e2e/eraser.spec.ts (shape brush split, second screen, undo, full erase).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"N drawn" in the sidebar is only the viewer's own count, so the second
student's screen always read "0 drawn" for Alex's ink. Join the second
browser as the teacher and read Alex's live item count on the Class tab,
the same way classroom.spec.ts checks ink sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BPMData
BPMData merged commit 26328b5 into main Nov 24, 2026
2 checks passed
@BPMData
BPMData deleted the claude/project-thread-380vka branch November 24, 2026 16:17
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.

2 participants