fix(whiteboard): stop malformed agent-drawn elements from crashing the board - #953
Closed
lukebrevoort wants to merge 2 commits into
Closed
fix(whiteboard): stop malformed agent-drawn elements from crashing the board#953lukebrevoort wants to merge 2 commits into
lukebrevoort wants to merge 2 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevent malformed agent-created whiteboard elements from crashing or hanging the whiteboard.
This is the main-repository version of the fix discussed in #857; the fork branch was not modified.
Verification
pnpm run checkpasses.