positron icon indicating copy to clipboard operation
positron copied to clipboard

Fully interactive IPyWidgets

Open seeM opened this issue 1 year ago • 1 comments

This PR adds support for fully interactive IPyWidgets, addressing #3276.

For example, create and display a widget:

import ipywidgets
w = ipywidgets.IntSlider()
display(w)

Interact with the widget in the UI, then check its value in the console:

w.value

Set the value in the console:

w.value = 13

Note the updated UI.


We've already been using VSCode notebook renderers to render interactive plots in the Plots pane. This PR adds a notebook renderer for IPyWidgets, and routes messages between the renderer (widget frontend) and the runtime (widget backend) via the updated Positron IPyWidgets service.

Unit Tests

The new implementation of the IPyWidgets service is unit tested. This PR adds a few mocks to make that possible. Most useful are TestLanguageRuntimeSession and TestRuntimeClientInstance, although they're only implemented as far as needed for this PR.

I used the convention of starting Positron test suites with Positron - . There's also a new script to run only Positron's unit tests excluding VSCode's:

./scripts/test-positron.sh

Note that this script is not included in our CI since we already run ./scripts/test.sh which is a superset.

seeM avatar Jul 29 '24 17:07 seeM

🙌 This is awesome. It's a big one so I'm going to tackle the review tomorrow morning! Excited about having this in!

nstrayer avatar Jul 29 '24 20:07 nstrayer

Thank you for the reviews! I've addressed all of the comments, will merge once CI passes 🎉

seeM avatar Jul 30 '24 17:07 seeM