Description
Description
When pasting an image from clipboard using Ctrl+V in OpenCode TUI on Windows, the terminal tab title permanently changes from the OpenCode session title (e.g. OC | <session name>) to "Windows PowerShell 5.1" and never recovers.
Root Cause
In packages/tui/src/clipboard.ts, the read() function spawns powershell.exe (Windows PowerShell 5.1) to read clipboard image data:
const image = await command("powershell.exe", ["-NonInteractive", "-NoProfile", "-command", script])
PowerShell 5.1 calls SetConsoleTitle() on startup, which overwrites the terminal title. Since the child process shares the console with the parent, the title change is visible immediately. OpenCode does not restore the title after the command completes.
Expected Behavior
Terminal title should remain unchanged (or be restored) after pasting an image.
Suggested Fix
Option A: Restore the terminal title after spawning powershell.exe using ANSI escape:
process.stdout.write(`\x1b]2;${currentTitle}\x07`)
Option B: Use pwsh.exe (PowerShell 7) when available — it does not change the console title on startup.
Steps to Reproduce
- Open OpenCode TUI in Windows Terminal (note the tab title shows
OC | <session>)
- Copy any image to clipboard (e.g. screenshot via Win+Shift+S)
- Press Ctrl+V in the OpenCode prompt
- Observe: terminal tab title permanently changes to "Windows PowerShell 5.1"
Environment
- OpenCode: 1.17.9
- OS: Windows 11
- Terminal: Windows Terminal
- Shell: PowerShell 7 (pwsh)
Screenshot
Plugins
No response
OpenCode version
1.17.9
Steps to reproduce
When pasting an image from clipboard using Ctrl+V in OpenCode TUI on Windows, the terminal tab title permanently changes from the OpenCode session title (e.g. OC | ) to "Windows PowerShell 5.1" and never recovers.
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows Terminal
Description
Description
When pasting an image from clipboard using Ctrl+V in OpenCode TUI on Windows, the terminal tab title permanently changes from the OpenCode session title (e.g.
OC | <session name>) to "Windows PowerShell 5.1" and never recovers.Root Cause
In
packages/tui/src/clipboard.ts, theread()function spawnspowershell.exe(Windows PowerShell 5.1) to read clipboard image data:PowerShell 5.1 calls
SetConsoleTitle()on startup, which overwrites the terminal title. Since the child process shares the console with the parent, the title change is visible immediately. OpenCode does not restore the title after the command completes.Expected Behavior
Terminal title should remain unchanged (or be restored) after pasting an image.
Suggested Fix
Option A: Restore the terminal title after spawning powershell.exe using ANSI escape:
Option B: Use
pwsh.exe(PowerShell 7) when available — it does not change the console title on startup.Steps to Reproduce
OC | <session>)Environment
Screenshot
Plugins
No response
OpenCode version
1.17.9
Steps to reproduce
When pasting an image from clipboard using Ctrl+V in OpenCode TUI on Windows, the terminal tab title permanently changes from the OpenCode session title (e.g. OC | ) to "Windows PowerShell 5.1" and never recovers.
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows Terminal