Skip to content

Fix blank page after debate completion and ensure judgment popup rendering#366

Open
spinola103 wants to merge 3 commits into
AOSSIE-Org:mainfrom
spinola103:fix/blank-page-after-debate
Open

Fix blank page after debate completion and ensure judgment popup rendering#366
spinola103 wants to merge 3 commits into
AOSSIE-Org:mainfrom
spinola103:fix/blank-page-after-debate

Conversation

@spinola103

@spinola103 spinola103 commented Mar 21, 2026

Copy link
Copy Markdown

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:

  • Conflicting conditional rendering logic
  • Loader popup blocking the UI
  • Unsafe state handling and race conditions
  • Component rendering failures due to undefined values

Changes Made:

  • Refactored rendering logic to ensure judgment popup is always displayed when data is available
  • Removed redundant and conflicting state (showJudgment)
  • Eliminated duplicate render paths causing UI inconsistency
  • Ensured loader popup is properly dismissed after judging
  • Implemented safe JSON parsing for backend responses
  • Fixed component crash due to missing props (botDesc)
  • Added defensive rendering using optional chaining to prevent runtime failures
  • Ensured stable and predictable UI flow after debate completion

Screenshots/Recordings:

gsoc.mp4

Video evidence included demonstrating:

  1. Full debate flow
  2. Score calculation phase
  3. Judgment popup rendering correctly (no blank screen)
  4. Smooth user experience post-debate

Additional Notes:

  • This fix improves the reliability of a core feature (debate result display)
  • No changes were made to backend logic
  • UI behavior is now consistent and robust across all scenarios

AI Usage Disclosure:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and will share this PR with maintainers
  • I have read the Contribution Guidelines
  • I will address CodeRabbit AI review comments after submission
  • I have filled this PR template completely and carefully

Hey @bhavik-mangla, kindly review this PR for issue #347. Video testing evidence has been included. Thanks

Summary by CodeRabbit

  • Bug Fixes

    • Improved AI opponent description fallback shown in judgment results.
    • Made judgment parsing and display more reliable and deterministic.
    • Fixed judgment error/fallback behavior; closing a judgment now returns users to the game.
  • Chores

    • Removed the support page route from site navigation.

@coderabbitai

coderabbitai Bot commented Mar 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9783796-75b6-43ec-a803-75a8da12fe25

📥 Commits

Reviewing files that changed from the base of the PR and between 618df3d and 12abecd.

📒 Files selected for processing (1)
  • frontend/src/Pages/DebateRoom.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/Pages/DebateRoom.tsx

📝 Walkthrough

Walkthrough

Removed the support-debateai public route; judgment UI now driven solely by judgmentData (removed showJudgment state), parsing of judge results simplified, JudgmentPopup close now clears judgmentData and navigates to /game, and botDesc fallback added to JudgementPopup.

Changes

Cohort / File(s) Summary
Routing Changes
frontend/src/App.tsx
Removed the support-debateai route and its SupportOpenSource import from the public Layout-wrapped routes.
Judgment Handling & Navigation
frontend/src/Pages/DebateRoom.tsx
Removed showJudgment state; judgment visibility now depends on judgmentData. judgeDebateResult now parses when result is a string or validates object shape otherwise. On judgment close, clear judgmentData and navigate to "/game"; removed delayed re-enable fallback.
Component Props & Fallbacks
frontend/src/components/JudgementPopup.tsx
Added botDesc to props and updated player2Desc to use `botDesc

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 I hopped through code where routes did roam,

A judgement popped and guided me home.
No blank-screen scare, just verdicts clear,
A bot described, now ever near.
Hooray — on to the next debate cheer! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main fix: resolving the blank page issue after debate completion by ensuring proper judgment popup rendering.
Linked Issues check ✅ Passed All code changes directly address issue #347: refactored judgment rendering to display results instead of blank page, fixed state conflicts, and ensured proper navigation after debate completion.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the blank page bug in the debate completion flow; no unrelated modifications or scope creep detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Dead 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 if branch, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 09ef1bb and ab69bb8.

📒 Files selected for processing (3)
  • frontend/src/App.tsx
  • frontend/src/Pages/DebateRoom.tsx
  • frontend/src/components/JudgementPopup.tsx
💤 Files with no reviewable changes (1)
  • frontend/src/App.tsx

Comment thread frontend/src/Pages/DebateRoom.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (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

📥 Commits

Reviewing files that changed from the base of the PR and between ab69bb8 and 618df3d.

📒 Files selected for processing (1)
  • frontend/src/Pages/DebateRoom.tsx

Comment thread frontend/src/Pages/DebateRoom.tsx
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]: Blank page displayed after debate vs bot ends instead of showing result or redirecting

1 participant