Increase CRDT DB persist debounce from 2s to 30s since it's only needed for
crash recovery (CRDT handles real-time sync). Increase LocalStorage draft
save debounce from 1s to 5s.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add connection timeout (15s) to handle stale initial subscribes, inactivity
pause (5min) to save resources when idle, and automatic resume on user activity
or tab focus. The heartbeat now detects unhealthy channel states and consecutive
failures to trigger reconnects. Unexpected CLOSED status also triggers reconnect
instead of staying disconnected silently.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of relying on Yjs broadcast serialization (which has delivery
issues), use a lightweight state-refresh broadcast event. When any
client persists (manual save or CRDT auto-persist), it broadcasts
state-refresh. Other clients fetch the latest flowchart_data from the
database and update their local state and CRDT.
Added isSuppressed flag to CRDTManager to prevent broadcast/persist
loops during initialization and refresh operations.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a user saves, the full Yjs document state is broadcast so all
connected clients converge, even if they missed incremental updates.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The yjs-update broadcast listener was added after the Supabase channel
was already subscribed, which meant it never received messages. Moved
the listener registration to the builder chain before .subscribe()
(matching how cursor/node-lock listeners work), and removed the broken
isRemoteUpdateRef guard that caused ReferenceErrors preventing local
changes from reaching the CRDT.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Yjs map observers were calling notifyNodesChange/notifyEdgesChange
for local changes, creating a feedback loop that reset React Flow state
mid-drag. Remote notifications are already handled by the connectChannel
handler, so the observers only need to schedule persistence.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>