feat: show rejoin link when bot is already in a fight

- Track active fight IDs per bot in orchestrator (Set → Map)
- Return fightId in "already in fight" error responses (409)
- Frontend shows "REJOIN FIGHT" link instead of generic error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-09 09:27:48 +00:00
co-authored by Claude Opus 4.6
parent 64273cf145
commit e31d49898b
5 changed files with 49 additions and 21 deletions
+6 -3
View File
@@ -1,7 +1,7 @@
import { db, schema } from '../db/index.js'
import { logger } from '../lib/logger.js'
import { eq } from 'drizzle-orm'
import { runFightAsync, isInFight } from './orchestrator.js'
import { runFightAsync, isInFight, getActiveFightId } from './orchestrator.js'
import { seedMockBots } from './mock.js'
interface QueueEntry {
@@ -55,9 +55,12 @@ export async function joinQueue(botId: string): Promise<string> {
throw new Error(`Cooldown active. Wait ${waitSec}s.`)
}
// Check if already in a fight
// Check if already in a fight — return the fight ID so frontend can redirect
if (isInFight(botId)) {
throw new Error('Bot is already in a fight.')
const activeFightId = getActiveFightId(botId)
const err = new Error('Bot is already in a fight.')
;(err as any).fightId = activeFightId
throw err
}
// Load bot