Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 2.02 KB

File metadata and controls

66 lines (46 loc) · 2.02 KB

Room State Synchronization Test

To test the fix for the room state synchronization issue:

Test Steps:

  1. Start the frontend: Run npm run dev in the frontend directory

  2. Open first browser window:

    • Navigate to http://localhost:3000
    • Create a new room (e.g., "test-room")
    • Enter username (e.g., "user1")
    • Join the room
  3. Add some content:

    • Type some code in the editor (e.g., "console.log('Hello from user1');")
    • Switch to whiteboard and draw something
    • Switch back to editor and add more code
  4. Open second browser window:

    • Navigate to http://localhost:3000
    • Join the SAME room ("test-room")
    • Enter different username (e.g., "user2")
  5. Verify state synchronization:

    • The second user should immediately see:
      • The code that user1 typed
      • The whiteboard drawings from user1
      • The correct language setting
  6. Test real-time sync:

    • User2 types in editor → User1 should see changes
    • User2 draws on whiteboard → User1 should see drawings
    • User1 makes changes → User2 should see them

Expected Behavior:

  • ✅ New users get current room state immediately
  • ✅ No more "empty state overwrites existing work" bug
  • ✅ Real-time synchronization works for both editor and whiteboard
  • ✅ No infinite update loops

Backend Changes Made:

  • Added RoomState struct to store room state
  • Store code, language, and whiteboard elements per room
  • Send current state to new users in WELCOME message
  • Update room state when changes are broadcast

Frontend Changes Made:

  • Added initialization tracking to prevent immediate overwrites
  • Whiteboard waits for WELCOME message before sending updates
  • Code editor waits for initialization before sending changes
  • Both components handle initial state from WELCOME message

Debug Info:

Check browser console for:

  • "WebSocket URL:" - should show correct URL
  • "RECEIVED: action 'WELCOME'" - should show state object
  • "SENDING: action 'CODE_CHANGE'" - should only appear after initialization