Skip to content

[FEATURE] Select and annotate code snippets in /explorer for targeted refactoring #599

Description

@edenreich

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

  1. Browse to a file via /explorer (existing behavior).
  2. Select a range of lines (or a syntactic region) within the file.
  3. 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").
  4. 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

  • /explorer supports entering a snippet-selection mode on an open file (e.g. an /explorer select sub-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.

Activity

  1. added
    enhancement
    on Jun 5, 2026
  2. changed the title [-]feat: allow selecting and annotating code snippets in /explorer for targeted refactoring[/-] [+][FEATURE] Select and annotate code snippets in /explorer for targeted refactoring[/+] on Jun 5, 2026
  3. added theissue type on Jun 5, 2026
  4. moved this to Todo in 2026on Jun 5, 2026
  5. added a commit that references this issue on Jun 19, 2026
    df05a3f
  6. moved this from Todo to QA in 2026on Jun 20, 2026
  7. added 2 commits that reference this issue on Jun 20, 2026
    7e619f9
    227511c
  8. moved this from QA to Done in 2026on Jun 20, 2026
  9. inference-gateway-releaser commented on Jun 20, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.122.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions