@@ -378,6 +378,8 @@ export const useBroadcastController = (): BroadcastStreamController => {
378378 return
379379 }
380380
381+ let allGamesAfterUpdate : BroadcastGame [ ] = [ ]
382+
381383 setRoundData ( ( prevRoundData ) => {
382384 // Start with existing games
383385 const existingGames =
@@ -410,6 +412,9 @@ export const useBroadcastController = (): BroadcastStreamController => {
410412 gameStates . current . set ( game . id , newLiveGame )
411413 }
412414
415+ // Store all games for auto-selection logic
416+ allGamesAfterUpdate = Array . from ( updatedGames . values ( ) )
417+
413418 const newRoundData : BroadcastRoundData = {
414419 roundId : currentRoundId . current || '' ,
415420 broadcastId : currentBroadcast ?. tour . id || '' ,
@@ -438,14 +443,15 @@ export const useBroadcastController = (): BroadcastStreamController => {
438443 )
439444 }
440445 // Important: Do NOT change game selection if current game is not in the update
441- } else if ( parseResult . games . length > 0 ) {
446+ } else if ( allGamesAfterUpdate . length > 0 ) {
442447 // Auto-select first game only if no game is currently selected
448+ // Use the first game from the complete games list, not just the updated games
443449 console . log ( 'No game selected - auto-selecting first game' )
444450 console . log (
445451 'Auto-selecting:' ,
446- parseResult . games [ 0 ] . white + ' vs ' + parseResult . games [ 0 ] . black ,
452+ allGamesAfterUpdate [ 0 ] . white + ' vs ' + allGamesAfterUpdate [ 0 ] . black ,
447453 )
448- setCurrentGame ( parseResult . games [ 0 ] )
454+ setCurrentGame ( allGamesAfterUpdate [ 0 ] )
449455 }
450456
451457 // Update broadcast state
0 commit comments