human fight non multiple choice fix
This commit is contained in:
@@ -265,6 +265,11 @@ async function getBotResponse(
|
||||
): Promise<WebhookResponse> {
|
||||
if (isHumanPlayer(bot.webhookUrl)) {
|
||||
logger.info('fight', `${bot.name} is human player, waiting for browser response`)
|
||||
// Start waitForHumanResponse FIRST so the pending challenge is stored
|
||||
// before the SSE event tells the frontend to fetch it (fixes race condition
|
||||
// where frontend fetched before pending was set → no choices shown)
|
||||
const start = Date.now()
|
||||
const resultPromise = waitForHumanResponse(fightId, bot.id, challenge, roundNumber)
|
||||
emit(fightId, 'human_challenge', {
|
||||
botId: bot.id,
|
||||
round: roundNumber,
|
||||
@@ -274,8 +279,7 @@ async function getBotResponse(
|
||||
timeoutMs: challenge.timeout_ms,
|
||||
scoring: challenge.scoring,
|
||||
})
|
||||
const start = Date.now()
|
||||
const result = await waitForHumanResponse(fightId, bot.id, challenge, roundNumber)
|
||||
const result = await resultPromise
|
||||
const elapsed = Date.now() - start
|
||||
return { answer: result.answer, trashTalk: result.trashTalk, timeMs: elapsed, timedOut: result.timedOut, error: false }
|
||||
}
|
||||
@@ -389,7 +393,7 @@ async function executeFightRounds(fightId: string, botA: BotRecord, botB: BotRec
|
||||
|
||||
for (let round = 1; round <= MAX_ROUNDS; round++) {
|
||||
lastRound = round
|
||||
const challenge = round === retroRound
|
||||
const challenge = (round === retroRound && !hasHuman)
|
||||
? generateRetroChallenge()
|
||||
: pickChallenge(usedTypes, arena.modifier, undefined, round, hasHuman)
|
||||
usedTypes.add(challenge.type)
|
||||
|
||||
Reference in New Issue
Block a user