## Related issues: - https://github.com/openai/codex/issues/3939 - https://github.com/openai/codex/issues/2292 - https://github.com/openai/codex/issues/7528 (After correction https://github.com/openai/codex/pull/3990) **Area:** `codex-cli` (image handling / clipboard & file uploads) **Platforms affected:** WSL (Ubuntu on Windows 10/11). No behavior change on native Linux/macOS/Windows. ## Summary This PR fixes image pasting and file uploads when running `codex-cli` inside WSL. Previously, image operations failed silently or with permission errors because paths weren't properly mapped between Windows and WSL filesystems. ## Visual Result <img width="1118" height="798" alt="image" src="https://github.com/user-attachments/assets/14e10bc4-6b71-4d1f-b2a6-52c0a67dd069" /> ## Last Rust-Cli <img width="1175" height="859" alt="image" src="https://github.com/user-attachments/assets/7ef41e29-9118-42c9-903c-7116d21e1751" /> ## Root cause The CLI assumed native Linux/Windows environments and didn't handle the WSL↔Windows boundary: - Used Linux paths for files that lived on the Windows host - Missing path normalization between Windows (`C:\...`) and WSL (`/mnt/c/...`) - Clipboard access failed under WSL ### Why `Ctrl+V` doesn't work in WSL terminals Most WSL terminal emulators (Windows Terminal, ConEmu, etc.) intercept `Ctrl+V` at the terminal level to paste text from the Windows clipboard. This keypress never reaches the CLI application itself, so our clipboard image handler never gets triggered. Users need `Ctrl+Alt+V`. ## Changes ### WSL detection & path mapping - Detects WSL by checking `/proc/sys/kernel/osrelease` and the `WSL_INTEROP` env var - Maps Windows drive paths to WSL mount paths (`C:\...` → `/mnt/c/...`) ### Clipboard fallback for WSL - When clipboard access fails under WSL, falls back to PowerShell to extract images from the Windows clipboard - Saves to a temp file and maps the path back to WSL ### UI improvements - Shows `Ctrl+Alt+V` hint on WSL (many terminals intercept plain `Ctrl+V`) - Better error messages for unreadable images ## Performance - Negligible overhead. The fallback adds a single FS copy to a temp file only when needed. - Direct streaming remains the default. ## Files changed - `protocol/src/lib.rs` – Added platform detection module - `protocol/src/models.rs` – Added WSL path mapping for local images - `protocol/src/platform.rs` – New module with WSL detection utilities - `tui/src/bottom_pane/chat_composer.rs` – Added base64 data URL support and WSL path mapping - `tui/src/bottom_pane/footer.rs` – WSL-aware keyboard shortcuts - `tui/src/clipboard_paste.rs` – PowerShell clipboard fallback ## How to reproduce the original bug (pre-fix) 1. Run `codex-cli` inside WSL2 on Windows. 2. Paste an image from the Windows clipboard or drag an image from `C:\...` into the terminal. 3. Observe that the image is not attached (silent failure) or an error is logged; no artifact reaches the tool. ## How to verify the fix 1. Build this branch and run `codex-cli` inside WSL2. 2. Paste from clipboard and drag from both Windows and WSL paths. 3. Confirm that the image appears in the tool and the CLI shows a single concise info line (no warning unless fallback was used). I’m happy to adjust paths, naming, or split helpers into a separate module if you prefer. ## How to try this branch If you want to try this before it’s merged, you can use my Git branch: Repository: https://github.com/Waxime64/codex.git Branch: `wsl-image-2` 1. Start WSL on your Windows machine. 2. Clone the repository and switch to the branch: ```bash git clone https://github.com/Waxime64/codex.git cd codex git checkout wsl-image-2 # then go into the Rust workspace root, e.g.: cd codex-rs 3. Build the TUI binary: cargo build -p codex-tui --bin codex-tui --release 4. Install the binary: sudo install -m 0755 target/release/codex-tui /usr/local/bin/codex 5. From the project directory where you want to use Codex, start it with: cd /path/to/your/project /usr/local/bin/codex On WSL, use CTRL+ALT+V to paste an image from the Windows clipboard into the chat. |
||
|---|---|---|
| .devcontainer | ||
| .github | ||
| .vscode | ||
| codex-cli | ||
| codex-rs | ||
| docs | ||
| scripts | ||
| sdk/typescript | ||
| shell-tool-mcp | ||
| .codespellignore | ||
| .codespellrc | ||
| .gitignore | ||
| .npmrc | ||
| .prettierignore | ||
| .prettierrc.toml | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| cliff.toml | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| NOTICE | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| PNPM.md | ||
| README.md | ||
npm i -g @openai/codex
or brew install --cask codex
Codex CLI is a coding agent from OpenAI that runs locally on your computer.
If you want Codex in your code editor (VS Code, Cursor, Windsurf), install in your IDE
If you are looking for the cloud-based agent from OpenAI, Codex Web, go to chatgpt.com/codex
Quickstart
Installing and running Codex CLI
Install globally with your preferred package manager. If you use npm:
npm install -g @openai/codex
Alternatively, if you use Homebrew:
brew install --cask codex
Then simply run codex to get started:
codex
If you're running into upgrade issues with Homebrew, see the FAQ entry on brew upgrade codex.
You can also go to the latest GitHub Release and download the appropriate binary for your platform.
Each GitHub Release contains many executables, but in practice, you likely want one of these:
- macOS
- Apple Silicon/arm64:
codex-aarch64-apple-darwin.tar.gz - x86_64 (older Mac hardware):
codex-x86_64-apple-darwin.tar.gz
- Apple Silicon/arm64:
- Linux
- x86_64:
codex-x86_64-unknown-linux-musl.tar.gz - arm64:
codex-aarch64-unknown-linux-musl.tar.gz
- x86_64:
Each archive contains a single entry with the platform baked into the name (e.g., codex-x86_64-unknown-linux-musl), so you likely want to rename it to codex after extracting it.
Using Codex with your ChatGPT plan
Run codex and select Sign in with ChatGPT. We recommend signing into your ChatGPT account to use Codex as part of your Plus, Pro, Team, Edu, or Enterprise plan. Learn more about what's included in your ChatGPT plan.
You can also use Codex with an API key, but this requires additional setup. If you previously used an API key for usage-based billing, see the migration steps. If you're having trouble with login, please comment on this issue.
Model Context Protocol (MCP)
Codex can access MCP servers. To configure them, refer to the config docs.
Configuration
Codex CLI supports a rich set of configuration options, with preferences stored in ~/.codex/config.toml. For full configuration options, see Configuration.
Execpolicy
See the Execpolicy quickstart to set up rules that govern what commands Codex can execute.
Docs & FAQ
- Getting started
- Configuration
- Sandbox & approvals
- Execpolicy quickstart
- Authentication
- Automating Codex
- Advanced
- Zero data retention (ZDR)
- Contributing
- Install & build
- FAQ
- Open source fund
License
This repository is licensed under the Apache-2.0 License.