From 1e82bf9d98f69a89ac84bd91ac71d3da4d8f52af Mon Sep 17 00:00:00 2001 From: Jeremy Rose <172423086+nornagon-openai@users.noreply.github.com> Date: Thu, 4 Sep 2025 08:51:02 -0700 Subject: [PATCH] tui: avoid panic when active exec cell area is zero height (#3133) #### Summary Avoid a potential panic when rendering the active execution cell when the allocated area has zero height. #### Changes - Guard rendering with `active_cell_area.height > 0` and presence of `active_exec_cell`. - Use `saturating_add(1)` for the Y offset to avoid overflow. - Render via `active_exec_cell.as_ref().unwrap().render_ref(...)` after the explicit `is_some` check. --- codex-rs/tui/src/chatwidget.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 75149211..e8381c6f 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -1371,9 +1371,11 @@ impl WidgetRef for &ChatWidget { fn render_ref(&self, area: Rect, buf: &mut Buffer) { let [active_cell_area, bottom_pane_area] = self.layout_areas(area); (&self.bottom_pane).render(bottom_pane_area, buf); - if let Some(cell) = &self.active_exec_cell { + if !active_cell_area.is_empty() + && let Some(cell) = &self.active_exec_cell + { let mut active_cell_area = active_cell_area; - active_cell_area.y += 1; + active_cell_area.y = active_cell_area.y.saturating_add(1); active_cell_area.height -= 1; cell.render_ref(active_cell_area, buf); }