Skip to content

Feature: Line selection in file view to reference in prompts #10019

Closed

Description

@kyashrathore

Summary

Add the ability to select lines in the file view panel and reference them in prompts. When lines are selected, show an indicator in the prompt area displaying "selected lines X-Y from filename" which gets included as context when sending a message.

Motivation

When discussing code changes or asking questions about specific parts of a file, it's currently necessary to manually type file paths and line numbers or copy-paste code snippets. Line selection would allow users to:

  • Precisely reference code sections when requesting edits
  • Ask clarifying questions about specific lines
  • Provide targeted context without copying code into the prompt

Proposed UX

  1. Selection: Click and drag in the file view to select a line range (single file only, new selection replaces previous)

  2. Indicator: Show a dismissible indicator in the prompt area:

    [file icon] lines 13-14 from config.ts [x]
    
  3. Submit behavior: When sending a message with a selection, prepend context like:

    > selected lines 13-14 from config.ts
    
    [user's message]
    
  4. Clear selection:

    • Click the X on the indicator
    • Press Escape
    • Auto-clear after submitting a message

Current State

The infrastructure partially exists:

  • Code component already has enableLineSelection and selectedLines props
  • FileProvider tracks selectedLines per file
  • session.tsx passes onLineSelected callback to Code

The gap is surfacing the selection state in the prompt area.

Implementation Notes

Main files to modify:

  • New SelectionIndicator component
  • prompt-input.tsx - display indicator, include selection in submit
  • session.tsx - Escape key handler

See spec: specs/08-doc-editing-experience.md

Activity

  1. github-actions commented on Jan 22, 2026

    @github-actions
    Contributor

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  2. kyashrathore commented on Jan 23, 2026

    @kyashrathore
    ContributorAuthor

    WIP in #7008 so closing.

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

Metadata

Metadata

Assignees

Labels

webRelates to opencode on web / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions