Synchronization of collapsed heading state between multiple views (incl. RTC)

Hey all,

consider you work on a notebook with many collapsible headings. You use multiple views (or even multiple browser windows with RTC). Whenever you collapse/expand a heading in one of the views the collapse state in the NB model gets updated. But the other views don’t get synchronized (which is good, I think). So after a while you are in a state where neither of the views are in sync with the NB model. When you save the NB and reopen it, the heading collapse state is pretty messed up.

Unfortunately, I don’t see an obvious way to fix this. Here some options I could think of:

  1. Sync the collapse state between all views, even within RTC. Pro: Everything nicely in sync. Con: No way to have different collapse states in different views; probably annoying for collaborators in context of RTC

  2. The first opened view is master: Only this one is allowed to write to the model and affects what gets saved. The others expand/collapse without updating the model Pro: It is in principle clear which state is saved… Con: … but only to those users familiar with the internal logic; Annoying for RTC, as the later-starting-to-edit colleagues cannot save their state (might even get blocked)

  3. The widgets write to the model only on NB save. At this time lab knows which view is active and therewith the active view’s collapse state is saved. Pro: Reasonable collapse state becomes saved (the one the user sees as he hits ctrl-s). Everyone may save his state (RTC context). Con: Behavior still not obvious (but probably better than in 2).

I’d love to hear your thoughts on this.

Oh and btw: there is a bug when opening a second view with collapsed headings. The caret indicates the right collapse state but the section contents are always visible. I’ll take care of this one at some point :slight_smile: