From fa6a9f43716dda75ab1c8438d238485133cf6a71 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Sun, 16 Nov 2025 03:13:07 -0700 Subject: [PATCH] fix custom shape type validation errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add case normalization for custom shape types to prevent validation errors when loading shapes with lowercase type names (e.g., "chatBox" → "ChatBox"). The TLDraw schema expects PascalCase type names for custom shapes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/automerge/AutomergeToTLStore.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/automerge/AutomergeToTLStore.ts b/src/automerge/AutomergeToTLStore.ts index a2fb253..3e14891 100644 --- a/src/automerge/AutomergeToTLStore.ts +++ b/src/automerge/AutomergeToTLStore.ts @@ -576,7 +576,33 @@ export function sanitizeRecord(record: any): TLRecord { if (sanitized.type === 'Transcribe') { sanitized.type = 'Transcription' } - + + // CRITICAL: Normalize case for custom shape types (lowercase → PascalCase) + // The schema expects PascalCase (e.g., "ChatBox" not "chatBox") + const customShapeTypeMap: Record = { + 'chatBox': 'ChatBox', + 'videoChat': 'VideoChat', + 'embed': 'Embed', + 'markdown': 'Markdown', + 'mycrozineTemplate': 'MycrozineTemplate', + 'slide': 'Slide', + 'prompt': 'Prompt', + 'transcription': 'Transcription', + 'obsNote': 'ObsNote', + 'fathomNote': 'FathomNote', + 'holon': 'Holon', + 'obsidianBrowser': 'ObsidianBrowser', + 'fathomMeetingsBrowser': 'FathomMeetingsBrowser', + 'locationShare': 'LocationShare', + 'imageGen': 'ImageGen', + } + + // Normalize the shape type if it's a custom type with incorrect case + if (sanitized.type && typeof sanitized.type === 'string' && customShapeTypeMap[sanitized.type]) { + console.log(`🔧 Normalizing shape type: "${sanitized.type}" → "${customShapeTypeMap[sanitized.type]}"`) + sanitized.type = customShapeTypeMap[sanitized.type] + } + // CRITICAL: Infer type from properties BEFORE defaulting to 'geo' // This ensures arrows and other shapes are properly recognized if (!sanitized.type || typeof sanitized.type !== 'string') {