Bugs
Two spectator bugs found while watching a Connect Four (player vs bot) game.
Bug 1 — Chat message attributed to bot
When a spectator sends a chat message, it appears in the chat attributed to the second player's name (the bot).
Root cause: sendChat() computes myName = myDisc === 1 ? p1Name : p2Name. For spectators myDisc is null, so the condition is false → always uses p2Name (bot). Same issue in Tic-Tac-Toe (mySymbol === 'X' ? xName : oName).
Bug 2 — Bot failed toast for spectators
Spectators occasionally see "Bot failed to make a move" toast even though the bot plays normally.
Root cause: useBotTurn hook has no isSpectator guard — spectators' clients trigger bot-turn API calls, compete with the real player's client (409 conflicts), and on certain error paths show the error toast.
Affected files
app/lobby/[code]/connect-four-page.tsx
app/lobby/[code]/tic-tac-toe-page.tsx
app/lobby/[code]/hooks/useBotTurn.ts
app/lobby/[code]/LobbyPageClient.tsx
Bugs
Two spectator bugs found while watching a Connect Four (player vs bot) game.
Bug 1 — Chat message attributed to bot
When a spectator sends a chat message, it appears in the chat attributed to the second player's name (the bot).
Root cause:
sendChat()computesmyName = myDisc === 1 ? p1Name : p2Name. For spectatorsmyDiscisnull, so the condition isfalse→ always usesp2Name(bot). Same issue in Tic-Tac-Toe (mySymbol === 'X' ? xName : oName).Bug 2 — Bot failed toast for spectators
Spectators occasionally see "Bot failed to make a move" toast even though the bot plays normally.
Root cause:
useBotTurnhook has noisSpectatorguard — spectators' clients trigger bot-turn API calls, compete with the real player's client (409 conflicts), and on certain error paths show the error toast.Affected files
app/lobby/[code]/connect-four-page.tsxapp/lobby/[code]/tic-tac-toe-page.tsxapp/lobby/[code]/hooks/useBotTurn.tsapp/lobby/[code]/LobbyPageClient.tsx