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

Session recovery (recovery 4/3) #3323

Merged
merged 9 commits into from
Jun 1, 2024
Merged

Session recovery (recovery 4/3) #3323

merged 9 commits into from
Jun 1, 2024

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented May 26, 2024

This is an attempt to perfect a way to recover work after Gaphor has crashed, or terminated. The idea is that a user doesn't loose his 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.

PR Type

What kind of change does this PR introduce?

  • Bug fix
  • Feature
  • Chore (refactoring, formatting, local variables, other cleanup)
  • Documentation content changes

What is the current behavior?

In #3284, models are recovered by file name. This does not work if:

  1. A model is opened multiple times: now, changes are just not tracked in the subsequently opened models
  2. A model is opened by multiple processes: Only one event log will be saved.
  3. No event log is generated for newly created model: a model needs a file name before Gaphor can create an event log

What is the new behavior?

This PR is an attempt to improve session recording and recovery.

Sessions in the "sessions" folder are automatically restored on startup, also newly created (unsaved) models.

Each session will get a unique id. We can continue a session by providing it the id of a previously interrupted session.

This ensures that event logs are unique, since they're based of a session, instead of a model name. Also, we can record changes made to new models.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • TODO: test if recovery and sanitizer service interfere
  • TODO: test a lot with undo/redo
  • TODO: deal with faulty headers (e.g. not a dict)
  • TODO: Is a ModelSaved event emitted and handled when a user saves the model on quit?

@github-actions github-actions bot added the python Pull requests that update Python code label May 26, 2024
@amolenaar amolenaar changed the title Session recovery (recovery 4/3) Draft: Session recovery (recovery 4/3) May 26, 2024
@amolenaar amolenaar marked this pull request as draft May 27, 2024 08:04
@amolenaar amolenaar changed the title Draft: Session recovery (recovery 4/3) Session recovery (recovery 4/3) May 29, 2024
@amolenaar amolenaar changed the base branch from main to model-recovery May 29, 2024 22:36
@amolenaar amolenaar requested a review from danyeaw May 29, 2024 22:37
@amolenaar amolenaar marked this pull request as ready for review May 29, 2024 22:37
@danyeaw danyeaw added feature A new feature and removed python Pull requests that update Python code labels May 31, 2024
@danyeaw
Copy link
Member

danyeaw commented May 31, 2024

One interesting thing about this is that it also paves the way (if we want) to have the behavior like Elementary OS wants for closing an app here: https://docs.elementary.io/hig/user-workflow/closing. If you close and then reopen the app, you go right back to where you left off.

@amolenaar
Copy link
Member Author

One interesting thing about this is that it also paves the way (if we want) to have the behavior like Elementary OS wants for closing an app here: https://docs.elementary.io/hig/user-workflow/closing. If you close and then reopen the app, you go right back to where you left off.

In that case we should always save the model when it's closed. No more dialog 😄 .

@github-actions github-actions bot added the python Pull requests that update Python code label May 31, 2024
The session id can be used to identify the session,
as well as recover changes from unsaved sessions.
Instead of the translated model xml. Now we can add it to the recovery
log.
E.i. the ones that have no special context assigned.
Base automatically changed from model-recovery to main June 1, 2024 01:10
@danyeaw danyeaw removed the python Pull requests that update Python code label Jun 1, 2024
Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing @amolenaar, really nice job. This brings so much better reliability to Gaphor with users not having to worry about losing work.

@danyeaw danyeaw merged commit ca12404 into main Jun 1, 2024
4 checks passed
@danyeaw danyeaw deleted the session-recovery branch June 1, 2024 01:49
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

Successfully merging this pull request may close these issues.

None yet

2 participants