Skip to content

ctrl+v image + @file accepts images - #1695

Merged
pap-openai merged 44 commits into
mainfrom
copy_images
Aug 22, 2025
Merged

pap-openai merged 44 commits into
mainfrom
copy_images

Conversation

@pap-openai

@pap-openai pap-openai commented Jul 27, 2025 •

Copy link
Copy Markdown
Contributor

allow ctrl+v in TUI for images + @file that are images are appended as raw files (and read by the model) rather than pasted as a path that cannot be read by the model.

Re-used components and same interface we're using for copying pasted content in 72504f1. @aibrahim-oai as you've implemented this, mind having a look at this one?

ctrl-v-image.mp4

@pap-openai pap-openai changed the title ctrl+v image + /image ctrl+v image + @clipboard-image / @file Jul 27, 2025
@pap-openai pap-openai changed the title ctrl+v image + @clipboard-image / @file ctrl+v image + @file accepts images Aug 1, 2025
@aibrahim-oai

Copy link
Copy Markdown
Contributor

Can we have cmd + v also?

Comment thread codex-rs/tui/src/app.rs Outdated
/// Time window for debouncing redraw requests.
const REDRAW_DEBOUNCE: Duration = Duration::from_millis(10);

// Testable helper: generic over paste function so we can inject stubs in unit tests.

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.

Move it closer to the tests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For reference:

- Rust files should generally be organized such that the public parts of the API appear near the top of the file and helper functions go below. This is analagous to the "inverted pyramid" structure that is favored in journalism.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Though also, app.rs should be focused on driving the event loop. The specifics for how each event is handled should live in their own files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved it closer to test. @bolinfest do you suggest I move this to another file?

// Drop popup borrow before using self mutably again.
self.insert_selected_path(&sel_path);
// If selected path looks like an image (png/jpeg), attach as image instead of inserting text.
let is_image = {

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.

let's move the logic to a helper function so that we have better abstraction

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅

@github-actions

github-actions Bot commented Aug 20, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Comment thread codex-rs/tui/src/chatwidget.rs Resolved
Comment thread codex-rs/tui/src/chatwidget.rs Resolved
Comment thread codex-rs/tui/src/chatwidget.rs Resolved
Comment thread codex-rs/tui/src/clipboard_paste.rs Resolved
Comment thread codex-rs/tui/src/clipboard_paste.rs Resolved
Comment thread codex-rs/tui/src/app.rs Outdated
/// Time window for debouncing redraw requests.
const REDRAW_DEBOUNCE: Duration = Duration::from_millis(10);

// Testable helper: generic over paste function so we can inject stubs in unit tests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Though also, app.rs should be focused on driving the event loop. The specifics for how each event is handled should live in their own files.

Comment thread codex-rs/tui/src/app.rs Outdated
&& key_event.code == KeyCode::Char('v')
&& key_event
.modifiers
.contains(crossterm::event::KeyModifiers::CONTROL)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So does cmd get mapped to CONTROL in this case on macOS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, terminal don't paste events on CMD+V if content in clipboard is an image unfortunately, hence the ctrl+v. We could however change shortcuts or ask users to change shortcuts to support this (by sending keystroke we could listen for) but I feel like ctrl+v is a good start (similar to how we did ctrl+j for new lines for terminals that don't support shift+enter/kitty protocol).

Windows should work with ctrl+maj+v as this conditions should satisfy it, ignoring maj but sending the event. Ctrl+v will not work on windows as its the paste event and will probably not be sent to the terminal

Comment thread codex-rs/tui/src/app.rs Resolved
@pap-openai
pap-openai enabled auto-merge (squash) August 22, 2025 17:01
@pap-openai
pap-openai merged commit c5d21a4 into main Aug 22, 2025
@pap-openai
pap-openai deleted the copy_images branch August 22, 2025 17:05
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 22, 2025
@openai openai deleted a comment Aug 23, 2025
@openai openai deleted a comment Aug 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants