1.6 KiB
1.6 KiB
Context: Spire Tab "maxFloorReached" Error Fix
Problem Statement
The Spire tab fails to load with error: TypeError: Cannot read properties of undefined (reading 'maxFloorReached')
Error Analysis
This error indicates that the code is trying to access maxFloorReached on an undefined object. Likely causes:
- Missing or undefined combat store state
- Incorrect access of combat state in SpireTab.tsx
- Race condition in store initialization
- Legacy store references in Spire tab components
Key Files to Investigate/Modify
src/components/game/tabs/SpireTab.tsx- Spire tab componentsrc/lib/game/stores/combatStore.ts- Combat state (contains maxFloorReached)src/lib/game/stores/index.ts- Store exportssrc/components/game/tabs/SpireHeader.tsx- Spire header componentsrc/components/game/tabs/FloorControls.tsx- Floor control components
Architecture Rules (from AGENTS.md)
- Use modular stores: import
useCombatStorefromsrc/lib/game/stores/ - NEVER import from legacy
src/lib/game/store.tsorsrc/lib/game/store/ - All files must stay under 400 lines
- Use Zustand store hooks properly (avoid direct getState() in render)
Debugging Steps
- Check SpireTab.tsx for undefined state access
- Verify combatStore.ts has
maxFloorReachedproperly initialized - Ensure store subscriptions are correctly set up
- Check for race conditions in component mounting
Expected Outcome
- Spire tab loads without errors
maxFloorReachedis properly accessed from combatStore- All legacy store references in Spire-related files are removed
- Regression test added to
src/lib/game/stores/__tests__/combat-store-tests/