WSL + VS Code image paste: Ctrl+Alt+V hint is unusable and PowerShell fallback requires Windows PATH
What version of Codex CLI is running?
codex-cli 0.145.0 (latest according to codex doctor --json at the time of testing)
Environment
- Windows 11, build
26200.8875 - WSL
2.7.10.0, kernel6.18.33.2-2 - Ubuntu
20.04.6 LTSunder WSL2 - VS Code
1.130.0(1b6a188127eeaf9194f945eb6eb89a657e93c54c), integrated terminal withTERM_PROGRAM=vscodeandTERM=xterm-256color - Windows Terminal with the same WSL distribution, used as a control
- Windows PowerShell
5.1.26100.8875 - WSL interop is enabled (
WSL_INTEROPis present), but automatic Windows PATH injection is intentionally disabled:
[interop]
appendWindowsPath = false
[boot]
systemd = true
Summary
Pasting a Windows clipboard image into the Codex TUI from WSL has two independent compatibility problems in this setup:
- The shortcut overlay recommends
Ctrl+Alt+Vfor every WSL terminal, but VS Code's Windows-hosted xterm.js treatsCtrl+Altas a potential AltGr/third-level shift and does not emit this key combination into the PTY. Codex never receives the shortcut.Alt+Vworks. - Once
Alt+Vreaches Codex, the WSL clipboard fallback can invoke Windows PowerShell only by command name. WithappendWindowsPath=false, no PowerShell command is on the Linux PATH, so the fallback fails even though WSL interop is enabled and Windows PowerShell is executable by absolute path.
Together, these make the advertised image-paste flow fail in a common Windows 11 + WSL2 + VS Code terminal setup. They are separate implementation issues, but they affect the same end-to-end user action, so I am reporting the complete tested workflow here. Problem 2 is also tracked in #23611.
Problem 1: the WSL shortcut hint is not usable in VS Code Terminal
With the composer empty, pressing ? shows:
ctrl + alt + v to paste images
Controlled result:
| Terminal running the same WSL distribution | Ctrl+Alt+V |
Alt+V |
|---|---|---|
| VS Code integrated terminal | Does not reach the Codex TUI | Reaches the TUI |
| Windows Terminal | Reaches the TUI | Reaches the TUI |
Setting CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=0 did not change this matrix.
VS Code keyboard shortcut troubleshooting confirms that VS Code receives the complete chord and does not invoke a matching workbench command:
[KeybindingService]: | Resolving ctrl+alt+V
[KeybindingService]: \ From 1 keybinding entries, no when clauses matched the context.
[KeybindingService]: / Received keydown event - modifiers: [ctrl,alt], code: KeyV, keyCode: 86, key: v
The bundled xterm.js version is 6.1.0-beta.288 (8aab310366549d8d865bd8fc4bd509051f2bb2a1). Its keydown path returns early for a third-level shift, and on Windows that condition explicitly includes altKey && ctrlKey:
- https://github.com/xtermjs/xterm.js/blob/8aab310366549d8d865bd8fc4bd509051f2bb2a1/src/browser/CoreBrowserTerminal.ts#L883-L885
- https://github.com/xtermjs/xterm.js/blob/8aab310366549d8d865bd8fc4bd509051f2bb2a1/src/browser/CoreBrowserTerminal.ts#L936-L947
Codex already accepts either a Control- or Alt-modified V for image paste:
- https://github.com/openai/codex/blob/44d76c6a6dd04fa2efc302b906ac8774267a1272/codex-rs/tui/src/chatwidget/interaction.rs#L73-L81
However, the shortcut overlay selects Ctrl+Alt+V based only on is_wsl:
- https://github.com/openai/codex/blob/44d76c6a6dd04fa2efc302b906ac8774267a1272/codex-rs/tui/src/bottom_pane/footer.rs#L1177-L1192
Codex already has WSL + VS Code terminal detection for its keyboard-enhancement compatibility logic, so that detection could be factored/reused for the hint:
- https://github.com/openai/codex/blob/44d76c6a6dd04fa2efc302b906ac8774267a1272/codex-rs/tui/src/tui/keyboard_modes.rs#L18-L37
- https://github.com/openai/codex/blob/44d76c6a6dd04fa2efc302b906ac8774267a1272/codex-rs/tui/src/tui/keyboard_modes.rs#L64-L79
Suggested behavior:
- WSL + VS Code Terminal: show
Alt+V to paste images - Other WSL terminals: keep
Ctrl+Alt+Vif appropriate - Non-WSL: keep the existing behavior
Related but not identical: #11708 reports a generic Ctrl+V versus Alt+V description mismatch. This report is specifically about the WSL-only Ctrl+Alt+V hint and the reproducible VS Code/xterm.js AltGr path.
Problem 2: the WSL PowerShell fallback depends on Windows PATH injection
With appendWindowsPath=false, none of these resolve:
command -v powershell.exe
command -v pwsh
command -v powershell
Pressing Alt+V reaches Codex, but image paste fails with the original Linux clipboard error:
Failed to paste image: no image on clipboard: The clipboard contents were not available in the requested format or the clipboard is empty.
Launching Codex with only the Windows PowerShell directory added makes the same Windows clipboard image paste successfully:
PATH="$PATH:/mnt/c/Windows/System32/WindowsPowerShell/v1.0" codex
Invoking the same PowerShell executable by absolute path also confirms that Get-Clipboard -Format Image can read the Windows clipboard image in this environment. I do not reproduce the separate Get-Clipboard-returns-null behavior described in #23611.
The current fallback tries only PATH-resolved command names:
- https://github.com/openai/codex/blob/44d76c6a6dd04fa2efc302b906ac8774267a1272/codex-rs/tui/src/clipboard_paste.rs#L195-L225
Suggested behavior: preserve the current PATH candidates, then, when running under WSL with interop enabled, try deterministic Windows PowerShell locations resolved to WSL paths (for example through wslpath) before giving up. This should not require enabling global Windows PATH injection or scanning the filesystem.
Expected behavior
For the tested setup:
- The TUI shortcut overlay should advertise a key combination that the active terminal can actually deliver (
Alt+Vfor VS Code + WSL). - With WSL interop enabled but
appendWindowsPath=false, image paste should locate Windows PowerShell without requiring the user to modify the global WSL PATH. - After both compatibility paths are applied, taking a Windows screenshot and pressing the advertised
Alt+Vin the VS Code WSL terminal should attach the image without extra startup flags.
These changes would leave the existing behavior for other terminals and non-WSL environments intact.
Additional root-cause data for the WSL fallback (PowerShell 7)
Re-verified on main @ 9f3cb259 and against tag rust-v0.172.0; both contain the same code. This adds a second, independent failure to the PATH problem described above: even when a PowerShell is found, the fallback script cannot work under PowerShell 7, and the pwsh candidate can never match on WSL.
Environment
codex-cli 0.172.0(also reproduced on 0.171.0), WSL2 Ubuntu, Windows Terminal- PowerShell 7.6.9:
/mnt/c/Program Files/PowerShell/7/pwsh.exe - Windows PowerShell 5.1.19041.6456:
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe - Default
$PATHcontains no/mnt/c/...entry
1. Get-Clipboard -Format Image is Windows PowerShell 5.1 only
try_dump_windows_clipboard_image() in clipboard_paste.rs hardcodes (main: L245-L249):
$img = Get-Clipboard -Format Image
PowerShell 7's Get-Clipboard has no -Format parameter. On 7.6.9 this is a non-terminating parameter-binding error; $img stays $null, so the script's else { exit 1 } runs:
PS> pwsh.exe -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
7.6.9
PS> pwsh.exe -NoProfile -Command '<the exact script above>'
Get-Clipboard: A parameter cannot be found that matches parameter name 'Format'. # localized on this machine
# stderr only, stdout empty, exit status 1 -> fallback logs non-zero and tries the next name, then returns None
The same script against Windows PowerShell 5.1 writes a temp PNG and prints its path (verified here: a 30978-byte PNG, decodable through /mnt/c/...).
#23611 described this as "Get-Clipboard returns $null"; here the parameter never binds at all. Both outcomes are avoided by the API below.
2. The pwsh candidate name cannot match a WSL-visible PowerShell
Command::new(cmd) resolves exact executable names. The candidate list is ["powershell.exe", "pwsh", "powershell"] (main: L251), but a Windows-side PowerShell 7 is exposed as pwsh.exe, not pwsh:
$ command -v powershell.exe # the 5.1 directory is not on PATH by default
(empty)
$ command -v pwsh.exe
/mnt/c/Program Files/PowerShell/7/pwsh.exe
$ command -v pwsh
(empty)
So the common setup "PowerShell 7 directory added to PATH" still fails for all three candidates. If a Linux-side pwsh does exist, it cannot see the Windows clipboard anyway.
3. A cross-version script, verified on both engines
This avoids -Format entirely and works on 5.1 and 7.x:
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$img = [System.Windows.Forms.Clipboard]::GetImage()
if ($null -eq $img) { exit 1 }
$p = [System.IO.Path]::ChangeExtension([System.IO.Path]::GetTempFileName(), 'png')
$img.Save($p, [System.Drawing.Imaging.ImageFormat]::Png)
Write-Output $p
Verified here:
pwsh.exe 7.6.9 -> apartment=STA, ok 546x466
v1.0\powershell.exe 5.1.19041 -> apartment=STA, ok 546x466
PowerShell 7 on Windows defaults to STA, so the -STA workaround proposed in #23611 is not required for 7.x (it remains harmless for 5.1).
4. The repo already has deterministic resolution for this
codex-rs/utils/path-utils/src/system_commands.rssystem_executable()adds/mnt/c/Windows/System32and/mnt/c/Windows/System32/WindowsPowerShell/v1.0whenis_wsl()(main: L108-L111).codex-rs/tui/src/clipboard_copy/wsl.rsalready usescodex_utils_path::system_executable("powershell.exe")for the write direction (main: L85).
clipboard_paste.rs is the only path still relying on ambient PATH names. Trying the PATH candidates first and then falling back to system_executable("powershell.exe") would keep current behavior while making it deterministic. Note that system_executable currently covers /mnt/c only and does not include Program Files/PowerShell/7; the cross-version script above makes that acceptable, but a pwsh.exe candidate under Program Files could be added for hosts without 5.1.
5. Two smaller problems in the same function
- No
current_dir("/"). WSL can fail to start a Windows executable when the cwd's\\wsl.localhost\...path exceeds MAX_PATH, so a deep repo cwd can break paste even after executable resolution succeeds. The same file already sets.current_dir("/")forwslpath(main: L389). .output()has no deadline; #63231 tracks the resulting TUI freeze. Reusingcommand_stdout_before_deadline(already used byconvert_windows_pathin this file) would bound it.
Suggested test points
- a fake PATH where no candidate resolves still finds Windows PowerShell through
system_executable - a failing first candidate continues to the next one
- the generated script contains
System.Windows.Forms.Clipboardrather thanGet-Clipboard -Format
Happy to test a patch on this setup (WSL2 with both PowerShell engines installed).