Skip to content

Refactor chat components and update dependencies - #13

Merged
hemjaygfx merged 6 commits into
mainfrom
sidebar
Jul 19, 2026
Merged

hemjaygfx merged 6 commits into
mainfrom
sidebar

Conversation

@hemjaygfx

@hemjaygfx hemjaygfx commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner
  • Removed unused dependencies from package.json and package-lock.json.
  • Updated react-router and daisyui versions in frontend dependencies.
  • Enhanced ActiveTabSwitch, ChatsList, and ContactList components for improved functionality and user experience.
  • Added new components: NoChatsFound and UsersLoadingSkeleton for better loading states.
  • Implemented profile image upload functionality in ProfileHeader.
  • Adjusted layout and styling in ChatPage and LoginPage for better responsiveness.

Open in Devin Review

Summary by CodeRabbit

  • New Features

    • Added Chats and Contacts tabs with selectable conversations and contacts.
    • Added online/offline status indicators, loading placeholders, and empty-state messaging.
    • Added profile avatar uploads, profile updates, logout, and sound controls.
    • Added a “Find contacts” action from the empty conversations state.
  • UI Improvements

    • Updated chat, login, and registration layouts with refreshed sizing, spacing, and dark styling.
    • Improved conversation and contact selection interactions.
  • Bug Fixes

    • Improved restoration of the saved sound preference when the app starts.

- Removed unused dependencies from package.json and package-lock.json.
- Updated react-router and daisyui versions in frontend dependencies.
- Enhanced ActiveTabSwitch, ChatsList, and ContactList components for improved functionality and user experience.
- Added new components: NoChatsFound and UsersLoadingSkeleton for better loading states.
- Implemented profile image upload functionality in ProfileHeader.
- Adjusted layout and styling in ChatPage and LoginPage for better responsiveness.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hemjaygfx, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5692a96c-9ec6-4cd2-917a-69a97fd55d78

📥 Commits

Reviewing files that changed from the base of the PR and between 3044e82 and 9280a90.

📒 Files selected for processing (5)
  • frontend/src/components/ContactList.jsx
  • frontend/src/components/ProfileHeader.jsx
  • frontend/src/pages/ChatPage.jsx
  • frontend/src/store/useAuthStore.js
  • frontend/src/store/useChatStore.js
📝 Walkthrough

Walkthrough

The PR replaces placeholder chat, contact, tab, empty-state, loading, and profile components with store-backed interfaces. It adds profile updates, adjusts page layouts and sound initialization, and changes dependency declarations.

Changes

Chat and profile UI

Layer / File(s) Summary
Chat and contact browsing
frontend/src/components/ActiveTabSwitch.jsx, frontend/src/components/ChatsList.jsx, frontend/src/components/ContactList.jsx, frontend/src/components/NoChatsFound.jsx, frontend/src/components/UsersLoadingSkeleton.jsx
Adds tab switching, fetched chat and contact lists, loading and empty states, online indicators, and selected-user handling.
Profile image persistence
frontend/src/components/ProfileHeader.jsx, frontend/src/store/useAuthStore.js, frontend/src/store/useChatStore.js
Adds avatar upload and profile persistence, logout and sound controls, and JSON-based sound setting initialization.
Page layout integration
frontend/src/pages/ChatPage.jsx, frontend/src/pages/LoginPage.jsx, frontend/src/pages/RegisterPage.jsx
Updates page sizing, backgrounds, panel styling, and chat sidebar visibility.
Dependency manifest updates
frontend/package.json, package.json
Updates frontend router and DaisyUI versions and removes the root DaisyUI development dependency.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ProfileHeader
  participant FileReader
  participant useAuthStore
  User->>ProfileHeader: Select profile image
  ProfileHeader->>FileReader: Read image as data URL
  FileReader-->>ProfileHeader: Return image data
  ProfileHeader->>useAuthStore: updateProfile({ profilePic })
  useAuthStore-->>ProfileHeader: Update authUser
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main code refactor and dependency updates in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sidebar

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread frontend/src/components/ChatsList.jsx Resolved
onClick={() => setSelectedUser(contact)}
>
<div className="flex items-center gap-3">
<div className={`avatar ${onlineUsers.includes(contact._id) ? "online" : "offline"}`}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Contacts list crashes when any contacts exist

The online status check reads a contact list from the auth store that does not exist (onlineUsers.includes(contact._id) at frontend/src/components/ContactList.jsx:26), so once there is at least one contact to display the component tries to call a method on an undefined value and the screen crashes.
Impact: When the contacts tab loads any contacts, it throws an error and fails to render.

Missing onlineUsers in useAuthStore

frontend/src/components/ContactList.jsx:9 destructures const { onlineUsers } = useAuthStore();, but useAuthStore (frontend/src/store/useAuthStore.js:6-74) never defines onlineUsers. So onlineUsers is undefined and onlineUsers.includes(contact._id) at line 26 throws TypeError during render whenever allContacts is non-empty.

Prompt for agents
The ContactList component reads onlineUsers from useAuthStore, but useAuthStore (frontend/src/store/useAuthStore.js) never defines onlineUsers, so onlineUsers.includes(contact._id) throws a TypeError when contacts render. Either add an onlineUsers state array to useAuthStore (populated via socket), or guard the access, e.g. (onlineUsers || []).includes(contact._id). The same issue exists in ChatsList.jsx.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread frontend/src/store/useChatStore.js Resolved
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (1)
frontend/src/components/ProfileHeader.jsx (1)

7-7: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optionally guard Audio initialization for non-browser environments.

Initializing new Audio() at the module level will throw a ReferenceError if this file is imported in a non-browser environment, such as during server-side rendering (SSR) or when running unit tests with tools like Jest or Vitest.

Consider guarding it to improve testability and resilience.

♻️ Proposed fix
-const mouseClickSound = new Audio("/sounds/mouse-click.mp3");
+const mouseClickSound = typeof Audio !== "undefined" ? new Audio("/sounds/mouse-click.mp3") : null;

You will also need to safely play the audio on line 84:

-              mouseClickSound.currentTime = 0; // reset to start
-              mouseClickSound.play().catch((error) => console.log("Audio play failed:", error));
+              if (mouseClickSound) {
+                mouseClickSound.currentTime = 0;
+                mouseClickSound.play().catch((error) => console.log("Audio play failed:", error));
+              }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/ProfileHeader.jsx` at line 7, Guard the module-level
mouseClickSound initialization in ProfileHeader so Audio is only constructed
when the browser Audio API is available, avoiding SSR and test-environment
ReferenceError failures. Update the audio playback logic in the component’s
click handler to safely handle the absent sound instance before calling its play
method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/package.json`:
- Around line 19-20: Align the router dependencies in frontend/package.json on
one supported major: either downgrade react-router to v7 to match
react-router-dom, or complete the v8 migration by removing react-router-dom,
updating BrowserRouter and Link imports to the v8 packages, and upgrading
react/react-dom and Node to v8 minimum versions.

In `@frontend/src/components/ChatsList.jsx`:
- Line 28: Initialize onlineUsers to an empty array in useAuthStore.js,
preserving the existing includes() calls in both
frontend/src/components/ChatsList.jsx#L28 and
frontend/src/components/ContactList.jsx#L26; no direct changes are required at
those call sites.

In `@frontend/src/components/ContactList.jsx`:
- Line 28: Add an alt attribute to the avatar img element in ContactList, using
the contact’s name as descriptive alternative text while preserving the existing
profilePic fallback.

In `@frontend/src/components/ProfileHeader.jsx`:
- Around line 41-62: Update ProfileHeader’s render expressions to optional-chain
authUser before accessing profilePic and fullName, preserving the existing
fallback avatar and username behavior while preventing a null dereference during
logout.

In `@frontend/src/pages/ChatPage.jsx`:
- Around line 19-34: Restore mobile responsive visibility in the sidebar and
chat-container wrappers: hide the sidebar when selectedUser is set and hide the
chat container when no user is selected on mobile viewports, while preserving
both panels’ desktop visibility and the existing ChatsList, ContactList,
ChatContainer, and NoConversationPlaceholder rendering.

In `@frontend/src/store/useAuthStore.js`:
- Line 71: Update the error toast handling in the relevant authentication action
to safely access the response message when error.response is absent, using
optional chaining and the store’s established fallback message pattern. Preserve
the existing server-provided message when available and ensure network errors
still display a toast without throwing.

In `@frontend/src/store/useChatStore.js`:
- Line 15: Update the isSoundEnabled initialization to compare the raw
localStorage value directly with the string "true"; remove JSON.parse so
persisted sound settings initialize correctly.

---

Nitpick comments:
In `@frontend/src/components/ProfileHeader.jsx`:
- Line 7: Guard the module-level mouseClickSound initialization in ProfileHeader
so Audio is only constructed when the browser Audio API is available, avoiding
SSR and test-environment ReferenceError failures. Update the audio playback
logic in the component’s click handler to safely handle the absent sound
instance before calling its play method.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97c42a23-163e-47e2-a5ff-d109993b69c3

📥 Commits

Reviewing files that changed from the base of the PR and between fdac048 and 3044e82.

⛔ Files ignored due to path filters (9)
  • frontend/package-lock.json is excluded by !**/package-lock.json
  • frontend/public/avatar.png is excluded by !**/*.png
  • frontend/public/sounds/keystroke1.mp3 is excluded by !**/*.mp3
  • frontend/public/sounds/keystroke2.mp3 is excluded by !**/*.mp3
  • frontend/public/sounds/keystroke3.mp3 is excluded by !**/*.mp3
  • frontend/public/sounds/keystroke4.mp3 is excluded by !**/*.mp3
  • frontend/public/sounds/mouse-click.mp3 is excluded by !**/*.mp3
  • frontend/public/sounds/notification.mp3 is excluded by !**/*.mp3
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • frontend/package.json
  • frontend/src/components/ActiveTabSwitch.jsx
  • frontend/src/components/ChatsList.jsx
  • frontend/src/components/ContactList.jsx
  • frontend/src/components/NoChatsFound.jsx
  • frontend/src/components/ProfileHeader.jsx
  • frontend/src/components/UsersLoadingSkeleton.jsx
  • frontend/src/pages/ChatPage.jsx
  • frontend/src/pages/LoginPage.jsx
  • frontend/src/pages/RegisterPage.jsx
  • frontend/src/store/useAuthStore.js
  • frontend/src/store/useChatStore.js
  • package.json
💤 Files with no reviewable changes (1)
  • package.json

Comment thread frontend/package.json
Comment on lines +19 to 20
"react-router": "^8.2.0",
"react-router-dom": "^7.18.1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== package.json =="
sed -n '1,120p' frontend/package.json

echo
echo "== routing imports =="
rg -n --hidden --glob '!**/node_modules/**' 'react-router-dom|react-router/dom|react-router\b' frontend/src frontend | sed -n '1,200p'

Repository: hemjaygfx/NexTalk

Length of output: 2720


🌐 Web query:

React Router v8 react-router-dom removed DOM APIs react-router/dom minimum React and Node versions upgrade guide

💡 Result:

React Router v8 marks the official removal of the react-router-dom package, which was previously maintained as a convenience wrapper to support transitions from v6 to v7 [1][2][3]. Upgrade Requirements React Router v8 requires the following minimum versions [4][5]: - Node.js: 22.22.0 or higher [4][5] - React: 19.2.7 or higher (includes react and react-dom) [4][5] - Vite: 7.0.0 or higher [5] Updating Imports Because the react-router-dom package has been removed, you must update your import statements to point directly to the main packages [4][6]: - For DOM-specific APIs (such as RouterProvider or HydratedRouter), import from react-router/dom [4][3]. - For all other APIs, import directly from react-router [4][3]. Example migration: // Before import { Link, useLocation, RouterProvider } from "react-router-dom"; // After import { Link, useLocation } from "react-router"; import { RouterProvider } from "react-router/dom"; It is recommended to adopt these import changes while still on v7 to facilitate a smoother transition to v8 [4]. You can safely uninstall the react-router-dom package after updating your code [4][2].

Citations:


Keep the router packages on one major

  • react-router is on 8.2.0, but react-router-dom is still 7.18.1, and the app still imports BrowserRouter/Link from react-router-dom.
  • react/react-dom are 19.2.6, below React Router v8’s minimum 19.2.7.

Either stay on v7 for now or finish the v8 migration by removing react-router-dom, switching the imports to react-router/react-router/dom, and bumping React (and Node) to v8’s minimums.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/package.json` around lines 19 - 20, Align the router dependencies in
frontend/package.json on one supported major: either downgrade react-router to
v7 to match react-router-dom, or complete the v8 migration by removing
react-router-dom, updating BrowserRouter and Link imports to the v8 packages,
and upgrading react/react-dom and Node to v8 minimum versions.

onClick={() => setSelectedUser(chat)}
>
<div className="flex items-center gap-3">
<div className={`avatar ${onlineUsers.includes(chat._id) ? "online" : "offline"}`}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find which store defines and manages the `onlineUsers` state.
rg 'onlineUsers' frontend/src/store/

Repository: hemjaygfx/NexTalk

Length of output: 155


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== useAuthStore references ==\n'
rg -n 'useAuthStore|onlineUsers' frontend/src -g '!**/node_modules/**' || true

printf '\n== store files ==\n'
git ls-files frontend/src/store frontend/src | rg 'store|auth|socket|chat|contact'

printf '\n== relevant component excerpts ==\n'
sed -n '1,120p' frontend/src/components/ChatsList.jsx
printf '\n---\n'
sed -n '1,120p' frontend/src/components/ContactList.jsx
printf '\n---\n'
sed -n '1,220p' frontend/src/store/useAuthStore.js 2>/dev/null || true
printf '\n---\n'
sed -n '1,220p' frontend/src/store/authStore.js 2>/dev/null || true
printf '\n---\n'
sed -n '1,220p' frontend/src/store/useSocketStore.js 2>/dev/null || true
printf '\n---\n'
sed -n '1,220p' frontend/src/store/socketStore.js 2>/dev/null || true

Repository: hemjaygfx/NexTalk

Length of output: 6361


Initialize onlineUsers before calling .includes()
frontend/src/store/useAuthStore.js doesn’t define onlineUsers, so both ChatsList and ContactList can crash on render when they call .includes() on undefined. Add onlineUsers: [] to the store or guard both call sites:

  • frontend/src/components/ChatsList.jsx#L28
  • frontend/src/components/ContactList.jsx#L26
🧰 Tools
🪛 ast-grep (0.44.1)

[warning] 28-30: A list component should have a key to prevent re-rendering
Context:


<img src={chat.profilePic || "/avatar.png"} alt={chat.fullName} />

Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.

(list-component-needs-key)

📍 Affects 2 files
  • frontend/src/components/ChatsList.jsx#L28-L28 (this comment)
  • frontend/src/components/ContactList.jsx#L26-L26
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/ChatsList.jsx` at line 28, Initialize onlineUsers to
an empty array in useAuthStore.js, preserving the existing includes() calls in
both frontend/src/components/ChatsList.jsx#L28 and
frontend/src/components/ContactList.jsx#L26; no direct changes are required at
those call sites.

Comment thread frontend/src/components/ContactList.jsx Resolved
Comment thread frontend/src/pages/ChatPage.jsx Resolved
Comment thread frontend/src/store/useAuthStore.js Resolved
Comment thread frontend/src/store/useChatStore.js Resolved
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

hemjaygfx and others added 4 commits July 19, 2026 09:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@hemjaygfx
hemjaygfx merged commit d18e9a8 into main Jul 19, 2026
1 check 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.

1 participant