Skip to content

Attachments are not rendered correctly when cycling through prev prompts #3249

Closed as duplicate

Description

@geril07
[[message_history]]
  text = "xxx\n@README.md"

  [[message_history.attachments]]
    id = "0b652571-982a-4fe9-a526-267141f2ed38"
    type = "file"
    display = "@README.md"
    url = "file:///home/geril/code/oss/opencode/README.md"
    filename = "README.md"
    media_type = "text/plain"
    start_index = 4
    end_index = 14
    [message_history.attachments.source]
      path = "/home/geril/code/oss/opencode/README.md"
      mime = "text/plain"

What was typed as a prompt:

xxx
@README.md

Attachment from toml is correct there, but note, start_index and end_index are ABSOLUTE indexes.

Let's look at this piece of code of RestoreFromPrompt which is called when cycling through previous prompts

https://github.com/sst/opencode/blob/335d83365521728181248b13a55386a10ae41ef0/packages/tui/internal/components/chat/editor.go#L801-L805

It calls ReplaceRange with the absolute ranges

However, what we see in ReplaceRange function:

https://github.com/sst/opencode/blob/335d83365521728181248b13a55386a10ae41ef0/packages/tui/internal/components/textarea/textarea.go#L695-L723

It works with the current row, but the indexes passed into it are absolute ones(at least from RestoreFromPrompt fn)

And this is how it looks like when cycling previous prompts:

Image

Seems logical, absolute start_index 4 was used as a "col index", and therefore @REA is there

And also something affects a session message, but it's not related to the explained thing ig:

Image

should we wait until opentui?)

Activity

  1. changed the title [-]Attachments are not rendered correctly[/-] [+]Attachments are not rendered correctly when cycling through prev prompts[/+] on Oct 17, 2025
  2. github-actions commented on Oct 17, 2025

    @github-actions
    Contributor

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

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

  3. geril07 commented on Oct 17, 2025

    @geril07
    ContributorAuthor

    This issue might be a duplicate of existing issues.

    This issue is not a duplicate, it's a DUPLICATE DUPLICATE
    sorry about that 😄

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions