Skip to content

Commit 20b08be

Browse files
authored
feat(console): details view tweaks (console-rs#52)
* feat(console): task view shows if the task is complete also, i rearranged the task metrics so they are less likely to line wrap when the terminal is small. * fix(console): missing waker drops in task view Signed-off-by: Eliza Weisman <eliza@buoyant.io>
1 parent be1229e commit 20b08be

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

console/src/tasks.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ impl Task {
209209
&self.formatted_fields
210210
}
211211

212+
pub(crate) fn is_completed(&self) -> bool {
213+
self.stats.total.is_some()
214+
}
215+
212216
pub(crate) fn total(&self, since: SystemTime) -> Duration {
213217
self.stats
214218
.total

console/src/view/task.rs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ impl TaskView {
3838
.direction(layout::Direction::Vertical)
3939
.constraints(
4040
[
41-
layout::Constraint::Length(5),
41+
layout::Constraint::Length(1),
42+
layout::Constraint::Length(6),
4243
layout::Constraint::Percentage(60),
4344
]
4445
.as_ref(),
4546
)
4647
.split(area);
4748

49+
let controls_area = chunks[0];
4850
let stats_area = Layout::default()
4951
.direction(layout::Direction::Horizontal)
5052
.constraints(
@@ -54,29 +56,50 @@ impl TaskView {
5456
]
5557
.as_ref(),
5658
)
57-
.split(chunks[0]);
59+
.split(chunks[1]);
5860

59-
let fields_area = chunks[1];
61+
let fields_area = chunks[2];
62+
63+
let controls = Spans::from(vec![
64+
Span::raw("controls: "),
65+
bold("esc"),
66+
Span::raw(" = return to task list, "),
67+
bold("q"),
68+
Span::raw(" = quit"),
69+
]);
6070

6171
let attrs = Spans::from(vec![bold("ID: "), Span::raw(task.id_hex())]);
6272

63-
let metrics = Spans::from(vec![
73+
let mut total = vec![
6474
bold("Total Time: "),
6575
Span::from(format!("{:.prec$?}", task.total(now), prec = DUR_PRECISION,)),
66-
Span::raw(", "),
76+
];
77+
78+
// TODO(eliza): maybe surface how long the task has been completed, as well?
79+
if task.is_completed() {
80+
total.push(Span::raw(" (completed)"));
81+
};
82+
83+
let total = Spans::from(total);
84+
85+
let busy = Spans::from(vec![
6786
bold("Busy: "),
6887
Span::from(format!("{:.prec$?}", task.busy(), prec = DUR_PRECISION,)),
69-
Span::raw(", "),
88+
]);
89+
let idle = Spans::from(vec![
7090
bold("Idle: "),
7191
Span::from(format!("{:.prec$?}", task.idle(now), prec = DUR_PRECISION,)),
7292
]);
7393

94+
let metrics = vec![attrs, total, busy, idle];
95+
7496
let wakers = Spans::from(vec![
7597
bold("Current wakers: "),
7698
Span::from(format!("{} (", task.waker_count())),
7799
bold("clones: "),
78100
Span::from(format!("{}, ", task.waker_clones())),
79101
bold("drops: "),
102+
Span::from(format!("{})", task.waker_drops())),
80103
]);
81104

82105
let mut wakeups = vec![
@@ -100,10 +123,11 @@ impl TaskView {
100123
let mut fields = Text::default();
101124
fields.extend(task.formatted_fields().iter().cloned().map(Spans::from));
102125

103-
let task_widget = Paragraph::new(vec![attrs, metrics]).block(block_for("Task"));
126+
let task_widget = Paragraph::new(metrics).block(block_for("Task"));
104127
let wakers_widget = Paragraph::new(vec![wakers, wakeups]).block(block_for("Waker"));
105128
let fields_widget = Paragraph::new(fields).block(block_for("Fields"));
106129

130+
frame.render_widget(Block::default().title(controls), controls_area);
107131
frame.render_widget(task_widget, stats_area[0]);
108132
frame.render_widget(wakers_widget, stats_area[1]);
109133
frame.render_widget(fields_widget, fields_area);

0 commit comments

Comments
 (0)