Why
display_item_urgency returns Urgency::Low as the default when a Group has zero items. The current code prevents this path, but there is no assertion that a Group always contains at least one item — a future refactor that constructs a stale DisplayItem::Group { items: vec![] } would silently be assigned Low urgency with no diagnostic.
Current state
ui/tui/src/display.rs lines 337–344: DisplayItem::Group { items, .. } => items.first().map(item_urgency).unwrap_or(domain::Urgency::Low). The unwrap_or fallback is currently unreachable but is not guarded by an assertion. A caller holding a zero-item Group silently receives the lowest possible urgency.
Ideal state
- An assertion
assert!(!items.is_empty(), "Group must contain at least one item") is present in display_item_urgency (and symmetrically in display_item_line).
- The empty-group invariant is explicit rather than implicitly maintained by construction order.
Starting points
ui/tui/src/display.rs — lines 337–344 (display_item_urgency) and the corresponding arm in display_item_line
QA plan
- Construct a
DisplayItem::Group { items: vec![] } and call display_item_urgency on it — expect an assertion failure rather than Urgency::Low.
- Run
cargo test — expect all existing tests pass.
Done when
display_item_urgency asserts a non-empty items list for Group variants, making the empty-group invariant explicit and catchable.
Why
display_item_urgencyreturnsUrgency::Lowas the default when aGrouphas zero items. The current code prevents this path, but there is no assertion that aGroupalways contains at least one item — a future refactor that constructs a staleDisplayItem::Group { items: vec![] }would silently be assignedLowurgency with no diagnostic.Current state
ui/tui/src/display.rslines 337–344:DisplayItem::Group { items, .. } => items.first().map(item_urgency).unwrap_or(domain::Urgency::Low). Theunwrap_orfallback is currently unreachable but is not guarded by an assertion. A caller holding a zero-item Group silently receives the lowest possible urgency.Ideal state
assert!(!items.is_empty(), "Group must contain at least one item")is present indisplay_item_urgency(and symmetrically indisplay_item_line).Starting points
ui/tui/src/display.rs— lines 337–344 (display_item_urgency) and the corresponding arm indisplay_item_lineQA plan
DisplayItem::Group { items: vec![] }and calldisplay_item_urgencyon it — expect an assertion failure rather thanUrgency::Low.cargo test— expect all existing tests pass.Done when
display_item_urgencyasserts a non-empty items list forGroupvariants, making the empty-group invariant explicit and catchable.