Support pasting an image file from a file manager
Open 💬 0 comments Opened Jul 26, 2026 by thewh1teagle
Description
When copying an image file from a file manager (e.g. Finder) and pasting it into the Codex TUI composer, some terminals paste only the basename (e.g. screenshot.png) instead of the full path. Codex then just inserts that filename as plain text instead of attaching the image, so the model never receives the image.
Expected behavior
When the pasted text is an image filename that matches a file in the clipboard's file list, Codex should resolve the full path from the clipboard and attach it as a local image attachment.
Fix
I implemented a fix, but since PRs to this repo aren't accepted from external contributors, I'm sharing it here:
- Branch: https://github.com/thewh1teagle/codex/tree/fix/image-filename-clipboard-paste
- Commit: https://github.com/thewh1teagle/codex/commit/2e034f086ae5f3b1e723a02bbe10ef9ef0786455
What it does:
- In
chat_composer.rs, when a pasted path fails to resolve as an image, it now falls back to matching the pasted filename against the clipboard's file list (viaarboard) and attaches the matching image file. - Adds
image_path_from_clipboard_file_list()andis_supported_image_filename()inclipboard_paste.rs, with case-insensitive filename matching on Windows and validation that the file is actually a decodable image (image::image_dimensions). - Consolidates the supported-extension check (png/jpg/jpeg/gif/webp) into one helper used by both modules.
- Includes unit tests for extension filtering and clipboard file-list matching.
Feel free to take the code as-is — happy to answer questions about the approach.
Version
Codex Version 26.721.41059 (5848)
System info
- macOS 26.5.2 (build 25F84)
- MacBook Pro, Apple M4 Pro (arm64)
- 24 GB RAM