feat(@-refs): inline @file context via chat/queryFiles#4
Open
ssjoleary wants to merge 3 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds inline @file context references to the chat flow, wiring file picker selection into prompt contexts and user-message rendering.
Changes:
- Adds
chat/queryFilesprotocol support and@picker state handling. - Sends selected file contexts with
chat/prompt. - Styles inline
@pathtokens in rendered user messages and adds test coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/eca_cli/state.clj |
Adds @ trigger handling and async file query command. |
src/eca_cli/picker.clj |
Adds at-file picker state, filtering, and selection insertion. |
src/eca_cli/chat.clj |
Includes pending contexts in prompt sends and clears them after submit. |
src/eca_cli/protocol.clj |
Adds chat-query-files! request wrapper. |
src/eca_cli/view.clj |
Adds picker label for file selection. |
src/eca_cli/view/blocks.clj |
Styles rendered @path tokens with ANSI bold. |
test/eca_cli/at_refs_test.clj |
Adds unit tests for @ picker, contexts, rendering, and protocol params. |
bb.edn |
Adds the new test namespace to the test task. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+426
to
+428
| (send-chat-prompt! (:server state) (:chat-id state) text | ||
| (cond-> (:opts state) | ||
| (seq contexts) (assoc :contexts contexts))) |
| (let [new-state (-> state | ||
| (update :items conj {:type :user :text text}) | ||
| (assoc :mode :chatting :pending-message text :echo-pending true) | ||
| (assoc :pending-contexts []) |
| (nth filtered idx))] | ||
| (if path | ||
| [(-> state | ||
| (update :input #(-> % (insert-at-cursor (str "@" path)) ti/focus)) |
Comment on lines
+257
to
+259
| (autocomplete-at? state msg) | ||
| [(picker/open-at-file-picker state) | ||
| (query-files-cmd (:server state) (:chat-id state) "")] |
Addresses PR #4 review (4 issues): - Filter :pending-contexts to inline @<path> tokens at send so deleted tokens drop their contexts. - Preserve :pending-contexts across login-retry by capturing into :opts before clearing. - Insert separator around @<path> when cursor is adjacent to non-whitespace, so `foo|bar` -> `foo @path bar` not `foo@pathbar`. - Re-dispatch chat/queryFiles on filter typing so server-capped list doesn't trap files the user is searching for. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collapse two near-identical cond branches in update-state behind a single named predicate at-file-filter-keystroke?. The duplicated branches (printable-char and backspace) shared their entire body — hand to picker, re-query server with current :query. Predicate names the policy (what counts as filter typing); the single branch carries the mechanism (dispatch + re-query). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@in:ready(at start of input, or after a space) opens a fuzzy file picker that dispatcheschat/queryFilesto the server.@<path>at the cursor and added to:pending-contexts, which is sent as thecontextsarray on the nextchat/promptand reset to[]after send.@<token>tokens with ANSI bold while preserving the outer reverse-video wrap.Tracks Phase 11a in
docs/roadmap.md.Decisions worth flagging
@invocation — matches eca-nvim + eca-emacs ecosystem (multiple files = multiple@presses). Multi-file batch selection deliberately deferred.eca-chat-context.el:449-458) and aligns with the eca server's own inline parser (eca/src/eca/features/context.clj:124-139). Belt-and-braces send: inline@pathtoken AND explicitcontextsarray.@only opens the picker when preceded by space, start-of-line, or empty input. Mid-word@(e.g.user@host) inserts a literal@.@<path>at the cursor (not end-of-string), viasubs/set-value.\\033[1m...\\033[22m(not0mreset) so the outer reverse-video wrap on user lines is preserved.wrap-textis already ANSI-aware so token boldness survives wrapping./-autocomplete suppression is already enforced by the existing:ready-only guard inautocomplete-slash?; new test pins this down explicitly.Out of scope (deliberate)
@cursor,@repoMap,@mcpResource).@file.clj:L1-L10— server supports but defer client surfacing.Test plan
bb test— 96 tests, 431 assertions, 0 failurestest/eca_cli/at_refs_test.clj(9 tests, 24 assertions): keystroke opens picker, mid-word no-op, after-space, selection appends tag + context, escape no side effects, pending-contexts flushed on send, slash suppressed while picker open, ANSI-bold render, async loaded results splicebrepl smoke
@keystroke intercept in:ready:User-message render with
@-tokens (ANSI bold visible):