Lightweight coding agent that runs in your terminal
Rust
refactor: remove AttachImage tui event (#3191)
Jeremy Rose323a5cb7e70c
diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rsindex 40a7f20886..12cd789c5f 100644--- a/codex-rs/tui/src/app.rs+++ b/codex-rs/tui/src/app.rs@@ -183,15 +183,6 @@ impl App {},)?;}- TuiEvent::AttachImage {- path,- width,- height,- format_label,- } => {- self.chat_widget- .attach_image(path, width, height, format_label);- }}}Ok(true)diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rsindex 7acb802c73..65ecbf749f 100644--- a/codex-rs/tui/src/chatwidget.rs+++ b/codex-rs/tui/src/chatwidget.rs@@ -57,6 +57,7 @@ use crate::bottom_pane::CancellationEvent;use crate::bottom_pane::InputResult;use crate::bottom_pane::SelectionAction;use crate::bottom_pane::SelectionItem;+use crate::clipboard_paste::paste_image_to_temp_png;use crate::get_git_diff::get_git_diff;use crate::history_cell;use crate::history_cell::CommandOutput;@@ -745,6 +746,17 @@ impl ChatWidget {self.on_ctrl_c();return;}+ KeyEvent {+ code: KeyCode::Char('v'),+ modifiers: KeyModifiers::CONTROL,+ kind: KeyEventKind::Press,+ ..+ } => {+ if let Ok((path, info)) = paste_image_to_temp_png() {+ self.attach_image(path, info.width, info.height, info.encoded_format.label());+ }+ return;+ }other if other.kind == KeyEventKind::Press => {self.bottom_pane.clear_ctrl_c_quit_hint();}diff --git a/codex-rs/tui/src/tui.rs b/codex-rs/tui/src/tui.rsindex df957fee87..26c188668d 100644--- a/codex-rs/tui/src/tui.rs+++ b/codex-rs/tui/src/tui.rs@@ -1,7 +1,6 @@use std::io::Result;use std::io::Stdout;use std::io::stdout;-use std::path::PathBuf;use std::pin::Pin;use std::sync::Arc;use std::sync::atomic::AtomicBool;@@ -20,10 +19,7 @@ use crossterm::cursor::MoveTo;use crossterm::event::DisableBracketedPaste;use crossterm::event::EnableBracketedPaste;use crossterm::event::Event;-use crossterm::event::KeyCode;use crossterm::event::KeyEvent;-use crossterm::event::KeyEventKind;-use crossterm::event::KeyModifiers;use crossterm::event::KeyboardEnhancementFlags;use crossterm::event::PopKeyboardEnhancementFlags;use crossterm::event::PushKeyboardEnhancementFlags;@@ -38,7 +34,6 @@ use ratatui::crossterm::terminal::enable_raw_mode;use ratatui::layout::Offset;use ratatui::text::Line;-use crate::clipboard_paste::paste_image_to_temp_png;use crate::custom_terminal;use crate::custom_terminal::Terminal as CustomTerminal;use tokio::select;@@ -154,12 +149,6 @@ pub enum TuiEvent {Key(KeyEvent),Paste(String),Draw,- AttachImage {- path: PathBuf,- width: u32,- height: u32,- format_label: &'static str,- },}pub struct Tui {@@ -305,29 +294,6 @@ impl Tui {select! {Some(Ok(event)) = crossterm_events.next() => {match event {- // Detect Ctrl+V to attach an image from the clipboard.- Event::Key(key_event @ KeyEvent {- code: KeyCode::Char('v'),- modifiers: KeyModifiers::CONTROL,- kind: KeyEventKind::Press,- ..- }) => {- match paste_image_to_temp_png() {- Ok((path, info)) => {- yield TuiEvent::AttachImage {- path,- width: info.width,- height: info.height,- format_label: info.encoded_format.label(),- };- }- Err(_) => {- // Fall back to normal key handling if no image is available.- yield TuiEvent::Key(key_event);- }- }- }-crossterm::event::Event::Key(key_event) => {#[cfg(unix)]if matches!(