Compare commits

...

1 Commits

Author SHA1 Message Date
Jeremy Rose
5fdeb074db handle PatchApplyEnd 2025-08-04 15:50:37 -07:00
2 changed files with 28 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ use codex_core::protocol::McpToolCallBeginEvent;
use codex_core::protocol::McpToolCallEndEvent;
use codex_core::protocol::Op;
use codex_core::protocol::PatchApplyBeginEvent;
use codex_core::protocol::PatchApplyEndEvent;
use codex_core::protocol::TaskCompleteEvent;
use codex_core::protocol::TokenUsage;
use crossterm::event::KeyEvent;
@@ -386,6 +387,16 @@ impl ChatWidget<'_> {
changes,
));
}
EventMsg::PatchApplyEnd(PatchApplyEndEvent {
call_id: _,
stdout,
stderr,
success,
}) => {
if !success {
self.add_to_history(HistoryCell::new_patch_failed_event(stdout, stderr));
}
}
EventMsg::ExecCommandEnd(ExecCommandEndEvent {
call_id,
exit_code,

View File

@@ -113,6 +113,9 @@ pub(crate) enum HistoryCell {
/// model wants to apply before being prompted to approve or deny it.
PendingPatch { view: TextBlock },
/// A patch failed to apply.
PatchFailed { view: TextBlock },
/// A humanfriendly rendering of the model's current plan and step
/// statuses provided via the `update_plan` tool.
PlanUpdate { view: TextBlock },
@@ -137,6 +140,7 @@ impl HistoryCell {
| HistoryCell::CompletedExecCommand { view }
| HistoryCell::CompletedMcpToolCall { view }
| HistoryCell::PendingPatch { view }
| HistoryCell::PatchFailed { view }
| HistoryCell::PlanUpdate { view }
| HistoryCell::ActiveExecCommand { view, .. }
| HistoryCell::ActiveMcpToolCall { view, .. } => {
@@ -148,6 +152,7 @@ impl HistoryCell {
],
}
}
pub(crate) fn new_session_info(
config: &Config,
event: SessionConfiguredEvent,
@@ -629,6 +634,18 @@ impl HistoryCell {
view: TextBlock::new(lines),
}
}
pub fn new_patch_failed_event(stdout: String, stderr: String) -> Self {
let lines: Vec<Line<'static>> = vec![
Line::from("patch failed".red().bold()),
Line::from(stdout),
Line::from(stderr),
Line::from(""),
];
HistoryCell::PatchFailed {
view: TextBlock::new(lines),
}
}
}
fn create_diff_summary(changes: HashMap<PathBuf, FileChange>) -> Vec<String> {