Skip to content

[Bug][TUI/Windows] Pasting image via Ctrl+V permanently changes terminal title to "Windows PowerShell 5.1" #34775

Description

@sevelee

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

  1. Open OpenCode TUI in Windows Terminal (note the tab title shows OC | <session>)
  2. Copy any image to clipboard (e.g. screenshot via Win+Shift+S)
  3. Press Ctrl+V in the OpenCode prompt
  4. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions