nlpsuge / gnome-shell-extension-another-window-session-manager

A Gnome shell extension to close open windows gracefully and save them as a session. The previous session can be restored at startup. Most importantly, it supports both X11 and Wayland!
https://extensions.gnome.org/extension/4709/another-window-session-manager/
GNU General Public License v3.0
140 stars 8 forks source link

Duplicate windows / multiple instances of one app support #102

Open blauweb opened 7 months ago

blauweb commented 7 months ago

Hi, It looks like the extension does not support multiple instances of one window/app. Only one of the stored apps opens, despite the fact, that the json file does store the multiple instances.

The problem is with the recovery: By analyzing the logs, it looks like the windows are being restored by their titles - if a window with a specific title is open, then another one wont open. When the session is being stored, the windows, depending on their content have different titles. But on restoration (reopening the windows), the title resets to their default (because certain apps launch with a default state), which causes the extensions to ignore the following instances, because they all have the same "title". By the session json file, it does not seem like the windows have a unique ID assigned, which would imply, that they are being stored/restored based on their title, and this causes the issue I have described.

Related apps in the issue:

  1. Terminal
  2. Firefox

Please let me know, if I get it right, and if yes, would it be possible to include multiple instances of apps in the extension?

Environment: Ubuntu 22.04 Gnome 42.9 Windowing System: X11

carafelix commented 2 months ago

Hi, I'm facing the same issue, any news? I could work the feature, any relevant entry points to look at? @nlpsuge

blauweb commented 2 months ago

Not from my end. I am still using the extension, and have just found "peace" with the lack of this feature. I lack the knowledge and time, to work on it.

krodelabestiole commented 2 months ago

Related apps in the issue:

1. Terminal

2. Firefox

I guess Nautilus also meets this issue ? Unless I'm miss the point ? Also it won't recall the open directories... (whereas VSCodium does retrieve its previous state, but I guess it comes from its inner session management...)

carafelix commented 2 months ago

I guess Nautilus also meets this issue ?

It happens to every app which you would like to open twice. My cheeky solution was to just open two different terminals (gnome-terminal, wrap) and do the same with browsers (firefox-like, chromium).

brownbat commented 1 week ago

Can confirm it hits multiple applications, including calculator, terminal, firefox, and others.

The problem seems to be that all windows from the same app are assigned the same ID with the following code: https://github.com/nlpsuge/gnome-shell-extension-another-window-session-manager/blob/101b26f382d8d0809fd6f2894919600f5c13f7c1/saveSession.js#L239

and

https://github.com/nlpsuge/gnome-shell-extension-another-window-session-manager/blob/101b26f382d8d0809fd6f2894919600f5c13f7c1/restoreSession.js#L189

This leads to:

https://github.com/nlpsuge/gnome-shell-extension-another-window-session-manager/blob/101b26f382d8d0809fd6f2894919600f5c13f7c1/restoreSession.js#L192

Where the restoration process skips over additional windows of the same app because they are all identified by the same shell_app key.

One potential solution could be to modify the shell_app key to include both the window position and the desktop file ID, ensuring that each window is uniquely identified and correctly restored.