-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model recovery from an event log (recovery 3/3) #3284
Conversation
9c53eb7
to
8e2e6c1
Compare
5a63582
to
5af83fd
Compare
This covers the simple ones. The challenge will be RevertibleEvents: hey come in many forms and each one is applied differently.
Only reconnect is needed, we do not need the disconnect.
This service automatically runs after a model is loaded and adds an extra transaction for replayed state.
So users get a hint that there are unsaved changes.
This avoids a range of issues that can happen if we apply changes to another model (-version) than what we worked with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amolenaar These changes look really great!
One thing I noticed is if I create a model, save it, edit it, and then force close Gaphor, when it comes back up it recovers the changes when I open the model which is great. However, I am not then able to save the model during that session from the menu or by hitting Ctrl+s. For example, I can hit Ctrl+s, the unsaved changes shows in the titlebar, and it will ask if I want to save when I go to close the model even though I just tried to save them.
I see that the "edited" dot remains after saving. Saving itself works with me. |
@danyeaw The modified indicator works again. I also changed how the modified indicator is set when changes are done, so it will always show modified after modification. Now, if you do edit, save, undo, it will show as modified. |
Windows doesn't like that.
Nice one @amolenaar! |
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Models are not automatically saved.
Issue Number: #2831
What is the new behavior?
In this PR, I want to pivot the idea of an event log. The event log contains all (model related) events. This log can be stored on disk and replayed. The goal is to provide a feature in Gaphor that prevents users from losing their work in case Gaphor crashes and the user has not saved his work in time.
The idea is that we log all transactions to a file. This file is based on the hash of the absolute filename of the model , similar to the per model user properties.
If such a log exists after a model is loaded, the log is applied and a notification is shown to the user.
The log will replay all user transactions, so the user should be able to continue his work and undo any step he's done previously. The model will show as modified.
When a model is saved, the event log (on disk) is truncated/reset.
If we have an event log for an unsaved model, we display that as first entry in the "Recent Models" list on the greeter window.
New models should get a unique event log file, so that you can have multiple new models open at any time.
The Greeter window should show any new, unsaved model (with a date?) so a user can re-open it and continue working.
Extra
get_config_dir()
andget_cache_dir()
togaphor.settings
To do
git pull
)? -> Add a checksum/hash at the beginning of the event log file.Future ideas
Does this PR introduce a breaking change?
Other information
An alternative is to actually save the model every so many minutes. However, saving can take a bit of time, especially for big models. With the event log approach we can restore the session to the point where Gaphor was shut down (or crashed).