Treat pasted image paths as literal text in shell mode#24715
Treat pasted image paths as literal text in shell mode#24715etraut-openai wants to merge 1 commit into
Conversation
74b493d to
f25bb2d
Compare
f25bb2d to
bbb707c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbb707cf91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.draft.pending_pastes.push((placeholder, pasted)); | ||
| } else if char_count > 1 | ||
| && self.image_paste_enabled() | ||
| && !self.draft.is_bash_mode |
There was a problem hiding this comment.
Treat trimmed bang prompts as shell mode
This only disables image-path attachment when the internal bash-mode flag is set, but the rest of the composer treats leading-whitespace bang input as a shell command: is_bang_shell_command() uses trim_start(), and submission trims before shell dispatch. In a draft like !python script.py, pasting /tmp/a.png still attaches an image placeholder instead of inserting the literal path, so the submitted shell command receives [Image #1] rather than the file path. The new image-paste shortcut has the same starts_with('!') limitation, so both paste paths should use the same trimmed shell-command predicate.
Useful? React with 👍 / 👎.
| Ok(files | ||
| .into_iter() | ||
| .next() | ||
| .map(|path| path.to_string_lossy().into_owned())) |
There was a problem hiding this comment.
Quote file-list paths before shell insertion
When the shell-mode paste shortcut falls back to an OS file-list entry, this returns the raw filesystem path and handle_paste_image_shortcut() inserts it directly into the ! command buffer. User shell commands are later executed under the user's shell, so common image filenames like Screen Shot 2026-05-27.png are split into multiple arguments instead of being a usable literal path; file-list paths should be shell-escaped/quoted before insertion in this shell-only path.
Useful? React with 👍 / 👎.
|
|
||
| #[cfg(not(target_os = "android"))] | ||
| pub fn paste_text_or_file_path() -> Result<Option<String>, String> { | ||
| let mut cb = arboard::Clipboard::new().map_err(|e| format!("clipboard unavailable: {e}"))?; |
There was a problem hiding this comment.
Add WSL fallback for shell clipboard reads
In WSL shell mode, this new text/file-path clipboard path returns immediately when arboard::Clipboard::new() fails, but the existing image paste path has a PowerShell fallback because arboard cannot commonly access the Windows clipboard from WSL. As a result, pressing the shortcut in ! mode with Windows clipboard text or a copied file path now just warns and inserts nothing, even though the feature is supposed to paste clipboard text/file paths in shell mode; this path needs an equivalent WSL fallback for text/file lists.
Useful? React with 👍 / 👎.
Fixes #24711.
In shell mode, pasted content is intended to become shell command text. Treating a pasted local image path as an image attachment makes commands like
!open-image /path/to/image.pngharder to use because the path turns into an[Image #1]placeholder instead of remaining a usable argument.This keeps image-path conversion out of shell mode in both paste paths. Text paste handling now leaves image paths literal while chat mode still attaches images, and the
Ctrl+Vimage-paste shortcut reads clipboard text or an OS file path when the composer is in shell mode instead of creating an image attachment.