frontend
frontend copied to clipboard
Playground breakpoints: removal of last breakpoint leads to spurious "Run" action
Here is the sequence. Notice the missing 4 in the last screen shot: Removing the last breakpoint triggered a "Run".
This bug is still there. Just tried. Here is the program: https://share.sourceacademy.nus.edu.sg/1ijs1
This bug is still there.
https://share.sourceacademy.nus.edu.sg/5ya5k
The bug shows up in Source §3 but also in Source §1.
When the number of breakpoints goes from 1 to 0, line 763 is run which clears the REPL output: https://github.com/source-academy/frontend/blob/5391c8a76bc51822cac281d29b54186c385a8cc4/src/pages/playground/Playground.tsx#L744-L770
The reason this is done is because playground.debuggerContext.result.value is an array of objects used by the stepper (at least in Source 1) when the breakpoint is set:

Whereas without breakpoints, the playground.debuggerContext.result.value is an actual value that the REPL can display:

As such, we are forced to clear the REPL output because if the stepper's playground.debuggerContext.result.value is parsed by the normal REPL, the frontend crashes. @martin-henz It would seem that playground.debuggerContext.result.value is being used for 2 different purposes, and should be refactored into separate variables if we want to fix this bug.
The stepper's use of breakpoints is quite lame right now: It switches to the stepper when a breakpoint is set, but it doesn't do anything with the breakpoints. It seems like the use of breakpoints by stepper wasn't well designed. Would it be a lot of trouble removing breakpoints from the stepper entirely? The loss would be minimal. Then, once we have a clear idea how to make use of breakpoints in the stepper, we can revisit this, hopefully with a better solution.
The stepper's use of breakpoints is quite lame right now: It switches to the stepper when a breakpoint is set, but it doesn't do anything with the breakpoints. It seems like the use of breakpoints by stepper wasn't well designed. Would it be a lot of trouble removing breakpoints from the stepper entirely? The loss would be minimal. Then, once we have a clear idea how to make use of breakpoints in the stepper, we can revisit this, hopefully with a better solution.
It seems that the refactoring might not be as simple as removing breakpoints from the stepper entirely since the debuggerContext.result.value is used by the stepper. In fact, the current design has led to previous bugs such as the one fixed in #2305. There is an issue #2306 that is tracking the same refactoring that is necessary to solve this issue.