fix(coding-agent): fix WSL clipboard image paste

closes #2469
This commit is contained in:
Mario Zechner
2026-04-30 23:08:51 +02:00
parent 04527355c5
commit 0b8452c32f
3 changed files with 41 additions and 2 deletions

View File

@@ -172,17 +172,17 @@ function readClipboardImageViaPowerShell(): ClipboardImage | null {
return null;
}
const psQuotedWinPath = winPath.replaceAll("'", "''");
const psScript = [
"Add-Type -AssemblyName System.Windows.Forms",
"Add-Type -AssemblyName System.Drawing",
"$path = $env:PI_WSL_CLIPBOARD_IMAGE_PATH",
`$path = '${psQuotedWinPath}'`,
"$img = [System.Windows.Forms.Clipboard]::GetImage()",
"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }",
].join("; ");
const result = runCommand("powershell.exe", ["-NoProfile", "-Command", psScript], {
timeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,
env: { ...process.env, PI_WSL_CLIPBOARD_IMAGE_PATH: winPath },
});
if (!result.ok) {
return null;