jupyter-server / jupyter_ydoc

Jupyter document structures for collaborative editing using Yjs/pycrdt
https://jupyter-ydoc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
25 stars 16 forks source link

Support stdin output #233

Open davidbrochart opened 1 month ago

davidbrochart commented 1 month ago

A frontend observing cell output changes would see the addition of an output of type stdin, and consequently show an input box. In JupyterLab, we could use a CodeMirror text editor, which would have the advantage of having the awareness for free (and show user cursors). The stdin output has an id, which we use to create a WebSocket connector to the room in the backend with this id. Along with the text editor, there should be a "submit" button. Once submitted, the text editor is removed and the plain text shown instead.

krassowski commented 1 month ago

we could use a CodeMirror text editor

As long as we configure it to be 1-line editor this would not be a problem. input() does not accept multi-line. There is also a question of latency and performance. Though yes, it might be worth exploring.

davidbrochart commented 1 month ago

But input() is Python, while the kernel protocol for stdin is more general, and it can actually be an improvement to have multi-line support, what do you think?

davidbrochart commented 1 month ago

There is also a question of latency and performance.

Mmm but CRDTs are local-first, so there shouldn't be any latency for what the local user types, only for remote users, which mostly depends on the network.