-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sprite Lab] Workspace alert for execution errors #45055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Do we want to cover this with a test in SpriteLabTest.js?
apps/src/p5lab/P5Lab.js
Outdated
* If there is an executionError, alert the user. In Sprite Lab there is | ||
* no user-facing console, so we instead create a WorkspaceAlert. | ||
*/ | ||
this.alertStudent(this.JSInterpreter.executionError?.message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming nit: this function makes an assumption about what it should do ("if i hit an execution error, alert the student"). there are a few problems with this assumption:
- the user won't always be a student
- changing how we react to execution errors would require changing the same of this function (what if, in the future, instead of alerting, we decide to log to the debug console?)
- this code shouldn't really care how the error is handled, but rather that consumers who do care can handle it however they want
@@ -89,6 +91,22 @@ export default class SpriteLab extends P5Lab { | |||
} | |||
} | |||
|
|||
alertStudent(msg) { | |||
if (msg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: always prefer returning early to reduce nesting (which improves readability) over wrapping all functionality in a conditional
if (!msg) {
return;
}
// now everything else can be at this indentation level
apps/src/p5lab/P5Lab.js
Outdated
|
||
/** | ||
* If there is an executionError, alert the user. In Sprite Lab there is | ||
* no user-facing console, so we instead create a WorkspaceAlert. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this context is useful, but it should probably live in SpriteLab.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - workspace alert looks great, ahead of ship let's notify the curriculum team of the change in their slack channel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 great work, mike -- diving into the JSInterpreter code was really complicated and you did a great job navigating it!
Context and summary: If a behavior or function is undefined in a student's Blockly code, calling it results in an execution error. There is no user-facing console in Sprite Lab so all feedback is hidden. Because execution errors cause Sprite Lab to crash, these issues are often misdiagnosed by users as "disappearing sprites". Ideally, we want to prevent student programs from getting into this kind of state. In the meantime, we can alert the user if they do get into this state.
This change utilizes
WorkspaceAlert
which we also use across various labs for other purposes, such as when warning the student about code changes while the program is running.Function Example:
![image](https://user-images.githubusercontent.com/43474485/155800166-4ff0f095-ff2a-4f6d-865a-e51210811705.png)
![image](https://user-images.githubusercontent.com/43474485/155800306-ab89a22c-88dc-412d-a1fd-41ac2a33e9fd.png)
![2022-02-25 15-46-50 2022-02-25 15_48_11](https://user-images.githubusercontent.com/43474485/155800683-5f913810-8af6-4e41-8bbc-2c8262688f84.gif)
Behavior Example:
Animation to show non-immediate error:
Links
Testing story
This change would not be used in Game Lab, because there is a Debug Console already available:
![image](https://user-images.githubusercontent.com/43474485/155801296-cc5018b6-2916-4a7e-8788-cc2fce26044a.png)
This change would be easy to add to Poetry, but is likely not needed. Behaviors are only selectable by drop-down and cannot be edited or deleted. Functions are also not available to students.
![image](https://user-images.githubusercontent.com/43474485/155801578-778b9ece-fc27-42e4-b19f-67852e5126ce.png)
Deployment strategy
Follow-up work
STAR-121: [Sprite Lab] Prevent broken behaviors from causing a crash
PR Checklist: