Skip to content

Commit 07c1db3

Browse files
rework patch/exec approval UI (#4573)
| Scenario | Screenshot | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | short patch | <img width="1096" height="533" alt="short patch" src="https://github.com/user-attachments/assets/8a883429-0965-4c0b-9002-217b3759b557" /> | | short command | <img width="1096" height="533" alt="short command" src="https://github.com/user-attachments/assets/901abde8-2494-4e86-b98a-7cabaf87ca9c" /> | | long patch | <img width="1129" height="892" alt="long patch" src="https://github.com/user-attachments/assets/fa799a29-a0d6-48e6-b2ef-10302a7916d3" /> | | long command | <img width="1096" height="892" alt="long command" src="https://github.com/user-attachments/assets/11ddf79b-98cb-4b60-ac22-49dfa7779343" /> | | viewing complete patch | <img width="1129" height="892" alt="viewing complete patch" src="https://github.com/user-attachments/assets/81666958-af94-420e-aa66-b60d0a42b9db" /> |
1 parent 31102af commit 07c1db3

30 files changed

+1125
-1139
lines changed

codex-rs/tui/src/app.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
use crate::app_backtrack::BacktrackState;
22
use crate::app_event::AppEvent;
33
use crate::app_event_sender::AppEventSender;
4+
use crate::bottom_pane::ApprovalRequest;
45
use crate::chatwidget::ChatWidget;
6+
use crate::diff_render::DiffSummary;
7+
use crate::exec_command::strip_bash_lc_and_escape;
58
use crate::file_search::FileSearchManager;
69
use crate::history_cell::HistoryCell;
710
use crate::pager_overlay::Overlay;
11+
use crate::render::highlight::highlight_bash_to_lines;
812
use crate::resume_picker::ResumeSelection;
913
use crate::tui;
1014
use crate::tui::TuiEvent;
@@ -292,7 +296,7 @@ impl App {
292296
} else {
293297
text.lines().map(ansi_escape_line).collect()
294298
};
295-
self.overlay = Some(Overlay::new_static_with_title(
299+
self.overlay = Some(Overlay::new_static_with_lines(
296300
pager_lines,
297301
"D I F F".to_string(),
298302
));
@@ -324,12 +328,18 @@ impl App {
324328
Ok(()) => {
325329
if let Some(profile) = profile {
326330
self.chat_widget.add_info_message(
327-
format!("Model changed to {model} for {profile} profile"),
331+
format!("Model changed to {model}{reasoning_effort} for {profile} profile", reasoning_effort = effort.map(|e| format!(" {e}")).unwrap_or_default()),
328332
None,
329333
);
330334
} else {
331-
self.chat_widget
332-
.add_info_message(format!("Model changed to {model}"), None);
335+
self.chat_widget.add_info_message(
336+
format!(
337+
"Model changed to {model}{reasoning_effort}",
338+
reasoning_effort =
339+
effort.map(|e| format!(" {e}")).unwrap_or_default()
340+
),
341+
None,
342+
);
333343
}
334344
}
335345
Err(err) => {
@@ -363,6 +373,25 @@ impl App {
363373
AppEvent::OpenReviewCustomPrompt => {
364374
self.chat_widget.show_review_custom_prompt();
365375
}
376+
AppEvent::FullScreenApprovalRequest(request) => match request {
377+
ApprovalRequest::ApplyPatch { cwd, changes, .. } => {
378+
let _ = tui.enter_alt_screen();
379+
let diff_summary = DiffSummary::new(changes, cwd);
380+
self.overlay = Some(Overlay::new_static_with_renderables(
381+
vec![diff_summary.into()],
382+
"P A T C H".to_string(),
383+
));
384+
}
385+
ApprovalRequest::Exec { command, .. } => {
386+
let _ = tui.enter_alt_screen();
387+
let full_cmd = strip_bash_lc_and_escape(&command);
388+
let full_cmd_lines = highlight_bash_to_lines(&full_cmd);
389+
self.overlay = Some(Overlay::new_static_with_lines(
390+
full_cmd_lines,
391+
"E X E C".to_string(),
392+
));
393+
}
394+
},
366395
}
367396
Ok(true)
368397
}

codex-rs/tui/src/app_event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use codex_core::protocol::ConversationPathResponseEvent;
44
use codex_core::protocol::Event;
55
use codex_file_search::FileMatch;
66

7+
use crate::bottom_pane::ApprovalRequest;
78
use crate::history_cell::HistoryCell;
89

910
use codex_core::protocol::AskForApproval;
@@ -76,4 +77,7 @@ pub(crate) enum AppEvent {
7677

7778
/// Open the custom prompt option from the review popup.
7879
OpenReviewCustomPrompt,
80+
81+
/// Open the approval popup.
82+
FullScreenApprovalRequest(ApprovalRequest),
7983
}

0 commit comments

Comments
 (0)