Fixes production error "Cannot read properties of undefined (reading 'carryBoxes')" that occurred when users tried to adjust difficulty settings. Root cause: displayRules was undefined for new users or users with old V1 config in database. Difficulty adjustment buttons accessed displayRules.carryBoxes without checking if displayRules existed first. Changes: - AdditionWorksheetClient: Initialize displayRules with defaults when missing - ConfigPanel: Use null-coalescing operators instead of non-null assertions - ConfigPanel: Add error logging when required fields are missing - NEW: WorksheetErrorBoundary component to catch all errors in worksheet page - page.tsx: Wrap client component with error boundary This ensures users see helpful error messages instead of blank pages, and never need to open the browser console to understand what went wrong. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4.6 KiB
4.6 KiB
Integration Summary
✅ Completed: Apps/Web Integration with Abacus-React Enhancements
Features Implemented & Integrated
1. Theme Presets (ABACUS_THEMES)
Status: ✅ Fully integrated
Files Updated:
apps/web/src/components/MyAbacus.tsx- Now usesABACUS_THEMES.lightandABACUS_THEMES.trophyapps/web/src/components/HeroAbacus.tsx- Now usesABACUS_THEMES.lightapps/web/src/components/LevelSliderDisplay.tsx- Now usesABACUS_THEMES.dark
Code Eliminated: ~60 lines of duplicate theme style definitions
2. Compact Prop
Status: ✅ Fully integrated
Files Updated:
apps/web/src/app/arcade/complement-race/components/AbacusTarget.tsx- Now usescompact={true}
Before:
<AbacusReact
value={number}
columns={1}
interactive={false}
showNumbers={false}
hideInactiveBeads={true}
scaleFactor={0.72}
customStyles={{ columnPosts: { opacity: 0 } }}
/>
After:
<AbacusReact
value={number}
columns={1}
compact={true}
interactive={false}
showNumbers={false}
hideInactiveBeads={true}
scaleFactor={0.72}
/>
3. Utility Functions
Status: ✅ Fully integrated
Files Updated:
apps/web/src/utils/beadDiff.ts- Now re-exports from abacus-reactapps/web/src/utils/abacusInstructionGenerator.ts- Now re-exports from abacus-reactapps/web/src/components/tutorial/TutorialPlayer.tsx- ImportscalculateBeadDiffFromValuesfrom abacus-reactapps/web/src/components/tutorial/TutorialEditor.tsx- ImportscalculateBeadDiffFromValuesfrom abacus-react
Exports from abacus-react:
numberToAbacusState()abacusStateToNumber()calculateBeadChanges()calculateBeadDiff()calculateBeadDiffFromValues()validateAbacusValue()areStatesEqual()
Code Eliminated: ~200+ lines of duplicate utility implementations
4. React Hooks
Status: ✅ Exported and ready to use
Available Hooks:
useAbacusDiff(fromValue, toValue, maxPlaces)- Memoized bead diff calculationuseAbacusState(value, maxPlaces)- Memoized state conversion
Not yet used in app (available for future tutorials)
5. Column Highlighting
Status: ✅ Implemented, not yet used
New Props:
highlightColumns?: number[]- Highlight specific columnscolumnLabels?: string[]- Add educational labels above columns
Usage Example:
<AbacusReact
value={123}
highlightColumns={[1]}
columnLabels={["ones", "tens", "hundreds"]}
/>
Code Deduplication Summary
Total Lines Eliminated: ~260-300 lines
Breakdown:
- Theme style definitions: ~60 lines
- Utility function implementations: ~200 lines
- Custom styles for inline abacus: ~5-10 lines per usage
Remaining Work (Optional Future Enhancements)
- Use
highlightColumnsandcolumnLabelsin tutorial components - Replace manual bead diff calculations with
useAbacusDiffhook in interactive tutorials - Use
useAbacusStatefor state inspection in debugging/development tools - Consider implementing
frameVisibletoggles in settings pages
Files Modified
packages/abacus-react:
src/AbacusReact.tsx- Added new props (frameVisible, compact, highlightColumns, columnLabels)src/AbacusThemes.ts- NEW FILE - 6 theme presetssrc/AbacusUtils.ts- NEW FILE - Core utility functionssrc/AbacusHooks.ts- NEW FILE - React hookssrc/index.ts- Updated exportssrc/AbacusReact.themes-and-utilities.stories.tsx- NEW FILE - Storybook demosREADME.md- Updated with new features documentationENHANCEMENT_PLAN.md- Updated with completion status
apps/web:
src/components/MyAbacus.tsx- Using ABACUS_THEMESsrc/components/HeroAbacus.tsx- Using ABACUS_THEMESsrc/components/LevelSliderDisplay.tsx- Using ABACUS_THEMESsrc/app/arcade/complement-race/components/AbacusTarget.tsx- Using compact propsrc/components/tutorial/TutorialPlayer.tsx- Importing from abacus-reactsrc/components/tutorial/TutorialEditor.tsx- Importing from abacus-reactsrc/utils/beadDiff.ts- Re-exports from abacus-reactsrc/utils/abacusInstructionGenerator.ts- Re-exports from abacus-react
Testing
✅ Build successful for packages/abacus-react ✅ TypeScript compilation passes for integrated files ✅ Runtime tests confirm functions work correctly ✅ Storybook stories demonstrate all new features
Next Steps
- Monitor app for any runtime issues with the new integrations
- Consider using hooks in future tutorial implementations
- Explore using column highlighting in educational content
- Document best practices for theme usage in the app