fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
5k stars 296 forks source link

@bind cells with PlutoUI/HTML elements do not sync between parallel sessions #385

Closed dhanak closed 3 years ago

dhanak commented 4 years ago

A few of my friends and I started using Pluto as a collaborative, parallel platform: we have a server running in a shared location, everyone opens the same notebook in their browsers, and we edit it together.

Cells are neatly synced between the browsers (as long as we don't edit the very same cell in parallel), except for HTML binding elements. I.e., I add a slider to adjust the value of a variable, and use it to interact with the notebook. The value itself is indeed synced between the sessions, and all dependent cells are also updated everywhere, but the slider itself remains still. Which is sad, because this way we need a separate cell just to display the actual value of the adjusted variable, to make sure everyone sees its value.

It would be great if the sliders (and other HTML) elements were bound in both directions: the change in the bound value would also update the HTML element.

shashankp commented 4 years ago

Neat experiment!

Wondering would this be a more appropriate place?

fonsp commented 4 years ago

(Fun fact: it's technically impossible! Kind of! If you look at rectangle demo in the Interactivity sample notebook, you see an example of how bound elements are not fully described by their value.)

But the basic built-in HTML5 inputs do support setting its .value attribute to set its visual state, and custom element authors can write setters and getters for the .value. So this can be done! All clients already get the signal - I was planning to implement this at some point.

Same with repeating the same bond multiple times on the same page:

bond = @bind x Slider(1:100)
md"""
You can slide me:
$bond
"""
md"""
or me:
$bond
"""

The only two tricky things are:

fonsp commented 4 years ago

Also @dhanak please tell me more about your collaboration experiment! @dralletje

fonsp commented 4 years ago

We are also working on floating heads next to the cell that each person is editing :)

fonsp commented 4 years ago

Here's a Pluto server that people can test it on together if they like: http://104.131.73.175:2468/

dhanak commented 4 years ago

Also @dhanak please tell me more about your collaboration experiment! @dralletje

We do a lot of number crunching, statistical analysis and such on large amounts of data, and often verify the results by creating plots and doing visual inspection. Given the COVID situation, we all work from home, thus watching the same monitor together is not an option. We have been sharing a screen with the usual tools, but communication is clumsy, and mob programming in this way can be slow. Pluto is a really promising tool to visualize, share and co-edit the same data experiment.

We do have issues with aborting calculations, though, sometimes, the whole notebook just hangs and needs to be restarted, which can really be PITA, since then it has to recalculate all the intermediate data. Also, it would be great if independent cell updates could run on separate threads. We often find that while a longer calculation is running in one cell, we would like to update, e.g., a markdown description, but all cell calculations are on hold until he currently running one finishes. Still, Pluto is a very promising tool, and I believe it has a great future ahead.

fonsp commented 4 years ago

@dralletje You fixed this right? Do you still have the code?

grero commented 3 years ago

Here's a Pluto server that people can test it on together if they like: http://104.131.73.175:2468/

Is this still running? I'd love to check it out, but it seems like the server is no longer responding?

fonsp commented 3 years ago

Nope, it's replaced by:

https://pluto-with-friends.glitch.me/

fonsp commented 3 years ago

@dralletje is playing hard to get but he wrote this: https://gist.github.com/dralletje/9ae74e22b535ee83382eb411178a913c

You can add these cells to your notebook to enable the experimental new collaboration UI

dhanak commented 3 years ago

Thanks! I tried this. If I get it correctly, I get two features out of this:

The drawback of the snippet is obviously that it "leaks" information to an external synchronization server, but other than that, it is a good start.

dralletje commented 3 years ago

@dhanak you actually tried it out! Very nice :) It also should show the others scroll position.

Indeed it now leaks to firebase, but soon we won't need that. Also there is no useful info going to firebase: just chatacter numbers, cell ids and scroll positions, so I hope it won't stop you from testing 😁

fonsp commented 3 years ago

Fixed in the next release! (and on master)