Skip to content

Treat pasted image paths as literal text in shell mode#24715

Open
etraut-openai wants to merge 1 commit into
mainfrom
etraut/shell-mode-image-path-paste
Open

Treat pasted image paths as literal text in shell mode#24715
etraut-openai wants to merge 1 commit into
mainfrom
etraut/shell-mode-image-path-paste

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented May 27, 2026

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.png harder 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+V image-paste shortcut reads clipboard text or an OS file path when the composer is in shell mode instead of creating an image attachment.

@etraut-openai etraut-openai marked this pull request as ready for review May 27, 2026 05:50
@etraut-openai etraut-openai force-pushed the etraut/shell-mode-image-path-paste branch from 74b493d to f25bb2d Compare May 27, 2026 06:09
@etraut-openai etraut-openai force-pushed the etraut/shell-mode-image-path-paste branch from f25bb2d to bbb707c Compare May 27, 2026 06:15
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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}"))?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Treat pasted image paths as literal text in shell mode

1 participant