Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions src/cortex-tui-components/src/toast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,32 +275,38 @@ impl ToastManager {
}

/// Adds a toast to the manager and returns its ID.
pub fn push(&mut self, mut toast: Toast) -> u64 {
let id = self.next_id;
self.next_id += 1;
toast.id = id;
self.toasts.insert(0, toast);
id
pub fn push(&mut self, toast: Toast) -> u64 {
// Toast notifications disabled
let _ = toast;
0
}

/// Adds a success toast and returns its ID.
pub fn success(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::success(message))
// Toast notifications disabled
let _ = message;
0
}

/// Adds an info toast and returns its ID.
pub fn info(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::info(message))
// Toast notifications disabled
let _ = message;
0
}

/// Adds a warning toast and returns its ID.
pub fn warning(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::warning(message))
// Toast notifications disabled
let _ = message;
0
}

/// Adds an error toast and returns its ID.
pub fn error(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::error(message))
// Toast notifications disabled
let _ = message;
0
}

/// Removes a specific toast by ID.
Expand Down Expand Up @@ -610,21 +616,26 @@ mod tests {

#[test]
fn test_toast_manager_push() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new();
let id1 = manager.success("First");
let id2 = manager.info("Second");
assert_eq!(manager.len(), 2);
assert_ne!(id1, id2);
assert_eq!(manager.len(), 0);
assert!(manager.is_empty());
assert_eq!(id1, 0);
assert_eq!(id2, 0);
}

#[test]
fn test_toast_manager_visible_limit() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new().with_max_visible(2);
manager.success("First");
manager.info("Second");
manager.warning("Third");
let visible = manager.visible();
assert_eq!(visible.len(), 2);
assert_eq!(visible.len(), 0);
assert!(manager.is_empty());
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions src/cortex-tui/src/runner/event_loop/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ impl EventLoop {
// Apply selection highlight
self.apply_selection_highlight(frame.buffer_mut());

// Render toast notifications
if !self.app_state.toasts.is_empty() {
let toast_widget = crate::widgets::ToastWidget::new(&self.app_state.toasts)
.terminal_size(area.width, area.height);
toast_widget.render(area, frame.buffer_mut());
}
// Toast notifications disabled
// if !self.app_state.toasts.is_empty() {
// let toast_widget = crate::widgets::ToastWidget::new(&self.app_state.toasts)
// .terminal_size(area.width, area.height);
// toast_widget.render(area, frame.buffer_mut());
// }
})?;

// Capture frame for TUI debugging
Expand Down
76 changes: 41 additions & 35 deletions src/cortex-tui/src/widgets/toast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,33 +274,38 @@ impl ToastManager {
}

/// Adds a toast to the manager and returns its ID.
pub fn push(&mut self, mut toast: Toast) -> u64 {
let id = self.next_id;
self.next_id += 1;
toast.id = id;
// Insert at the beginning (newest first)
self.toasts.insert(0, toast);
id
pub fn push(&mut self, toast: Toast) -> u64 {
// Toast notifications disabled
let _ = toast;
0
}

/// Adds a success toast and returns its ID.
pub fn success(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::success(message))
// Toast notifications disabled
let _ = message;
0
}

/// Adds an info toast and returns its ID.
pub fn info(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::info(message))
// Toast notifications disabled
let _ = message;
0
}

/// Adds a warning toast and returns its ID.
pub fn warning(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::warning(message))
// Toast notifications disabled
let _ = message;
0
}

/// Adds an error toast and returns its ID.
pub fn error(&mut self, message: impl Into<String>) -> u64 {
self.push(Toast::error(message))
// Toast notifications disabled
let _ = message;
0
}

/// Removes a specific toast by ID.
Expand Down Expand Up @@ -636,24 +641,25 @@ mod tests {

#[test]
fn test_toast_manager_push() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new();

let id1 = manager.success("First");
let id2 = manager.info("Second");
let id3 = manager.warning("Third");

assert_eq!(manager.len(), 3);
assert!(!manager.is_empty());
assert_eq!(manager.len(), 0);
assert!(manager.is_empty());

// IDs should be unique and incrementing
assert_ne!(id1, id2);
assert_ne!(id2, id3);
assert!(id2 > id1);
assert!(id3 > id2);
// All IDs should be 0 (no-op)
assert_eq!(id1, 0);
assert_eq!(id2, 0);
assert_eq!(id3, 0);
}

#[test]
fn test_toast_manager_dismiss() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new();

let id1 = manager.success("First");
Expand All @@ -662,60 +668,60 @@ mod tests {

manager.dismiss(id2);

assert_eq!(manager.len(), 2);

// Check remaining toasts
let visible = manager.visible();
let ids: Vec<u64> = visible.iter().map(|t| t.id).collect();
assert!(!ids.contains(&id2));
assert!(ids.contains(&id1));
assert!(ids.contains(&id3));
// No toasts stored, so nothing to dismiss
assert_eq!(manager.len(), 0);
assert!(manager.is_empty());
assert_eq!(id1, 0);
assert_eq!(id2, 0);
assert_eq!(id3, 0);
}

#[test]
fn test_toast_manager_clear() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new();

manager.success("First");
manager.info("Second");
manager.warning("Third");

assert_eq!(manager.len(), 3);
// No toasts stored (disabled)
assert_eq!(manager.len(), 0);
assert!(manager.is_empty());

manager.clear();

// Still empty after clear
assert!(manager.is_empty());
assert_eq!(manager.len(), 0);
}

#[test]
fn test_toast_manager_visible_limit() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new().with_max_visible(2);

manager.success("First");
manager.info("Second");
manager.warning("Third");

let visible = manager.visible();
assert_eq!(visible.len(), 2);

// Should be newest first
assert_eq!(visible[0].message, "Third");
assert_eq!(visible[1].message, "Second");
assert_eq!(visible.len(), 0);
assert!(manager.is_empty());
}

#[test]
fn test_toast_manager_newest_first() {
// Toast notifications are disabled - verifying no-op behavior
let mut manager = ToastManager::new();

manager.success("First");
manager.info("Second");
manager.warning("Third");

let visible = manager.visible();
assert_eq!(visible[0].message, "Third");
assert_eq!(visible[1].message, "Second");
assert_eq!(visible[2].message, "First");
assert_eq!(visible.len(), 0);
assert!(manager.is_empty());
}

#[test]
Expand Down
Loading