Skip to content

feat(chat): support deleting a chat turn (soft delete) - #784

Merged
haiphucnguyen merged 1 commit into
askimo-ai:mainfrom
rcpeken:feat/delete-chat-turn
Oct 28, 2026
Merged

haiphucnguyen merged 1 commit into
askimo-ai:mainfrom
rcpeken:feat/delete-chat-turn

Conversation

@rcpeken

@rcpeken rcpeken commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Closes #778

What

Adds turn-level delete for chat messages, as discussed in #778.

  • Schema: new chat_messages.deleted_at column (66.sqm + guarded AfterVersion(66) callback, anchored at the same number as the .sqm file per the rule documented in SqlDelightSchemaMigrations).
  • Read paths: every read query filters deleted_at IS NULL: session messages and pagination (also used by export), per-session and global search, selectRecentActive (LLM memory), all bookmark queries, and the phrase-habit/suggestion queries.
  • Delete: ChatMessageRepository.softDeleteTurn soft-deletes the user message and every message after it up to the next user message. This covers the normal response, a failed or missing response, and regenerated responses (the outdated attempts plus the active one).
  • Memory: ChatSessionService.deleteTurn deletes the persisted session memory and reloads the recent non-deleted messages via loadFromFilteredMemory, the same pattern as markMessagesAsOutdatedAfter. Unlike that method, it also rebuilds when the session isn't cached, because the persisted summary would otherwise bring the deleted turn back.
  • UI: a Delete action on user messages with a confirmation dialog. The deleted turn is hidden from ChatView (unlike outdated messages), bookmarks on it are hidden and the sidebar badge is updated. Deleting is blocked while a response is streaming. Strings added to all 10 locales.

Deliberately left out

  • Sync: deletion stays local, as agreed (selectUnsynced / updateMessageFromServer untouched).
  • No deletedAt on the ChatMessage domain model: all reads filter deleted rows, so it would always be null.
  • countByRole (lifetime prompt count) is not filtered.
  • Older outdated versions of an edited message are not deleted with the active turn.
  • Facts already merged into cross-session user memory are not removed.

Testing

  • ChatMessageRepositoryIT: 7 new tests (normal turn, no response, failed response, regenerated responses, invalid ids, hidden from pagination/search/memory reads, hidden bookmarks).
  • ChatSessionServiceIT: 2 new tests (stale persisted session memory is dropped on delete; deleting an assistant message is a no-op).
  • SchemaMigrationEquivalenceTest: new upgrade test that takes a version 66 database without deleted_at and migrates it to the current version.
  • Manually ran the desktop app: fresh install, and upgrade of an existing database with sessions and bookmarks (column added, data intact).
  • spotlessCheck, detekt, checkI18nKeys, detectMissingLocalizations pass.

Notes

  • Non-English translations would benefit from a native speaker's review.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 11:46
@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Thank you @rcpeken to take this issue, it is not the first issue for new user, and your PR shows you understand the codebase very well :).

Could you sign the CLA then I can merge?

@rcpeken

rcpeken commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@haiphucnguyen Thanks a lot for the kind words! I've signed the CLA.

@haiphucnguyen haiphucnguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rcpeken for this great PR!

@haiphucnguyen
haiphucnguyen merged commit ee73f36 into askimo-ai:main Oct 28, 2026
12 checks passed
@rcpeken

rcpeken commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks a lot @haiphucnguyen , it was a pleasure working on this! I'd be happy to keep contributing to Askimo. #345 (source-aware RRF in HybridContentRetriever) caught my eye since I'm focusing on ML and retrieval. I'll take a closer look at the code and comment on the issue before starting.

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Sure, can you discuss in that ticket then I can assign to you.

In fact, the quality of RAG is what I am concerning :). I also plan to look into the knowledge graph to increase the precisity of the AI answer. I am looking forward to your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support deleting chat messages (turn-level cascade delete)

4 participants