livebook icon indicating copy to clipboard operation
livebook copied to clipboard

Allow users to comment on cells

Open josevalim opened this issue 3 years ago • 15 comments

Those comments will become a thread. The thread will be persisted to markdown with the user info who wrote them.

josevalim avatar May 07 '21 14:05 josevalim

Hi @josevalim, I would like to work on this if its not picked up by anyone

sreecodeslayer avatar May 20 '21 17:05 sreecodeslayer

Hi @sreecodeslayer, thanks for reaching out. I think we need to do a bit more work specifying the future before anyone can work on it, sorry. :( I should save some time to organize the issues tracker so we are a bit more welcome. In case you want to look at something immediate, #281 and #277 should be actionable issues. :)

josevalim avatar May 20 '21 17:05 josevalim

I think we need to do a bit more work specifying the future before anyone can work on it, sorry. :(

Ah, makes sense, no worries 🙂 I was just playing around with this a bit, thought i'd reach out to see if you had more details

In case you want to look at something immediate, #281 and #277 should be actionable issues

sure, will check them 👌🏼

sreecodeslayer avatar May 20 '21 17:05 sreecodeslayer

Any news on this? Livebook is already a first-class option for documentation and knowledge sharing, even introducing simple comments similar to google docs would be terrific; and dare I say we could do much better than google docs' comments.

LeartS avatar Feb 23 '22 17:02 LeartS

Hey @LeartS :) We are yet to discuss details of this, but there are a couple other features we prioritize for now.

jonatanklosko avatar Feb 25 '22 23:02 jonatanklosko

Hi @josevalim @jonatanklosko, I can start working on or drafting specs for this feature if you want

basilenouvellet avatar Mar 21 '22 15:03 basilenouvellet

Hi @BasileNouvellet, that would be welcome. Note we do have a mockup of how it would look like:

Screenshot 2022-03-21 at 18 55 27

We are also aware of some of the complexities in the implementation. In particular, we will need to tackle which selection of a text the comment applies to. If I remove a text inside or around the selection, we should still keep the comment, but remove the comment altogether if the text is removed. This is definitely doable. Google Docs does it. Any collaborative text editor with bold/italics/etc support has to solve a similar issue and I think the Delta libraries for Elixir solve it too. I don't know how many conveniences the Monaco editor provide around it though.

Then once the above is solved, we need to choose a form to serialize comments in the .livemd files. Then we can freshen up the UI. :)

josevalim avatar Mar 21 '22 18:03 josevalim

Comments on selection are complicated, because for Markdown we show the rendered content most of the time. Also, recently we started to introduce new types of cells (smart cells), so we should support comments on those as well. Deepnote and Observable support comments per-cell, so we should be fine doing the same:

image

image

jonatanklosko avatar Mar 21 '22 18:03 jonatanklosko

Per cell is too low granularity for me in markdown cells. I wonder if we can keep it per paragraph or split a Markdown cell once comments are added?

josevalim avatar Mar 21 '22 18:03 josevalim

FTR one option is to handle comments on cell-level, but allow each comment to have an optional editor selection (so the selection is more of an additional info, and removing the selected text doesn't remove the comment). One thing to keep in mind is that smart cells may have two editors, so we would need to support it for the primary one, or persist editor names.

jonatanklosko avatar Mar 21 '22 20:03 jonatanklosko

After discussing offline, we agreed that comments should apply to the whole cell, forming a "Discussion".

We may also add support for ephemeral, source-related comments, but this is a separate feature. Those comments would go as # TODO in the source, we would parse them and show in the sidebar. This way they can be easily searched in version control, PRs, etc.

jonatanklosko avatar Mar 21 '22 21:03 jonatanklosko

Could you point out the areas in the code to contribute to for this feature? Something like a little roadmap, but in term of code files & function names. Thanks!

basilenouvellet avatar Mar 23 '22 17:03 basilenouvellet

Sure, here are the high-level parts

  • add comments to the notebook data structure, specifically each cell type (Notebook.Cell.*) will need a list of comments
  • add operations for adding/removing/editing comments in Session.Data (and matching functions in Session)
  • add UI for showing the comments and applying the above operations (mostly around SessionLive and CellComponent)
  • extend export/import to persist the comments in Live Markdown (this is pretty separate and can be left to the end)

jonatanklosko avatar Mar 24 '22 15:03 jonatanklosko

Hey guys,

I've made some progress on the feature. Here is a little demo: https://youtu.be/xZQT_LvH0i4

Left to do:

  1. Delete & edit comments
  2. Fix issue with autofocus not working on the comment text input
  3. Persist comments in .livemd / .exs files

Let me know what you think. I'll open a (draft) PR shortly.

basilenouvellet avatar Apr 04 '22 21:04 basilenouvellet

@BasileNouvellet awesome! Feel free to open a PR and we can iterate from there :)

jonatanklosko avatar Apr 05 '22 12:04 jonatanklosko

Livebook is moving to an architecture where developers run notebooks on their machine. So while we will definitely want comments in the future, comments are not helpful unless we have a central architecture where comments and collaboration happen on the fly. So we are postponing the focus on comments for now. :)

josevalim avatar Aug 23 '22 06:08 josevalim