Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

Detect if notebook has been edited outside of Pluto and offer to backup and restart notebook

Open BioTurboNick opened this issue 2 months ago • 4 comments

Due to the way Pluto works, with a notebook process operating in the background and a browser tab just being a view into a notebook, it's possible for users to miss whether a notebook is truly closed. If a user thinks they have closed the notebook, edits the file in an external editor, and then attempts to go back to Pluto, Pluto may silently overwrite the changes when auto-reload is disabled, as it is by default. This can be a frustrating experience for a user.

It would be nice if, at a minimum, Pluto would notice that a notebook has been edited externally (e.g. modified date later than the last time Pluto saved it). Pluto could ask the user if they would like to restart the notebook, possibly also backing up Pluto's copy (similar to the backup done when packages are updated).

Other options are possible, but I think the most important part is detecting an external change has occurred, and avoiding overwriting those changes.

BioTurboNick avatar Oct 18 '25 15:10 BioTurboNick

Thanks for the issue!

I agree that this is a good feature, but this requires file watching, just like the auto_reload_from_file feature.

The problem here is that Julia has no good file watching library.

  • The standard library https://docs.julialang.org/en/v1/stdlib/FileWatching/ (currently used by auto_reload_from_file) does not work well enough if the file changes frequently.
  • We made our own library https://github.com/JuliaPluto/BetterFileWatching.jl which works well, but it has a heavy dependency. (The README also explains limmitations of the julia filewatching stdlib.)
  • Paul started on another implementation https://github.com/JuliaPluto/BetterFileWatching.jl/pull/2 but this was too much work to complete.

fonsp avatar Oct 20 '25 10:10 fonsp

Does it require file watching? Can it just be a manual check before Pluto saves the next time?

BioTurboNick avatar Oct 20 '25 13:10 BioTurboNick

Ah you mean based on mtime? That could work... But ideally you get the notification when the file is edited from the outside, instead of waiting until the moment that you try to save something else (and there is already a conflict).

fonsp avatar Oct 21 '25 12:10 fonsp

Oh absolutely. I was conceiving of this as something that could be done in the interim, until the more complex issue can be resolved.

BioTurboNick avatar Oct 21 '25 13:10 BioTurboNick