GeezerVison is showing github.com — fix(tui): support clipboard image paste with proper filename on WSL2 by mmdsnb · Pull Request #8209 · anomalyco/opencode
Conversation
Summary
Fixes clipboard image pasting in WSL2 terminal environment. When users copy image files from Windows file manager and paste into OpenCode TUI, the full Windows path (e.g., D:\temp\image.png) was being displayed instead of just the filename.
Changes
1. Enhanced Clipboard Reading (clipboard.ts)
- Added support for
ContainsFileDropList() to detect copied image files on Windows
- Automatically extract filename from Windows file paths
- Convert Windows paths to WSL paths (
D:\... → /mnt/d/...)
- Return filename in
Clipboard.Content interface
2. Fixed Paste Event Handling (prompt/index.tsx)
- Call
event.preventDefault() immediately in onPaste to prevent default text insertion
- Check clipboard for images before processing pasted text
- Manually handle text insertion for all paste scenarios
- Use extracted filename instead of "clipboard" label
Testing
Tested on WSL2 with Windows Terminal:
- ✅ Copy image file from Windows file manager (Ctrl+C) → Paste (Ctrl+V)
- ✅ Drag image file from file manager to terminal window
- ✅ Copy image from application (e.g., browser) → Paste
- ✅ Normal text pasting still works correctly
Before
D:\temp\ScreenShot_2026-01-13_191354_854.png [Image 1]
After
ScreenShot_2026-01-13_191354_854.png [Image 1]
Technical Details
- PowerShell script now outputs
FILEPATH: prefix to indicate file path source
- Path conversion only happens in WSL environment (detected via
os.release())
- No performance impact on normal text pasting (< 500 chars check optimization)
Fixes #issue-number-if-exists
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- Add support for copying image files from Windows file manager (Ctrl+C)
- Automatically convert Windows paths to WSL paths (D:\... -> /mnt/d/...)
- Extract and display only filename instead of full path
- Fix onPaste event handling to prevent duplicate text insertion
- Add FileDropList detection in PowerShell clipboard script
Fixes issue where pasted images showed full Windows path instead of filename
in WSL2 terminal environment.
|
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number> or Closes #<number> to this PR description
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
No duplicate PRs found
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jan 18, 2026
This was referenced Feb 8, 2026
This was referenced Feb 16, 2026
This was referenced Mar 14, 2026
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.