From 962238485b45458accd81aeda4bb8ea79a2371f7 Mon Sep 17 00:00:00 2001 From: devanbenz Date: Sat, 17 Feb 2024 12:17:10 -0600 Subject: [PATCH 1/2] feat: Adjust task and waker panel for long names --- tokio-console/src/view/task.rs | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/tokio-console/src/view/task.rs b/tokio-console/src/view/task.rs index 8f3024520..7c4836ff4 100644 --- a/tokio-console/src/view/task.rs +++ b/tokio-console/src/view/task.rs @@ -9,6 +9,7 @@ use crate::{ help::HelpText, }, }; +use ratatui::widgets::Wrap; use ratatui::{ layout::{self, Layout}, text::{Span, Spans, Text}, @@ -131,8 +132,8 @@ impl TaskView { .direction(layout::Direction::Horizontal) .constraints( [ - layout::Constraint::Percentage(50), - layout::Constraint::Percentage(50), + layout::Constraint::Percentage(60), + layout::Constraint::Percentage(40), ] .as_ref(), ) @@ -156,16 +157,8 @@ impl TaskView { ])); let title = "Location: "; - let location_max_width = stats_area[0].width as usize - 2 - title.len(); // NOTE: -2 for the border - let location = if task.location().len() > location_max_width { - let ellipsis = styles.if_utf8("\u{2026}", "..."); - let start = task.location().len() - location_max_width + ellipsis.chars().count(); - format!("{}{}", ellipsis, &task.location()[start..]) - } else { - task.location().to_string() - }; - overview.push(Spans::from(vec![bold(title), Span::raw(location)])); + overview.push(Spans::from(vec![bold(title), Span::raw(task.location())])); let total = task.total(now); @@ -195,21 +188,21 @@ impl TaskView { Span::from(format!("{})", task.waker_drops())), ])]; - let mut wakeups = vec![ + let wakeups = vec![ bold("Woken: "), Span::from(format!("{} times", task.wakes())), ]; + waker_stats.push(Spans::from(wakeups)); + // If the task has been woken, add the time since wake to its stats as well. if let Some(since) = task.since_wake(now) { - wakeups.reserve(3); - wakeups.push(Span::raw(", ")); - wakeups.push(bold("last woken:")); - wakeups.push(Span::from(format!(" {:?} ago", since))); + waker_stats.push(Spans::from(vec![ + bold("Last woken:"), + Span::from(format!(" {:?} ago", since)), + ])); } - waker_stats.push(Spans::from(wakeups)); - if task.self_wakes() > 0 { waker_stats.push(Spans::from(vec![ bold("Self Wakes: "), @@ -229,7 +222,9 @@ impl TaskView { frame.render_widget(warnings, warnings_area); } - let task_widget = Paragraph::new(overview).block(styles.border_block().title("Task")); + let task_widget = Paragraph::new(overview) + .wrap(Wrap { trim: true }) + .block(styles.border_block().title("Task")); let wakers_widget = Paragraph::new(waker_stats).block(styles.border_block().title("Waker")); let poll_percentiles_title = "Poll Times Percentiles"; From b266c677390243d16fa38c92feca409cbbb1f032 Mon Sep 17 00:00:00 2001 From: Devan Date: Sat, 17 Feb 2024 21:03:03 -0600 Subject: [PATCH 2/2] ci