diff --git a/crates/tui/src/chatwidget/render.rs b/crates/tui/src/chatwidget/render.rs index 27c7dbb4..610c92a7 100644 --- a/crates/tui/src/chatwidget/render.rs +++ b/crates/tui/src/chatwidget/render.rs @@ -119,7 +119,6 @@ impl Renderable for ChatWidget { history_height .saturating_add(self.subagent_live_list_desired_height()) .saturating_add(self.bottom_pane.desired_height(width)) - .saturating_add(2) } fn cursor_pos(&self, area: Rect) -> Option<(u16, u16)> { @@ -136,15 +135,19 @@ impl Renderable for ChatWidget { impl ChatWidget { fn chat_layout_areas(&self, area: Rect) -> (Rect, Rect, Rect) { - let bottom_height = self - .bottom_pane - .desired_height(area.width) - .min(area.height.saturating_sub(1).max(3)); + let bottom_height = self.bottom_pane.desired_height(area.width).min(area.height); let subagent_height = self .subagent_live_list_desired_height() - .min(area.height.saturating_sub(bottom_height).saturating_sub(1)); + .min(area.height.saturating_sub(bottom_height)); + let history_height = u16::try_from(self.active_viewport_lines(area.width.max(1)).len()) + .unwrap_or(u16::MAX) + .min( + area.height + .saturating_sub(bottom_height) + .saturating_sub(subagent_height), + ); let [history_area, subagent_area, bottom_area] = Layout::vertical([ - Constraint::Min(1), + Constraint::Length(history_height), Constraint::Length(subagent_height), Constraint::Length(bottom_height), ])