Commit Graph

236 Commits

Author SHA1 Message Date
Jeff Emmett c18d204814 fix: simplify Automerge document creation for concurrent access
Removed document ID storage/retrieval logic that was causing "Document unavailable"
errors. Each client now creates its own Automerge document handle and syncs content
via WebSocket binary protocol. This allows multiple boards to load the same room
simultaneously without conflicts.

- Removed /room/:roomId/documentId endpoints usage
- Each client creates document with repo.create()
- Content syncs via Automerge's native binary sync protocol
- Initial content still loaded from server via HTTP

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 21:40:15 -07:00
Jeff Emmett 3231720004 fix: add await to repo.find() call
repo.find() returns a Promise<DocHandle>, not DocHandle directly.
Added missing await keyword to fix TypeScript build error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 21:26:42 -07:00
Jeff Emmett ca9f250de8 fix: handle concurrent Automerge document access with try-catch
When multiple clients try to load the same room simultaneously, repo.find()
throws "Document unavailable" error if the document isn't in the repo yet.
Wrapped repo.find() in try-catch to create a new handle when document isn't
available, allowing multiple boards to load the same page concurrently.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 21:15:56 -07:00
Jeff Emmett 6ab966cc95 fix: use proper Automerge URL format for repo.find()
The issue was that repo.find() was creating a NEW document instead of
waiting for the existing one to sync from the network.

Changes:
- Use 'automerge:{documentId}' URL format for repo.find()
- Remove try-catch that was creating new documents
- Let repo.find() properly wait for network sync

This ensures all clients use the SAME document ID and can sync in real-time.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 21:00:18 -07:00
Jeff Emmett 02808d170e fix: handle Document unavailable error with try-catch in repo.find()
When repo.find() is called for a document that exists on the server but not
locally, it throws 'Document unavailable' error. This fix:

- Wraps repo.find() in try-catch block
- Falls back to creating new handle if document not found
- Allows sync adapter to merge with server state via network

This handles the case where clients join existing rooms and need to sync
documents from the network.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 20:33:31 -07:00
Jeff Emmett 2cc7c52755 refactor: remove OddJS dependency and fix Automerge sync
Major Changes:
- Fix Automerge "Document unavailable" error by awaiting repo.find()
- Remove @oddjs/odd package and all related dependencies (205 packages)
- Remove location sharing features (OddJS filesystem-dependent)
- Simplify auth to use only CryptoAuthService (WebCryptoAPI-based)

Auth System Changes:
- Refactor AuthService to remove OddJS filesystem integration
- Update AuthContext to remove FileSystem references
- Delete unused auth files (account.ts, backup.ts, linking.ts)
- Delete unused auth components (Register.tsx, LinkDevice.tsx)

Location Features Removed:
- Delete all location components and routes
- Remove LocationShareShape from shape registry
- Clean up location references across codebase

Documentation Updates:
- Update WEBCRYPTO_AUTH.md to remove OddJS references
- Correct component names (CryptoLogin → CryptID)
- Update file structure and dependencies
- Fix Automerge README WebSocket path documentation

Build System:
- Successfully builds without OddJS dependencies
- All TypeScript errors resolved
- Production bundle size optimized

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 20:19:02 -07:00
Jeff Emmett 1e68150b60 fix: implement real-time Automerge sync across clients
- Add document ID coordination via server to ensure all clients sync to same document
- Add new endpoints GET/POST /room/:roomId/documentId for document ID management
- Store automergeDocumentId in Durable Object storage
- Add enhanced logging to CloudflareAdapter send() method for debugging
- Add sharePolicy to Automerge Repo to enable document sharing
- Fix TypeScript errors in useAutomergeSyncRepo

This fixes the issue where each client was creating its own Automerge document
with a unique ID, preventing real-time sync. Now all clients in a room use the
same document ID, enabling proper real-time collaboration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 19:45:36 -07:00
Jeff Emmett 0882648565 feat: rebrand CryptoLogin to CryptID
- Rename CryptoLogin component to CryptID
- Update all imports and usages across the codebase
- Display 'CryptID: username' in user dropdown menu
- Update UI text to reference CryptID branding
- Update Profile component header to show CryptID
- Update component comments and documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 14:09:23 -07:00
Jeff Emmett f963152238 chore: remove Vercel dependencies and config files
- Remove @vercel/analytics dependency and usage
- Remove vercel CLI dependency
- Delete vercel.json configuration file
- Delete .vercel cache directory
- Site now fully configured for Cloudflare Pages deployment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 13:35:50 -07:00
Jeff Emmett 48dac00f59 fix: use repo.create() instead of invalid document ID format
Change from repo.find('automerge:patricia') to repo.create() because
Automerge requires proper UUID-based document IDs, not arbitrary strings.

Each client creates a local document, loads initial data from server,
and syncs via WebSocket. The server syncs documents by room ID, not
by Automerge document ID.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 05:13:37 -07:00
Jeff Emmett 776526c65e fix: add type cast for currentDoc to fix TypeScript error
Cast handle.doc() to any to fix TypeScript error about missing 'store' property.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 05:04:54 -07:00
Jeff Emmett 64d4a65613 fix: await repo.find() to fix TypeScript build errors
repo.find() returns a Promise<DocHandle>, so we need to await it.
This fixes the TypeScript compilation errors in the build.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 05:00:04 -07:00
Jeff Emmett 432e90d9ef fix: enable production logging for R2 persistence debugging
Add console logs in production to debug why shapes aren't being saved to R2.
This will help identify if saves are:
- Being triggered
- Being deferred/skipped
- Successfully completing

Logs added:
- 💾 When persistence starts
-  When persistence succeeds
- 🔍 When shape patches are detected
- 🚫 When saves are skipped (ephemeral/pinned changes)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 04:56:32 -07:00
Jeff Emmett 71e7e5de05 fix: remove ImageGen references to fix build
Remove ImageGenShape import and references from useAutomergeStoreV2.ts
to fix TypeScript build error. ImageGen feature files are not yet committed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 04:17:49 -07:00
Jeff Emmett 90605bee09 fix: enable real-time multiplayer sync for automerge
Add manual sync triggering to broadcast document changes to other peers in real-time.
The Automerge Repo wasn't auto-broadcasting because the WebSocket setup doesn't use peer discovery.

Changes:
- Add triggerSync() helper function to manually trigger sync broadcasts
- Call triggerSync() after all document changes (position updates, eraser changes, regular changes)
- Pass Automerge document to patch handlers to prevent coordinate loss
- Add ImageGenShape support to schema

This fixes the issue where changes were being saved to Automerge locally but not
broadcast to other connected clients until page reload.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 04:00:31 -07:00
Jeff Emmett 7a17b0944a fix custom shape type validation errors
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 <noreply@anthropic.com>
2025-11-16 03:13:07 -07:00
Jeff Emmett f5582fc7d1 prevent coordinate collapse on reload
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 03:03:39 -07:00
Jeff Emmett 4d7b05efa2 update obsidian shape deployment 2025-11-12 16:23:08 -08:00
Jeff Emmett ab1d0344a5 fix cloudflare deployment glitches 2025-11-11 22:47:36 -08:00
Jeff Emmett 04f6fe5192 deployment fix 2025-11-11 22:42:38 -08:00
Jeff Emmett 2528ad4726 update cloudflare errors 2025-11-11 22:38:24 -08:00
Jeff Emmett ffef04df50 pin object, fix fathom, and a bunch of other things 2025-11-11 22:32:36 -08:00
Jeff Emmett 5fd83944fc coordinate fix 2025-11-11 01:08:55 -08:00
Jeff Emmett a3950baf17 fix coords 2025-11-11 00:57:45 -08:00
Jeff Emmett ef4a84e8f1 remove coordinate reset 2025-11-11 00:53:55 -08:00
Jeff Emmett d1179169cc fix coordinates 2025-11-10 23:54:54 -08:00
Jeff Emmett 0e90e2d097 preserve coordinates 2025-11-10 23:51:53 -08:00
Jeff Emmett eafbf6c9fe shape rendering on prod 2025-11-10 23:36:12 -08:00
Jeff Emmett edbe76ebda fix coordinates 2025-11-10 23:25:44 -08:00
Jeff Emmett ef39328d95 preserve coordinates 2025-11-10 23:17:16 -08:00
Jeff Emmett 229f4d6b41 fix coordinates 2025-11-10 23:04:52 -08:00
Jeff Emmett 0fa1652f72 prevent coordinate reset 2025-11-10 23:01:35 -08:00
Jeff Emmett 1b172d7529 update x & y coordinates 2025-11-10 22:42:52 -08:00
Jeff Emmett c1df50c49b fix prod 2025-11-10 22:27:21 -08:00
Jeff Emmett 053bd95d4a fix prod I hope 2025-11-10 20:53:29 -08:00
Jeff Emmett 73ac456e17 update dev and prod shape render 2025-11-10 20:16:45 -08:00
Jeff Emmett 92cac8dee5 fix prod shape render 2025-11-10 20:05:07 -08:00
Jeff Emmett b8fb64c01b update prod shape render 2025-11-10 19:54:20 -08:00
Jeff Emmett 680b6a5359 update prod 2025-11-10 19:44:49 -08:00
Jeff Emmett fec80ddd18 fix shape rendering in prod 2025-11-10 19:42:06 -08:00
Jeff Emmett 5b32184012 fix shape deployment in prod 2025-11-10 19:26:44 -08:00
Jeff Emmett be5f1a5a3a fix prod deployment 2025-11-10 19:23:15 -08:00
Jeff Emmett bf5d214e45 update for prod 2025-11-10 19:21:22 -08:00
Jeff Emmett f8e4fa3802 update production shape loading 2025-11-10 19:15:36 -08:00
Jeff Emmett 04135a5487 updates to production 2025-11-10 18:57:04 -08:00
Jeff Emmett 5e11183557 fix cloudflare 2025-11-10 18:48:39 -08:00
Jeff Emmett b5463d4d64 update for shape rendering in prod 2025-11-10 18:43:52 -08:00
Jeff Emmett bda2523e3b fix production automerge 2025-11-10 18:29:19 -08:00
Jeff Emmett 3072dc70c0 fix prod 2025-11-10 18:10:55 -08:00
Jeff Emmett 62afed445e final automerge errors on cloudflare 2025-11-10 18:01:36 -08:00