From 6923ee439f269de41603b6258273f2f8c63a2ba9 Mon Sep 17 00:00:00 2001 From: vikingowl Date: Mon, 13 Oct 2025 23:04:36 +0200 Subject: [PATCH] =?UTF-8?q?fix(tui):=20add=20width=20bounds=20and=20y?= =?UTF-8?q?=E2=80=91position=20clamp=20for=20popups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Limit popup width to a configurable range (40‑80 characters) and ensure a minimum width of 1. - Preserve original width when the terminal is narrower than the minimum. - Clamp the y coordinate to the top of the area to avoid negative positioning. --- crates/owlen-tui/src/ui.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/owlen-tui/src/ui.rs b/crates/owlen-tui/src/ui.rs index f680a96..c5b259e 100644 --- a/crates/owlen-tui/src/ui.rs +++ b/crates/owlen-tui/src/ui.rs @@ -3768,17 +3768,21 @@ fn render_command_suggestions(frame: &mut Frame<'_>, app: &ChatApp) { let mut height = visible_count.saturating_mul(2).saturating_add(6); height = height.clamp(6, area.height); - let mut width = area.width.saturating_sub(10); - if width < 50 { - width = area.width.saturating_sub(4); - } - if width == 0 { + let max_width: u16 = 80; + let min_width: u16 = 40; + let mut width = area.width.min(max_width); + if area.width >= min_width { + width = width.max(min_width); + } else { width = area.width; } - let width = width.min(area.width); + width = width.max(1); let x = area.x + (area.width.saturating_sub(width)) / 2; - let y = area.y + (area.height.saturating_sub(height)) / 3; + let mut y = area.y + (area.height.saturating_sub(height)) / 3; + if y < area.y { + y = area.y; + } let popup_area = Rect::new(x, y, width, height); frame.render_widget(Clear, popup_area);