Repository navigation
Description
Summary
The current /explorer lets users browse files and view their contents, but there is no way to select a specific code snippet and attach an instruction for the LLM. To refactor a particular function, block, or expression, users must manually copy-paste the relevant code into their prompt, losing the rich file context that /explorer already provides.
This feature extends /explorer to support snippet selection and annotation. Within a browsed file, a user can select a range of lines (or a syntactic region), annotate it with a natural-language instruction, and have the annotated snippet plus instruction injected into the conversation context - so the model knows exactly which code to change and how, while the surrounding file stays available.
Workflow
- Browse to a file via
/explorer(existing behavior). - Select a range of lines (or a syntactic region) within the file.
- Annotate the selection with a natural-language instruction (e.g. "refactor this function to use early returns", "extract this block into a helper", "add error handling here").
- The annotated snippet + instruction is sent to the LLM as part of the conversation context.
Example UX
/explorer src/handler.go
→ file rendered with line numbers
→ user highlights lines 42-58
→ inline prompt: "Extract this HTTP middleware into a separate function"
→ LLM receives: [file context] + [highlighted lines 42-58] + [user instruction]
Benefits
- Precision - the LLM sees the exact lines to modify, reducing hallucination and off-target suggestions.
- Context preservation - the surrounding file stays available; the annotation highlights the focus area.
- Faster iteration - no manual copy-paste; the user stays in the chat flow.
- Multi-snippet support - annotate several disjoint regions (in one file or across files) for a coordinated refactor.
Open questions
- Should selection be line-based or syntax-tree-node-based?
- Should annotations persist across turns in the conversation?
- How should overlapping or conflicting annotations be resolved?
Acceptance Criteria
-
/explorersupports entering a snippet-selection mode on an open file (e.g. an/explorer selectsub-command or an interactive TUI toggle). - Users can select a line range within the file, and the selection is rendered with a distinct visual style (e.g. highlighted background) in the TUI.
- Users can attach a natural-language annotation to a selection.
- Selections are stored as
(file, start_line, end_line, annotation)tuples in the conversation context. - The annotated snippet plus instruction, together with the surrounding file context, is injected into the LLM conversation.
- Multiple disjoint selections can be annotated in a single request (within one file or across files).
- Tests cover selection, annotation, and context injection.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]feat: allow selecting and annotating code snippets in /explorer for targeted refactoring[/-][+][FEATURE] Select and annotate code snippets in /explorer for targeted refactoring[/+]feat(explorer): add snippet selection and annotation for targeted ref…
feat(explorer): add snippet selection and annotation for targeted ref…
feat(explorer): add snippet selection and annotation for targeted ref…
chore(release): 0.122.0 [skip ci]
inference-gateway-releaser commentedon Jun 20, 2026
🎉 This issue has been resolved in version 0.122.0 🎉
The release is available on:
Your semantic-release bot 📦🚀