fix(timeline): report true total_events in robot JSON meta

The robot JSON envelope's meta.total_events field was incorrectly
reporting events.len() (the post-limit count), making it identical
to meta.showing. This defeated the purpose of having both fields.

Changes across the pipeline to fix this:

- collect_events now returns (Vec<TimelineEvent>, usize) where the
  second element is the total event count before truncation
- TimelineResult gains a total_events_before_limit field (serde-skipped)
  so the value flows cleanly from collect through to the renderer
- main.rs passes the real total instead of the events.len() workaround

Additional cleanup in this pass:

- Derive PartialEq/Eq/PartialOrd/Ord on TimelineEventType, replacing
  the hand-rolled event_type_discriminant() function. Variant declaration
  order now defines sort tiebreak, documented in a doc comment.
- Validate --since input with a proper LoreError::Other instead of
  silently treating invalid values as None
- Fix ANSI-aware tag column padding with console::pad_str (colored tags
  like "[merged]" were misaligned because ANSI escapes consumed width)
- Remove dead print_timeline_json and infer_max_depth functions that
  were superseded by print_timeline_json_with_meta

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-02-06 09:35:02 -05:00
parent f1cb45a168
commit 32783080f1
5 changed files with 47 additions and 73 deletions

View File

@@ -170,7 +170,7 @@ fn pipeline_seed_expand_collect_end_to_end() {
assert!(total_entities >= 2, "Should have at least issue + MR");
// COLLECT: gather all events
let events = collect_events(
let (events, _) = collect_events(
&conn,
&seed_result.seed_entities,
&expand_result.expanded_entities,
@@ -224,7 +224,7 @@ fn pipeline_empty_query_produces_empty_result() {
let expand_result = expand_timeline(&conn, &seed_result.seed_entities, 1, false, 100).unwrap();
assert!(expand_result.expanded_entities.is_empty());
let events = collect_events(
let (events, _) = collect_events(
&conn,
&seed_result.seed_entities,
&expand_result.expanded_entities,
@@ -259,7 +259,7 @@ fn pipeline_since_filter_excludes_old_events() {
let expand_result = expand_timeline(&conn, &seed_result.seed_entities, 0, false, 100).unwrap();
// Collect with since=5000: should exclude Created(1000) and closed(2000)
let events = collect_events(
let (events, _) = collect_events(
&conn,
&seed_result.seed_entities,
&expand_result.expanded_entities,