feat: Add practice sandbox, custom timers, and interactive flowchart … - #6
Open
Anki-agrh wants to merge 1 commit into
Open
feat: Add practice sandbox, custom timers, and interactive flowchart …#6Anki-agrh wants to merge 1 commit into
Anki-agrh wants to merge 1 commit into
Conversation
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.
feat: Interactive Practice Sandbox, Live Branching Flowchart Visualizer & Double-Hover Code Linking
Overview
This PR significantly elevates the PyBe learning experience by transforming the static "view AI solution"
post-reasoning flow into an active, timed code practice environment with a live Python
control flow visualizer that links interactively with the code editor.
Rather than immediately revealing the AI mentor's solution after reasoning submission, learners are now
gated through an intentional choice: either attempt to write the Python code themselves in a timed
sandbox, or display the solution immediately.
Features Added
1. Choice Launcher Gate
After the AI mentor returns abstraction mapping results, users now see a gate card:
This preserves full backward compatibility while adding an entirely new active-learning path.
2. Configurable Practice Timer
When users choose to practice, they are presented with a timer configuration step before the sandbox opens:
3. Interactive Python IDE Sandbox
A full-featured code editor powered by Pyodide (v0.26.2) — running Python entirely in the browser:
Run Codebutton executes user Python instantly in-browser via WebAssemblyVerifybutton runs scenario-specific assertions to check correctnessstdoutandstderr4. Live Branching Control Flow Visualizer
As the user types code in the sandbox editor, a live flowchart panel renders their logic structure
in real-time using a purpose-built parser:
❓ Is weight > 5?) forif/elif/elsebranches🔁 For each:,🔁 While:) for iteration blocks📝 weight = 10) for assignments and function declarations🖨️ Print: Heavy) for print statements5. Double-Hover Code–Flowchart Linking
A novel UX interaction that creates a bidirectional visual link between the code editor and
the live flowchart:
lineNo— the source line index from the user's codeonHoverLine(lineNo)which propagates up tothe workspace state
bold weight, subtle glow)
transform: scale(1.03)) with a borderhighlight animation
This creates a seamless cognitive link between abstract logic diagrams and raw Python syntax.
6. Dual Resizable Split Panels
Replaced all fixed-width CSS grid structures with custom drag-to-resize dividers:
results panel (30%–80% bounds)
(30%–80% bounds)
mouseup/touchendto prevent stale handlers7. Post-Challenge Comparison View
After the timer expires or the user gives up/solves the scenario:
File Changes
New Files
| File | Purpose |
|
client/src/components/ChallengeWorkspace.jsx| Self-contained practice IDE with all hooks: timers, Pyodide compiler, resize sliders, hint system, verify assertions, and post-challenge reveal states ||
client/src/components/CodeFlowChart.jsx| Recursive flowchart renderer —FlowNodesListrecursively renders branch columns and diamond decision nodes; acceptshoveredLineandonHoverLineprops for double-highlight linking ||
client/src/components/EmptyResult.jsx| Stateless fallback card shown in the AI Mentor Output panel before any reasoning is submitted ||
client/src/utils/parser.js|parsePythonLogiclexical scanner +buildASTFlowrecursive AST tree builder ||
client/src/utils/verification.js| Scenario-specific Pyodide assertion runners — validates user code against expected variable states and output patterns ||
client/src/utils/hints.js| Static progressive hint database — maps scenario titles to ordered hint arrays |Modified Files
client/src/styles.cssgutter-activeandflow-card-activedouble-highlight classesScreenshots