Skip to content

Conversation

@Malayt04
Copy link
Contributor

@Malayt04 Malayt04 commented Aug 10, 2025

#207

When a user initiates a call from the contacts list, the "Start Call" modal now opens with the selected contact pre-filled and ready.

Screen.Recording.2025-08-10.121428.mp4

Summary by CodeRabbit

  • New Features

    • The "Start Call" modal now preselects a contact when initiated from the contacts list, streamlining the call setup process.
    • Contacts are automatically fetched and preloaded in the call creation modal.
  • Improvements

    • Selecting "Call Contact" from the contacts list opens the call modal with the chosen contact already selected.
    • Modal data is now consistently initialized and cleared when opened or closed for smoother user interactions.

@vercel
Copy link

vercel bot commented Aug 10, 2025

@Malayt04 is attempting to deploy a commit to the cloudec31-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Aug 10, 2025

Walkthrough

This change enhances the call creation and contact selection workflow by enabling preloading and preselecting contacts in modals. It introduces a selectedContact prop and modal data handling, updates modal state management, fetches contacts from the backend, and ensures consistent initialization and clearing of modal data throughout the relevant components and hooks.

Changes

Cohort / File(s) Change Summary
Commit Message File Removal
COMMIT_MSG.tmp
Deleted the initial commit message file containing project scaffolding and configuration notes; no impact on code or exports.
Create Call Modal Enhancements
apps/web/components/app/section/_components/create-call-modal.tsx
Added optional selectedContact prop, fetches contacts from backend on mount, and preselects contact if provided.
Contacts List Integration
apps/web/components/app/section/contacts-list.tsx
Modified to use useModal hook, enabling "Call Contact" action to open modal with selected contact's email.
Start Call Modal Improvements
apps/web/components/modal/start-call.tsx
Utilizes selectedContact from modal data, auto-appends to selection, and includes minor UI formatting adjustments.
Modal State Management
apps/web/hooks/use-modal.tsx
Extended ModalData with selectedContact, updated onOpen/onClose to handle modal data initialization and clearing more robustly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ContactsList
    participant useModal
    participant CreateCallModal
    participant Backend

    User->>ContactsList: Clicks "Call Contact"
    ContactsList->>useModal: onOpen("start-call", {selectedContact: email})
    useModal->>CreateCallModal: Passes selectedContact via modal data
    CreateCallModal->>Backend: Fetch contacts on mount
    Backend-->>CreateCallModal: Returns contacts list
    CreateCallModal->>CreateCallModal: Preselects contact if selectedContact provided
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Poem

A rabbit hops through fields of code,
Preselecting contacts, lightening the load.
Modals now smarter, state clean and clear,
Fetching friends from backend, bringing them near.
With every click, a call can start—
Hoppy connections, code from the heart! 🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (6)
apps/web/hooks/use-modal.tsx (2)

22-22: Naming nit: clarify intent of selectedContact

Consider selectedContactEmail to make it explicit this is an email string, and to avoid confusion with contact objects elsewhere.


37-39: Defensive copy to prevent accidental mutations of data

If callers reuse/mutate the same object reference after calling onOpen, the store’s state can be mutated outside of Zustand. Make a shallow copy when opening.

Apply this diff:

-  onOpen: (type, data = {}) => set({ isOpen: true, type, data }),
+  onOpen: (type, data = {}) => set({ isOpen: true, type, data: { ...data } }),
apps/web/components/modal/start-call.tsx (1)

33-42: Guard selection effect to only run when the modal is actually open

Preselection works. To avoid any accidental state changes when the modal isn’t open (or if another modal instance reuses the store), add a guard on isOpen and type.

Apply this diff:

-useEffect(() => {
-  if (selectedContact) {
-    setSelectedContacts((prev) => {
-      if (prev.includes(selectedContact)) {
-        return prev;
-      }
-      return [...prev, selectedContact];
-    });
-  }
-}, [selectedContact]);
+useEffect(() => {
+  if (!isOpen || type !== "start-call" || !selectedContact) return;
+  setSelectedContacts((prev) => {
+    if (prev.includes(selectedContact)) return prev;
+    return [...prev, selectedContact];
+  });
+}, [selectedContact, isOpen, type]);
apps/web/components/app/section/_components/create-call-modal.tsx (3)

18-23: Prop addition is fine; consider consolidating modal variants

Adding selectedContact?: string is fine. There’s overlap now between this modal and StartCall for preselecting invitees. Consider consolidating to a single source of truth (one modal/selector) to reduce duplication.


34-51: Add AbortController to avoid setting state after unmount

The fetch effect is correct, but can set state on an unmounted component during fast navigations. Add an abort signal and cleanup.

Apply this diff:

 useEffect(() => {
-  const fetchContacts = async () => {
+  const controller = new AbortController();
+  const fetchContacts = async () => {
     try {
       const res = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/contacts`, {
         credentials: "include",
+        signal: controller.signal,
       });
       if (!res.ok) {
         console.error("Failed to fetch contacts");
         return;
-        };
+        }
       const data = await res.json();
       setContacts(data.contacts || []);
     } catch (err) {
-      console.error("Failed to fetch contacts", err);
+      // Ignore abort errors to avoid noisy logs on unmount
+      if ((err as any)?.name !== "AbortError") {
+        console.error("Failed to fetch contacts", err);
+      }
     }
   };
   fetchContacts();
-}, []);
+  return () => controller.abort();
+}, []);

57-66: Preselection works; consider consistent email normalization and surfacing non-list emails

Effect logic is correct. For robustness:

  • Normalize email casing before comparing to avoid duplicates.
  • If selectedContact isn’t in the fetched list, consider temporarily surfacing it in the UI (placeholder row) so users see who will be invited.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1314cd9 and 92490a0.

📒 Files selected for processing (5)
  • COMMIT_MSG.tmp (0 hunks)
  • apps/web/components/app/section/_components/create-call-modal.tsx (2 hunks)
  • apps/web/components/app/section/contacts-list.tsx (4 hunks)
  • apps/web/components/modal/start-call.tsx (3 hunks)
  • apps/web/hooks/use-modal.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • COMMIT_MSG.tmp
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/components/app/section/contacts-list.tsx (3)
apps/web/hooks/use-modal.tsx (1)
  • useModal (33-39)
apps/web/app/(app)/app/contact/page.tsx (1)
  • ContactPage (8-24)
apps/web/components/app/section/_components/call-history.tsx (1)
  • useModal (278-300)
apps/web/components/modal/start-call.tsx (2)
apps/web/hooks/use-modal.tsx (1)
  • useModal (33-39)
apps/web/lib/QUERIES.ts (1)
  • CALLS_QUERY (23-45)
🔇 Additional comments (4)
apps/web/components/app/section/contacts-list.tsx (2)

26-26: LGTM: integrates useModal

Import looks correct and aligns with the modal store.


228-228: LGTM: open modal from card

Using useModal inside ContactCard keeps concerns localized.

apps/web/components/modal/start-call.tsx (2)

27-29: LGTM: consuming modal data

Destructuring data and reading selectedContact is aligned with the updated store shape.


49-51: LGTM: pluralization copy

Concise and correct pluralization.

</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem>
<DropdownMenuItem onClick={() => onOpen("start-call", { selectedContact: contact.email })}>
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Pre-filling selected contact is correct; consider email normalization

The onOpen("start-call", { selectedContact: contact.email }) flow is correct. To avoid case-related duplicates in selections, consider normalizing emails (e.g., lowercasing) consistently across the app.

Run a quick scan to see if email normalization is already in place for selections:


🏁 Script executed:

#!/bin/bash
rg -n --no-heading --pretty $'toLowerCase\\(\\).*email|selectedContacts' || true

Length of output: 2810


Normalize emails to lowercase before storing and comparing

I didn’t find any .toLowerCase() usage around contact emails in the selection flows (contacts-list.tsx, contact-selector.tsx, start-call.tsx). To prevent case‐related duplicates, normalize email values (e.g. email.trim().toLowerCase()) when invoking onOpen, adding to selectedContacts, and when checking for membership.

Places to update:

  • apps/web/components/app/section/contacts-list.tsx (line 242)
  • apps/web/components/modal/contact-selector.tsx (lines 37 & 93)

Example change:

- onOpen("start-call", { selectedContact: contact.email })
+ onOpen("start-call", {
+   selectedContact: contact.email.trim().toLowerCase()
+ })

Ensure you apply the same normalization in your setSelectedContacts calls and in any selectedContacts.includes(...) checks.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<DropdownMenuItem onClick={() => onOpen("start-call", { selectedContact: contact.email })}>
<DropdownMenuItem onClick={() => onOpen("start-call", {
selectedContact: contact.email.trim().toLowerCase()
})}>
🤖 Prompt for AI Agents
In apps/web/components/app/section/contacts-list.tsx at line 242, the email
passed to onOpen is not normalized, which can cause case-related duplicates. Fix
this by applying email normalization using trim() and toLowerCase() before
passing the email, and ensure similar normalization is applied in all places
where emails are stored or compared, including setSelectedContacts calls and
membership checks.

@kunal697
Copy link
Contributor

@Malayt04 just noticed a thing in video, when you click on join call button in notification both join call and decline button were in loading state, we can improve this

@Malayt04
Copy link
Contributor Author

Yeah, but @abuharish02's pr is already merged for this issue now.

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.

2 participants