From 2b93f8c72b0a0f49785ed3be0abe00cf69ad9b5c Mon Sep 17 00:00:00 2001 From: BlackAngelTV Date: Wed, 11 Nov 2026 21:31:41 +0100 Subject: [PATCH] fix(session): save the last session before the windows are torn down The save ran from the cleanup path, after the quit request had already made the C side close every OS window, so the serialized session was always empty. Save from the quit paths instead, where the windows still exist, and keep the cleanup path as a no-op fallback. --- kitty/boss.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kitty/boss.py b/kitty/boss.py index 7702622..9e0fa72 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -2528,6 +2528,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 @@ -2557,9 +2558,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