Skip to content

Rerun control widgets incrementally instead of restarting the runtime - #229

Merged
pearmini merged 1 commit into
mainfrom
fix/incremental-control-rerun
Sep 6, 2026
Merged

pearmini merged 1 commit into
mainfrom
fix/incremental-control-rerun

Conversation

@pearmini

@pearmini pearmini commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Radio, toggle, and number now call incremental run() after editing the source literal, instead of destroying the runtime.
  • Unrelated cells keep running (recho.interval on the default notebook no longer resets when you click the number).
  • Dependent cells still dispose via Observable invalidation (sorting Run mid-animation, setInterval + echo.dispose on a cell that reads the control).

Test plan

  • Open a new notebook (car + recho.number): click the number; the tilde line updates and the car does not jump back to the start.
  • Open a notebook with recho.radio/toggle plus an independent interval: the interval keeps going.
  • Cell that depends on the control and uses setInterval + echo.dispose: old timer stops (no stacked intervals).
  • /examples/sorting: click Run mid-animation; still 4 live intervals, not 8.
  • Toolbar Rerun still does a full stop + fresh run.

Made with Cursor

A full restart reset unrelated generators such as recho.interval when clicking number, radio, or toggle.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
recho-notebook Ready Ready Preview Sep 6, 2026 7:33pm UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread editor/controls/number.js
Comment thread editor/controls/radio.js
Comment thread editor/controls/toggle.js
Comment thread editor/index.js
@pearmini
pearmini merged commit 32a1372 into main Sep 6, 2026
4 checks passed
@pearmini
pearmini deleted the fix/incremental-control-rerun branch September 6, 2026 19:38

This branch was successfully deployed

1 active deployment
Preview — b237447b Deployed Sep 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants