atg / chocolat-public

Public bug tracker for the private chocolat project
http://chocolatapp.com
180 stars 4 forks source link

“Save on Window Defocus” should save all files #1727

Open jbrennan opened 9 years ago

jbrennan commented 9 years ago

The preference “Save on Window Defocus” works, but only for the currently open file. If you edit other files and defocus the window, only the current active file is saved. I really expect it to save everything.

pketh commented 9 years ago

+1 to this

atg commented 9 years ago

lol, when I made save all there were complaints that it saved all files. And that was explicit!

I would quite like to implement an autosave feature. But not Apple's autosave because that's a privacy nightmare.

pketh commented 9 years ago

@fileability Maybe the complaints didn't account for a world before Git/Reviewing your commits? :)

Practically for me, the save on window defocus is a nice balance of predictability when you have processes that watch and rebuild on file changes and you don't want them continuously/unpredictably working.

atg commented 9 years ago

I think there is some merit in having a mode where chocolat automatically saves files at certain intervals. I'd use that, probably.

atg commented 9 years ago

Reminds me that also undo serialisation would be really nice.

jbrennan commented 9 years ago

Yeah I run into the situation where I make some changes in a few files, hop over to the browser and reload the page, then spend a few cycles trying to figure out why only some of my changes have shown up, then remembering to go back and cmd+s all the files I just edited. It’s a bummer.

pketh commented 9 years ago

Yeah especially when you're really working a bunch of tabs, this comes up a lot.

atg commented 9 years ago

I have been thinking about this whole issue. Treatise incoming.

The main utility is to be able to open and close Chocolat without having to bother with save dialogs. Also it means we can reduce Chocolat's memory footprint by closing files that have been opened but are not being actively used.

Really I don't have a problem with OS X's "Versions" feature, except for every detail of its implementation. Like how an entire history goes into the quasi secret .DocumentRevisions-V100 database, unencrypted and with apparently no regard for privacy whatsoever. If I accidentally paste a password into a text document, I don't want it hanging around in plaintext for evermore!

I do like how Chocolat is a traditional open/save kind of an app. It's predictable: if you haven't saved, it's in memory. If you have saved, it's on disk. All programmers implicitly understand this mode of operation.

However, it would be nice if there was a basic (non-magical) autosave feature that encompassed both untitled and unsaved files.

Ground rules:

  1. Autosave should work approximately the same way with untitled (not on disk) and edited (on disk) files.
  2. For untitled documents, they should be saved into some document store at regular intervals.
  3. For edited documents, they should be saved to disk automatically, and the previous version on disk should be saved into the document store, until the user explicitly saves, then the backup should be deleted.

Note that if you switch the functionality of edited documents around, you get a different but equally valid model: documents on disk aren't committed to disk unless the user does so explicitly (cmd-S). However the latest user version is kept in the document store just in case chocolat crashes. I'm going to avoid this model because it's not radical enough to warrant the development effort.

As for the implementation, we can follow OS X Versions roughly:

  1. The data should be stored in ~/Library/Caches
  2. An sqlite database would store metadata (document id, timestamp, file path, blob id)
  3. File blobs should be stored on disk (encrypted)

Only one revision of each document would be stored, minimising to risk to security & privacy, and simplifying the UI. Also, autosave should be disabled for documents larger than a certain size (e.g. 8MB?).


For the UI, I am determined to avoid the "open chocolat and get dozens of untitled files you had open last time" syndrome. When I open Chocolat I want a clean slate. So autosaved untitled files should be easily accessible but not mass-opened by default on next launch. I propose an "open untitled" UI.

For unsaved edited files it's easier. We just need a way to revert to the revision in the document store. A button in the titlebar would do it.

borisyurkevich commented 9 years ago

It would be great to have Apple's Autosave feature. Use Desk app as an example of perfect text editor. I don't know why owner thinks about it as a privacy concern.