You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a mechanism for macOS apps to restore themselves to their original Spaces #10124
This feature request is related to #5362 but is specific to macOS. It is motivated by microsoft/vscode#979.
Expected behavior
When an Electron app is restarted on macOS, all the windows should restore to the Space (i.e. virtual desktop) they were originally in.
Actual behavior
Currently, there doesn't appear to be a way to do this, and restarted Electron apps like Visual Studio Code restore all their windows to the default Space. The user then has to manually replace all the windows in their correct Space. This happens every time the app or OS is restarted.
macOS seems to offer a concept known as a restoration class by which applications can preserve interface data like what Space they belong to. This may be what Electron needs to wrap in order to provide the functionality described here.
As pointed out in the linked threads, Apple does not provide a mechanism for apps to restore to previous Spaces during app restart.
However, Apple does provide this capability across system restart. Adding support for this would allow apps that were active when the computer began it's reboot process to restore to their previous configuration (including Space assignment) when the computer completes the process. All native Apple apps work this way. The fix is outlined in the Chromium bug thread:
[I]f they’re trying to do their own state restoration and not going through NSWindow, the space isn’t going to be restored.
These apps need to use NSWindow’s encodeRestorableStateWithCoder: and restoreStateWithCoder:.
I should add that this is only related to #5362 in that it refers to "workspaces/virtual desktops". However, it appears that Apple does not provide public APIs for programmatic Space assignment.
This issue is specifically related to being a "good macOS citizen" and properly restoring windows to their previous Spaces after a system reboot.
Hi, while we appreciate this enhancement request it's not something that our team will be able to implement in the foreseeable future, and since we use our issues tab as the team's backlog, we prefer to only retain issues that are on our immediate roadmap. If you'd like to make a PR for this request we would welcome that but in the meantime I'm going to go ahead and close this.
@codebytere The relevant upstream(?) issue (in Chromium) was recently closed as fixed. Is it possible that the Chromium support will affect Electron support for the feature?
Reacted by Nicholas Chammas, Daniel Bayley, tomtwo, Miguel Lo-A-Foe, Brandon Zylstra and Tyler Mandry
@xgdgsc I'm not 100% sure but it seems to work for me on multiple monitors, at least some of the time. I did notice that it never works if the Mac was not properly shut down, but always if it was restarting / shut down properly.
@bpasero I created Issue #37494 to track this feature request. It's both still open and contains a lot more information/context (it links both this issue and microsoft/vscode#146915 in the summary, for instance). That might be the better issue to reference...
Activity
ericdrobinson commentedon Jul 26, 2017
As pointed out in the linked threads, Apple does not provide a mechanism for apps to restore to previous Spaces during app restart.
However, Apple does provide this capability across system restart. Adding support for this would allow apps that were active when the computer began it's reboot process to restore to their previous configuration (including Space assignment) when the computer completes the process. All native Apple apps work this way. The fix is outlined in the Chromium bug thread:
ericdrobinson commentedon Jul 28, 2017
I should add that this is only related to #5362 in that it refers to "workspaces/virtual desktops". However, it appears that Apple does not provide public APIs for programmatic Space assignment.
This issue is specifically related to being a "good macOS citizen" and properly restoring windows to their previous Spaces after a system reboot.
codebytere commentedon Jan 30, 2018
Hi, while we appreciate this enhancement request it's not something that our team will be able to implement in the foreseeable future, and since we use our issues tab as the team's backlog, we prefer to only retain issues that are on our immediate roadmap. If you'd like to make a PR for this request we would welcome that but in the meantime I'm going to go ahead and close this.
ericdrobinson commentedon Jan 30, 2018
🤔
@codebytere Am I missing something? If you do use the issues tab as the team's backlog, then shouldn't this remain?
It is correctly labeled as a macOS enhancement. I understand not prioritizing it - perhaps add a Backlog label?
gandalfsaxe commentedon Nov 28, 2018
Please prioritize this 👍 It's madness to have to rearrange all the VSCode windows upon system restart.
ericdrobinson commentedon Oct 11, 2019
@codebytere The relevant upstream(?) issue (in Chromium) was recently closed as
fixed. Is it possible that the Chromium support will affect Electron support for the feature?xgdgsc commentedon Jun 18, 2020
https://bugs.chromium.org/p/chromium/issues/detail?id=1065557 From my experience, it still not working for multi-monitor.
gandalfsaxe commentedon Jun 18, 2020
@xgdgsc I'm not 100% sure but it seems to work for me on multiple monitors, at least some of the time. I did notice that it never works if the Mac was not properly shut down, but always if it was restarting / shut down properly.
ericdrobinson commentedon Jun 18, 2020
@xgdgsc The bug you linked is for Windows. This Issue is specifically for macOS.
@gandalfsaxe Are you seeing that on macOS with Chrome or Electron-based apps?
Regardless, you might do well to post about your experience on this Chromium bug report to help the cause.
gandalfsaxe commentedon Jun 20, 2020
@ericdrobinson I meant Chrome, not electron apps.
But though the fix for Chrome once worked for me (at least most of the time), it doesn't work anymore.
Thanks, left a comment in the issue thread.
brandonzylstra commentedon Nov 5, 2021
This is a request for a bug fix, not for an "enhancement".
xxalilov commentedon Nov 5, 2021
bpasero commentedon Oct 11, 2023
@codebytere can this be reopened to better support VS Code scenarios around restoring all state that the user has setup?
Related to #5362
ericdrobinson commentedon Oct 11, 2023
@bpasero I created Issue #37494 to track this feature request. It's both still open and contains a lot more information/context (it links both this issue and microsoft/vscode#146915 in the summary, for instance). That might be the better issue to reference...