fix: server crash from syntax error in challenges.ts, voice overlap, human fight UX

- Remove stray duplicate template block outside TEMPLATES array that caused parse error preventing server startup (fixes /api/queue/status 500)
- Add choices field to Challenge/PromptEntry interfaces for multiple choice support
- Allow voice lines to overlap naturally instead of cancelling previous speech on every call, with safety flush at depth > 3
- Buffer challenges during cooldown in polling path, auto-submit random choice on timeout
- Block auto-battle for human fights, guard replay-done auto-transition

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-07 21:15:42 +00:00
co-authored by Claude Opus 4.6
parent c5f6c6bbf9
commit 4307a02d25
3 changed files with 767 additions and 213 deletions
+16 -4
View File
@@ -187,7 +187,13 @@ async function pollForChallenge() {
const data = await res.json()
if (data.pending) {
if (roundCooldown.value > 0) return
if (roundCooldown.value > 0) {
// Buffer for when cooldown ends
if (!pendingChallengeData.value || (data.roundNumber && data.roundNumber > (pendingChallengeData.value.data.roundNumber || 0))) {
pendingChallengeData.value = { data, receivedAt: Date.now() }
}
return
}
if (!humanChallenge.value || humanChallenge.value.roundNumber !== data.roundNumber) {
applyChallenge(data)
}
@@ -206,7 +212,13 @@ function startTimer() {
humanTimer.value--
if (humanTimer.value <= 0) {
if (timerHandle) clearInterval(timerHandle)
if (!humanSubmitted.value) humanSubmitted.value = true
if (!humanSubmitted.value) {
// Auto-submit a random choice on timeout
if (humanChoices.value.length > 0 && !humanAnswer.value.trim()) {
humanAnswer.value = humanChoices.value[Math.floor(Math.random() * humanChoices.value.length)]
}
submitHumanAnswer()
}
}
}, 1000)
}
@@ -618,14 +630,14 @@ async function matchmake(botId: string) {
function onReplayDone() {
replayDone.value = true
if (autoBattle.value && myBotId.value) {
if (autoBattle.value && myBotId.value && !isHumanFight.value) {
autoBattleCount.value++
fightAgain(myBotId.value)
}
}
function startAutoBattle() {
if (!myBotId.value) return
if (!myBotId.value || isHumanFight.value) return
autoBattle.value = true
autoBattleCount.value = 0
fightAgain(myBotId.value)