Visualization Creation or Update
Create or update algorithm visualizations that synchronize code execution with visual state for problems identified by /problem/:id.
Workflow
1. Locate the visualization file
Search src/components/visualizations/algorithms/ for the file matching the problem ID.
- File exists: Update it to match the standards below.
- File missing: Confirm with the user before generating a new visualization.
2. Implement the visualization
Code display rules
- The execution steps MUST be perfectly synchronized with the highlighted lines of code in the editor view.
- The algorithm code block MUST NOT contain any comments — remove all inline and block comments.
- Always use the
AnimatedCodeEditorcomponent for code blocks. Do not add redundant wrapperdivs, headings, or extra layout containers around it.
Layout rules
- Place
SimpleStepControlsat the top of the visualization, above the main content grid. - Use a two-column grid on large screens with consistent
VariablePanelplacement. - Place the descriptive commentary box above the
VariablePanelto provide immediate context. - Use theme-aware text classes (
text-foreground,text-primary-foreground) instead of hardcoded colors. - Do not add index labels (e.g., "idx") to array visual elements.
Interaction rules
- Disable all click-based animations — transitions between steps must be instantaneous.
- Only implement multiple test cases if explicitly requested. When implemented, provide a visually polished toggle UI using
lucide-reacticons. Switching cases must resetcurrentStepIndexto 0 andisPlayingto false.
Commentary rules
- Write descriptive, step-by-step narrative commentary explaining why each action is taken and how the algorithm progresses toward the solution.
3. Verify
Confirm each of the following before completing:
- [ ] No comments inside the code block string
- [ ] Variable/pointer states match the active execution step at every step index
- [ ]
SimpleStepControlsrenders above the content grid - [ ]
AnimatedCodeEditorhas no redundant wrapper elements - [ ] Text colors use theme-aware classes