Skip to content

Conversation

@shanto12
Copy link

Summary

This PR implements file filter autocomplete for the Obsidian chat interface, as requested in issue #1183.

Changes

  • Added fileFilterDropdown, fileFilterSuggestions, and selectedFileFilterIndex properties to track dropdown state
  • Added fetchUserFiles() method to fetch files from /api/content/files endpoint
  • Added showFileFilterDropdown() method to display and position the autocomplete dropdown
  • Added hideFileFilterDropdown() method to hide the dropdown
  • Modified onChatInput() to detect file: pattern using regex /file:(\S*)$/ and trigger autocomplete

How It Works

  1. When user types file: in the Obsidian chat input, the dropdown appears with a list of synced files
  2. As user types more characters after file:, the suggestions are filtered
  3. Clicking a suggestion inserts file:"selected_file" into the input
  4. Dropdown hides when pattern is no longer detected

Related Issues

- Added autocomplete suggestions for file: query filter in web chat
- Fetches user's synced files from /api/content/files endpoint  
- Filters suggestions as user types more characters
- Uses existing Command component pattern for consistent UX
Initial commit adding file filter autocomplete properties for Obsidian chat.

This is part of implementing issue khoj-ai#1183 - Show autocomplete suggestions for File Query Filters in Chat on Obsidian App.

Added:
- fileFilterDropdown: HTMLElement property
- fileFilterSuggestions: string[] for storing file list
- selectedFileFilterIndex: number for dropdown navigation

TODO: Add methods for showing/hiding dropdown and file: pattern detection in onChatInput()
Part of issue khoj-ai#1183 - Obsidian file filter autocomplete

- fetchUserFiles(): Fetches list of user files from /api/content/files
- hideFileFilterDropdown(): Hides the file filter dropdown
Part of issue khoj-ai#1183 - Obsidian file filter autocomplete

Added showFileFilterDropdown() method that:
- Fetches and caches user files from API
- Filters files based on user input
- Creates and positions dropdown above input
- Handles file selection click events
Completes issue khoj-ai#1183 - Obsidian file filter autocomplete

Modified onChatInput() to detect file: pattern using regex /file:(\S*)$/
- Shows file filter dropdown when pattern detected
- Hides dropdown when pattern not present
- Filters suggestions based on characters after file:
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.

Show autocomplete suggestions for File Query Filters in Chat on Obsidian App

1 participant