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 profiles table RLS policies only allowed users to view their own
profile, causing the share feature to fail when searching for users
by email. Added a policy allowing any authenticated user to read profiles.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add isSaving as a prop so the save button properly shows disabled/spinner
state. Add a back arrow link to /dashboard for editor navigation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ChoiceNode was passing incompatible props (optionId, optionLabel, onSave,
onRemove, onCancel) to OptionConditionEditor which expects (condition,
onChange, onClose). This caused a build failure preventing the component
tree from rendering.
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>
The merge at bcbad57 lost utility functions, type definitions, and
handlers from the developing branch. This restores: imports (useRef,
useEffect, ConditionalEdge, ContextMenu), constants (AUTOSAVE_DEBOUNCE_MS),
types (ContextMenuState, ConditionEditorState), utility functions
(fromReactFlowNodes, fromReactFlowEdges, saveDraft, loadDraft, clearDraft,
flowchartDataEquals, isValidFlowchartData, convertToRenpyFormat), context
menu handlers, proper FlowchartEditorProps (userId, userDisplayName,
isOwner), ReactFlow container height (h-screen), and fixes stale closure
dependency arrays for characters/variables.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use SECURITY DEFINER helper functions to break circular dependencies
between projects and project_collaborators table policies.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace the variableName text input in edge conditions with a
Combobox-based variable selector. Adds ConditionEditor modal
that opens on edge click, with type-aware operators (comparison
for numeric, == and != for string/boolean) and type-adaptive
value inputs (number, text, or boolean toggle).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>