Repository navigation
Chore/videocall - #173
Chore/videocall#173
Conversation
…ions Co-authored-by: Copilot <copilot@github.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds like/match interaction functionality to video calls: the like button UI adapts based on like state, an animated banner notifies users of matches, and socket event handlers manage like interactions with automatic state expiration. Enhances video call teardown to decline matchmaking and fully reset session state before re-entering. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User A
participant UI as UI Layer
participant Socket as Socket/Signaling
participant Peer as User B (Peer)
User->>UI: Clicks Like Button
UI->>Socket: Emit send_like
Socket->>Peer: Deliver like notification
Peer->>UI: Receives like state update
UI->>UI: Display "You got liked!" banner
Peer->>UI: Clicks "Like Back"
Peer->>Socket: Emit send_like_back
Socket->>User: Deliver like_back notification
User->>UI: Receives mutualLike state
UI->>UI: Animate banner to "It's a match"
UI->>UI: Disable like button (mutual match)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 55 minutes and 33 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/`(protected)/videocall/index.tsx:
- Around line 453-455: The handler handleNextUser (referenced via
handleNextUserRef.current and invoked on the "peer_left" event and from the Next
button) must be guarded against concurrent execution: add an in-flight or mutex
flag (e.g., isHandlingNextUser) at the same scope as the handleNextUser
function, have both call sites (the socket "peer_left" listener and the Next
button path) check and return immediately if the flag is true, set the flag true
at start of handleNextUser, and ensure the flag is cleared in a
finally/finalization path so it always resets on success or error; apply the
same guard to the other code paths mentioned in the 691-765 region to prevent
overlapping decline/leave/deactivate/activate sequences.
- Around line 686-689: The handleLikeBack handler currently emits
"send_like_back" unguarded; make it idempotent by checking and setting a local
flag/ref before emitting (similar to handleLike). Add a boolean ref or state
(e.g., hasLikedBackRef) checked at the top of handleLikeBack (if true, return),
then set it true immediately after the check and only then call
socketRef.current?.emit("send_like_back") (include roomIdRef in logs as now).
This prevents duplicate emits and local UI race conditions.
🪄 Autofix (Beta)
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: e55b14b3-dce5-4fbd-8d1f-2969addc5c1b
📒 Files selected for processing (2)
app/(protected)/videocall/(pages)/CallScreen.tsxapp/(protected)/videocall/index.tsx
| socket.on("peer_left", () => { | ||
| handleNextUserRef.current(); | ||
| }); |
There was a problem hiding this comment.
Guard handleNextUser against concurrent execution.
handleNextUser can be triggered automatically from Line 454 (peer_left) and manually via the Next button path, but there is no in-flight guard. Overlapping runs can duplicate decline/leave/deactivate/activate sequences and produce inconsistent call state.
Suggested fix
+const nextUserInFlightRef = useRef(false);
async function handleNextUser() {
+ if (nextUserInFlightRef.current) return;
+ nextUserInFlightRef.current = true;
+ try {
const roomId = roomIdRef.current;
// Decline current match so these two users won't match again
if (roomId) {
try {
await api("/matchmaking/decline", {
method: "POST",
body: JSON.stringify({ roomId }),
});
} catch {}
}
// Clean up video session without touching the matchmaking socket
localStreamRef.current?.getTracks()?.forEach((t: any) => t.stop());
localStreamRef.current = null;
startingRef.current = false;
...
try {
await deactivateMatchmakingRef.current();
} catch {}
await activateMatchmaking();
+ } finally {
+ nextUserInFlightRef.current = false;
+ }
}Also applies to: 691-765
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/`(protected)/videocall/index.tsx around lines 453 - 455, The handler
handleNextUser (referenced via handleNextUserRef.current and invoked on the
"peer_left" event and from the Next button) must be guarded against concurrent
execution: add an in-flight or mutex flag (e.g., isHandlingNextUser) at the same
scope as the handleNextUser function, have both call sites (the socket
"peer_left" listener and the Next button path) check and return immediately if
the flag is true, set the flag true at start of handleNextUser, and ensure the
flag is cleared in a finally/finalization path so it always resets on success or
error; apply the same guard to the other code paths mentioned in the 691-765
region to prevent overlapping decline/leave/deactivate/activate sequences.
| function handleLikeBack() { | ||
| console.log("[LikeBack] User liked back in room:", roomIdRef.current); | ||
| socketRef.current?.emit("send_like_back"); | ||
| } |
There was a problem hiding this comment.
Make handleLikeBack idempotent before emitting.
Unlike handleLike (Line 681), this path has no guard, so repeated taps can emit duplicate send_like_back events and race local UI state.
Suggested fix
function handleLikeBack() {
- console.log("[LikeBack] User liked back in room:", roomIdRef.current);
- socketRef.current?.emit("send_like_back");
+ if (isLiked || mutualLike) return;
+ setIsLiked(true);
+ setReceivedLike(false);
+ socketRef.current?.emit("send_like_back");
}📝 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.
| function handleLikeBack() { | |
| console.log("[LikeBack] User liked back in room:", roomIdRef.current); | |
| socketRef.current?.emit("send_like_back"); | |
| } | |
| function handleLikeBack() { | |
| if (isLiked || mutualLike) return; | |
| setIsLiked(true); | |
| setReceivedLike(false); | |
| socketRef.current?.emit("send_like_back"); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/`(protected)/videocall/index.tsx around lines 686 - 689, The
handleLikeBack handler currently emits "send_like_back" unguarded; make it
idempotent by checking and setting a local flag/ref before emitting (similar to
handleLike). Add a boolean ref or state (e.g., hasLikedBackRef) checked at the
top of handleLikeBack (if true, return), then set it true immediately after the
check and only then call socketRef.current?.emit("send_like_back") (include
roomIdRef in logs as now). This prevents duplicate emits and local UI race
conditions.
Summary by CodeRabbit
Release Notes