Merge branch 'feat/session-restore'

Restore the tabs, layouts and working directories of the last session with
kitty --session=last, from state saved on exit.
This commit is contained in:
BlackAngelTV committed 2026-11-12 07:29:04 +01:00
commit d373fe5df8
9 files changed
+388 -1

No files matched your search

+19
View File
@@ -2530,6 +2530,7 @@ class Boss:
if not self._call_on_quit_watchers({'confirmed': True}):
set_application_quit_request(NO_CLOSE_REQUESTED)
return
self.save_last_session()
self.save_session_if_logging_out()
set_application_quit_request(IMPERATIVE_CLOSE_REQUESTED)
return
@@ -2559,9 +2560,20 @@ class Boss:
if not self._call_on_quit_watchers({'confirmed': True}):
set_application_quit_request(NO_CLOSE_REQUESTED)
return
self.save_last_session()
self.save_session_if_logging_out()
set_application_quit_request(IMPERATIVE_CLOSE_REQUESTED if confirmed else NO_CLOSE_REQUESTED)
def save_last_session(self) -> None:
# Must run before the quit request is set: the C side then closes the windows and there is
# nothing left to serialize. Saving an empty session is a no-op, so this never clobbers a
# good state with a torn down one.
from .main import is_panel_kitten
from .session_restore import save_session_of
if not is_panel_kitten():
save_session_of(self)
def save_session_if_logging_out(self) -> None:
from .logout_session import is_logout_in_progress
@@ -3991,6 +4003,13 @@ class Boss:
def goto_session(self, *cmdline: str) -> None:
goto_session(self, cmdline)
@ac('session', 'Restore the tabs and windows of the session saved when kitty last quit. See :ref:`sessions`.')
def restore_last_session(self) -> None:
from .session_restore import restore_last_session_into
if not restore_last_session_into(self):
self.ring_bell_if_allowed()
@ac('session', 'Save the current kitty state as a session file. See :ref:`save_as_session`.')
def save_as_session(self, *cmdline: str) -> None:
save_as_session(self, cmdline)