diff --git a/lib/community-sync.ts b/lib/community-sync.ts index d20cc0e..85cd411 100644 --- a/lib/community-sync.ts +++ b/lib/community-sync.ts @@ -263,6 +263,7 @@ export class CommunitySync extends EventTarget { * Apply incoming Automerge sync message */ #applySyncMessage(message: Uint8Array): void { + const oldDoc = this.#doc; const result = Automerge.receiveSyncMessage( this.#doc, this.#syncState, @@ -276,10 +277,16 @@ export class CommunitySync extends EventTarget { this.#scheduleSave(); this.#persistSyncState(); - // Apply changes to DOM if we received new patches - const patch = result[2] as { patches: Automerge.Patch[] } | null; - if (patch && patch.patches && patch.patches.length > 0) { - this.#applyPatchesToDOM(patch.patches); + // Apply changes to DOM if the document changed + if (this.#doc !== oldDoc) { + const patch = result[2] as { patches: Automerge.Patch[] } | null; + if (patch && patch.patches && patch.patches.length > 0) { + this.#applyPatchesToDOM(patch.patches); + } else { + // Automerge 2.x receiveSyncMessage may not return patches; + // fall back to full document-to-DOM reconciliation + this.#applyDocToDOM(); + } } // Generate response if needed diff --git a/website/canvas.html b/website/canvas.html index 022b027..5ee7af0 100644 --- a/website/canvas.html +++ b/website/canvas.html @@ -249,6 +249,13 @@ touch-action: none; /* Prevent browser gestures, handle manually */ } + #canvas-content { + position: absolute; + top: 0; + left: 0; + transform-origin: 0 0; + } + /* Touch-friendly resize handles */ @media (pointer: coarse) { folk-shape::part(resize-top-left), @@ -326,6 +333,34 @@ outline: 3px solid #22c55e !important; outline-offset: 4px !important; } + + /* Mobile toolbar: icon-only scrollable strip */ + @media (max-width: 768px) { + #toolbar { + max-width: calc(100vw - 32px); + overflow-x: auto; + scrollbar-width: none; + gap: 4px; + padding: 6px 8px; + touch-action: pan-x; + } + #toolbar::-webkit-scrollbar { + display: none; + } + #toolbar button { + max-width: 36px; + min-width: 36px; + padding: 8px; + overflow: hidden; + white-space: nowrap; + } + #community-info { + display: none; + } + #memory-panel { + max-width: calc(100vw - 32px); + } + }
@@ -381,7 +416,7 @@ Connecting... - +