Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 4, 2025

  • Add robust null checks for user presence in conversation header
  • Implement fallback UI for missing user data in conversations
  • Create test page for comprehensive user presence debugging
  • Improve error handling and status display in UserStatusIndicator
  • Add logging and manual controls for user presence management This change improves the reliability of user presence display and provides better error handling for edge cases in messaging interactions.

Summary by CodeRabbit

  • Bug Fixes
    • Conversations with missing user data now display properly with fallback indicators instead of errors.
    • User presence tracking is now more reliable with enhanced status updates and periodic data synchronization to maintain accurate availability information.

- Add robust null checks for user presence in conversation header
- Implement fallback UI for missing user data in conversations
- Create test page for comprehensive user presence debugging
- Improve error handling and status display in UserStatusIndicator
- Add logging and manual controls for user presence management
This change improves the reliability of user presence display and provides better error handling for edge cases in messaging interactions.
@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
codeunia Building Building Preview Comment Nov 4, 2025 4:39am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR enhances the messaging system by adding null-checks for missing user data across UI components, introducing debug logging for state transitions in presence tracking, and refactoring the presence hook to handle missing records gracefully with periodic refresh mechanisms and improved online status management.

Changes

Cohort / File(s) Summary
UI Components - Messaging
app/protected/messages/page.tsx, components/messages/ConversationList.tsx, components/messages/UserStatusIndicator.tsx
Added null-check guards for other_user.id before rendering UserStatusIndicator; fallback UI elements introduced (text span and red dot) for missing user data. Debug logging added via useEffect to observe state transitions in presence availability and conversation data.
Presence Hook
hooks/useUserPresence.ts
Replaced single() with maybeSingle() for safer presence queries. Added error handling, periodic refresh (10s), subscription with status callback, and updatePresence routine (30s). Online status set immediately on mount and after delay. Upsert calls updated with conflict resolution and updated_at field.

Sequence Diagram(s)

sequenceDiagram
    participant Component as React Component
    participant Hook as useUserPresence
    participant DB as Database
    participant Sub as Subscription

    Component->>Hook: Mount (e.g., ConversationList)
    Hook->>DB: Initial fetch (maybeSingle)
    DB-->>Hook: presence data or null
    alt Data present
        Hook->>Hook: Initialize state, log data
    else Data missing
        Hook->>Hook: Initialize offline, log missing
    end
    
    Note over Hook: Set online immediately + 1s delay
    Hook->>DB: Update presence (upsert)
    
    Hook->>Sub: Subscribe to changes
    Sub-->>Hook: Status callback + real-time updates
    Hook->>Hook: Log subscription status
    
    rect rgb(200, 220, 255)
        Note over Hook: Periodic tasks (every 10s fetch, every 30s updatePresence)
    end
    
    Hook->>Component: State updated
    Component->>Component: Re-render with presence data
    
    Component->>Hook: Unmount
    Hook->>Hook: Clear refresh interval
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • hooks/useUserPresence.ts requires careful attention to the refactored presence fetching logic, periodic refresh scheduling, and the new upsert signature with conflict resolution
  • Verify that maybeSingle() properly handles missing records and that error paths are correctly logged
  • Confirm subscription lifecycle management and interval cleanup on unmount
  • Cross-check the timing of online status updates (immediate + 1s delay) and the 30-second periodic refresh against intended presence behavior

Possibly related PRs

Poem

🐰 A rabbit debugging with glee,
Null-checks and logs for all to see,
Presence refreshed every tick and tock,
No more silent presence locks!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/messageuserstatus

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd05812 and 9f381dc.

📒 Files selected for processing (4)
  • app/protected/messages/page.tsx (1 hunks)
  • components/messages/ConversationList.tsx (2 hunks)
  • components/messages/UserStatusIndicator.tsx (1 hunks)
  • hooks/useUserPresence.ts (4 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeunia-dev codeunia-dev merged commit d2f2482 into main Nov 4, 2025
2 of 4 checks passed
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.

3 participants