Skip to content

Major updates to Obsidian Khoj plugin chat interface and editing features #1109

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

Merged
merged 107 commits into from
Jun 1, 2025

Conversation

hjamet
Copy link
Contributor

@hjamet hjamet commented Feb 11, 2025

Description

This PR introduces significant improvements to the Obsidian Khoj plugin's chat interface and editing capabilities, enhancing the overall user experience and content management functionality.

Features

🔍 Enhanced Communication Mode

I've implemented radio buttons below the chat window for easier communication mode selection. The modes are now displayed as emojis in the conversation for a cleaner interface, replacing the previous text-based system (e.g., /default, /research). I've also documented the search mode functionality in the help command.

Screenshots

  • Radio buttons for mode selection
  • Emoji display in conversations
    Recording 2025-02-11 at 18 56 10

💬 Revamped Message Interaction

I've redesigned the message buttons with improved spacing and color coding for better visual differentiation. The new edit button allows quick message modifications - clicking it removes the conversation up to that point and copies the message to the input field for easy editing or retrying questions.

Screenshots

  • New message styling and color scheme
    Recording 2025-02-11 at 18 44 48
  • Edit button functionality
    Recording 2025-02-11 at 18 47 52

🤖 Advanced Agent Selection System

I've added a new chat creation button with agent selection capability. Users can now choose from their available agents when starting a new chat. While agents can't be switched mid-conversation to maintain context, users can easily start fresh conversations with different agents.

Screenshots

  • Agent selection dropdown
    Recording 2025-02-11 at 18 51 27

👁️ Real-Time Context Awareness

I've added a button that gives Khoj access to read Obsidian opened tabs. This allows Khoj to read open notes and track changes in real-time, maintaining a history of previous versions to provide more contextual assistance.

Screenshots

  • Window access toggle
    Recording 2025-02-11 at 18 59 01

✏️ Smart Document Editing

Inspired by Cursor IDE's intelligent editing and ChatGPT's Canvas functionality, I've implemented a first version of a content creation system we've been discussing. Using a JSON-based modification system, Khoj can now make precise changes to specific parts of files, with changes previewed in yellow highlighting before application. Modification code blocks are neatly organized in collapsible sections with clear action summaries. While this is just a first step, it's working remarkably well and I have several ideas for expanding this functionality to make Khoj an even more powerful content creation assistant.

Screenshots

  • JSON modification preview
  • Change highlighting system
  • Collapsible code blocks
  • Accept/cancel controls
    Recording 2025-02-11 at 19 02 32

debanjum added 21 commits May 25, 2025 03:27
Upgrading standard dompurify package breaks the khoj obsidian plugin.
Isomorphic dompurify wraps the latest dompurify 3.2.6, works with
the khoj obsidian plugin and is recommended on the dompurify npm
package as well. So migrate to that
Ask khoj to return file edits in the SEARCH/REPLACE form.
This is a more standard form, also used by aider.

Remove json5 package as we now rely on regex to pars edit blocks from
khoj's response

Remove unused functions in chat_view.
Can re-nable if invalid edit blocks higher than tolerable and clean-up
chat history clutter after edit block fixup retries
These should be used sparingly and in UX where icons do not work like
error messages and notices.
- Show user profile picture or email initial if signed in
- Show connection status as status dot
- Add link to get khoj api key from khoj url
- Add interact, connect section to improve setting groups
- Switch between similar and chat view in the same leaf node when
  opened via the header pane nav links
- Only show new conversation when in chat view, not similar view
- Put new conversation container after header row. Previously it would
  flex around in the header row which felt untidy.
Copy link
Member

@debanjum debanjum left a comment

Choose a reason for hiding this comment

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

I've pushed another set of improvements. Changes look good from my side now! Let me know if you have question, concerns. Otherwise we can merge this PR in a day or two.

@debanjum
Copy link
Member

Some notes for future reference on the document editing capabilities:

  • I've soft-disabled the retry logic for now as it pollutes the chat history (on reloading chat you see all the retries).
  • The edit application logic needs some improvements, we can do that as a follow-up.

@debanjum
Copy link
Member

Hey @hjamet can you put the new content synchronization commit you pushed into a separate PR? I don't want to increase the size of this PR further. I can review your synchronization changes separately but do not want to delay merging this PR.

@hjamet
Copy link
Contributor Author

hjamet commented May 31, 2025

Hey @hjamet can you put the new content synchronization commit you pushed into a separate PR? I don't want to increase the size of this PR further. I can review your synchronization changes separately but do not want to delay merging this PR.

Indeed, very bad practice on my part. Since it was a significant bug, I wanted to take advantage of the opportunity to fix it in one go ^^ I'll make a separate pull request for the fix :)

@debanjum debanjum merged commit dbfac89 into khoj-ai:master Jun 1, 2025
3 checks passed
@debanjum
Copy link
Member

debanjum commented Jun 1, 2025

Excited to get this PR merged!

Indeed, very bad practice on my part. Since it was a significant bug, I wanted to take advantage of the opportunity to fix it in one go ^^ I'll make a separate pull request for the fix :)

Also thanks for pulling your syncing changes into a separate PR. Keeping changes modular, makes reviews easier, faster and better :)

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.

3 participants