AOSSIE-Org / AOSSIE-Org/DebateAI
Blank screen after bot debate completion and duplicate judge API calls
- 主要语言
- TypeScript
- 星标
- 84
- 派生
- 198
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 30
描述
**Description**
After completing a debate against a bot, users experience two critical issues:
The judgment popup crashes with a ReferenceError, leaving users on a blank screen
The judge endpoint is called twice, wasting API quota and causing potential race conditions
**Steps** **to** **Reproduce**
**Issue 1: Blank Screen After Debate**
: Start a bot debate (any difficulty level)
: Complete all debate phases (opening statement, cross-examination, closing)
: Wait for judgment to complete
: Observe that the judgment popup crashes
: User is left on a blank screen with no way to navigate back
**Issue 2: Duplicate Judge Calls**
: Start and complete a bot debate
: Open browser DevTools → Network tab
: Observe two POST requests to /vsbot/judge endpoint
: Check backend logs - two separate judgment processes run
**Expected Behavior**
After debate completion:
: Judgment popup displays with scores and analysis
: User can view results
: Clicking "Close" navigates back to home page
Judge API calls:
: Judge endpoint called exactly once per debate
: No duplicate processing or API quota waste
**Actual Behavior**
**Blank screen issue:**
: Browser console shows: Uncaught ReferenceError: botDesc is not defined at JudgementPopup.tsx:184
: React error boundary triggered
: User stuck on blank screen
**Duplicate calls:**
: Backend logs show two sequential judge calls ~10 seconds apart
: Double API usage (problematic with rate-limited APIs like Gemini
```
[GIN] 2026/01/12 - 03:32:58 | OPTIONS "/vsbot/judge"
[GIN] 2026/01/12 - 03:32:59 | POST "/vsbot/judge" ← First call
[GIN] 2026/01/12 - 03:33:09 | POST "/vsbot/judge" ← Duplicate! (10s later)
```
**Root Cause Analysis**
Issue 1: Missing Prop Destructuring
File: frontend/src/components/JudgementPopup.tsx
**Problem**
- `botDesc` is defined in `JudgmentPopupProps` (line 77)
- But **not destructured** in component parameters (line 107)
- Line 184 tries to access an undefined variable
Issue 2: No Guard Against Duplicate Calls
File: frontend/src/Pages/DebateRoom.tsx
**Problem**
- judgeDebateResult function (line 577) has no guard against concurrent calls
- React's re-render or state updates can trigger multiple executions
- No ref to track if judging is already in progress
**Proposed Solution**
**Fix 1: Add Missing Prop Destructuring**
File: `frontend/src/components/JudgementPopup.tsx`
```
const JudgmentPopup: React.FC = ({
judgment,
userAvatar,
botAvatar,
botName,
userStance,
botStance,
botDesc, // ADD THIS
forRole,
againstRole,
localRole = null,
localDisplayName,
localAvatarUrl,
opponentDisplayName,
opponentAvatarUrl,
ratingSummary,
onClose={() => {
setShowJudgment(false);
navigate('/'); // ← ADD THIS
}}
```
**Fix 2: Add Navigation After Popup Close**
File: `frontend/src/Pages/DebateRoom.tsx`
```
JudgmentPopup
judgment={judgmentData}
userAvatar={userAvatar}
botAvatar={bot.avatar}
botName={debateData.botName}
userStance={state.userStance}
botStance={state.botStance}
botDesc={bot.desc}
onClose={() => {
setShowJudgment(false);
navigate('/'); // ← ADD THIS
}}
```
**Fix 3: Prevent Duplicate Judge Calls**
File: `frontend/src/Pages/DebateRoom.tsx `
**Add ref**
```
const judgingRef = useRef(false);
```
**Wrap judgeDebateResult function**
```
const judgeDebateResult = async (messages: Message[]) => {
// Prevent duplicate calls
if (judgingRef.current) {
console.log(" Judging already in progress, skipping duplicate call");
return;
}
judgingRef.current = true;
try {
console.log("Starting judgment with messages:", messages);
const { result } = await judgeDebate({
history: messages,
userId: debateData.userId,
});
// ... rest of existing code
} catch (error) {
// ... error handling
} finally {
judgingRef.current = false; // ← ADD THIS
}
};
```
After implementing fixes, verify:
- [ ] Complete a bot debate successfully
- [ ] Judgment popup displays without errors
- [ ] All scores and analysis show correctly
- [ ] Clicking "Close" navigates to home page
- [ ] Only ONE POST to `/vsbot/judge` in Network tab
- [ ] Backend logs show single judgment process
- [ ] No console errors in browser DevTools
- [ ] Works with different bot difficulty levels
@bhavik-mangla
I have identified and fixed the root causes for both issues, including the judgment popup crash and the duplicate judge API calls.
I would like to raise a Pull Request with the implemented fixes for review.
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。