Skip to content

Support for line range with file tagging? #2129

Closed

Description

@regb

Hello, recently started to use opencode, I like it a lot, thanks for all that hard work!
I've been trying to figure out if there is a way to append line ranges to file tagging in TUI. I've been trying to explore the codebase a bit and it seems the backend supports the concept of file range with the message attachment and the Read tool can thus read specific file-range, and apparently there's a way to pass it with the API. But as far as I can tell, it's not possible to trigger it through the TUI.

The use-case I had in mind is something similar to Cursor, where you can navigate in your editor, select a few lines of code, and use a plugin to attach the file tag with the lines to the opencode input prompt via the TUI API. Not sure how much of a tiny optimization that is compared to sending the entire file, but in my experience that was useful to give precise context to the agent and guide it.

In my tests I've noticed that the agent will usually naturally make the tool call to read the file if you do something like @filepath:10:20, but that's not the same as it requires the agent to make the decision to invoke the Read tool, and it's both less reliable and more expensive than just having opencode pro-actively inline that information before sending to the LLM.

Activity

  1. github-actions commented on Aug 21, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • Editor integrations #216: Editor integrations - This issue discusses editor integrations that would "see what you have open and selected in neovim, and if it could display diffs in neovim." The use case of selecting lines of code in an editor and passing them to opencode is very similar to what you're requesting with line range support for file tagging.

    Feel free to ignore if none of these address your specific case.

  2. quantonganh commented on Oct 18, 2025

    @quantonganh

    In my tests I've noticed that the agent will usually naturally make the tool call to read the file if you do something like @filepath:10:20

    Have you tried something like this: @filepath:L10-20?

  3. regb commented on Oct 25, 2025

    @regb
    ContributorAuthor

    In my tests I've noticed that the agent will usually naturally make the tool call to read the file if you do something like @filepath:10:20

    Have you tried something like this: @filepath:L10-20?

    Thanks for the suggestion, unfortunately that doesn't work too. I tried multiple variations, but I don't think the TUI supports this syntax.

  4. dennypenta commented on Jan 15, 2026

    @dennypenta

    I found a problem.
    warning: I'm reading the codebase the first time ever.

    I found the code responsible for line range

    apparently web/desktop and tui have different line range syntax.
    to perform it in TUI do @filepath#12-42, where #12-42 is :L12-42 for web/desktop (I guess, never used them).
    proof it works is here, you can see my prompt and how it calls the read tool with offset and limit: https://opncd.ai/share/H0jN92x0

    there are 3 possible things to fix:

    1. documentation, perhaps worth explicitly mention the difference in the clients
    2. tui highlight, when you autocomplete the file to read, adding line range is not going into the highlighted file name. not sure its worth it, because with no triggered autocompletion nothing is highlighted anyway
    3. make line range syntax compatible with desktop, perhaps there are constrains Im not aware of, but from top of my head it's due to historical reasons.

    @adamdotdevin wdyt?

  5. rekram1-node commented on Jan 15, 2026

    @rekram1-node
    Collaborator

    yes those are all great ideas that we just havent gotten around to!

  6. ewired commented on Jan 22, 2026

    @ewired
    Contributor

    @dennypenta Line range syntax in #4238 was originally @somefile:12-42 and changed to @somefile#12-42 as this was the VS code extension's syntax at the time. Possibly they all need to be unified and that should be a separate issue, as the PR mentioning this is not relevant to what this original issue is asking IMO. This issue is asking about handling mentions in the TUI API again which could be solved by #3996.

  7. github-actions commented on Mar 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions