Bug 493665

Summary: kate losts session after restore plasma session
Product: [Applications] kate Reporter: Piotr Mierzwinski <piotr.mierzwinski>
Component: sessionsAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: accounts+kde, aspotashev, christoph, KDE, mpeter.68m0y, piotr.mierzwinski, schneider.cedric, waqar.17a
Priority: NOR Keywords: qt6, wayland-only
Version First Reported In: Git   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: kate lost session
missing recent files
kate-session-no_docs
multiply "Untilted"
kate - "Manage Sessions"
Kate - .config
Kate - .local/share/kate
Kate - .config/session
UserFeedback
kate lost session 20250224

Description Piotr Mierzwinski 2024-09-25 23:43:31 UTC
SUMMARY
One day I prepare my session ("mySession2), so open two files and one "untilted"(where I put something). Happens update of system. I do it (as installation after restart), power off. Next day I login to Plasma, Kate starts but without opened files. To be clear there is only couple empty "untilted". BTW. Option in menu "File -> Open recent" is disabled (because empty list). This is really annoying, because every day or max evey 2 days I need to open again the same files.

STEPS TO REPRODUCE
1.  Start Kate
2. Open two text files
3. Click "New" to have new untilted document
4. Put something into new document
5. Save as session "mySession2"
6. Make update
7. Make restart of PC

OBSERVED RESULT
No files opened which were saved in session

EXPECTED RESULT
Files saved in session should be opened

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 6.1.90
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
Neon unstable edition
Comment 1 Piotr Mierzwinski 2024-09-26 22:01:39 UTC
Created attachment 174123 [details]
kate lost session
Comment 2 Piotr Mierzwinski 2024-09-26 22:02:12 UTC
Created attachment 174124 [details]
missing recent files
Comment 3 Piotr Mierzwinski 2024-10-02 20:40:24 UTC
I thought it has fixed already, because through few days (I think 3 Kate was restoring the session). Unfortunately today (fourth day) I found no  documents opened. In documents view I found only one empty "untilted" and recent option is disabled (because the list is empty).
Therefore I consider that restore session in Kate doesn't work well, for sure it is not reliable.
Comment 4 Waqar Ahmed 2024-10-03 12:49:19 UTC
Need an easier way to reproduce this.

When this happens next, can you check what's in your ~/.local/share/kate/stash/SESSION_NAME_HERE directory.
Comment 5 Piotr Mierzwinski 2024-10-04 10:19:47 UTC
Today, after login to Plasma I met no restored session (and no recent) in Kate (is present only empty "untilted").

$ pwd
piotr@Dell:/home/piotr/.local/share/kate/stash/mySession2.katesession

piotr@Dell:~/.local/share/kate/stash/mySession2.katesession$ ls -l
total 28
-rw-rw-r-- 1 piotr piotr  20 wrz 19 02:32 'Document 0'
-rw-rw-r-- 1 piotr piotr 152 wrz 19 02:32 'Document 0~'
-rw-rw-r-- 1 piotr piotr  18 paź  4 02:06 'Document 2'
-rw-rw-r-- 1 piotr piotr  95 paź  3 00:35 'Document 2~'
-rw-rw-r-- 1 piotr piotr  13 wrz 19 02:33 'Document 3'
-rw-rw-r-- 1 piotr piotr 364 wrz 19 02:32 'Document 3~'
-rw-rw-r-- 1 piotr piotr 122 sie 31 03:41 'Document 4'

BTW. Documents in stash don't look like those I had opened recently. It looks like some old state of session.

To be clear.
At October, 2-nd (so when sent last post) I met no restored session in Kate, despite in title bar was name of my session, so I opened again documents I usually work with. Today again the same situation - no restored session in Kate.
Only on activity I've done was updating one document (and save)  - it was normal file (not untilted).
Comment 6 Waqar Ahmed 2024-10-04 11:26:29 UTC
How do you quit Kate? Do you quit it even?
Comment 7 Piotr Mierzwinski 2024-10-05 21:26:47 UTC
(In reply to Waqar Ahmed from comment #6)
> How do you quit Kate? Do you quit it even?

No, I don't quit Kate manually.
Comment 8 Piotr Mierzwinski 2024-10-05 21:29:05 UTC
> How do you quit Kate? Do you quit it even?

No, I don't quit Kate manually.
Plasma close all running application. I use restore session of Plasma, so why I would need to quit Kate manually.
Comment 9 Waqar Ahmed 2024-10-06 13:01:45 UTC
> why I would need to quit Kate manually

because it might not quit correctly and then you risk loosing your session data, like the stashed untitled documents that you keep loosing
Comment 10 Piotr Mierzwinski 2024-10-07 20:47:26 UTC
(In reply to Waqar Ahmed from comment #9)
> > why I would need to quit Kate manually
> 
> because it might not quit correctly and then you risk loosing your session
> data, like the stashed untitled documents that you keep loosing

Anyway this is bug, IMHO. Not sure if in Kate or in "restore session", but bug.
I don't remember if this works well in X11 and this is only issue in Wayland session, or also in X11 works not well. Tell me please if you know.

And please, I don't want to remember everyday to close Kate to don't lose the session, if I have (in Plasma) option "restore session" turned on.
IMHO manual quit is like going to back to the past, whereas Plasma/KDE is adverted like modern environment :/.

BTW. I'm waiting till real restore session will be implemented in Plasma, because current is, let say, clumsy.
Comment 11 Waqar Ahmed 2024-10-08 05:56:07 UTC
> Anyway this is bug, IMHO

Kind of, yeah. IIRC we don't save untitled documents (lets call them "stash docs") periodically. So this needs to be done. Our session is saved every 5 seconds whenever a document changes, so we just need to save "stash docs" as well.

This doesn't have anything to do with x/wayland etc.
Comment 12 Piotr Mierzwinski 2024-10-08 20:35:17 UTC
(In reply to Waqar Ahmed from comment #11)
> > Anyway this is bug, IMHO
> 
> Kind of, yeah. 
For me without a doubt this is a bug. Kate losts session randomly if user don't quit it (Kate) manually.
In my session I have 2 regular files and one "untilted". The files from my subdirectory "mySession2.katesession" doesn't reflect files what usually I have open. I open my 3 files in mentioned session, it (session) lives couple days and disappears.
BTW. Today Kate again lost session. Please consider that such thing doesn't happen in Notepad++ (working on Windows), or I didn't meet it yet and I use it in my job since dozen of a years.

> IIRC we don't save untitled documents (lets call them "stash docs") periodically. 
> So this needs to be done. Our session is saved every 5
> seconds whenever a document changes, so we just need to save "stash docs" as
> well.
Yes, I agree. I have this option turned on (save every 5 sec.), but seems to session as is seems to be incorrectly saved/or not saved if Kate is stopped/killed by Plasma.
 
> This doesn't have anything to do with x/wayland etc.
I've heard/read somewhere some times ago (maybe some kde blog) that the issue coming from plasma, which kill Kate in moment of shutdown/restart. And is hard to support this and then save session.
Comment 13 Waqar Ahmed 2024-10-08 20:57:12 UTC
> I've heard/read somewhere some times ago (maybe some kde blog) that the issue coming from plasma, which kill Kate in moment of shutdown/restart. And is hard to support this and then save session.

That might be true.

I will try to improve the stability in the coming days, it would be great if you can rigorously test this. We need to make this feature stable and reliable enough for daily use. Otherwise the option is totally useless.
Comment 14 Christoph Cullmann 2024-10-12 16:56:59 UTC
The full stashing feature is not that well tested.
In a perfect world me would just always create a dummy file for untitled stuff. Them we even would have swap files for crash recovery.
Comment 15 Bug Janitor Service 2024-10-15 14:18:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1620
Comment 16 Christoph Cullmann 2024-10-17 10:09:26 UTC
Git commit 519037af35316007d8aba5424d720abc08390f93 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 17/10/2024 at 10:05.
Pushed by cullmann into branch 'master'.

include stash docs when auto saving

M  +0    -1    apps/lib/kateapp.cpp
M  +0    -2    apps/lib/katemainwindow.cpp
M  +5    -0    apps/lib/session/katesessionmanager.cpp

https://invent.kde.org/utilities/kate/-/commit/519037af35316007d8aba5424d720abc08390f93
Comment 17 Piotr Mierzwinski 2024-10-23 22:56:13 UTC
Sorry, but this still doesn't work.
I had created a session. Today I found two "Untilted" (second one I could even not close by close button, so I closed first one).
I opened  two regular files, and two "Untilted" where I put some text. I made update, restarted PC, logged in to Plasma and found Kate with one empty "Untilted", so seems to be worse than earlier.

I'm not sure if the fix made at 2024-10-17 was applied in my system before today test.  I don't know how to check this. I just update system every day.

piotr@Dell:~$ cd /home/piotr/.local/share/kate/stash/mySession2.katesession
piotr@Dell:~/.local/share/kate/stash/mySession2.katesession$ ll
total 28
-rw-rw-r-- 1 piotr piotr  20 wrz 19 02:32 'Document 0'
-rw-rw-r-- 1 piotr piotr 152 wrz 19 02:32 'Document 0~'
-rw-rw-r-- 1 piotr piotr  84 paź 24 00:37 'Document 2'
-rw-rw-r-- 1 piotr piotr 187 paź 24 00:37 'Document 2~'
-rw-rw-r-- 1 piotr piotr  59 paź 24 00:37 'Document 3'
-rw-rw-r-- 1 piotr piotr  13 paź 24 00:37 'Document 3~'
-rw-rw-r-- 1 piotr piotr 122 sie 31 03:41 'Document 4'

Please consider that "Document 2" and "Document 3" are the my both "Untilted" (I checked content), what I left before restart of PC. And unfortunately they were not restored. As I said I met Kate with one empty "Untilted".
Comment 18 Waqar Ahmed 2024-10-24 03:21:14 UTC
Did you check whether kate had opened the needed session, maybe it was some other session? We save the session every ~5 seconds WHENEVER a new doc is created or closed so I can't see why its failing.

Why this happens now is beyond me atm, can't see why it would fail.
Comment 19 Waqar Ahmed 2024-10-24 03:31:38 UTC
> Please consider that "Document 2" and "Document 3" are the my both "Untilted" (I checked content),

If the content is there then can we say that there was no content loss?
Comment 20 Piotr Mierzwinski 2024-10-24 21:01:34 UTC
(In reply to Waqar Ahmed from comment #18)
> Did you check whether kate had opened the needed session, maybe it was some
> other session? We save the session every ~5 seconds WHENEVER a new doc is
> created or closed so I can't see why its failing.

I can see session name in title bar, so I'm sure that Kate opened correct one. I will attach screenshot.
Yesterday I did the same what at the day before yesterday, and result was the same - I met "mySession2" as empty.

piotr@Dell:~$ cd /home/piotr/.local/share/kate/stash/mySession2.katesession
piotr@Dell:~/.local/share/kate/stash/mySession2.katesession$ ll
total 28
-rw-rw-r-- 1 piotr piotr  20 wrz 19 02:32 'Document 0'
-rw-rw-r-- 1 piotr piotr 152 wrz 19 02:32 'Document 0~'
-rw-rw-r-- 1 piotr piotr 306 paź 24 01:56 'Document 2'
-rw-rw-r-- 1 piotr piotr  84 paź 24 01:56 'Document 2~'
-rw-rw-r-- 1 piotr piotr  59 paź 24 00:37 'Document 3'
-rw-rw-r-- 1 piotr piotr  13 paź 24 00:37 'Document 3~'
-rw-rw-r-- 1 piotr piotr 122 sie 31 03:41 'Document 4'

And again 'Document 2' and 'Document 3' have correct content, only have not been reopened.
BTW.
Maybe session should be also saved at the moment when Kate is closed manually and when is killed, otherwise something could be lost.

> Why this happens now is beyond me atm, can't see why it would fail.
Maybe you could add some more debug messages (triggered on some env.variable), or even you could send binary and I could run it and send you such report.
Comment 21 Piotr Mierzwinski 2024-10-24 21:02:02 UTC
Created attachment 175197 [details]
kate-session-no_docs
Comment 22 Piotr Mierzwinski 2024-10-24 21:03:05 UTC
(In reply to Waqar Ahmed from comment #19)
> > Please consider that "Document 2" and "Document 3" are the my both "Untilted" (I checked content),
> 
> If the content is there then can we say that there was no content loss?

Yes, only documents were not opened in the restored session.
Comment 23 Piotr Mierzwinski 2024-10-27 00:14:49 UTC
Created attachment 175261 [details]
multiply "Untilted"

Couple days ago I reported lost session in Kate. Next day "Documents" view was empty, or actually one was present only one "Untilted", today I have several "Untilted" ("Untitled (2)", "Untitled (3)"...) - check attached screenshot "multiply "Untilted", so seems appearing several "Untilted", after restart of Kate is still not fixed. This is another case for Bug 468573, where user quit Kate manually and here Plasma kill Kate and restore it.
Please notice I start my PC every day, today (Saturday) I started twice.
Comment 24 Piotr Mierzwinski 2024-10-27 00:31:46 UTC
Created attachment 175262 [details]
kate - "Manage Sessions"

BTW. In "Manage Sessions" I cannot remove "mySession2". Button "Delete" is from some reason not available (is "grayed"). Before I opened "Manage Sessions" I closed all duplicated Untilted (left one).
Comment 25 Piotr Mierzwinski 2024-10-27 00:37:56 UTC
(In reply to Piotr Mierzwinski from comment #24)
> Created attachment 175262 [details]
> kate - "Manage Sessions"
> 
> BTW. In "Manage Sessions" I cannot remove "mySession2". Button "Delete" is
> from some reason not available (is "grayed"). Before I opened "Manage
> Sessions" I closed all duplicated Untilted (left one).

Ok. I understand. Because this is currently opened.
I removed that session, after I created and opened another one "mySession3". And here opened 3 documents: two regular files and one Untilted. I will see tomorrow (Sunday) if session will be restored.
Comment 26 Piotr Mierzwinski 2024-10-27 22:02:27 UTC
Today again Documents view is empty (is present only one new Untilted).
Seems creating new session and open here documents only confirmed that the problem with restore session persists.

I"m not sure why anybody cannot reproduce the issue. Maybe I didn't clicked proper options in settings?
Comment 27 Waqar Ahmed 2024-10-30 07:55:41 UTC
I dont think many people are trying and I am not an active user of sessions or plasma restore. I rarely shutdown my pc.

Can you reproduce the issue if you kill kate and start again?

it must be sigkill, Kate handles other signals and tries to shutdown gracefully.
Comment 28 Piotr Mierzwinski 2024-10-31 23:17:36 UTC
(In reply to Waqar Ahmed from comment #27)
> I dont think many people are trying and I am not an active user of sessions
> or plasma restore. I rarely shutdown my pc.
so instead do you put your computer to sleep?

> Can you reproduce the issue if you kill kate and start again?
> it must be sigkill, Kate handles other signals and tries to shutdown
> gracefully.

I killed kate by SIGKILL, and run it using Kicker. In result session was restored only I lost content of "Untilted" (appeared empty).
I did it twice with the same result. Also tried with default signal, so TERM and worked well. 
I don't know how plasmashell closes its children, maybe this is some specific way what is not supported by kate?
Comment 29 Piotr Mierzwinski 2024-11-03 01:07:05 UTC
Today (Saturday) surprise, so all have been restored correctly (including 2 "Untilted"). We will see tomorrow.
Comment 30 Piotr Mierzwinski 2024-11-06 16:08:14 UTC
(In reply to Piotr Mierzwinski from comment #29)
> Today (Saturday) surprise, so all have been restored correctly (including 2
> "Untilted"). We will see tomorrow.

Also it worked well at Sunday and Monday.
Unfortunately today I met empty Documents list (except one empty "Untilted") :(
The only difference was that I did nothing in Kate since last days.
I'm not sure if solution implemented in Kate is reliable.
Comment 31 Waqar Ahmed 2024-11-18 08:40:38 UTC
There are bugs still, yes.

It would help more if the bug report contains exact steps to reproduce the issue quickly. That way it is likely that it will get fixed soon. With a generic report "i have a problem that happens", things will take a while because someone needs to put in the effort and find how exactly the bug happens before fixing it. There are probably cases still left where session is not saved properly.
Comment 32 Piotr Mierzwinski 2024-11-29 23:45:34 UTC
(In reply to Waqar Ahmed from comment #31)
> There are bugs still, yes.
> 
> It would help more if the bug report contains exact steps to reproduce the
> issue quickly. That way it is likely that it will get fixed soon. With a
> generic report "i have a problem that happens", things will take a while
> because someone needs to put in the effort and find how exactly the bug
> happens before fixing it. 

Sorry, but my report for sure is not like "i have a problem that happens". I described the steps to reproduce. I even updated them with screenshots, I provided information what you requested, so I completely don't understand this why you say like this. I'm confused.
Tell me please how much detailed steps do you need?  Do you need to I report every day what I do with Kate?

My fist step, long time ago, was starting Kate and open here couple files, and one "Untilted" document and not save it. Through these time I only modified opened files, and sometimes put or remove some new text to "Untilted" document. I saved this as session. After some time I even created new session with newly opened documents, but issue still happens.
Recently even I didn't open "Untilted" to exclude this case, unfortunately issue happened again. From my perspective it happens randomly, I told about this.
I didn't close Kate manually, it was closed by Plasma and also restored.
I configured Kate and didn't change its setup very often, rather very rare.

If this will help I can add that I update Neon by automatically way, and daily. My settings:
System Settings -> Software Update
- Update software: Automatically
- Update frequency: Daily
- Apply System Updates: After rebooting
More often I just Shut down than do Restart, but not sure if this is the issue.

I attach all configuration files related with Kate, I found.

> There are probably cases still left where session is not saved properly.
For sure, I experience it quite often - every couple days.
Comment 33 Piotr Mierzwinski 2024-11-29 23:49:28 UTC
Created attachment 176226 [details]
Kate - .config
Comment 34 Piotr Mierzwinski 2024-11-29 23:50:13 UTC
Created attachment 176227 [details]
Kate - .local/share/kate
Comment 35 Piotr Mierzwinski 2024-11-29 23:52:36 UTC
Created attachment 176228 [details]
Kate - .config/session
Comment 36 Piotr Mierzwinski 2024-11-29 23:53:14 UTC
Created attachment 176229 [details]
UserFeedback
Comment 37 Piotr Mierzwinski 2025-02-20 22:21:03 UTC
Since 2 weeks I don't experience issue.
Comment 38 Waqar Ahmed 2025-02-21 09:07:19 UTC
I fixed another Session related issue, so it might have fixed this as well. 

In any case, thanks for diligently testing. People rarely do that :)
Comment 39 Piotr Mierzwinski 2025-02-24 22:01:25 UTC
Seems I praised too early, because again stopped work correctly. This time "Untilted is not saved". I put some text into newly opened "Untilted" document. Shutdown PC. And another day document "Untilted" is empty.
All happened after recent update of Neon.
Comment 40 Piotr Mierzwinski 2025-02-24 22:22:43 UTC
It is worse than I thought. :(
After I wrote previous comment I put some text to empty "Untilted" document, and after couple o minutes I called "Restart" from Kicker. Please notice that originally I had opened two regular files and "Untilted" document was third.
When Plasma session started (I have autologin applied) restoring my all application I noticed that Kate session is empty, or actually I found there two documents: "Untilted" and "Untilted (2)" - both empty. 
I noticed notification about updates, so do I applied them (installation after restart).
I closed both "Untilted" documents and opened again my previously regular files and one Untilted, where put some text. So now there is turn  restart of Plasma.
Comment 41 Piotr Mierzwinski 2025-02-24 22:23:27 UTC
Created attachment 178844 [details]
kate lost session 20250224
Comment 42 Piotr Mierzwinski 2025-02-25 22:08:00 UTC
After Plasma with applications was restored, turned out that unfortunately document "Untilted" was empty, despite I put some text before I did Restart my PC. 
Seems content has not been loaded at all, but was saved - in my case in file "Document 3" (located in  "~/.local/share/kate/stash/mySession3.katesession").
BTW. When it was working I saw in Document list, for example name: "Document 0" instead of "Untilted" like now.

~/.local/share/kate/stash/mySession3.katesession$ ls -l
total 36
-rw-rw-r-- 1 piotr piotr    44 lut 25 20:48 'Document 0'
-rw-rw-r-- 1 piotr piotr    44 lut 25 20:48 'Document 0~'
-rw-rw-r-- 1 piotr piotr   391 paź 30 12:44 'Document 1'
-rw-rw-r-- 1 piotr piotr    23 lut 24 23:24 'Document 2'
-rw-rw-r-- 1 piotr piotr    20 lut 24 23:24 'Document 2~'
-rw-rw-r-- 1 piotr piotr    84 lut 25 20:48 'Document 3'
-rw-rw-r-- 1 piotr piotr 12004 lut 25 20:48 'Document 3~'

In file  ~/.local/share/kate/sessions/mySession3.katesession I have:
[Document 0]
URL=

[Document 1]
Bookmarks=143
URL=file:///home/piotr/Documents/filmy_info/obejrzane.txt

[Document 2]
Bookmarks=226,109
URL=file:///home/piotr/Documents/filmy_info/filmy_do_sciagniecia_1_20220627.txt

[Document 3]
URL=


Please consider I applied all updates for Plasma till now.
Comment 43 Piotr Mierzwinski 2025-04-14 18:32:16 UTC
Unfortunately session has not been restored after couple days.
BTW. At Saturday were opened few files (including one "untilted") - I opened them few days ago, and today session has not been restored.
Comment 44 Waqar Ahmed 2025-04-21 04:58:28 UTC
*** Bug 503083 has been marked as a duplicate of this bug. ***
Comment 45 mpeter.68m0y 2025-04-24 12:58:39 UTC
Did some tests with the currently newest version on Flathub, and with my current old version that is up to date from my distro package manager (for comparison to see how things changed).

Kate 25.04.0, flatpak

"Settings > Open/Save > Advanced > Swap file mode" is set to "Enabled, Store in Default Directory"
"Settings > Session > Application Startup/Shutdown Behavior > Automatically save and restore: Newly-created unsaved files" is ticked


testing quit normally

1. open saved session or save the current one in sessions toolbar
2. open 3 new files
3. type something into them
4. close kate with quit button, or by sending a SIGTERM to it (makes no difference)
5. reopen kate and load session

result:
- ~/.var/app/org.kde.kate/.local/share directory does not exist (and so neither a kate session directory in it) while quit
- ~/.var/app/org.kde.kate/.local/state contains a katestaterc file
- after session reopen 3 tabs are opened but all of them are empty


testing quit with SIGKILL (similar to system crash)

1. open saved session or save the current one in sessions toolbar
2. open 3 new files
3. type something into them
4. close kate with SIGKILL
5. reopen kate and load session

result:
- ~/.var/app/org.kde.kate/.local/share directory does not exist (and so neither a kate session directory in it) while quit
- ~/.var/app/org.kde.kate/.local/state contains a katestaterc file
- after session reopen 3 tabs are opened, all empty
- 3 utitled files in the Documents panel on the left, without content (all activates the existing tabs)


---


Kate 23.08.5, distro package

"Settings > Open/Save > Advanced > Swap file mode" is set to "Enabled, Store in Default Directory"
"Settings > Session > Application Startup/Shutdown Behavior > Automatically save and restore: Newly-created unsaved files" is ticked


testing quit normally

1. open saved session or save the current one in sessions toolbar
2. open 3 new files
3. type something into them
4. close kate with quit button
5. reopen kate and load session

result:
- ~/.local/share/kate/stash/sessionname/ exists while Kate is quit, with files for the unsaved files including their content
- after sesssion reopen no tabs are opened
- the former unsaved files are accessible in the left Documents panel, on click they are opened with their last content


testing quit with SIGKILL (similar to system crash)

1. open saved session or save the current one in sessions toolbar
2. open 3 new files
3. type something into them
4. close kate with SIGKILL
5. reopen kate and load session

result:
- no tabs are opened
- 3 utitled files in the Documents panel on the left, without content
- ~/.local/share/kate/stash/sessionname/ exists while Kate is quit, but no files in there


---


Summary:
- 23.08.5 kept its state up to date, and remembered that there were untitled files. 25.04.0 does that too, but it now opens these files on tabs instead of keeping them in the Documents panel
- 23.08.5 made a backup of the unsaved files when quitting normally (quit button, SIGTERM), 25.04.0 does not do that anymore
- both versions lose the content on SIGKILL
Comment 46 princess 2025-07-17 06:12:59 UTC
(In reply to mpeter.68m0y from comment #45)
> Did some tests with the currently newest version on Flathub, and with my
> current old version that is up to date from my distro package manager (for
> comparison to see how things changed).
> 
> Kate 25.04.0, flatpak
> 
> "Settings > Open/Save > Advanced > Swap file mode" is set to "Enabled, Store
> in Default Directory"
> "Settings > Session > Application Startup/Shutdown Behavior > Automatically
> save and restore: Newly-created unsaved files" is ticked
> 
> 
> testing quit normally
> 
> 1. open saved session or save the current one in sessions toolbar
> 2. open 3 new files
> 3. type something into them
> 4. close kate with quit button, or by sending a SIGTERM to it (makes no
> difference)
> 5. reopen kate and load session
> 
> result:
> - ~/.var/app/org.kde.kate/.local/share directory does not exist (and so
> neither a kate session directory in it) while quit
> - ~/.var/app/org.kde.kate/.local/state contains a katestaterc file
> - after session reopen 3 tabs are opened but all of them are empty
> 
> 
> testing quit with SIGKILL (similar to system crash)
> 
> 1. open saved session or save the current one in sessions toolbar
> 2. open 3 new files
> 3. type something into them
> 4. close kate with SIGKILL
> 5. reopen kate and load session
> 
> result:
> - ~/.var/app/org.kde.kate/.local/share directory does not exist (and so
> neither a kate session directory in it) while quit
> - ~/.var/app/org.kde.kate/.local/state contains a katestaterc file
> - after session reopen 3 tabs are opened, all empty
> - 3 utitled files in the Documents panel on the left, without content (all
> activates the existing tabs)
> 
> 
> ---
> 
> 
> Kate 23.08.5, distro package
> 
> "Settings > Open/Save > Advanced > Swap file mode" is set to "Enabled, Store
> in Default Directory"
> "Settings > Session > Application Startup/Shutdown Behavior > Automatically
> save and restore: Newly-created unsaved files" is ticked
> 
> 
> testing quit normally
> 
> 1. open saved session or save the current one in sessions toolbar
> 2. open 3 new files
> 3. type something into them
> 4. close kate with quit button
> 5. reopen kate and load session
> 
> result:
> - ~/.local/share/kate/stash/sessionname/ exists while Kate is quit, with
> files for the unsaved files including their content
> - after sesssion reopen no tabs are opened
> - the former unsaved files are accessible in the left Documents panel, on
> click they are opened with their last content
> 
> 
> testing quit with SIGKILL (similar to system crash)
> 
> 1. open saved session or save the current one in sessions toolbar
> 2. open 3 new files
> 3. type something into them
> 4. close kate with SIGKILL
> 5. reopen kate and load session
> 
> result:
> - no tabs are opened
> - 3 utitled files in the Documents panel on the left, without content
> - ~/.local/share/kate/stash/sessionname/ exists while Kate is quit, but no
> files in there
> 
> 
> ---
> 
> 
> Summary:
> - 23.08.5 kept its state up to date, and remembered that there were untitled
> files. 25.04.0 does that too, but it now opens these files on tabs instead
> of keeping them in the Documents panel
> - 23.08.5 made a backup of the unsaved files when quitting normally (quit
> button, SIGTERM), 25.04.0 does not do that anymore
> - both versions lose the content on SIGKILL

Hello, thank you for your detailed investigation. Downgrading to 23.08.5 appears to be the
Comment 47 Waqar Ahmed 2025-07-18 18:01:21 UTC
We have fixed a couple more bugs related to stashing and sessions in the next release. We also added some tests to prevent regressions w.r.t sessions and stashing. Hopefully things will be a bit better or at least not get worse.

I will try to find out why plasma session restore is having problems.

I thank you all for your patience and testing.
Comment 48 Waqar Ahmed 2025-08-20 08:44:33 UTC
Is this reproducible with latest release / latest master?
Comment 49 princess 2025-08-20 14:22:53 UTC
On 25.08, unsaved text buffers correctly restore with my previously-affected configuration (Open/Save -> Enable Auto Save activated, Session -> Automatically restore Newly-created unsaved files + Files with unsaved changes both checked).

Thank you very much for fixing this issue <3 Hope others can confirm the fix as well.
Comment 50 Waqar Ahmed 2025-08-20 18:53:47 UTC
Thanks I will mark this as fixed then. If there are issues still, we can look at those.
Comment 51 mpeter.68m0y 2025-08-20 21:55:18 UTC
(In reply to Waqar Ahmed from comment #48)
> Is this reproducible with latest release / latest master?

sorry for not responding earlier.

with Kate 25.08.0 from Flathub, unsaved files are persisted when quitting normally, and on reopening the session they are reopened and their contents are the same as when the user quit.

when the kate process gets a SIGKILL, or the computer crashes, on reopening the session the state (open unsaved files and their contents) restored is the latest of
a) the state saved when Kate was normally quit last time
b) the state saved when the user saves the session with "toolbar > Sessions > Save Session"
but changes to these files are otherwise not persisted to the stash.

newly created untitled files are saved to the stash soon after the user stops typing into them (in ~3 seconds), but after that these files are not resaved when they get edited either, so with a SIGKILL or a computer crash the changes would get lost.
I think if the user's settings in the "Open/Save" category, "Advanced" tab, "Swap file mode" is "Enabled, *", then the untitled files should also be resaved to the stash when changed after some time (the amount of time could be linked to the "Swap files every" setting below the other setting).
Comment 52 mpeter.68m0y 2025-08-20 21:59:48 UTC
one more observation: closing untitled files with "Close > Discard" does not delete the discarded file from the stash, even on closing Kate and reopening it. creating a new file, writing something into it and quitting results in the formerly discarded file with the same temporary number (like Document 0) getting overwritten with the new contents.