Rerun control widgets incrementally instead of restarting the runtime - #229
Merged
Merged
Conversation
A full restart reset unrelated generators such as recho.interval when clicking number, radio, or toggle. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Control widget handlers can throw when the runtime hasn’t been initialized (runtimeRef.current is null), breaking interaction flows unless a safe run helper is used.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR changes control widgets (radio/toggle/number) to trigger an incremental runtime.run() after editing the source literal, avoiding a full runtime destroy/restart so unrelated cells (e.g., independent intervals) keep running.
Changes:
- Updated control widgets to rerun incrementally after applying editor-source edits.
- Removed the editor-side “restart runtime on next tick” mechanism.
- Added a runtime test ensuring unrelated cells are not disposed when another cell’s source changes.
File summaries
| File | Description |
|---|---|
| test/runtime-dispose.spec.js | Adds coverage for incremental runs preserving unrelated cells (no dispose / no restart). |
| editor/index.js | Removes restart scheduling and changes the runtime reference shape used by controls. |
| editor/controls/toggle.js | Switches toggle edits from restart to incremental run. |
| editor/controls/radio.js | Switches radio edits from restart to incremental run. |
| editor/controls/number.js | Switches number edits from restart to incremental run. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch was successfully deployed
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.
Summary
run()after editing the source literal, instead of destroying the runtime.recho.intervalon the default notebook no longer resets when you click the number).setInterval+echo.disposeon a cell that reads the control).Test plan
recho.number): click the number; the tilde line updates and the car does not jump back to the start.recho.radio/toggleplus an independent interval: the interval keeps going.setInterval+echo.dispose: old timer stops (no stacked intervals)./examples/sorting: click Run mid-animation; still 4 live intervals, not 8.Made with Cursor