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

Prompt to confirm shutdown or restart when workspace is dirty #649

Open
Tracked by #1425
jmcphers opened this issue May 30, 2023 · 4 comments
Open
Tracked by #1425

Prompt to confirm shutdown or restart when workspace is dirty #649

jmcphers opened this issue May 30, 2023 · 4 comments
Assignees
Labels
area: core Issues related to Core category.

Comments

@jmcphers
Copy link
Collaborator

Shutting down a language runtime is a destructive operation; you lose anything in your environment you haven't saved, as well as any UI that can't survive without a backend (resizable plots, data viewers, etc). However, this operation has no confirmation and also can't be undone, so it's too easy to lose data as things stand today.

There are a few ways we could address this.

  • Always prompt for confirmation before shutting down.
  • Require language runtimes to supply a method that can be used to determine whether the workspace contains unsaved changes. When the user requests shutdown, call this method; without unsaved changes, proceed to shut down; with them, prompt to shut down.
  • As above, but require the language runtime to supply richer data and/or a message to present to the user instead of a boolean dirty/not dirty flag.
  • Add a onShutdownRequested method to language runtimes that gives them a hook to handle shutdown requests before an actual shutdown happens.
  • Do nothing at the Positron level; let language runtimes themselves decide what to do with a shutdown request. The shutdown() method is async, so they can prompt the user if they want to and remain in full control over the experience (so long as they only use the extension API)
@jmcphers
Copy link
Collaborator Author

An argument for letting language runtimes drive the shutdown is that they might also want to offer to save state before shutdown, but that's a pretty language-dependent workflow which doesn't feel like something we want to try to plumb all the way through the top-level language runtime API.

@DavisVaughan
Copy link
Contributor

I see that "or restart" is mentioned in the title. I don't think I would want CMD+SHIFT+0 to prompt me for some kind of additional confirmation about doing a restart. I wholly accept that I am going to lose objects in the global env when I do that (in fact it is often one of the reasons I do a restart in the first place), and I want that to be a fast operation.

@jmcphers
Copy link
Collaborator Author

Yeah, that's a good point! I think the prompt should have a "don't show again" option for advanced users that understand they'll lose data.

@jmcphers
Copy link
Collaborator Author

In terms of plumbing, we could probably use the UI comm as a way to have Positron do things like ask the user to confirm quit, and return the user's answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to Core category.
Projects
None yet
Development

No branches or pull requests

5 participants