fix: Spire tab maxFloorReached undefined error
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 2m43s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 2m43s
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# 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:
|
||||
1. Missing or undefined combat store state
|
||||
2. Incorrect access of combat state in SpireTab.tsx
|
||||
3. Race condition in store initialization
|
||||
4. Legacy store references in Spire tab components
|
||||
|
||||
## Key Files to Investigate/Modify
|
||||
- `src/components/game/tabs/SpireTab.tsx` - Spire tab component
|
||||
- `src/lib/game/stores/combatStore.ts` - Combat state (contains maxFloorReached)
|
||||
- `src/lib/game/stores/index.ts` - Store exports
|
||||
- `src/components/game/tabs/SpireHeader.tsx` - Spire header component
|
||||
- `src/components/game/tabs/FloorControls.tsx` - Floor control components
|
||||
|
||||
## Architecture Rules (from AGENTS.md)
|
||||
- Use modular stores: import `useCombatStore` from `src/lib/game/stores/`
|
||||
- NEVER import from legacy `src/lib/game/store.ts` or `src/lib/game/store/`
|
||||
- All files must stay under 400 lines
|
||||
- Use Zustand store hooks properly (avoid direct getState() in render)
|
||||
|
||||
## Debugging Steps
|
||||
1. Check SpireTab.tsx for undefined state access
|
||||
2. Verify combatStore.ts has `maxFloorReached` properly initialized
|
||||
3. Ensure store subscriptions are correctly set up
|
||||
4. Check for race conditions in component mounting
|
||||
|
||||
## Expected Outcome
|
||||
- Spire tab loads without errors
|
||||
- `maxFloorReached` is 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/`
|
||||
Reference in New Issue
Block a user