Skip to content

fix(tui): expand pasted image and PDF paths on click - #57305

Open
maharshi365 wants to merge 10 commits into
anomalyco:devfrom
maharshi365:expand-image-path
Open

maharshi365 wants to merge 10 commits into
anomalyco:devfrom
maharshi365:expand-image-path

Conversation

@maharshi365

@maharshi365 maharshi365 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #57298
Closes #57698

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Clicking a pasted image or PDF attachment label now replaces it with the original editable path and removes the attachment. This reuses the existing pasted-text expansion handler. Quotes and spaces are preserved for single-path pastes; clipboard screenshots without a source path stay attachments. No new shortcut or duplicate-paste behavior. This also addresses #57698: PDF paths can be restored as text before sending to a model that does not support PDF input. PDF auto-attachment behavior is unchanged.

How did you verify your code works?

  • Regression test failed before the fix and passes after it: paste a quoted image path, click the label, submit, and check that only text is sent.
  • 20 focused tests pass in packages/tui (prompt-paste, local-attachment, attachment).
  • The original regression passed 10 consecutive runs.
  • bun run check passes (lint warnings, no errors).

Screenshots / recordings

Recording.2026-10-20.014436.mp4

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #57162, #48190

Retain pasted local paths in prompt attachment metadata and reuse the placeholder click handler to restore editable path text. Remove the expanded attachment through existing extmark synchronization.

Add a regression test that clicks a quoted image path and verifies submission contains only text. Clipboard images without a source path remain attachments.

Fixes anomalyco#57298
Replace the nested expansion ternary with simple if statements. Reuse existing session, agent, and model fixtures to shorten the image-path regression test.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I reproduced it in the TUI with opencode-drive. On the base, a pasted quoted image path becomes [Image 1] and clicking the label does nothing. With this change, the click puts back the original quoted path as editable text. With the change I also sent an image without expanding it, and the server accepted the prompt even with the extra pastedPath field on the file. The new and existing prompt tests in packages/tui pass, and the type check is clean.

Public API: unchanged. pastedPath is a TUI-only field on the local prompt/history type (it is also saved in prompt-history.jsonl). It is sent along with file parts in requests, but the server accepts it. No SDK, schema, config or CLI changes.

No blocking concerns. When several paths are pasted at once, each expands to its plain file path rather than the exact pasted text. That seems fine.

Related: #57162, #48190

Before

After

@maharshi365 maharshi365 changed the title fix(tui): expand pasted image paths on click fix(tui): expand pasted image and PDF paths on click Oct 21, 2026

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commits only merge dev into the branch. The PR's own changes are unchanged since my last review, and I have no open points from it. On the new head the prompt tests in packages/tui still pass and tsc -b is clean. I also checked the newly linked PDF case in the TUI: on the base, a pasted quoted .pdf path stays [PDF 1] when clicked. With this change, the click puts the original quoted path back as text.

Public API: unchanged.

No new concerns.

Before

After

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges dev into the branch. The PR's own changes are unchanged since my last review, and I have no open points from it. On the new head the prompt tests in packages/tui still pass and tsc -b is clean.

Public API: unchanged.

No new concerns.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges dev into the branch. The PR's own changes are unchanged since my last review, and I have no open points from it. On the new head the prompt tests in packages/tui still pass and tsc -b is clean.

Public API: unchanged.

No new concerns.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges dev into the branch. The PR's own changes are unchanged since my last review, and I have no open points from it. On the new head the prompt tests in packages/tui still pass and tsc -b is clean.

Public API: unchanged.

No new concerns.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tui: pasting a PDF path auto-attaches it, which text-only models cannot read TUI: pasted image paths force attachments in V2

1 participant