aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-08 14:53:45 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-08 14:53:45 +0300
commitc08e51e666f6df9a940393b568943b67940ceedc (patch)
tree6a6c4cd3c8ea5ddf9e97a4695c6b0d31eb0d0717 /src/ui
parentb0aa7b2cddc57a55a1c0285a1ea82b59ac9783bd (diff)
feat: make agent toasts focus panes
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/mobile.rs18
-rw-r--r--src/ui/status.rs26
2 files changed, 30 insertions, 14 deletions
diff --git a/src/ui/mobile.rs b/src/ui/mobile.rs
index 79f97136..50cbed0c 100644
--- a/src/ui/mobile.rs
+++ b/src/ui/mobile.rs
@@ -172,6 +172,18 @@ pub(crate) fn render_mobile_header(app: &AppState, frame: &mut Frame, area: Rect
render_switch_button(app, frame, switch);
}
+pub(crate) fn mobile_toast_banner_rect(area: Rect, offset_for_warning: bool) -> Rect {
+ if area.width == 0 || area.height == 0 {
+ return Rect::default();
+ }
+
+ let y = area.y
+ + area
+ .height
+ .saturating_sub(1 + if offset_for_warning { 1 } else { 0 });
+ Rect::new(area.x, y, area.width, 1)
+}
+
pub(crate) fn render_mobile_toast_banner(
frame: &mut Frame,
area: Rect,
@@ -188,11 +200,7 @@ pub(crate) fn render_mobile_toast_banner(
ToastKind::Finished => p.blue,
ToastKind::UpdateInstalled => p.accent,
};
- let y = area.y
- + area
- .height
- .saturating_sub(1 + if offset_for_warning { 1 } else { 0 });
- let banner = Rect::new(area.x, y, area.width, 1);
+ let banner = mobile_toast_banner_rect(area, offset_for_warning);
let bg = p.surface0;
frame.render_widget(Clear, banner);
diff --git a/src/ui/status.rs b/src/ui/status.rs
index 2eece8a0..bb506da6 100644
--- a/src/ui/status.rs
+++ b/src/ui/status.rs
@@ -12,6 +12,22 @@ use crate::{
detect::AgentState,
};
+pub(crate) fn toast_notification_rect(
+ area: Rect,
+ toast: &ToastNotification,
+ offset_for_warning: bool,
+) -> Rect {
+ let content_width = (toast.title.len().max(toast.context.len()) as u16) + 4;
+ let width = content_width.saturating_add(2).min(area.width);
+ let height = 4u16.min(area.height);
+ let x = area.x + area.width.saturating_sub(width);
+ let y = area.y
+ + area
+ .height
+ .saturating_sub(height + if offset_for_warning { 1 } else { 0 });
+ Rect::new(x, y, width, height)
+}
+
pub(super) fn render_toast_notification(
frame: &mut Frame,
area: Rect,
@@ -24,15 +40,7 @@ pub(super) fn render_toast_notification(
ToastKind::Finished => p.blue,
ToastKind::UpdateInstalled => p.accent,
};
- let content_width = (toast.title.len().max(toast.context.len()) as u16) + 4;
- let width = content_width.saturating_add(2).min(area.width);
- let height = 4u16.min(area.height);
- let x = area.x + area.width.saturating_sub(width);
- let y = area.y
- + area
- .height
- .saturating_sub(height + if offset_for_warning { 1 } else { 0 });
- let toast_area = Rect::new(x, y, width, height);
+ let toast_area = toast_notification_rect(area, toast, offset_for_warning);
frame.render_widget(Clear, toast_area);
let block = Block::default()