Skip to content

Add document search support with /doc trigger#47

Merged
trialiya merged 5 commits into
mainfrom
claude/message-input-slash-commands-c3ywys
Jun 21, 2026
Merged

Add document search support with /doc trigger#47
trialiya merged 5 commits into
mainfrom
claude/message-input-slash-commands-c3ywys

Conversation

@trialiya

Copy link
Copy Markdown
Owner

Summary

Extends the file chip input component to support searching and inserting documents via a new /doc trigger, alongside the existing /file trigger for repository files.

Key Changes

  • New /doc trigger: Added parallel document search functionality using a new documentsApi module

    • Supports searching by document name or numeric ID
    • When query is numeric, performs dual search (by name and by ID) and merges results
  • Document token format: Introduced ⟦doc:ID:TITLE⟧ token format with corresponding makeDocToken() and parseDocToken() functions

  • UI enhancements:

    • Document chips display with 📋 icon and show title + ID
    • FilePickerDropdown now handles both file and document result types with conditional rendering
    • Added i18n strings for document search hints and messages (English and Russian)
  • Token expansion: Updated expandTokensForSend() to fetch and embed document content when sending messages

  • Refactored trigger detection: Generalized trigger matching to support both /file and /doc commands with improved cursor position tracking

  • API integration: Created documentsApi.js with searchByName() and getById() methods supporting abort signals for request cancellation

Implementation Details

  • Document search uses searchDocsAsync() helper that intelligently routes numeric queries to both name and ID searches
  • Picker state now tracks type: 'file' | 'doc' to determine which search and rendering logic to use
  • Trigger position calculation improved to use lastIndexOf() for more robust command boundary detection
  • Document chips are non-editable (like file chips) and skip preview mode on click

https://claude.ai/code/session_01BA6oSYD68zVgMGt7L2QQiU

claude and others added 5 commits June 20, 2026 23:22
- /file now triggers the picker immediately without requiring a space;
  characters typed right after (/filefoo) become the search query
- /doc command added for documents: searches by name, and by ID if the
  query is numeric (ID result shown first, merged with name results)
- Document chips use the ⟦doc:ID:TITLE⟧ token format and expand to
  document title + description when the message is sent
- FilePickerDropdown extended with a type prop to render doc items
  (title + #ID, folder/document icon) alongside existing file items
- i18n: added docInput keys in ru and en

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BA6oSYD68zVgMGt7L2QQiU
- Enter / click on picker row now inserts a reference chip (📎) for
  both files (⟦ref:PATH⟧) and documents (⟦docref:ID:TITLE⟧)
- Each picker item gains an "📄 содержимое" button on the right that
  inserts the full-content token (⟦file:PATH⟧ / ⟦doc:ID:TITLE⟧)
- Button is hidden until the row is hovered or keyboard-selected to
  keep the list uncluttered
- fileChips: added makeDocRefToken / parseDocRefToken; TOKEN_RE updated
  to include docref; expandTokensForSend expands docref to a plain
  «Title» (#ID) mention without fetching description
- Footer hint updated: Enter → "вставить ссылку"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BA6oSYD68zVgMGt7L2QQiU
Showing the button on both :hover and --selected caused two buttons to
be visible simultaneously when mousing over a row other than the
keyboard-selected one. Button is now shown on hover only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BA6oSYD68zVgMGt7L2QQiU
@trialiya trialiya merged commit cd40224 into main Jun 21, 2026
4 checks passed
@trialiya trialiya deleted the claude/message-input-slash-commands-c3ywys branch June 21, 2026 14:10
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.

2 participants