diff --git a/crates/rundown-converter/src/gui.rs b/crates/rundown-converter/src/gui.rs index e515198..3c6fa88 100644 --- a/crates/rundown-converter/src/gui.rs +++ b/crates/rundown-converter/src/gui.rs @@ -562,6 +562,7 @@ impl App { Tab::Review => self.review(ui), Tab::Details => { ui.heading("Analysis status"); + self.analysis_summary(ui); ui.label(&self.status); if let Some(a) = &self.analysis { ui.label(format!( diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index d703bf1..380d26f 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -40,6 +40,7 @@ fn short(text: &str, count: usize) -> String { result } +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); @@ -260,7 +261,71 @@ fn show_row(row: &PreviewRow, filter: RowFilter, table: Option<&Table>, profile: } } +fn ignorable_rows(a: &Analysis, table: Option<&Table>, profile: &Profile) -> Vec { + preview_rows(a, table) + .into_iter() + .filter(|r| { + r.row > 0 + && r.source_only + && !r.issues.is_empty() + && r.issues + .iter() + .all(|i| needs_information(&a.diagnostics[*i])) + && !ignored_row(r.row, table, profile) + && !profile.row_kinds.contains_key(&r.row) + && !profile.durations.contains_key(&r.row) + }) + .map(|r| r.row) + .collect() +} + +fn stage_state(a: &Analysis, stage: u8, dirty: bool) -> (&'static str, Color32, &'static str) { + if dirty { + ( + "~", + PREVIEW_AMBER, + "Decisions changed; recheck to refresh this result", + ) + } else if a.diagnostics.iter().any(|d| d.stage == stage) { + ("!", PREVIEW_AMBER, "Needs attention") + } else if a.completed_stage >= stage { + ("OK", PREVIEW_SUCCESS, "Completed successfully") + } else { + ("—", Color32::GRAY, "Not checked yet") + } +} + impl App { + pub(super) fn analysis_summary(&self, ui: &mut egui::Ui) { + let Some(a) = &self.analysis else { + return; + }; + ui.horizontal_wrapped(|ui| { + for (stage, label, explanation) in [ + ( + 1, + "Columns", + "Column roles inferred and all relevant timing cells checked", + ), + (2, "Gaps", "Untimed breaks and schedule gaps identified"), + ( + 3, + "Schedule", + "Complete intermediate schedule constructed from timings", + ), + ( + 4, + "Checks", + "Schedule checked for invalid durations, backward times and overlaps", + ), + ] { + let (symbol, color, status) = stage_state(a, stage, self.dirty); + ui.colored_label(color, format!("{symbol} {label}")) + .on_hover_text(format!("{status}\n{explanation}")); + } + }); + } + pub(super) fn decisions_changed(&mut self) { self.dirty = true; self.completed = None; @@ -322,6 +387,7 @@ impl App { self.resolutions_open = true; } }); + self.analysis_summary(ui); ui.separator(); match self.review_view { ReviewView::Rows => self.schedule_preview(ui), @@ -585,8 +651,10 @@ impl App { fn columns_view(&mut self, ui: &mut egui::Ui) { ui.heading("Column meanings"); - ui.label("Choose the intended role when inference is ambiguous. Every timing cell is still validated."); - ui.label("Metadata goes into Ontime notes. Ignore excludes the column from inference and Ontime export. Auto includes other columns as metadata."); + ui.label("Review detected roles or choose a correction."); + ui.collapsing("Column role help", |ui| { + ui.label("Metadata goes into Ontime notes. Ignore excludes the column from inference and Ontime export. Auto includes other columns as metadata. Every timing cell is validated."); + }); if ui.link("Remap columns in Setup →").clicked() { self.settings = true; self.tab = Tab::Setup; @@ -597,9 +665,35 @@ impl App { ) { let before = serde_json::to_string(&profile).unwrap(); let (mapping, evidence) = detect::inspect(table, &profile); - for text in &evidence { - ui.label(text); + match &mapping { + Ok(m) => { + ui.colored_label(PREVIEW_SUCCESS, "OK Column mapping verified"); + ui.horizontal_wrapped(|ui| { + for (role, column) in [ + ("Start", Some(m.start)), + ("End", m.end), + ("Duration", m.duration), + ("Title", Some(m.title)), + ] { + if let Some(column) = column { + ui.label(format!("{role}: {}", column_name(column))); + } + } + ui.weak(format!("Header: row {}", m.header_row)); + }); + } + Err(errors) => { + ui.colored_label( + PREVIEW_AMBER, + format!("! Column mapping needs attention · {} issues", errors.len()), + ); + } } + ui.collapsing("Detection evidence", |ui| { + for text in &evidence { + ui.label(text); + } + }); let header = profile .header_row .or_else(|| { @@ -664,7 +758,7 @@ impl App { } else { "metadata" }; - ui.weak(format!("Detected: {role}")); + ui.colored_label(PREVIEW_SUCCESS, format!("OK {role}")); } }); let samples = table @@ -687,6 +781,19 @@ impl App { } fn schedule_preview(&mut self, ui: &mut egui::Ui) { + let ignorable = self + .analysis + .as_ref() + .and_then(|a| { + let profile = serde_json::from_str::(&self.profile).ok()?; + Some(ignorable_rows( + a, + self.tables.iter().find(|t| t.name == a.sheet), + &profile, + )) + }) + .unwrap_or_default(); + let mut ignore_all = false; ui.horizontal_wrapped(|ui| { ui.selectable_value(&mut self.row_filter, RowFilter::All, "All rows"); ui.selectable_value(&mut self.row_filter, RowFilter::Included, "Included rows") @@ -697,7 +804,16 @@ impl App { if ui.add_enabled(self.selected_row.is_some(), egui::Button::new("Edit row…")).clicked() { self.row_details = true; } + ignore_all = ui.add_enabled(!ignorable.is_empty(), egui::Button::new(format!("Ignore all unresolved ({})", ignorable.len()))) + .on_hover_text("Ignores unresolved source rows across this sheet, including rows outside the current filter. Timed rows, timing errors and existing row corrections are kept. Apply & recheck; restore ignored rows under All rows.").clicked(); }); + if ignore_all && let Ok(mut profile) = serde_json::from_str::(&self.profile) { + for row in ignorable { + profile.row_kinds.insert(row, "ignore".into()); + } + self.profile = serde_json::to_string_pretty(&profile).unwrap(); + self.decisions_changed(); + } if self.show_issue_details { self.issue_navigator(ui); } @@ -1206,6 +1322,82 @@ mod tests { assert_eq!(app.selected_row, Some(3)); } + #[test] + fn bulk_ignore_skips_timed_rows_errors_and_previous_decisions() { + let mut app = sample(); + app.analysis + .as_mut() + .unwrap() + .diagnostics + .push(Diagnostic::new( + 4, + "NEGATIVE_DURATION", + "Show!row 4", + "Invalid timing", + )); + let profile = Profile { + row_kinds: [(5, "ignore".into()), (6, "note".into())] + .into_iter() + .collect(), + durations: [(7, "2 min".into())].into_iter().collect(), + ..Default::default() + }; + app.profile = serde_json::to_string(&profile).unwrap(); + let ctx = egui::Context::default(); + configure_style(&ctx); + let size = [560.0, 400.0]; + render(&mut app, &ctx, size, vec![]); + let labels = render(&mut app, &ctx, size, vec![]); + let button = labels + .iter() + .find(|(s, _)| s == "Ignore all unresolved (8)") + .unwrap() + .1 + .center(); + click_size(&mut app, &ctx, button, size); + let profile: Profile = serde_json::from_str(&app.profile).unwrap(); + assert_eq!(profile.row_kinds.len(), 10); + assert_eq!(profile.row_kinds[&6], "note"); + assert_eq!(profile.durations[&7], "2 min"); + assert_eq!(profile.row_kinds[&3], "ignore"); + assert!(!profile.row_kinds.contains_key(&2)); + assert!(!profile.row_kinds.contains_key(&4)); + assert!(!profile.row_kinds.contains_key(&15)); + assert!(app.dirty); + } + + #[test] + fn stage_summary_distinguishes_success_blocked_and_stale_results() { + let mut app = sample(); + let a = app.analysis.as_ref().unwrap(); + assert_eq!(stage_state(a, 1, false).0, "OK"); + assert_eq!(stage_state(a, 2, false).0, "OK"); + assert_eq!(stage_state(a, 3, false).0, "!"); + assert_eq!(stage_state(a, 4, false).0, "—"); + assert_eq!(stage_state(a, 1, true).0, "~"); + let ctx = egui::Context::default(); + configure_style(&ctx); + app.review_view = ReviewView::Columns; + render(&mut app, &ctx, [860.0, 900.0], vec![]); + let labels = render(&mut app, &ctx, [860.0, 900.0], vec![]); + assert!( + labels + .iter() + .any(|(s, _)| s == "OK Column mapping verified") + ); + assert!(labels.iter().any(|(s, _)| s == "Start: A")); + assert!(!labels.iter().any(|(s, _)| s.starts_with("Header suggests"))); + let evidence = labels + .iter() + .find(|(s, _)| s == "Detection evidence") + .unwrap() + .1 + .center(); + click_size(&mut app, &ctx, evidence, [860.0, 900.0]); + let labels = render(&mut app, &ctx, [860.0, 900.0], vec![]); + assert!(labels.iter().any(|(s, _)| s.starts_with("Header suggests"))); + } + #[test] fn ignore_shortcut_sets_resolution_and_retains_source_for_recovery() { let mut app = sample(); diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index 9462e2d..d715e3b 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -33,7 +33,10 @@ directories must already exist. Exit codes: 0 success, 1 read/profile/write fail CLI logs are plain text on stderr; JSON results go to stdout. In the desktop app, choose or drop one file, read its sheets, select a sheet and -click **Analyze rundown**. Review has two views: +click **Analyze rundown**. A compact summary shows **Columns**, **Gaps**, +**Schedule**, and **Checks**: green OK labels mark success, amber marks attention or +pending recheck, and gray marks steps not yet checked. Hover for explanations. +Review has two views: - **Schedule & corrections** combines the schedule preview and row editing in one table. Start/end/duration, titles, colored issues and row types are visible @@ -58,7 +61,9 @@ click **Analyze rundown**. Review has two views: Unknown values show `?`. Unresolved source rows offer **Ignore** to set the ignore resolution and **Details** to open the row editor. Ignoring requires recheck and can be undone - under All rows. + under All rows. **Ignore all unresolved (N)** applies this to unresolved source + rows across the sheet, regardless of the current filter. Timed rows, timing + errors and existing manual row/duration corrections are excluded. Hover over a title or details button for row status and full diagnostic explanations. Double-click anywhere on a source row, or click its **Details** / **Error** button, to open the same editor (inline dropdowns keep their normal interaction). @@ -70,8 +75,9 @@ click **Analyze rundown**. Review has two views: On narrow windows, timing values stack so corrections remain accessible. Changes require recheck; the timing preview and diagnostics continue to show the previous analysis. -- **Columns** shows inference evidence, per-column role dropdowns, and sample - values. Selecting one duration column explicitly resolves duplicate TIMER +- **Columns** shows a concise verified mapping summary, green detected roles, + per-column role dropdowns, and sample values. Expand **Detection evidence** for + full inference and validation details; **Column role help** explains the choices. Selecting one duration column explicitly resolves duplicate TIMER headers. **Metadata** keeps a column as Ontime notes without treating its values as timing or titles; **Ignore** excludes it from inference and Ontime output. Several columns can be metadata or ignored. **Auto** restores inference; other