Bug 506687 - Chat appears to be deleted but reappears after restarting KAIChat
Summary: Chat appears to be deleted but reappears after restarting KAIChat
Status: RESOLVED FIXED
Alias: None
Product: KAIChat
Classification: Applications
Component: general (other bugs)
Version First Reported In: 0.3.3
Platform: Other Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Laurent Montel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-06 18:21 UTC by lucenz
Modified: 2025-07-23 11:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Terminal errors after deleting chat: message not removed. Chat "ccc" still visible. KAIChat 0.33, KDE Plasma 6.4.2. (404.25 KB, image/png)
2025-07-06 18:21 UTC, lucenz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lucenz 2025-07-06 18:21:30 UTC
Created attachment 183016 [details]
Terminal errors after deleting chat: message not removed. Chat "ccc" still visible. KAIChat 0.33, KDE Plasma 6.4.2.

SUMMARY
Chat appears to be deleted but reappears after restarting KAIChat

STEPS TO REPRODUCE
1. Open KAIChat
2. Right-click on a conversation in the list
3. Select "Delete"
4. Observe that the chat disappears from the UI
5. Restart the application

OBSERVED RESULT
The chat seems to be deleted at first, but it reappears after restarting the application.

EXPECTED RESULT
The selected chat should be permanently deleted and not come back after restart.

SOFTWARE/OS VERSIONS
Operating System: CachyOS (Arch-based)
KDE Plasma Version: 6.4.2
KDE Frameworks Version: 6.4.2
Qt Version: 6.9.1
KAIChat Version: 0.33 (built from source, master branch)

ADDITIONAL INFORMATION
I launched KAIChat via terminal to investigate the issue. When deleting a chat, the following messages appear:

org.kde.kf.textautogeneratetext.database: Filename doesn't exist: "/home/simone/.local/share/kaichat/ai-database/messages/..."
org.kde.kf.textautogeneratetext.database: The assumption was wrong, deleteMessage was called before addMessage
qt.sql.qsqldatabase: QSqlDatabasePrivate::removeDatabase: connection ... is still in use, all queries will cease to work.

It appears that deleteMessage() is being called before addMessage(), meaning the deletion is not correctly persisted in the database. This results in the conversation being visually removed only temporarily and returning after a restart.

A screenshot of the terminal output is attached.
Comment 1 Laurent Montel 2025-07-19 12:32:43 UTC
Hi,
Yep I can reproduce it.
I will work on it soon.
Regards
Comment 2 Laurent Montel 2025-07-23 11:17:29 UTC
Git commit 04b0ef56fbfaa8568fd47126b84b4445a96d57f9 by Laurent Montel.
Committed on 23/07/2025 at 11:09.
Pushed by mlaurent into branch 'master'.

Fix delete chat

M  +1    -1    textautogeneratetext/core/autotests/textautogeneratelocalchatsdatabasetest.cpp
M  +1    -0    textautogeneratetext/core/autotests/textautogeneratelocalmessagesdatabasetest.cpp
M  +1    -1    textautogeneratetext/core/localdatabase/textautogeneratelocalchatsdatabase.cpp

https://invent.kde.org/libraries/ktextaddons/-/commit/04b0ef56fbfaa8568fd47126b84b4445a96d57f9