AutoSave would be useful if

[These thoughts were spurred from @saqimtiaz autosave experiments ]

For the sake of this thread, I’m here defining three terms but kindly enlighten me if there is established, or simply better, terminology:

  • enable autosave ~ to click the checkbox in
    Controlpanel > Saving > General > "save changes automatically"
  • trigger autosave ~ to “start preparing” for autosaving
  • execute autosave ~ autosaving actually starts to save the wiki

Default behaviour in TW is that triggering and executing autosave happens without a delay inbetween.

Request:

Autosave would be much more useful if:

  1. it triggers from making any change in the wiki
  2. …and if there then was a delay between triggering and executing the saving, i.e some timer countdown to avoid non-stop saving.

Regarding (1.) - currently Autosave is only triggered from clicking the tiddler editview Done button. But the system does know when “any change” is made as evidenced from the save-wiki button turning red.

The necessity to click Done means that very basic uses cases such as clicking a button to set some value, or editing transcluded content do not trigger autosave.

Could the behaviour of Autosave be enhanced to feature this?

(Note: @saqimtiaz 's experimental implementation does not address this aspect but accepts the requirement to click Done and allows you to only then control the duration before the save is executed.)

Note that you can trigger autosave from your own code: https://tiddlywiki.com/#WidgetMessage%3A%20tm-auto-save-wiki

Thanks but how would one send that message when “any change” is made?

One option would be background actions, planned for v5.4.0 and a part of this PR:

  • Background actions that are triggered whenever there is a change to the results of a specified filter

I think the main problem that Saq wants to tackle in the other thread is, that triggering autosave rapidly, can cause problems if you save to a server.

Eg: Triggering autosave for a big wiki 3 times in 1 second, will cause problems, since the first save is not finished, when the second save is already triggered. Most likely you will get a server error, with an unknown save state.

I think [IDEA] Autosave frequency throttle · Issue #6979 · TiddlyWiki/TiddlyWiki5 · GitHub is similar to this FYI.

Edit: I posted this before I had read through the other thread. Now I see that there are already references that link back to this issue, so my comment isn’t super useful. Apologies!

That is how nodejs wiki works, don’t you use nodejs tiddlywiki?

After you use it, you only need to worry about “auto backup”. When to backup whole wiki will still needs consideration.

No I use single files and the majority are on Tiddlyhost where the OP would be very useful.

Back when I had single-file wikis I had modified the saver-handler.js so that every change to the tiddler store would trigger a configurable timer that would initiate a save and delete any timer that might have already been running.

The wiki would therefore only save when I had not been working on it for some fixed time, but never as long as I was actively working on it. Depending on your workflow and the length of your “sessions” you might also want to trigger a save after some maximum interval, but I found the wait time during save to be always very distracting (around 10 seconds in my case IIRC).

The code was mostly this:

if(self.numChanges > 0) {
	if (self.saveTimer) clearTimeout(self.saveTimer);
	self.saveTimer = setTimeout( function() {
		self.saveWiki({
			method: "save",
			downloadType: "text/plain"
		});
	}, SaveDelay);
}
4 Likes