Merge pull request #17 from Jeff-Emmett/add-runpod-AI-API

fix: use repo.create() instead of invalid document ID format
This commit is contained in:
Jeff Emmett 2025-11-16 05:15:49 -07:00 committed by GitHub
commit 8d5ab7b104
1 changed files with 7 additions and 9 deletions

View File

@ -116,16 +116,14 @@ export function useAutomergeSync(config: AutomergeSyncConfig): TLStoreWithStatus
console.log("🔌 Initializing Automerge Repo with NetworkAdapter for room:", roomId)
if (mounted) {
// CRITICAL: Use repo.find() with a consistent document ID based on roomId
// This ensures all windows/tabs share the same Automerge document and can sync properly
// Format: automerge:${roomId} matches what the server expects (see AutomergeDurableObject.ts line 327)
const documentId = `automerge:${roomId}` as any
console.log(`🔌 Finding or creating Automerge document with ID: ${documentId}`)
// CRITICAL: Create or find the document for this room
// We use repo.create() which generates a proper Automerge document ID
// The document will be shared across clients via the WebSocket sync protocol
console.log(`🔌 Creating Automerge document for room: ${roomId}`)
// Use repo.find() to get or create the document with this ID
// This ensures all windows share the same document instance
// Note: repo.find() returns a Promise, so we await it
const handle = await repo.find(documentId)
// Create a new document - Automerge will generate a proper document ID
// All clients connecting to the same room will sync via the WebSocket
const handle = repo.create<TLStoreSnapshot>()
console.log("Found/Created Automerge handle via Repo:", {
handleId: handle.documentId,