1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Footer indicator for detached background commands (#762).
//!
//! A genuinely long command (`cargo test`, a build) runs detached so it does
//! not churn toward the bash 600s cap, and the turn ends immediately. That
//! left the TUI with nothing to draw: the agent says it is waiting, the
//! spinner is gone because no turn is active, and a five-minute build is
//! indistinguishable from a hang.
//!
//! Pure formatting, so the shape is testable without a terminal or a live
//! task. Elapsed seconds are passed in rather than read from a clock here.
/// How much of a command label the indicator shows.
///
/// The stored label allows 60 characters, which is fine for a log line and far
/// too long for a border title: a full `cargo test --locked --profile ci --lib
/// 2>&1 | tail -40` crowded out everything beside it. The leading words are
/// what identify the command, so the tail is what gets dropped.
pub const LABEL_CHARS: usize = 28;
/// `cargo test 32s`, or `cargo test 32s +2` when other tasks are also running.
///
/// The oldest task is the one named: it is the one the user has been waiting
/// on longest, and it is the one whose elapsed time answers "is this stuck".
/// `None` when nothing is running, so the caller omits the field entirely
/// rather than showing an empty slot.
///
/// `max_label` truncates the command, never the elapsed time or the overflow
/// count: those are short, fixed-width, and the whole point of the indicator.
pub
/// Cut `label` to `max` characters, marking the cut. Counts chars, not bytes,
/// so a command carrying non-ASCII does not split mid-character.
/// `32s` / `4m 20s` / `1h 5m`, matching the turn header's duration style so the
/// two read as the same kind of number.