Skip to content

fix(whiteboard): stop malformed agent-drawn elements from crashing the board - #953

Closed
lukebrevoort wants to merge 2 commits into
mainfrom
fix/whiteboard-malformed-elements
Closed

fix(whiteboard): stop malformed agent-drawn elements from crashing the board#953
lukebrevoort wants to merge 2 commits into
mainfrom
fix/whiteboard-malformed-elements

Conversation

@lukebrevoort

Copy link
Copy Markdown
Collaborator

Summary

Prevent malformed agent-created whiteboard elements from crashing or hanging the whiteboard.

  • Sanitize required point arrays before Excalidraw receives scene data.
  • Normalize freedraw pressures alongside points, defaulting invalid values to 0.5.
  • Preserve valid pen pressures and simulatePressure=true behavior.
  • Keep the existing whiteboard error boundary and self-healing read/write paths.
  • Add regression coverage for malformed arrows, lines, freedraw points, and pressures.

This is the main-repository version of the fix discussed in #857; the fork branch was not modified.

Verification

  • pnpm run check passes.
  • Server build passes.
  • Focused whiteboard suite: 45/45 passing.
  • Pre-commit checks pass.
  • Full unit/E2E suites require Docker/PostgreSQL, unavailable in this environment.

lukebrevoort-mytra and others added 2 commits July 30, 2026 11:06
…e board

An agent drew a flow diagram via the whiteboard_update MCP tool and emitted
arrows with no `points` array. Excalidraw's restoreElements() calls
isInvisiblySmallElement() — which reads `element.points.length` unguarded —
before restoreElement() applies its own [[0,0],[width,height]] fallback, so
the scene threw "Cannot read properties of undefined (reading 'length')" and
took down the whole route.

Add sanitizeElements() and apply it in loadWhiteboard and saveWhiteboard, so
malformed geometry can neither be persisted nor served. It applies the same
fallback Excalidraw itself would, just early enough to matter. Sanitizing on
read means boards already holding bad elements render immediately and heal on
their next write, with no data migration.

Also wrap the whiteboard tab in an error boundary so an unrenderable scene
degrades to a message instead of blanking the app, and correct the MCP tool
cheat sheet, which listed `points` as optional and told agents not to
over-validate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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