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

Notebook code cell stream output schema #200

Closed davidbrochart closed 1 month ago

davidbrochart commented 7 months ago

Problem

Currently, a notebook code cell defines outputs as an untyped YArray where we store the output list as-is. Each item of the outputs can be of different type:

But for a stream output type, the structure looks like this (for e.g. an stdout stream):

{
  "output_type": "stream",
  "name": "stdout",
  "text": ["some", "content"]
}

Since the "text" list can be appended to as the cell is executing (by the kernel printing to stdout), the current situation is not great because we cannot observe changes to "text": the whole output in the YArray has to be set, with just that new item in the "text".

Proposed Solution

We should define an output of type stream as follows:

YMap[
  "output_type": "stream",
  "name": str,
  "text": YArray[str]
]