Skip to content

Fix: App restarts lose game state #13

@offendingcommit

Description

@offendingcommit

Problem Description

The Bingo app is restarting unexpectedly and losing game state. When the app restarts (either due to code changes, server restarts, or other reasons), the following state is lost:

  • Clicked tiles
  • Game closed/open status
  • Header text
  • Bingo patterns found
  • User connections

Expected Behavior

Game state should persist across app restarts using NiceGUI's app.storage.general.

Current Behavior

State is being saved but not properly restored on app initialization, or the app is restarting in ways that bypass the state restoration logic.

Acceptance Criteria (Gherkin)

Feature: Persistent Game State
  As a bingo game player
  I want my game state to persist across app restarts
  So that I don't lose progress if the app needs to restart

  Background:
    Given I have a bingo game in progress
    And I have clicked tiles at positions (0,1), (2,3), and (4,4)
    And the game header shows "3 tiles clicked"

  Scenario: State persists through graceful restart
    When the app restarts gracefully
    Then the clicked tiles should remain at (0,1), (2,3), and (4,4)
    And the header should still show "3 tiles clicked"
    And the board should show the same phrases

  Scenario: State persists through unexpected restart
    When the app crashes and restarts
    Then the clicked tiles should remain at (0,1), (2,3), and (4,4)
    And the header should still show "3 tiles clicked"
    And the board should show the same phrases

  Scenario: State persists when code changes trigger reload
    When I modify a source file
    And NiceGUI triggers a hot reload
    Then the game state should be preserved
    And all clicked tiles should remain clicked

  Scenario: Multiple users maintain separate views
    Given User A is on the main page
    And User B is on the stream page
    When the app restarts
    Then User A should see the interactive board with saved state
    And User B should see the read-only board with saved state
    And both users should see the same clicked tiles

Technical Investigation Needed

  1. How is NiceGUI's hot reload affecting state persistence?
  2. Is app.storage.general being cleared on certain types of restarts?
  3. Are we properly awaiting async storage operations?
  4. Is the state loading logic in init_app() being called reliably?

Definition of Done

  • Failing tests written that reproduce the issue
  • Root cause identified and documented
  • State persistence works across all restart scenarios
  • BDD tests pass
  • Unit tests have >90% coverage for state management
  • No regressions in existing functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions