Kate does not save session on reboot/shutdown

Hi all,
I am a software engineer who likes to use Kate to keep notes and code snippets for work.
But noticed weird behaviour that makes Kate open blank tab instead of previously opened tabs with text contents in it.

If the Kate window was closed manually (click on close icon in the window at the top) before reboot/shutdown - everything is saved and restored correctly after next system launch. But if I do just system reboot/shutdown without this step nothing is saved. Looks like Kate does not flush cache or close I/O streams. For the same reason Chrome is always asking if I’d like to restore previously opened tabs like the process was just killed and not properly terminated upon reboot/shutdown. Can this be fixed somehow without altering and recomplining source code?

Googled all possible Kate settings, nothing helped.
Tried to add logout script that executes “wmctrl -c kate” command to shutdown application properly. But shutdown and script execution are done at almost the same time and the script does not have enough time to execute properly…

Maybe somebody already found a solution to such case by chance or knows how to do it?
The solution can be to change something in Kate, or to configure Manjaro to terminate apps correctly
System settings are:

██████████████████ ████████ zaub3rschlosss@wint3rmag1c
██████████████████ ████████ --------------------------
██████████████████ ████████ OS: Manjaro Linux x86_64
██████████████████ ████████ Host: HP Pavilion Gaming Laptop 15-ec1xxx
████████ ████████ Kernel: 5.18.14-1-MANJARO
████████ ████████ ████████ Uptime: 5 mins
████████ ████████ ████████ Packages: 1366 (pacman), 5 (flatpak)
████████ ████████ ████████ Shell: bash 5.1.16
████████ ████████ ████████ Resolution: 1920x1080, 1920x1080
████████ ████████ ████████ DE: Plasma 5.24.6
████████ ████████ ████████ WM: KWin
████████ ████████ ████████ WM Theme: Breeze
████████ ████████ ████████ Theme: [Plasma], Breeze [GTK2/3]
████████ ████████ ████████ Icons: Relax-Dark-Icons [Plasma], Relax-Dark-Icons [GTK2/3]
Terminal: konsole
Terminal Font: Hack 12
CPU: AMD Ryzen 5 4600H with Radeon Graphics (12) @ 3.000GHz
GPU: AMD ATI 05:00.0 Renoir
GPU: NVIDIA GeForce GTX 1050 3 GB Max-Q
Memory: 5574MiB / 15356MiB

You can save the session and give it a name, and then you can recall the session again at any point in time later on. Anonymous sessions are not saved because — as you yourself said already — the application doesn’t have the time to do so if you close Plasma without properly closing Kate.

That said, it is Good Practice™ to always properly exit your applications before logging out, rebooting or shutting down. If you don’t want that, then perhaps hibernating the computer would be a better option in your case than shutting down.

Have you tried this?

PS: you can delete the █ and use ` to display

code blocks

I have specifically created separate session and use it, not the default one.
Clicked “Save session”. Reboot → all tabs and tabs contents are gone after reboot.
Tried launching Kate with different params, including params to save and load session with a specific name.
Edited ~/.config/katerc file, nothing changes.

So it looks like I’d either have to close the application manually every time in order not to loose some important notes, create separate text files for separate tabs and save them before exit, or look for another text editor 💁🏼‍♂
Bad thing about approach to close apps manually each time, is that you may forget to do it sometimes and click reboot…

Still have an idea to investigate if it’s possible to modify some kind of reboot/shutdown hook or commands and add some script like “sleep 1 && wmctrl -c kate”, but that’s too complicated just to make text editor work the way I need

Tried
Nothing changed, unfortunately

@zauberschloss Do you get the Session Chooser window with the last opened timestamp when you start Kate?