Skip to content

Conversation

@ayush00git
Copy link

@ayush00git ayush00git commented Dec 23, 2025

Fixes: #123 #131 #135 #136

Changes i made -

  • Fixed Build-Breaking Syntax, i removed all conflict markers across these 4 files =>
    Game.tsx
    MatchLogs.tsx
    TeamBuilder.tsx
    TeamDebateRoom.tsx

  • TeamDebateRoom.tsx: Removed 3 duplicate function definitions (multiple toggleCamera functions), consolidated redundant useEffect hooks, and fixed a syntax error caused by a duplicated case "ready" block.

Thanks : )

Summary by CodeRabbit

  • Bug Fixes

    • Improved in-game message processing reliability with enhanced error handling
    • Fixed team capacity calculation edge cases in team builder
  • Improvements

    • Refined game state-based control disabling logic for better user experience
    • Enhanced match logs UI with improved score display formatting
    • Optimized team matchmaking component visibility and data handling

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Walkthrough

The PR resolves merge conflicts and refactors multiple frontend components: centralizing WebSocket message handling in Game.tsx with a dedicated parseContent helper and switch-based message dispatcher, restructuring match winner and stage determination logic in MatchLogs.tsx, adjusting conditional rendering for TeamMatchmaking in TeamBuilder.tsx based on user presence, and addressing syntax conflicts in TeamDebateRoom.tsx.

Changes

Cohort / File(s) Change Summary
WebSocket Message Handling
frontend/src/Pages/Game.tsx
Introduced parseContent<T>() helper for JSON parsing with error handling; replaced inline message handlers with centralized handleWebSocketMessage() callback using switch statement covering DEBATE_START, DEBATE_END, TURN_START, TURN_END, CHAT_MESSAGE, GENERATING_TRANSCRIPT, TYPING_START/STOP, SPEAKING_START/STOP, GAME_RESULT; adjusted chat/input disabled state to use gameEnded or loading instead of turn-based condition.
Match Logic & Rendering
frontend/src/Pages/MatchLogs.tsx
Merge-conflict artifacts in winner determination: tiebreaker logic now conditionally selects between log.matchIncludes("First Round Match 3") and isFirstRoundMatch3 check; refactored stage badge className composition and numeric score rendering to use consolidated conditionals. ⚠️ Potential merge residue affecting winner tiebreaker assignment.
Team Management & Rendering
frontend/src/Pages/TeamBuilder.tsx
Conditional rendering of TeamMatchmaking now guarded by user existence and id presence; adjusted capacity calculation from team.maxSize || 4 to explicit ternary checking for positive value; minor formatting and null-safe access adjustments.
Team Debate Environment
frontend/src/Pages/TeamDebateRoom.tsx
Formatting and whitespace normalization; restructured toggleCamera function removal/reintroduction addressing reported double declaration syntax error; no runtime or API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #116: Modifies frontend/src/Pages/Game.tsx with identical parseContent helper and centralized WebSocket message handling refactor.
  • PR #112: Also refactors frontend/src/Pages/Game.tsx WebSocket message handling and parsing logic for chat/typing/speaking message types.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR contains out-of-scope changes: Game.tsx and MatchLogs.tsx modifications go beyond resolving merge conflicts, including refactored logic (centralized message handling, disabled state conditions) not mentioned in linked issues. Separate refactoring changes (Game.tsx centralized handler, MatchLogs.tsx logic consolidation) into dedicated PRs and focus this PR only on resolving merge conflict markers as specified in issue #123.
Title check ❓ Inconclusive The title 'fix: resolved merge conflicts' is vague and generic, using non-descriptive terms that don't convey what specific changes or merge conflicts were resolved. Use a more specific title that describes the primary change, e.g., 'fix: resolve merge conflicts in Game, MatchLogs, TeamBuilder, and TeamDebateRoom components'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR addresses the primary coding requirement from issue #123 (fixing duplicate toggleCamera declaration and syntax errors in TeamDebateRoom.tsx), but does not address the backend issue about DebateWebsocketHandler being undefined.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

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

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/src/Pages/TeamDebateRoom.tsx (1)

1492-1503: Hardcoded localhost URL will break in production.

The transcript submission endpoint uses a hardcoded http://localhost:1313 URL, but BASE_URL is already defined and used elsewhere for WebSocket connections. This will fail in any non-local environment.

🔎 Proposed fix
-      const response = await fetch(`http://localhost:1313/submit-transcripts`, {
+      const response = await fetch(`${BASE_URL}/submit-transcripts`, {
frontend/src/Pages/MatchLogs.tsx (1)

219-223: Bug: Tiebreaker note condition will never match.

The stage variable can only be "First Round", "Semifinal", or "Final" (computed at lines 105-109), but this condition checks for "First Round Match 3" which is never assigned to stage. The tiebreaker note will never display.

🔎 Proposed fix - check the original match string instead
-                {stage === "First Round Match 3" && (
+                {log.match.includes("First Round Match 3") && (
                   <p className="text-xs text-muted-foreground mt-2">
                     * Ayaan Khanna advanced via tiebreaker
                   </p>
                 )}
🧹 Nitpick comments (1)
frontend/src/Pages/TeamDebateRoom.tsx (1)

643-668: Missing handlePhaseDone in dependency array may cause stale closure.

The timer countdown effect calls handlePhaseDone() on expiration, but handlePhaseDone is not included in the dependency array. This could cause stale closures if handlePhaseDone captures state that changes during the timer.

🔎 Proposed fix - wrap handlePhaseDone with useCallback and add to deps
-  }, [timer, debatePhase, isMyTurn, speechTranscripts, localRole, debateId]);
+  }, [timer, debatePhase, isMyTurn, speechTranscripts, localRole, debateId, handlePhaseDone]);

Also wrap handlePhaseDone with useCallback:

-  const handlePhaseDone = () => {
+  const handlePhaseDone = useCallback(() => {
     const currentIndex = phaseOrder.indexOf(debatePhase);
     ...
-  };
+  }, [debatePhase, phaseOrder, logMessageHistory]);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 251aa47 and 52583af.

📒 Files selected for processing (4)
  • frontend/src/Pages/Game.tsx
  • frontend/src/Pages/MatchLogs.tsx
  • frontend/src/Pages/TeamBuilder.tsx
  • frontend/src/Pages/TeamDebateRoom.tsx
💤 Files with no reviewable changes (1)
  • frontend/src/Pages/Game.tsx
🔇 Additional comments (7)
frontend/src/Pages/TeamDebateRoom.tsx (2)

268-308: LGTM! - toggleCamera function is properly consolidated.

The PR objective mentioned removing duplicate toggleCamera function definitions. This implementation is now singular and handles camera toggle correctly with proper error handling and stream management.


145-148: LGTM! - Formatting changes are consistent.

The whitespace adjustments and formatting changes throughout the file maintain consistency with the codebase style. The isMyTurn memo and other logic remain correct.

Also applies to: 540-546

frontend/src/Pages/TeamBuilder.tsx (3)

234-249: LGTM! - Robust captain ID comparison with backwards compatibility.

The isCaptain function correctly handles both string IDs and MongoDB ObjectId-style objects ({ $oid: ... }). This defensive approach prevents comparison failures when ID formats differ.


821-824: Good defensive improvement to capacity calculation.

The updated logic correctly guards against maxSize being 0 or negative, which the previous || 4 fallback wouldn't handle correctly (since 0 || 4 would incorrectly default).


769-793: LGTM! - Captain action conditionals are correctly structured.

The nested conditionals properly verify captain status and prevent captains from removing themselves. The || null fallback ensures type safety for the isCaptain call.

frontend/src/Pages/MatchLogs.tsx (2)

105-109: LGTM! - Stage determination logic is correct.

The ternary chain correctly categorizes matches into "First Round", "Semifinal", or "Final" stages based on the match string.


198-217: LGTM! - Score highlighting logic is correct.

The total score cells correctly apply text-primary styling to the winning score. The formatting changes improve readability of the template literals.

@ayush00git
Copy link
Author

ayush00git commented Dec 23, 2025

Hey @bhavik-mangla,
please give it a review
Also i want to mention that PR - #132 also solves this issue but i feel like there were a lot of unnecessary changes in that, i know it was assigned to @Suraj0950 and i raised the PR because there were no updates and the project was not continuing. You can still consider his PR, no issues : )

@Suraj0950
Copy link

Hey @bhavik-mangla,
please give it a review
Also i want to mention that PR - #132 also solves this issue but i feel like there were a lot of unnecessary changes in that, i know it was assigned to @Suraj0950 and i raised the PR because there were no updates and the project was not continuing. You can still consider his PR, no issues : )

Brother I have already tested in local then raised PR, I think there is no unnecessary thing changed...I raised both issue and PR, If still have any type of issue I will definitely recheck and work on that, Thanks for the information...

@ayush00git
Copy link
Author

Hey @bhavik-mangla
Could you please look into this issue, the project is stopped due to this build process and could be open for contribution only after this issue is resolved.

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.

BUG: Unable to start the project for development

2 participants