Skip to content

fix(userPresence): show avatars by user ID not socket conn id#550

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/user-presence
Jun 26, 2025
Merged

fix(userPresence): show avatars by user ID not socket conn id#550
icecrasher321 merged 1 commit intostagingfrom
fix/user-presence

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

@icecrasher321 icecrasher321 commented Jun 26, 2025

Description

If same user on multiple tabs then doesn't show avatar anymore.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement
  • Performance improvement
  • Code refactoring (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

Additional Information:

Any additional information, configuration or data that might be necessary to reproduce the issue or use the feature.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim 🔄 Building (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 2:56pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jun 26, 2025 2:56pm

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Fixed user presence tracking to show unique avatars per user instead of per socket connection, preventing duplicate avatars when users have multiple tabs open.

  • Modified apps/sim/socket-server/rooms/manager.ts to track unique users by userId instead of socketId with new getUniqueUserCount() method
  • Updated apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-presence.ts to deduplicate users using Map and userId as key
  • Enhanced apps/sim/contexts/socket-context.tsx to properly handle socket cleanup and prevent duplicate connections
  • Improved socket connection lifecycle in apps/sim/socket-server/handlers/workflow.ts with separate tracking for unique users vs total connections

4 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

@delve-auditor
Copy link
Copy Markdown

delve-auditor Bot commented Jun 26, 2025

No security or compliance issues detected. Reviewed everything up to fb40d25.

Security Overview
  • 🔎 Scanned files: 4 changed file(s)
Detected Code Changes
Change Type Relevant files
Bug Fix ► use-presence.ts
    Implement user presence deduplication
► socket-context.tsx
    Fix socket connection handling and workflow joining logic
► workflow.ts
    Update user presence logging
► manager.ts
    Add unique user count functionality

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@icecrasher321 icecrasher321 merged commit 936d2d3 into staging Jun 26, 2025
3 of 4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/user-presence branch June 28, 2025 04:46
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
fix(userPresence): show avatars by user ID not socket conn id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant