Uh oh!
There was an error while loading. Please reload this page.
fix(presence): remove presence for a solo user - #1779
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR fixes a bug where solo users would see their own avatar in the presence indicator. The fix filters out the current user from the presence list by comparing user IDs.
Key Changes:
- Modified
usePresencehook to import and useuseSessionto get current user ID - Added filter to exclude users where
user.userId === currentUserIdfrom the presence list - Removed redundant code comments from avatar and socket handler files for cleaner code
Implementation:
The presence list from the socket server includes all users in a workflow room. By filtering out entries matching the current user's session ID, only other collaborators are displayed in the avatar stack. The filter is applied in the useMemo hook with currentUserId as a dependency to ensure proper reactivity when the session loads.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The change is straightforward and well-implemented. It uses a simple filter to remove the current user from the presence list, consistent with similar patterns used throughout the codebase. The implementation correctly adds the dependency to useMemo and follows existing code conventions.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-presence.ts | 5/5 | Added filter to exclude current user from presence list using session.user.id |
Sequence Diagram
sequenceDiagram
participant Client as Client Browser
participant Hook as usePresence Hook
participant Auth as Auth Session
participant Socket as Socket Context
participant Server as Socket Server
Client->>Auth: Load user session
Auth-->>Hook: session.user.id
Client->>Socket: Connect to workflow
Socket->>Server: join-workflow
Server->>Server: Add user to room
Server->>Socket: presence-update (all users)
Socket-->>Hook: presenceUsers array
Hook->>Hook: Filter out current user<br/>(user.userId !== currentUserId)
Hook-->>Client: Return filtered users<br/>(excluding self)
3 files reviewed, no comments
Summary
Type of Change
Testing
Tested manually.
Checklist