| Summary: | Improve autosave/stashing for unsaved documents to prevent data loss | ||
|---|---|---|---|
| Product: | [Applications] kate | Reporter: | Jaypers <jp> |
| Component: | sessions | Assignee: | KWrite Developers <kwrite-bugs-null> |
| Status: | REPORTED --- | ||
| Severity: | normal | CC: | christoph, waqar.17a |
| Priority: | NOR | ||
| Version First Reported In: | 25.08.0 | ||
| Target Milestone: | --- | ||
| Platform: | Ubuntu | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
I forgot to mention the initial step of saving a session with the name Default. Without this none of the session settings will apply. As a side note, in settings it's not obvious that a session first needs to be saved/created for it's features to become available. Perhaps a note in settings or popup at first startup could help with this. Note: I was confusing backup files for swap files in my original post. The behaviour for stash files still applies. Just auto saving every N seconds might be a cheaper and simpler solution. Tracking document edits might be More complex and costly The question is if we not could use the swap files for that. That would be the ideal solution. The current solution is very flaky |
SUMMARY Currently, stashed and swap files for unsaved documents in Kate are only updated under specific conditions: - When a new document tab is opened - When a document tab is closed - When the session is manually saved This behaviour leads to potential data loss if Kate or the system crashes, because unsaved files do not have continuously updated swap/stash data like normal saved files do. STEPS TO REPRODUCE 1. In Settings -> Open/Save -> Advanced: Enable "Swap file mode" and set the "Save swap files every:" to 5s 2. In Settings -> Session: Under "Automatically save and restore:" make sure "Newly-created unsaved files" checkbox is set. 3. In a terminal: watch 'cat ~/.local/share/kate/stash/Default.katesession/Document*' 4. Create a new file and start typing. 5. Observe in terminal that "Document 1" has been created. 6. Make further updates and observe no change to stash or swap. 7. Open new tab and start typing. 8. Observe Document 1, Document 1 swap and Document 2 updated. 9. Make changes to Document 1 and observe no change. 10. Close Document 2 and observe Document 1 is updated. 11. Make change to Document 1 and save the session (Sessions -> Save session) 12. Observe Document 1 is updated. EXPECTED RESULT One or more of the following could mitigate the issue: - Periodic session saving: Implement a configurable autosave timer that periodically saves the session state, including stashed documents. - CLI argument: Add a flag such as "kate --save-session" to allow external tools (cron/systemd/timers) to trigger session saving. - Improve stash/swap handling: Make unsaved stashed documents behave like normally saved files, i.e. continuously updated in the background, so that crashes do not cause data loss. SOFTWARE/OS VERSIONS Linux/KDE Plasma: Kubuntu 24.04.3 KDE Plasma Version: 5.27.12 KDE Frameworks Version: 5.115.0 Qt Version: 5.15.13 Kate Version: 25.08.0 (Snap install) ADDITIONAL INFORMATION Stashing of unsaved documents was fixed by: https://invent.kde.org/utilities/kate/-/merge_requests/1578 and is related to these bugs (amongst others): https://bugs.kde.org/show_bug.cgi?id=274102 (REOPENED) https://bugs.kde.org/show_bug.cgi?id=353654 (RESOLVED) https://bugs.kde.org/show_bug.cgi?id=375594 (RESOLVED) https://bugs.kde.org/show_bug.cgi?id=475210 (RESOLVED) https://bugs.kde.org/show_bug.cgi?id=504691 (RESOLVED)