diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index 3337671..cff8de8 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -59,6 +59,7 @@ const PREVIEW_SUCCESS: Color32 = Color32::from_rgb(115, 205, 150); const PREVIEW_AMBER: Color32 = Color32::from_rgb(235, 190, 95); const PREVIEW_GAP: Color32 = Color32::from_rgb(110, 200, 215); const PREVIEW_RED: Color32 = Color32::from_rgb(245, 125, 120); +const PREVIEW_INFERRED: Color32 = Color32::from_rgb(185, 160, 245); const COLUMN_FOCUS_PULSE_SECONDS: f64 = 1.8; fn needs_information(d: &Diagnostic) -> bool { @@ -86,6 +87,9 @@ struct PreviewRow { start: String, end: String, duration: String, + inferred_start: bool, + inferred_end: bool, + inferred_duration: bool, title: String, source_only: bool, automatically_ignored: bool, @@ -192,9 +196,19 @@ fn row_hover_text(row: &PreviewRow, analysis: &Analysis, status: &str) -> String explanation.push_str("\n\n"); } explanation.push_str(&format!("Status: {status}")); - if !row.decisions.is_empty() { + let other_decisions = row + .decisions + .lines() + .filter(|line| { + !line.starts_with("Start derived ") + && !line.starts_with("End derived ") + && !line.starts_with("Duration derived ") + }) + .collect::>() + .join("\n"); + if !other_decisions.is_empty() { explanation.push('\n'); - explanation.push_str(&row.decisions); + explanation.push_str(&other_decisions); } if row.row > 0 { explanation @@ -217,17 +231,16 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec { } rows.push(PreviewRow { row: e.source_rows.first().map_or(0, |s| s.row), - start: format!( - "{}{}", - display(e.start_ms), - if e.explicit_start { "" } else { " *" } - ), + start: display(e.start_ms), end: display(e.end_ms), duration: if e.kind == "marker" { "Marker".into() } else { display(e.duration_ms) }, + inferred_start: !e.explicit_start, + inferred_end: e.inferred_end, + inferred_duration: e.inferred_duration, title: e.title.clone(), source_only: false, automatically_ignored: false, @@ -290,6 +303,9 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec { start: raw(a.mapping.as_ref().map(|m| m.start)), end: raw(a.mapping.as_ref().and_then(|m| m.end)), duration: raw(a.mapping.as_ref().and_then(|m| m.duration)), + inferred_start: false, + inferred_end: false, + inferred_duration: false, title, source_only: true, automatically_ignored: false, @@ -371,6 +387,9 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec { start: gap.start_ms.map(display).unwrap_or_else(|| "?".into()), end: gap.end_ms.map(display).unwrap_or_else(|| "?".into()), duration: gap.start_ms.zip(gap.end_ms).map(|(start, end)| display(end - start)).unwrap_or_else(|| "?".into()), + inferred_start: false, + inferred_end: false, + inferred_duration: false, title: if rundown.resolved_gaps.iter().any(|g| g.key() == gap.key()) { "Allocated gap · included in adjacent timer".into() } else { gap.title.clone() }, @@ -1248,8 +1267,9 @@ impl App { ui.colored_label(PREVIEW_AMBER, "Unresolved"); ui.colored_label(PREVIEW_RED, "Error"); ui.colored_label(PREVIEW_GAP, "Gap / allocated interval"); + ui.colored_label(PREVIEW_INFERRED, "Inferred timing"); ui.weak("Ignored"); - ui.small("? unknown · * inferred · edits require recheck"); + ui.small("? unknown · edits require recheck"); }); let table = self.tables.iter().find(|t| t.name == a.sheet); let all_rows = preview_rows(a, table); @@ -1390,19 +1410,39 @@ impl App { ui.vertical(|ui| { ui.set_width(105.0); ui.set_min_height(row_height); - for (label, value) in [ - ("Start", &row.start), - ("End", &row.end), - ("Dur.", &row.duration), + for (label, value, inferred) in [ + ("Start", &row.start, row.inferred_start), + ("End", &row.end, row.inferred_end), + ("Dur.", &row.duration, row.inferred_duration), ] { - ui.colored_label(color, format!("{label} {value}")); + ui.colored_label( + if inferred && !ignored && !row.gap { + PREVIEW_INFERRED + } else { + color + }, + format!("{label} {value}"), + ); } }); } else { - for value in [&row.start, &row.end, &row.duration] { + for (value, inferred) in [ + (&row.start, row.inferred_start), + (&row.end, row.inferred_end), + (&row.duration, row.inferred_duration), + ] { ui.vertical(|ui| { ui.set_min_height(row_height); - ui.add(egui::Label::new(RichText::new(value).color(color)).extend()); + ui.add( + egui::Label::new(RichText::new(value).color( + if inferred && !ignored && !row.gap { + PREVIEW_INFERRED + } else { + color + }, + )) + .extend(), + ); }); } } @@ -1784,6 +1824,61 @@ mod tests { assert_eq!(app.selected_row, Some(3)); } + #[test] + fn inferred_timing_uses_per_cell_provenance_and_stays_out_of_hover() { + let cells = |values: &[&str]| { + values + .iter() + .map(|text| crate::model::Cell { + text: (*text).into(), + ..Default::default() + }) + .collect() + }; + let table = Table { + name: "Show".into(), + rows: vec![ + cells(&["Start", "End", "Duration", "Title"]), + cells(&["09:00", "", "10 min", "Opening"]), + cells(&["", "09:30", "", "Continuation"]), + ], + merges: vec![], + }; + let analysis = pipeline::analyze( + &table, + &Profile::default(), + &AtomicBool::new(false), + |_, _| {}, + ); + let rows = preview_rows(&analysis, Some(&table)); + assert!(!rows[0].inferred_start); + assert!(rows[0].inferred_end); + assert!(!rows[0].inferred_duration); + assert!(rows[1].inferred_start); + assert!(!rows[1].inferred_end); + assert!(rows[1].inferred_duration); + assert!(!rows[1].start.contains('*')); + let hover = row_hover_text(&rows[1], &analysis, "Timed"); + assert!(!hover.contains("derived")); + assert_eq!( + hover, + "Status: Timed\n\nDouble-click anywhere on this row to edit it and view original cells." + ); + + let mut app = App { + sheet: table.name.clone(), + tables: vec![table], + analysis: Some(analysis), + tab: Tab::Review, + ..Default::default() + }; + let ctx = egui::Context::default(); + configure_style(&ctx); + render(&mut app, &ctx, [860.0, 620.0], vec![]); + let labels = render(&mut app, &ctx, [860.0, 620.0], vec![]); + assert!(labels.iter().any(|(text, _)| text == "Inferred timing")); + } + #[test] fn resolutions_window_prioritizes_save_and_reuse() { let mut app = sample(); diff --git a/crates/rundown-converter/src/model.rs b/crates/rundown-converter/src/model.rs index a65533a..3c06cd4 100644 --- a/crates/rundown-converter/src/model.rs +++ b/crates/rundown-converter/src/model.rs @@ -114,6 +114,10 @@ pub struct Entry { pub end_ms: i64, pub duration_ms: i64, pub explicit_start: bool, + #[serde(default)] + pub inferred_end: bool, + #[serde(default)] + pub inferred_duration: bool, pub source_rows: Vec, pub decisions: Vec, } diff --git a/crates/rundown-converter/src/pipeline.rs b/crates/rundown-converter/src/pipeline.rs index 07cdcfe..02dffc6 100644 --- a/crates/rundown-converter/src/pipeline.rs +++ b/crates/rundown-converter/src/pipeline.rs @@ -144,15 +144,16 @@ pub fn identify_gaps(table: &Table, map: &Mapping, profile: &Profile) -> Vec Entry { + duration: i64, + explicit_start: bool, + inferred_end: bool, + inferred_duration: bool, +} + +fn entry(table: &Table, row: usize, kind: &str, timing: EntryTiming) -> Entry { Entry { id: Uuid::new_v5( &Uuid::NAMESPACE_URL, @@ -162,10 +163,12 @@ fn entry( .to_string(), kind: kind.into(), title: String::new(), - start_ms: start, - end_ms: end, - duration_ms: dur, - explicit_start: explicit, + start_ms: timing.start, + end_ms: timing.end, + duration_ms: timing.duration, + explicit_start: timing.explicit_start, + inferred_end: timing.inferred_end, + inferred_duration: timing.inferred_duration, source_rows: vec![source_row(table, row)], decisions: vec![], } @@ -307,7 +310,19 @@ pub fn construct( continue; }; if kind == Some("marker") { - let mut e = entry(table, r, "marker", start, start, 0, given_start.is_some()); + let mut e = entry( + table, + r, + "marker", + EntryTiming { + start, + end: start, + duration: 0, + explicit_start: given_start.is_some(), + inferred_end: false, + inferred_duration: false, + }, + ); e.title = title; e.decisions.push( "Explicitly classified as an untimed marker; excluded from Ontime timers".into(), @@ -352,10 +367,14 @@ pub fn construct( table, r, "event", - start, - end, - duration, - given_start.is_some(), + EntryTiming { + start, + end, + duration, + explicit_start: given_start.is_some(), + inferred_end: event_end.is_none(), + inferred_duration: d.is_none(), + }, ); e.title = title; if given_start.is_none() { @@ -514,11 +533,13 @@ fn resolve_gaps(rundown: &mut Rundown, profile: &Profile) -> Vec { let event = &mut rundown.entries[index]; if action == "extend_previous" { event.end_ms = end; + event.inferred_end = true; } else { event.start_ms = start; event.explicit_start = false; } event.duration_ms = event.end_ms - event.start_ms; + event.inferred_duration = true; event.decisions.push(format!( "Gap resolution {action}: absorbed {} ms from {} to {}", end - start, diff --git a/crates/rundown-converter/tests/conversion.rs b/crates/rundown-converter/tests/conversion.rs index c1ef7f9..6593bac 100644 --- a/crates/rundown-converter/tests/conversion.rs +++ b/crates/rundown-converter/tests/conversion.rs @@ -33,6 +33,8 @@ fn independent_anchors_and_implicit_lunch_gap() { let a = analyze(&simple(), &Profile::default()); assert!(a.diagnostics.is_empty(), "{:?}", a.diagnostics); let r = a.rundown.unwrap(); + assert!(r.entries.iter().all(|entry| !entry.inferred_duration)); + assert!(r.entries.iter().all(|entry| entry.inferred_end)); assert_eq!(r.gaps.len(), 1); assert_eq!(r.gaps[0].start_ms, Some(43_200_000)); assert_eq!(r.gaps[0].end_ms, Some(48_600_000)); @@ -47,6 +49,24 @@ fn independent_anchors_and_implicit_lunch_gap() { ); assert!(entries.values().any(|e| e["timeStart"] == 48_600_000)); } + +#[test] +fn ir_records_inferred_start_end_and_duration_provenance() { + let t = table(&[ + &["Start", "End", "Duration", "Title"], + &["09:00", "", "10 min", "Opening"], + &["", "09:30", "", "Continuation"], + ]); + let a = analyze(&t, &Profile::default()); + assert!(a.diagnostics.is_empty(), "{:?}", a.diagnostics); + let entries = a.rundown.unwrap().entries; + assert!(entries[0].explicit_start); + assert!(entries[0].inferred_end); + assert!(!entries[0].inferred_duration); + assert!(!entries[1].explicit_start); + assert!(!entries[1].inferred_end); + assert!(entries[1].inferred_duration); +} #[test] fn named_untimed_break_occupies_time_without_timer() { let t = table(&[ diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index d9b4dc1..39f3c22 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -75,10 +75,13 @@ visually distinct from labels and ordinary actions; the active tab uses the stro diagnostics from the last analysis and gaps for context. Ignored rows can be restored using All rows. Notes attached to another event keep their own source row and identify their parent timer instead of duplicating it. Amber means unresolved, red means an - error, gray means ignored, and teal marks gaps. An overlap marks both the later + error, gray means ignored, teal marks gaps, and purple timing values were inferred + rather than read directly from the rundown. Start, end and duration are colored + independently, so a row can show exactly which values were calculated. An overlap marks both the later cue and its predecessor in red because either timing may need correction; each row's hover leads with the warning or error severity, code, source location, - full explanation and a concrete way to resolve it. Row status and editing hints + full explanation and a concrete way to resolve it. Timing inference is conveyed + by the table colors instead of repeated in the hover. Row status and editing hints follow as secondary information; raw source cells remain in the double-click inspector. For overlaps, both affected rows explain their side of the conflict. Gaps appear in schedule order with their start, end and elapsed duration (no timer).