2.2 KiB
2.2 KiB
Task 6: System Integrity - Show Component Names Fix - Context
Task Description
From task2.md: Fix the "Show Component Names" debug option. Following the recent refactor, ensure this works for all components. Check for missing displayName properties or wrappers that might be masking component identities in the DOM/DevTools.
Current Implementation:
- "Show Component Names" is in
src/components/game/debug/GameStateDebug.tsx(line 28) - Uses
useDebug()hook fromsrc/lib/game/debug-context.tsx DebugNamewrapper component shows component names visually (yellow label) when enabledDebugNameis currently used insrc/app/page.tsxto wrap major components
How It Works:
GameStateDebug.tsxhas a Switch for "Show Component Names"- When enabled,
showComponentNamesbecomes true DebugNamewrapper shows a yellow label with the component name- Components need to be wrapped with
<DebugName name="ComponentName">...</DebugName>
What Needs To Be Done:
- Ensure
DebugNamewrapper is used for ALL components (not just top-level ones in page.tsx) - Check for missing
displayNameproperties on components:displayNamehelps with React DevTools identification- Components wrapped with
React.memo(),React.forwardRef(), etc. might lose their name - Fix by setting
ComponentName.displayName = "ComponentName"
- Check for wrappers masking component identities:
- Search for
React.memo,React.forwardRef, higher-order components - Ensure
displayNameis set on these
- Search for
- Test that "Show Component Names" works correctly for all components
- Commit with message: "Task 2: System Integrity - Fix Show Component Names for all components"
Key Files:
src/lib/game/debug-context.tsx- DebugName component and hooksrc/components/game/debug/GameStateDebug.tsx- Switch for showing namessrc/app/page.tsx- Currently uses DebugName for top-level components- Search for
React.memoandforwardRefinsrc/components/
Implementation Notes:
- The
DebugNamewrapper adds a visual label - this is for the in-game debug view - The
displayNameproperty is for React DevTools - this is a separate concern - Both should be fixed for full debugging support