Fix blank page after debate completion and ensure judgment popup rendering#366
Fix blank page after debate completion and ensure judgment popup rendering#366spinola103 wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRemoved the Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant DebateRoom as DebateRoom Component
participant Judge as Judge (local/worker)
participant JudgmentPopup as JudgmentPopup Component
participant Router as Router
User->>DebateRoom: complete debate
DebateRoom->>Judge: judgeDebateResult(result)
Judge-->>DebateRoom: judgmentData (object)
DebateRoom->>JudgmentPopup: render with judgmentData, botDesc
JudgmentPopup->>User: display verdict
User->>JudgmentPopup: click Close
JudgmentPopup->>DebateRoom: onClose -> clear judgmentData
DebateRoom->>Router: navigate("/game")
Router-->>User: show /game
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src/Pages/DebateRoom.tsx (1)
585-600:⚠️ Potential issue | 🟡 MinorDead code and redundant JSON extraction.
Lines 585-586 extract JSON and log it, but this result is never used. The new conditional block (lines 590-596) re-extracts JSON inside the
ifbranch, making the earlier extraction redundant.🧹 Proposed fix to remove dead code
console.log("Raw judge result:", result); - - const jsonString = extractJSON(result); - console.log("Extracted JSON string:", jsonString); let judgment: JudgmentData; if (typeof result === "string") { const jsonString = extractJSON(result); console.log("Extracted JSON:", jsonString); judgment = JSON.parse(jsonString); } else { judgment = result; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/Pages/DebateRoom.tsx` around lines 585 - 600, Remove the dead/redundant extraction and logging: delete the initial jsonString extraction and its console.log at the top of the snippet and rely only on the conditional branch that uses extractJSON when result is a string; ensure the if (typeof result === "string") branch calls extractJSON once and JSON.parse into the judgment variable, otherwise set judgment = result, then call setJudgmentData(judgment) and setPopup({...}) as existing. Keep references to extractJSON, judgment, setJudgmentData, setPopup and the result variable so behavior is unchanged but without duplicate extraction/logging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/src/Pages/DebateRoom.tsx`:
- Around line 594-596: The code assigns a non-string result directly to judgment
(else { judgment = result; }) without validating it matches the expected
JudgmentData shape, which can crash JudgmentPopup when accessing nested fields
like judgment.opening_statement.user.score; add a runtime type guard (e.g.,
isJudgmentData(obj): boolean) that checks for required nested keys/types
(opening_statement, opening_statement.user, score, etc.) and use it before
assigning result to judgment, falling back to a safe default or logging/throwing
an error if validation fails so JudgmentPopup always receives a valid structure.
---
Outside diff comments:
In `@frontend/src/Pages/DebateRoom.tsx`:
- Around line 585-600: Remove the dead/redundant extraction and logging: delete
the initial jsonString extraction and its console.log at the top of the snippet
and rely only on the conditional branch that uses extractJSON when result is a
string; ensure the if (typeof result === "string") branch calls extractJSON once
and JSON.parse into the judgment variable, otherwise set judgment = result, then
call setJudgmentData(judgment) and setPopup({...}) as existing. Keep references
to extractJSON, judgment, setJudgmentData, setPopup and the result variable so
behavior is unchanged but without duplicate extraction/logging.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cd87c46f-577b-494d-baee-122aaaf2609d
📒 Files selected for processing (3)
frontend/src/App.tsxfrontend/src/Pages/DebateRoom.tsxfrontend/src/components/JudgementPopup.tsx
💤 Files with no reviewable changes (1)
- frontend/src/App.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/src/Pages/DebateRoom.tsx (1)
595-603: Inconsistent indentation reduces readability.The nested code block has mixed indentation (0-space vs 1-space). Consider running a formatter or aligning consistently.
🧹 Proposed formatting fix
} else { - const res: any = result; - - if (res?.opening_statement && res?.verdict) { - judgment = res as JudgmentData; - } else { - console.error("Invalid judgment structure:", result); - throw new Error("Invalid judgment data structure"); - } + const res: any = result; + if (res?.opening_statement && res?.verdict) { + judgment = res as JudgmentData; + } else { + console.error("Invalid judgment structure:", result); + throw new Error("Invalid judgment data structure"); + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/Pages/DebateRoom.tsx` around lines 595 - 603, The snippet assigning res and validating its shape has mixed indentation around the if/else block (lines referencing res, judgment, and JudgmentData), so reformat that block to use consistent indentation (e.g., 2 or 4 spaces) or run the project's formatter/Prettier to normalize spacing; ensure the if (res?.opening_statement && res?.verdict) { judgment = res as JudgmentData; } else { console.error("Invalid judgment structure:", result); throw new Error("Invalid judgment data structure"); } block is consistently indented to match surrounding code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/src/Pages/DebateRoom.tsx`:
- Around line 589-607: The extractJSON(result) call is being invoked
unconditionally and is now redundant/unsafe; update the block around
extractJSON, the result handling, and judgment assignment (the code that sets
judgment, calls setJudgmentData and setPopup) so that extractJSON is only called
when typeof result === "string" (i.e., move or re-use extractJSON inside the
string branch) and remove the unconditional call; ensure the string branch uses
extractJSON(result) then JSON.parse into judgment and the object branch
validates res?.opening_statement && res?.verdict before casting to JudgmentData
and assigning judgment.
---
Nitpick comments:
In `@frontend/src/Pages/DebateRoom.tsx`:
- Around line 595-603: The snippet assigning res and validating its shape has
mixed indentation around the if/else block (lines referencing res, judgment, and
JudgmentData), so reformat that block to use consistent indentation (e.g., 2 or
4 spaces) or run the project's formatter/Prettier to normalize spacing; ensure
the if (res?.opening_statement && res?.verdict) { judgment = res as
JudgmentData; } else { console.error("Invalid judgment structure:", result);
throw new Error("Invalid judgment data structure"); } block is consistently
indented to match surrounding code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3c40ef9a-62ac-48bc-b80b-73073907395b
📒 Files selected for processing (1)
frontend/src/Pages/DebateRoom.tsx
PR Title:Fix blank page after debate completion and ensure judgment popup rendering
Addressed Issue:
Fixes #347
Description:
This PR resolves a critical UI issue where a blank page was displayed after completing a debate vs bot, instead of showing the judgment result.
The issue was caused by:
Changes Made:
showJudgment)botDesc)Screenshots/Recordings:
gsoc.mp4
Video evidence included demonstrating:
Additional Notes:
AI Usage Disclosure:
Checklist
Hey @bhavik-mangla, kindly review this PR for issue #347. Video testing evidence has been included. Thanks
Summary by CodeRabbit
Bug Fixes
Chores