terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Terminal not remember tabs after system restart

Open zimnyd opened this issue 3 years ago • 4 comments

What Happened

When you open terminal and some tabs, then when you close manually terminal, the tabs will be restored, but when you not close manually terminal but perform system restart, then the tabs will not be restored on next terminal start.

Expected Behavior

After system restart terminal tabs should be restored.

Steps to Reproduce

  1. Open terminal with some differents tabs
  2. Perform system restart without closing terminal
  3. After restart open terminal and non of tabs should be restored

Platform Information

elementary OS 6.0

zimnyd avatar Aug 22 '21 07:08 zimnyd

Thanks for the report. This longstanding issue is a consequence of the way the session is closed and has been raised elsewhere (https://github.com/elementary/wingpanel-indicator-session/issues/27). It is a general problem not specifically Terminal. Until a fix is developed, the only workround is to manually close all windows you want to restore before closing the session.

I'll leave this open, I think as it could be "fixed" by having Terminal continually save its state rather than do it on closing the window. There is some precedent for this in Code continually saving documents as they are edited.

jeremypw avatar Aug 22 '21 10:08 jeremypw

The issue linked dates back to 2017, however, in an elementary OS 5.1 installation that I have, the terminal tabs are remembered correctly. I have to turn off the computer issuing a shutdown command there so I never close terminal. Similarly Files tabs are remembered correctly. Note Hera (5.1) was released late 2019. Now in a 6.1 installation, I am facing these problems.

jgomer2001 avatar Jul 14 '22 21:07 jgomer2001

Please check that you have History enabled in the Settings Security & Privacy plug. If this is disabled then Terminal now honors that setting and does not restore previously used locations. Also check the result of gsettings get io.elementary.terminal.settings remember-tabs in a terminal.

jeremypw avatar Jul 15 '22 07:07 jeremypw

History was disabled. I enabled it and ensured the property value is true. Sadly tabs are not restored after a computer restart. So basically it's the same behavior as in the issue description

jgomer2001 avatar Jul 15 '22 13:07 jgomer2001

Workaround: when I open Terminal with the hotkey (Super+T, but I might have changed it), my tabs are correctly restored (almost, the order can be wrong). On OS7, I can't see Terminal in the data sources list in Security & Privacy / History.

volfpeter avatar Feb 28 '23 07:02 volfpeter

There are four conditions to be met for the app state to be remembered:

  1. The app is closed "normally" i.e. by clicking on the close button or pressing <Ctrl><Shift>Q or closing the last tab. The state is not remembered if the app closes by ending its process e.g. by logging out or directly

  2. The app setting io.elementary.terminal.settings.remember-tabs is true. This is the default and this setting is not exposed in the Terminal UI so this should be the case . Check with the command line gsettings get io.elementary.terminal.settings remember-tabs.

  3. The global setting org.gnome.desktop.privacy.remember-recent-files is true. This depends on the state of the switch in the Privacy & Security Settings plug. Check with gsettings get org.gnome.desktop.privacy remember-recent-files.

  4. The tab must have a valid shell location

Please advise if you are still experiencing the issue when all these conditions are met.

jeremypw avatar Feb 28 '23 11:02 jeremypw

If you check the setting io.elementary.terminal.saved-state.tabs after opening terminal and the expected tabs are not restored this would indicate whether the problem was in saving or in restoring the state.

jeremypw avatar Feb 28 '23 11:02 jeremypw

Thanks for the details. My settings are as described. The mentioned workaround seems to work for me persistently (both on OS 6 and 7, although I did not try to deliberately reproduce and debug the problem), so I thought I'd just share it.

volfpeter avatar Feb 28 '23 12:02 volfpeter

@volfpeter So you are getting different results depending on how you open Terminal? That's strange. All methods should be executing io.elementary.terminal. Have you made any changes to the default terminal?

It occurred to me there is one other situation where tabs are not restored. That is if there is already an instance of Terminal running. Tabs are only restored for the first window.

jeremypw avatar Feb 28 '23 12:02 jeremypw

Tabs are also not restored if Terminal is launched with the -x option.

jeremypw avatar Feb 28 '23 12:02 jeremypw

Yes, it definitely feels like that, but as I mentioned, I did not try to deliberately look into this. I default to Super+T, and occasionally start Terminal from the Dock just to see what happens :) No changes at all, I'm running stock OS7.

volfpeter avatar Feb 28 '23 12:02 volfpeter

I am inclined to close this as the original issue is not something Terminal can fix - it is a system level thing. Please open new issues relating to Terminal specific things if appropriate.

jeremypw avatar Oct 21 '23 16:10 jeremypw