Commit Graph

142 Commits

Author SHA1 Message Date
GHMiranda f077d902b4 Merge pull request 'developing' (#10) from developing into master
Reviewed-on: #10
2026-01-25 00:37:10 +00:00
GHMiranda 75750cf226 Merge pull request 'ralph/collaboration-and-character-variables' (#9) from ralph/collaboration-and-character-variables into developing
Reviewed-on: #9
2026-01-25 00:11:20 +00:00
Gustavo Henrique Santos Souza de Miranda cd3ecc4507 fix: only force-reconnect on tab visibility change, not on activity gaps
The 60s stale threshold was triggering during normal use (reading, thinking)
causing constant reconnects and presence join/leave toast spam. Now force-
reconnect only happens when the tab was hidden for 3+ minutes and becomes
visible again. Regular activity (mouse/keyboard) only resets the inactivity
timer without ever forcing a reconnect.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 19:35:00 -03:00
Gustavo Henrique Santos Souza de Miranda 3b19f58e26 fix: wait for auth session before connecting to realtime channel
On initial page load, the Supabase browser client's auth session may not
be ready yet (still loading from cookies). The Realtime channel subscription
silently fails without a valid access token. Now connect() awaits getSession()
first, which ensures the token is available and also refreshes expired tokens
on reconnect after inactivity.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 19:22:22 -03:00
Gustavo Henrique Santos Souza de Miranda 9769a80381 Merge branch 'developing' of git.gustavomiranda.xyz:GHMiranda/WebVNWrite into ralph/collaboration-and-character-variables 2026-01-24 19:15:17 -03:00
Gustavo Henrique Santos Souza de Miranda c28b9ac565 fix: force fresh reconnect when returning after idle period
The WebSocket can go stale during inactivity without triggering any error
status (channel still shows 'joined' but socket is dead). Now when the user
returns after 60+ seconds of inactivity, the connection is torn down and
re-established to guarantee a fresh WebSocket. This ensures CRDT broadcasts
actually reach other clients after returning from idle.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 19:14:14 -03:00
Gustavo Henrique Santos Souza de Miranda fa8437d03a fix: broadcast full CRDT state on connect and when new user joins
CRDT broadcasts are fire-and-forget, so any updates missed during a
disconnection were permanently lost. Now when a client connects (or
reconnects), it broadcasts its full Yjs doc state. When an existing client
sees a new user join, it also broadcasts its full state. Yjs merges
handle deduplication automatically, so this converges all clients.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 19:06:20 -03:00
Gustavo Henrique Santos Souza de Miranda 2d0c3b6df6 fix: reduce auto-save frequency to avoid excessive writes
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>
2026-01-24 18:58:54 -03:00
Gustavo Henrique Santos Souza de Miranda ec053d8126 fix: stop state ping-pong by removing broadcastStateRefresh from auto-persist
The CRDT auto-persist was broadcasting state-refresh after each save, causing
other clients to fetch from DB and overwrite their local variables/characters
with stale values. Since CRDT already syncs nodes/edges via yjs-update
broadcasts, the state-refresh from auto-persist was redundant and destructive.
Manual save still broadcasts state-refresh as intended.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 18:46:59 -03:00
Gustavo Henrique Santos Souza de Miranda cd73b31739 fix: improve realtime connection resilience with auto-reconnect and activity-based lifecycle
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>
2026-01-24 18:20:41 -03:00
Gustavo Henrique Santos Souza de Miranda eb86ccd291 feat: notify collaborators to refresh from DB after save
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>
2026-01-24 16:36:43 -03:00
Gustavo Henrique Santos Souza de Miranda cdaae6b965 feat: broadcast full CRDT state to other clients after manual save
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>
2026-01-24 16:12:58 -03:00
Gustavo Henrique Santos Souza de Miranda 34815d70ee fix: resolve CRDT collaboration sync by registering broadcast listener before channel subscribe
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>
2026-01-24 16:08:32 -03:00
Gustavo Henrique Santos Souza de Miranda dc7875eeea fix merge 2026-01-24 03:13:53 -03:00
Gustavo Henrique Santos Souza de Miranda c9f5231137 docs: update PRD and progress for US-053
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:58:14 -03:00
Gustavo Henrique Santos Souza de Miranda 315e34e25e feat: [US-053] - Revert changes from audit trail
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:57:36 -03:00
Gustavo Henrique Santos Souza de Miranda f06a30b2bf feat: [US-052] - Activity history sidebar
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:53:31 -03:00
Gustavo Henrique Santos Souza de Miranda 6c4a3ba2b7 docs: update PRD and progress for US-051
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:47:41 -03:00
Gustavo Henrique Santos Souza de Miranda 6ef5cfc7fa feat: [US-051] - Audit trail recording
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:46:52 -03:00
Gustavo Henrique Santos Souza de Miranda 4a85d7a64b feat: [US-049] - Node editing lock indicators
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 02:43:06 -03:00
Gustavo Henrique Santos Souza de Miranda 5b84170a28 fix: allow profile lookup for sharing by adding RLS policy
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>
2026-01-24 02:38:05 -03:00
Gustavo Henrique Santos Souza de Miranda ccb05e3a3e feat: [US-050] - Join/leave notifications
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:08:05 -03:00
Gustavo Henrique Santos Souza de Miranda 841a44112a feat: [US-047] - Live cursor positions on canvas
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:04:09 -03:00
Gustavo Henrique Santos Souza de Miranda 7fe10544a1 feat: [US-047] - Live cursor positions on canvas
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:03:17 -03:00
GHMiranda d2c48c0c9a Merge pull request 'ralph/collaboration-and-character-variables' (#8) from ralph/collaboration-and-character-variables into developing
Reviewed-on: #8
2026-01-24 00:00:47 +00:00
GHMiranda bda19a2970 Merge branch 'developing' into ralph/collaboration-and-character-variables 2026-01-23 23:59:55 +00:00
Gustavo Henrique Santos Souza de Miranda b6d85b1a47 fix: add isSaving prop and back-to-dashboard navigation to Toolbar
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>
2026-01-23 20:55:07 -03:00
Gustavo Henrique Santos Souza de Miranda 8f6cff52a9 fix: correct OptionConditionEditor props in ChoiceNode
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>
2026-01-23 20:54:54 -03:00
Gustavo Henrique Santos Souza de Miranda 6bc4e32fde fix: remove CRDT observer feedback loop causing drag issues
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>
2026-01-23 20:54:45 -03:00
Gustavo Henrique Santos Souza de Miranda fa336f05d9 fix: restore missing utilities, context menu, and props from failed merge
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>
2026-01-23 20:54:29 -03:00
Gustavo Henrique Santos Souza de Miranda 841eefb186 fix: resolve infinite recursion in RLS policies
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>
2026-01-23 20:11:58 -03:00
GHMiranda 76761e878b Merge pull request 'ralph/collaboration-and-character-variables' (#7) from ralph/collaboration-and-character-variables into developing
Reviewed-on: #7
2026-01-23 18:59:45 +00:00
Gustavo Henrique Santos Souza de Miranda bcbad57aa9 Merge branch 'developing' into ralph/collaboration-and-character-variables 2026-01-23 15:59:17 -03:00
Gustavo Henrique Santos Souza de Miranda 409b1848c8 chore: mark US-048 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:47:29 -03:00
Gustavo Henrique Santos Souza de Miranda 6b7b27236f feat: [US-048] - Integrate Yjs CRDT for conflict-free node/edge synchronization
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:46:39 -03:00
Gustavo Henrique Santos Souza de Miranda d75e2daeb0 chore: mark US-046 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:43:06 -03:00
Gustavo Henrique Santos Souza de Miranda f92fc1ad01 feat: [US-046] - Presence indicators for active collaborators
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:42:07 -03:00
Gustavo Henrique Santos Souza de Miranda 7278b7527f chore: mark US-044 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:38:10 -03:00
Gustavo Henrique Santos Souza de Miranda 37031c3889 feat: [US-044] - Project sharing and collaborator management
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:36:58 -03:00
Gustavo Henrique Santos Souza de Miranda 46b681462d chore: mark US-045 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:29:16 -03:00
Gustavo Henrique Santos Souza de Miranda 2e313a0264 feat: [US-045] - Supabase Realtime channel and connection management
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:28:23 -03:00
Gustavo Henrique Santos Souza de Miranda dfbaa0066d chore: mark US-043 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:23:55 -03:00
Gustavo Henrique Santos Souza de Miranda 2b4abd1eb7 feat: [US-043] - Database schema for collaboration sessions and audit trail
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:23:03 -03:00
Gustavo Henrique Santos Souza de Miranda 273130316b chore: mark US-064 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:21:43 -03:00
Gustavo Henrique Santos Souza de Miranda 0d72471f8f feat: [US-064] - Export validation for undefined references
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:21:09 -03:00
Gustavo Henrique Santos Souza de Miranda 8cdba7f858 fix: wrongfull jsx without single parent 2026-01-23 15:17:08 -03:00
Gustavo Henrique Santos Souza de Miranda 190e25228b fix: accepted git conflicts 2026-01-23 12:42:51 -03:00
Gustavo Henrique Santos Souza de Miranda a85d7cbeb3 chore: mark US-063 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 10:48:21 -03:00
Gustavo Henrique Santos Souza de Miranda a3e1d1cea2 feat: [US-063] - Import characters/variables from another project
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 10:47:38 -03:00
Gustavo Henrique Santos Souza de Miranda 49698dd9a9 chore: mark US-062 as complete and update progress log
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 10:43:45 -03:00