Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Delete chat message action to the Obsidian Plugin #1076

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

samhoooo
Copy link

@samhoooo samhoooo commented Jan 11, 2025

Closes #1020

Add Delete chat message action to the Obsidian Plugin

Description

The Khoj API supports deleting specific chat messages. The web app already uses that. But the Khoj Obsidian plugin doesn't use it yet.

This feature should

Add a Delete message button to each chat message footer in the Obsidian plugin's chat view
Clicking it should
Call the Khoj server API to delete the Khoj or user message
Refresh the Khoj Obsidian UI with the conversation turn (= Khoj + associated user message) deleted

Changes

  • Added ability to delete individual messages in chat conversations
  • Each message now has a delete button alongside copy and paste actions
  • Deleting a message removes both the user's message and Khoj's response (the full conversation turn)
  • Added confirmation dialog before deletion to prevent accidental deletions
  • Messages are deleted both from the UI and the Khoj server API
  • System messages cannot be deleted (e.g. setup hint)

Technical Details

  • Added new deleteMessage method to handle message deletion logic
  • Added DELETE API endpoint call to /api/chat/conversation/message
  • Delete button uses the same icon as in web version (trash-2)
  • Added new boolean parameter isSystemMessage to renderMessage method
  • Show delete button only if it is not a system message

Testing

  • Test deleting user messages
  • Test deleting Khoj responses
  • Verify both messages in a turn are removed
  • Verify deletion persists after page refresh
  • Verify no delete button on setup hint
  • Verify no delete button on error message
  • Verify no delete button on conversation starter
  • Test error cases (network failure, etc)

Screensort

Happy path:

Screen.Recording.2025-01-11.at.17.54.29.mov

Setup hint cannot be deleted:

image

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.

Add Delete chat message action to the Obsidian Plugin
1 participant