Skip to content
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

Add Automatic Save to a Temporary File #2831

Closed
alkis05 opened this issue Nov 12, 2023 · 6 comments
Closed

Add Automatic Save to a Temporary File #2831

alkis05 opened this issue Nov 12, 2023 · 6 comments
Labels
feature A new feature

Comments

@alkis05
Copy link

alkis05 commented Nov 12, 2023

Is your feature request related to a problem?

App crashed and lost a lot of work

Describe the solution you'd like

Of course I could save often, but it wouldn't heart to have a temporary file saved, say, after changing a diagram or something. This could be loaded in case the program closes for some reason before saving. At least offer the option for that. Like there is on text editors and many other tools.

Describe alternatives you've considered

Just remember to save often.

Additional context

Add any other context or screenshots about the feature request here.

@danyeaw danyeaw added the feature A new feature label Nov 19, 2023
@danyeaw danyeaw changed the title Lost a lot of work after a crash Add Automatic Save to a Temporary File Nov 19, 2023
@amolenaar
Copy link
Member

I've been thinking about this before.

It's a bit hard to do a full save operation: that will take a while for big projects.

Maybe it's an idea to build an event log and register all events that modify the model? We already do that for the undo functionality. If Gaphor crashes, we can replay the event log.

The only uncertainty is what happens if the event log cannot be fully replayed? Should it replay up to the point where it errors?

@amolenaar
Copy link
Member

I've been implementing a little service in Gaphor that records all (model) changes.

Doing this adds hardly any overhead and all changes (in case of a crash or abrupt termination of Gaphor) can be replayed (it's re-using undo functionality to some extents).

The idea is that a user doesn't loose any work in case of a failure.

I see three approaches at this point:

  1. On application startup, show to-be recovered sessions in the Greeter window and allow users to recover them, or delete them
  2. When a model is loaded, any unsaved changes are automatically applied.
  3. The application instantly opens with all user sessions, as if nothing happened.

For case 1 I created some screenshots.

image

NB. A delete button is missing on the "recover" rows.

I'm not sure if the difference between Recently Opened and Recover Models is clear. Maybe add them all to Recently Opened and add a note (with unsaved changes) ?

image

@danyeaw What do you think?

@danyeaw
Copy link
Member

danyeaw commented May 27, 2024

Hey @amolenaar, I really like your idea to integrate this with the current greeter! You also told me that you thought this might be getting too complex.

Since recovering from a crash should hopefully not be a frequent event, and because users should almost always want what they were working on back, what if we directly open the restored window?

@danyeaw
Copy link
Member

danyeaw commented Jun 1, 2024

@all-contributors please add @alkis05 for idea

Copy link
Contributor

@danyeaw

I've put up a pull request to add @alkis05! 🎉

@danyeaw
Copy link
Member

danyeaw commented Jun 1, 2024

Thanks @alkis05 for the enhancement request!

@amolenaar did a fantastic job implementing automatic recovery of unsaved changes, and it will be out in the next feature release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

3 participants