refactor: unify playground taxonomy, cut UI bloat, fix cross-family s… - #1
Merged
Merged
Conversation
…tep crash Collapse the game/sandbox/lab distinction into a single "Playground" concept and tighten cross-cutting consistency: - Taxonomy: DiscoveryItemKind is now a single 'playground'; discovery-items.ts maps every family uniformly. Drop the game/sandbox/lab badges and the apologetic home copy. Rename "Maze Game"->"Maze", "Graph Sandbox"->"Graph", "Tic-Tac-Toe Lab"->"Tic-Tac-Toe", and drop the appended " Lab". - Contract: local-search now exposes renderTabs(context) like every other registry family, so each page calls activeLab.renderTabs(ctx) uniformly. - Bloat: remove the duplicate SummaryCards (4 stat cards) from all five local-search board tabs; numbers now live only in the State/Metrics rail. - Crash: gate currentStep by algorithmId via useCurrentStep() so a foreign step can never leak into another family's renderer during navigation (fixes the Alpha-Beta board crash). Applied across all 6 pages + useAlgorithmPage; harden TicTacToeLab's nested .length accesses. - Maze migration: extract MAZE_LAB_MODULE (renderConfigPanel/renderTabs/ renderTitleActions) and reduce MazePage from 414 to ~165 lines. Graph Sandbox stays a cohesive page by design (documented in CONTRIBUTING.md). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the “interactive module” surface area to present a single, consistent Playground concept across algorithm families, while also reducing duplicated UI and hardening navigation safety around the global execution trace.
Changes:
- Introduces
useCurrentStep(algorithmId)to prevent cross-page navigation from passing a “foreign”currentStepinto an incompatible renderer (fixes crash class like the Alpha-Beta board issue). - Unifies local-search to expose
renderTabs(context)like other families, and removes duplicated local-search “SummaryCards” UI from board tabs. - Extracts a Maze lab module (
MAZE_LAB_MODULE) to shrinkMazePageinto a thinner shell and standardize page/module responsibilities; updates discovery taxonomy to a singleDiscoveryItemKind = 'playground'.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/store/execution.store.ts | Adds useCurrentStep() to gate currentStep by loaded algorithmId. |
| src/problems/search/labs.ts | Renames Search playground display names for the unified taxonomy. |
| src/problems/maze/labs.ts | Renames Maze playground display names for the unified taxonomy. |
| src/problems/maze/lab-modules.tsx | New Maze registry module that centralizes Maze page rendering into pure render functions. |
| src/problems/local-search/labs.ts | Extends the local-search lab contract with renderTabs(context). |
| src/problems/local-search/lab-modules.tsx | Implements the unified renderTabs for local-search modules. |
| src/problems/game-playing/lab-modules.tsx | Updates preset picker subtitle logic tied to lab naming. |
| src/pages/SearchPage.tsx | Uses useCurrentStep() to prevent step leakage into search visualizations. |
| src/pages/PlanningPage.tsx | Uses useCurrentStep() to prevent step leakage into planning visualizations. |
| src/pages/MazePage.tsx | Converts Maze page to a thin shell delegating UI to MAZE_LAB_MODULE; uses useCurrentStep(). |
| src/pages/LocalSearchPage.tsx | Uses useCurrentStep() and delegates tabs to activeLab.renderTabs(context). |
| src/pages/HomePage.tsx | Updates Playgrounds tab copy and badges to the unified “Playground” concept. |
| src/pages/GamePage.tsx | Uses useCurrentStep() to prevent step leakage into game-playing visualizations. |
| src/pages/CspPage.tsx | Uses useCurrentStep() to prevent step leakage into CSP visualizations. |
| src/lib/discovery-items.ts | Collapses discovery kind taxonomy to 'playground' and unifies mapping across families. |
| src/hooks/useAlgorithmPage.ts | Switches to useCurrentStep() inside the shared page hook. |
| src/components/visualization/TicTacToeLab.tsx | Hardens nested .length reads with optional chaining. |
| src/components/visualization/local-search/TspLab.tsx | Removes duplicated SummaryCards from the board tab. |
| src/components/visualization/local-search/NQueensLab.tsx | Removes duplicated SummaryCards from the board tab. |
| src/components/visualization/local-search/NPuzzleLab.tsx | Removes duplicated SummaryCards from the board tab. |
| src/components/visualization/local-search/LandscapeLab.tsx | Removes duplicated SummaryCards from the board tab. |
| src/components/visualization/local-search/GraphColoringLab.tsx | Removes duplicated SummaryCards from the board tab. |
| src/components/visualization/local-search/LocalSearchShared.tsx | Deletes the SummaryCards component now that it’s no longer used. |
| CONTRIBUTING.md | Updates contributor terminology/architecture docs to reflect “Playground” and Maze module extraction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| onOpenChange={onOpenChange} | ||
| title={`Choose a ${lab.name} Demo`} | ||
| subtitle={`Load a preset scenario for ${lab.name.toLowerCase().replace(' lab', '')}`} | ||
| subtitle={`Load a preset scenario for ${lab.name.toLowerCase()}`} |
Owner
Author
There was a problem hiding this comment.
We leave it be as it is, for now.
Comment on lines
+49
to
+55
| return defs.map((def) => ({ | ||
| id: `${def.id}${idSuffix}`, | ||
| name: def.name, | ||
| description: def.description, | ||
| path: def.path, | ||
| status: def.status ?? 'live', | ||
| kind: 'playground' as const, |
Comment on lines
+324
to
+330
| export function useCurrentStep<T = AlgorithmStep>(algorithmId: string | null | undefined): T | null { | ||
| return useExecutionStore((state) => | ||
| algorithmId != null && state.algorithmId === algorithmId | ||
| ? (state.currentStep as unknown as T | null) | ||
| : null, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Collapse the game/sandbox/lab distinction into a single "Playground" concept and tighten cross-cutting consistency: