canvas-website/backlog/tasks/task-053 - Fix-user-identit...

1.5 KiB

id title status assignee created_date updated_date labels dependencies priority
task-053 Fix user identity caching on logout/login Done
2025-12-15 23:40 2025-12-15 23:40
bug-fix
auth
presence
high

Description

Fixed issues with user identity state not being properly cleared/restored during logout and login cycles, causing duplicate cursors and stale presence data in the social network graph.

Acceptance Criteria

  • #1 Crypto keys and tldraw user IDs persist across logout (account data)
  • #2 Session-specific data cleared on logout (permissions, graph cache)
  • #3 No duplicate cursors when logging out and back in
  • #4 Tools load properly after login from logged-out state
  • #5 CryptIDDropdown and NetworkGraph reset state on logout

Implementation Notes

Implemented in commits df80a3f and related changes to Board.tsx.

Key changes:

  • sessionPersistence.ts: Added session-logged-in and session-cleared events, preserve tldraw user IDs and crypto keys on logout
  • Board.tsx: Check localStorage directly for auth in onMount, listen for session events
  • CryptIDDropdown.tsx: Clear connections state on logout
  • useNetworkGraph.ts: Clear graph cache on logout

The root cause was clearing tldraw-user-id-* keys on logout, which created new presence IDs on each login while old presence records persisted in Automerge.