Skip to content

refactor: unify playground taxonomy, cut UI bloat, fix cross-family s… - #1

Merged
thethinkmachine merged 1 commit into
mainfrom
refactor/playground-consistency
Jun 23, 2026
Merged

refactor: unify playground taxonomy, cut UI bloat, fix cross-family s…#1
thethinkmachine merged 1 commit into
mainfrom
refactor/playground-consistency

Conversation

@thethinkmachine

Copy link
Copy Markdown
Owner

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).

…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>
Copilot AI review requested due to automatic review settings June 23, 2026 03:40
@thethinkmachine
thethinkmachine merged commit 4a0a4c3 into main Jun 23, 2026
2 checks passed
@thethinkmachine
thethinkmachine deleted the refactor/playground-consistency branch June 23, 2026 03:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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” currentStep into 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 shrink MazePage into a thinner shell and standardize page/module responsibilities; updates discovery taxonomy to a single DiscoveryItemKind = '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()}`}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants