show "Viewed Image" when the model views an image (#4475)

<img width="1022" height="339" alt="Screenshot 2025-09-29 at 4 22 00 PM"
src="https://github.com/user-attachments/assets/12da7358-19be-4010-a71b-496ede6dfbbf"
/>
This commit is contained in:
Jeremy Rose
2025-10-02 11:36:03 -07:00
committed by GitHub
parent ec98445abf
commit 45936f8fbd
10 changed files with 83 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
source: tui/src/chatwidget/tests.rs
expression: combined
---
• Viewed Image
└ example.png

View File

@@ -35,6 +35,7 @@ use codex_core::protocol::ReviewRequest;
use codex_core::protocol::StreamErrorEvent;
use codex_core::protocol::TaskCompleteEvent;
use codex_core::protocol::TaskStartedEvent;
use codex_core::protocol::ViewImageToolCallEvent;
use codex_protocol::ConversationId;
use crossterm::event::KeyCode;
use crossterm::event::KeyEvent;
@@ -794,6 +795,25 @@ fn custom_prompt_enter_empty_does_not_send() {
assert!(rx.try_recv().is_err(), "no app event should be sent");
}
#[test]
fn view_image_tool_call_adds_history_cell() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
let image_path = chat.config.cwd.join("example.png");
chat.handle_codex_event(Event {
id: "sub-image".into(),
msg: EventMsg::ViewImageToolCall(ViewImageToolCallEvent {
call_id: "call-image".into(),
path: image_path,
}),
});
let cells = drain_insert_history(&mut rx);
assert_eq!(cells.len(), 1, "expected a single history cell");
let combined = lines_to_single_string(&cells[0]);
assert_snapshot!("local_image_attachment_history_snapshot", combined);
}
// Snapshot test: interrupting a running exec finalizes the active cell with a red ✗
// marker (replacing the spinner) and flushes it into history.
#[test]