When switching from Lessons mode to Sandbox mode and using Start debugging, the debugger executes code from the previous Lessons session instead of the code shown in the Sandbox editor.
Steps to reproduce
Open the JavaScript Playground in Lessons mode with lesson code (e.g. console.log("Hello from JavaScript!");).
Switch to Sandbox mode.
Enter different sandbox code in the editor (e.g. var testing = 'hello';).
Use Start debugging.
Observe that output/execution reflects the lesson code (e.g. "Hello from JavaScript!") rather than the sandbox content.
Expected behavior
Start debugging should always run and debug the code that is currently active in the Sandbox editor after mode switch.
Actual behavior
Debugging appears to use a stale reference to Lessons mode code while the UI still shows the Sandbox editor contents.
Notes
Likely causes to investigate: shared state not cleared on mode switch, wrong buffer/source passed to the debugger runner, or the debugger binding to the lesson document instead of the sandbox document.
## Summary
When switching from **Lessons** mode to **Sandbox** mode and using **Start debugging**, the debugger executes code from the **previous Lessons** session instead of the code shown in the Sandbox editor.
## Steps to reproduce
1. Open the JavaScript Playground in **Lessons** mode with lesson code (e.g. `console.log("Hello from JavaScript!");`).
2. Switch to **Sandbox** mode.
3. Enter different sandbox code in the editor (e.g. `var testing = 'hello';`).
4. Use **Start debugging**.
5. Observe that output/execution reflects the **lesson** code (e.g. `"Hello from JavaScript!"`) rather than the sandbox content.
## Expected behavior
**Start debugging** should always run and debug the code that is currently active in the **Sandbox** editor after mode switch.
## Actual behavior
Debugging appears to use a stale reference to **Lessons** mode code while the UI still shows the Sandbox editor contents.
## Notes
Likely causes to investigate: shared state not cleared on mode switch, wrong buffer/source passed to the debugger runner, or the debugger binding to the lesson document instead of the sandbox document.
Root cause confirmed (matches the "wrong buffer/source passed to the debugger" hypothesis in the notes): the step-debugger's source provider read LanguageRunner.code (codeSignal). In advanced sandbox mode the editor binds to the active file (activeFileContent), not codeSignal, so codeSignal still held the prior lesson/beginner code — the debugger ran that stale source while the editor showed the sandbox content.
Fixed in spikersoft-angular PR #51 by pointing the provider at the mode-aware getSourceForChrome() (active file in advanced sandbox, codeSignal otherwise) — the same source the Run Code button already uses, so Run and Debug now execute identical, current editor content. Tests: 29/29 across the JS runner + step-debugger suites. Will close once PR #51 merges.
Root cause confirmed (matches the "wrong buffer/source passed to the debugger" hypothesis in the notes): the step-debugger's source provider read `LanguageRunner.code` (`codeSignal`). In advanced sandbox mode the editor binds to the active file (`activeFileContent`), not `codeSignal`, so `codeSignal` still held the prior lesson/beginner code — the debugger ran that stale source while the editor showed the sandbox content.
Fixed in `spikersoft-angular` PR #51 by pointing the provider at the mode-aware `getSourceForChrome()` (active file in advanced sandbox, `codeSignal` otherwise) — the same source the Run Code button already uses, so Run and Debug now execute identical, current editor content. Tests: 29/29 across the JS runner + step-debugger suites. Will close once PR #51 merges.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
When switching from Lessons mode to Sandbox mode and using Start debugging, the debugger executes code from the previous Lessons session instead of the code shown in the Sandbox editor.
Steps to reproduce
console.log("Hello from JavaScript!");).var testing = 'hello';)."Hello from JavaScript!") rather than the sandbox content.Expected behavior
Start debugging should always run and debug the code that is currently active in the Sandbox editor after mode switch.
Actual behavior
Debugging appears to use a stale reference to Lessons mode code while the UI still shows the Sandbox editor contents.
Notes
Likely causes to investigate: shared state not cleared on mode switch, wrong buffer/source passed to the debugger runner, or the debugger binding to the lesson document instead of the sandbox document.
Root cause confirmed (matches the "wrong buffer/source passed to the debugger" hypothesis in the notes): the step-debugger's source provider read
LanguageRunner.code(codeSignal). In advanced sandbox mode the editor binds to the active file (activeFileContent), notcodeSignal, socodeSignalstill held the prior lesson/beginner code — the debugger ran that stale source while the editor showed the sandbox content.Fixed in
spikersoft-angularPR #51 by pointing the provider at the mode-awaregetSourceForChrome()(active file in advanced sandbox,codeSignalotherwise) — the same source the Run Code button already uses, so Run and Debug now execute identical, current editor content. Tests: 29/29 across the JS runner + step-debugger suites. Will close once PR #51 merges.