From c5b3bc66380bdc2d1aff5c7693824e5a3389c404 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 3 Nov 2026 16:30:53 +0100 Subject: [PATCH] Allow correcting rundown titles --- crates/rundown-converter/src/detect.rs | 1 + crates/rundown-converter/src/gui.rs | 2 +- crates/rundown-converter/src/gui/review.rs | 43 ++++++++++++++++++-- crates/rundown-converter/src/main.rs | 2 +- crates/rundown-converter/src/model.rs | 2 + crates/rundown-converter/src/pipeline.rs | 22 +++++++++- crates/rundown-converter/src/resolution.rs | 2 + crates/rundown-converter/tests/conversion.rs | 24 +++++++++++ docs/rundown-converter-plan.md | 2 +- docs/rundown-converter.md | 7 ++-- 10 files changed, 96 insertions(+), 11 deletions(-) diff --git a/crates/rundown-converter/src/detect.rs b/crates/rundown-converter/src/detect.rs index dc867b2..7bf13e6 100644 --- a/crates/rundown-converter/src/detect.rs +++ b/crates/rundown-converter/src/detect.rs @@ -171,6 +171,7 @@ fn infer_inner( } } for (role, values) in [ + ("TITLE", &profile.titles), ("START", &profile.starts), ("END", &profile.ends), ("DURATION", &profile.durations), diff --git a/crates/rundown-converter/src/gui.rs b/crates/rundown-converter/src/gui.rs index 6b2eecc..a7decf8 100644 --- a/crates/rundown-converter/src/gui.rs +++ b/crates/rundown-converter/src/gui.rs @@ -417,7 +417,7 @@ impl App { self.decisions_changed(); } } - ui.label("Optional JSON profile: columns (start/end/duration/title), column_usage (metadata/ignore), duration_unit, row_kinds, starts, ends, durations, untimed_as_notes, ignore_warnings. Column letters and source rows are shown in diagnostics."); + ui.label("Optional JSON profile: columns (start/end/duration/title), column_usage (metadata/ignore), duration_unit, row_kinds, titles, starts, ends, durations, untimed_as_notes, ignore_warnings. Column letters and source rows are shown in diagnostics."); if ui .add( egui::TextEdit::multiline(&mut self.profile) diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index 1c7b616..7e1dae5 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -469,6 +469,7 @@ fn ignorable_rows(a: &Analysis, table: Option<&Table>, profile: &Profile) -> Vec .all(|i| needs_information(&a.diagnostics[*i])) && !ignored_row(r.row, table, profile) && !profile.row_kinds.contains_key(&r.row) + && !profile.titles.contains_key(&r.row) && !profile.starts.contains_key(&r.row) && !profile.ends.contains_key(&r.row) && !profile.durations.contains_key(&r.row) @@ -883,6 +884,23 @@ impl App { }; Self::row_kind_control(ui, &mut profile, row, if self.dirty { None } else { detected }); }); + ui.label("Title"); + let mut title = profile.titles.get(&row).cloned().unwrap_or_default(); + if ui + .add( + egui::TextEdit::singleline(&mut title) + .id_salt(("title_override", row)) + .hint_text("e.g. Opening remarks") + .desired_width(f32::INFINITY), + ) + .changed() + { + if title.trim().is_empty() { + profile.titles.remove(&row); + } else { + profile.titles.insert(row, title); + } + } if !preview.gap { ui.label("Timing corrections"); ui.horizontal_wrapped(|ui| { @@ -2206,6 +2224,7 @@ mod tests { row_kinds: [(5, "ignore".into()), (6, "note".into())] .into_iter() .collect(), + titles: [(8, "Corrected title".into())].into_iter().collect(), starts: [(7, "09:30".into())].into_iter().collect(), ends: [(7, "09:32".into())].into_iter().collect(), durations: [(7, "2 min".into())].into_iter().collect(), @@ -2219,20 +2238,22 @@ mod tests { let labels = render(&mut app, &ctx, size, vec![]); let button = labels .iter() - .find(|(s, _)| s == "Ignore all unresolved (9)") + .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(), 11); + assert_eq!(profile.row_kinds.len(), 10); assert_eq!(profile.row_kinds[&6], "note"); + assert_eq!(profile.titles[&8], "Corrected title"); assert_eq!(profile.starts[&7], "09:30"); assert_eq!(profile.ends[&7], "09:32"); assert_eq!(profile.durations[&7], "2 min"); assert_eq!(profile.row_kinds[&3], "ignore"); assert_eq!(profile.row_kinds[&2], "ignore"); assert!(!profile.row_kinds.contains_key(&4)); + assert!(!profile.row_kinds.contains_key(&8)); assert!(!profile.row_kinds.contains_key(&15)); assert!(app.dirty); } @@ -2278,6 +2299,7 @@ mod tests { let size = [560.0, 400.0]; render(&mut app, &ctx, size, vec![]); let labels = render(&mut app, &ctx, size, vec![]); + assert!(!labels.iter().any(|(s, _)| s == "e.g. Opening remarks")); let ignore = labels .iter() .find(|(s, _)| s == "Ignore") @@ -2309,7 +2331,7 @@ mod tests { } #[test] - fn whole_row_selection_and_editor_timing_changes() { + fn whole_row_selection_and_editor_data_changes() { let mut app = sample(); app.selected_row = None; let ctx = egui::Context::default(); @@ -2328,6 +2350,20 @@ mod tests { assert!(app.row_details); render(&mut app, &ctx, size, vec![]); let labels = render(&mut app, &ctx, size, vec![]); + let title = labels + .iter() + .find(|(s, _)| s == "e.g. Opening remarks") + .unwrap() + .1 + .center(); + click_size(&mut app, &ctx, title, size); + render( + &mut app, + &ctx, + size, + vec![egui::Event::Text("Revised opening".into())], + ); + let labels = render(&mut app, &ctx, size, vec![]); let start = labels .iter() .find(|(s, _)| s == "e.g. 09:00") @@ -2370,6 +2406,7 @@ mod tests { vec![egui::Event::Text("2 min".into())], ); let profile: Profile = serde_json::from_str(&app.profile).unwrap(); + assert_eq!(profile.titles[&2], "Revised opening"); assert_eq!(profile.starts[&2], "08:55"); assert_eq!(profile.ends[&2], "09:00"); assert_eq!(profile.durations[&2], "2 min"); diff --git a/crates/rundown-converter/src/main.rs b/crates/rundown-converter/src/main.rs index 732eaa4..b5442ab 100644 --- a/crates/rundown-converter/src/main.rs +++ b/crates/rundown-converter/src/main.rs @@ -21,7 +21,7 @@ struct Args { /// Required for workbooks with multiple sheets; exact name. #[arg(long)] sheet: Option, - /// JSON profile: explicit columns, units, row classifications and timing corrections. + /// JSON profile: explicit columns, units, row classifications and row corrections. #[arg(long)] profile: Option, #[arg(short, long)] diff --git a/crates/rundown-converter/src/model.rs b/crates/rundown-converter/src/model.rs index caaa2b1..f36a372 100644 --- a/crates/rundown-converter/src/model.rs +++ b/crates/rundown-converter/src/model.rs @@ -75,6 +75,8 @@ pub struct Profile { pub ignore_warnings: bool, /// One-based source row -> event, gap, marker, note, or ignore. pub row_kinds: BTreeMap, + /// Explicit title overrides; original source cells remain in the IR. + pub titles: BTreeMap, /// Explicit start clock overrides (e.g. 09:30 or 09:30:00). pub starts: BTreeMap, /// Explicit end clock overrides (e.g. 10:15 or 10:15:00). diff --git a/crates/rundown-converter/src/pipeline.rs b/crates/rundown-converter/src/pipeline.rs index d4fd062..90b76ab 100644 --- a/crates/rundown-converter/src/pipeline.rs +++ b/crates/rundown-converter/src/pipeline.rs @@ -50,6 +50,13 @@ fn supplied_duration(table: &Table, row: usize, map: &Mapping, profile: &Profile .and_then(|c| duration(&table.cell(row, c), map.duration_unit.as_deref())) } } +fn supplied_title(table: &Table, row: usize, map: &Mapping, profile: &Profile) -> String { + profile + .titles + .get(&(row + 1)) + .cloned() + .unwrap_or_else(|| table.cell(row, map.title).text) +} fn override_clock(values: &std::collections::BTreeMap, row: usize) -> Option { values.get(&(row + 1)).and_then(|text| { clock(&Cell { @@ -93,7 +100,9 @@ pub fn identify_gaps(table: &Table, map: &Mapping, profile: &Profile) -> Vec = rows .iter() .filter_map(|&r| { - let title = if detect::structural_row(table, r, map.header_row - 1) { + let title = if let Some(title) = profile.titles.get(&(r + 1)) { + title.clone() + } else if detect::structural_row(table, r, map.header_row - 1) { table.rows[r] .iter() .find(|c| !c.text.is_empty()) @@ -297,7 +306,7 @@ pub fn construct( )); continue; } - let title = table.cell(r, map.title).text; + let title = supplied_title(table, r, &map, profile); if kind == Some("note") || (given_start.is_none() && given_end.is_none() @@ -361,6 +370,10 @@ pub fn construct( e.decisions.push( "Explicitly classified as an untimed marker; excluded from Ontime timers".into(), ); + if profile.titles.contains_key(&(r + 1)) { + e.decisions + .push("Title explicitly overridden by profile; original cells retained".into()); + } result.entries.push(e); cursor = Some(start); continue; @@ -411,6 +424,10 @@ pub fn construct( }, ); e.title = title; + if profile.titles.contains_key(&(r + 1)) { + e.decisions + .push("Title explicitly overridden by profile; original cells retained".into()); + } if given_start.is_none() { e.decisions .push("Start derived from preceding event or merged block".into()); @@ -733,6 +750,7 @@ pub fn analyze( *row > 0 && *row <= table.rows.len() && !effective.row_kinds.contains_key(row) + && !profile.titles.contains_key(row) && !profile.starts.contains_key(row) && !profile.ends.contains_key(row) && !profile.durations.contains_key(row) diff --git a/crates/rundown-converter/src/resolution.rs b/crates/rundown-converter/src/resolution.rs index e0ce1e6..4157c23 100644 --- a/crates/rundown-converter/src/resolution.rs +++ b/crates/rundown-converter/src/resolution.rs @@ -66,11 +66,13 @@ mod tests { }; let path = remembered_path(dir.path(), &table).unwrap(); let mut profile = Profile::default(); + profile.titles.insert(2, "Opening".into()); profile.starts.insert(2, "09:00".into()); profile.ends.insert(2, "09:02".into()); profile.durations.insert(2, "2 min".into()); save(&profile, &path, &source, false).unwrap(); let loaded = load(&path).unwrap(); + assert_eq!(loaded.titles[&2], "Opening"); assert_eq!(loaded.starts[&2], "09:00"); assert_eq!(loaded.ends[&2], "09:02"); assert_eq!(loaded.durations[&2], "2 min"); diff --git a/crates/rundown-converter/tests/conversion.rs b/crates/rundown-converter/tests/conversion.rs index 2da4dd0..3d4ac7b 100644 --- a/crates/rundown-converter/tests/conversion.rs +++ b/crates/rundown-converter/tests/conversion.rs @@ -297,6 +297,7 @@ fn explicit_corrections_preserve_originals() { &["09:00", "10:00", "TBC", "A"], ]); let p = Profile { + titles: BTreeMap::from([(2, "Corrected title".into())]), starts: BTreeMap::from([(2, "09:15".into())]), ends: BTreeMap::from([(2, "09:20".into())]), durations: BTreeMap::from([(2, "5 min".into())]), @@ -308,9 +309,11 @@ fn explicit_corrections_preserve_originals() { assert_eq!(r.entries[0].start_ms, 33_300_000); assert_eq!(r.entries[0].end_ms, 33_600_000); assert_eq!(r.entries[0].duration_ms, 300_000); + assert_eq!(r.entries[0].title, "Corrected title"); assert_eq!(r.entries[0].source_rows[0].cells["A"].text, "09:00"); assert_eq!(r.entries[0].source_rows[0].cells["B"].text, "10:00"); assert_eq!(r.entries[0].source_rows[0].cells["C"].text, "TBC"); + assert_eq!(r.entries[0].source_rows[0].cells["D"].text, "A"); for (profile, code) in [ ( @@ -362,6 +365,27 @@ fn explicit_corrections_preserve_originals() { corrected.diagnostics ); assert_eq!(corrected.rundown.unwrap().entries[1].start_ms, 36_000_000); + + let missing_title = table(&[ + &["Start", "Duration", "Title"], + &["09:00", "5 min", "Opening"], + &["09:05", "5 min", ""], + ]); + assert!( + analyze(&missing_title, &Profile::default()) + .diagnostics + .iter() + .any(|d| d.code == "MISSING_TITLE") + ); + let titled = analyze( + &missing_title, + &Profile { + titles: BTreeMap::from([(3, "Closing".into())]), + ..Profile::default() + }, + ); + assert!(titled.diagnostics.is_empty(), "{:?}", titled.diagnostics); + assert_eq!(titled.rundown.unwrap().entries[1].title, "Closing"); } #[test] fn atomic_publication_preserves_source_and_existing_output() { diff --git a/docs/rundown-converter-plan.md b/docs/rundown-converter-plan.md index 61b7808..7787dc1 100644 --- a/docs/rundown-converter-plan.md +++ b/docs/rundown-converter-plan.md @@ -249,7 +249,7 @@ errors must remain visible with direct corrective actions. - [x] Add initial Setup/Review/Results GUI, source preview, column/unit selectors, shared profile controls and worker/cancellation tests. - [x] Keep inference evidence and the source table on Review after failures; - add column-role dropdowns, row classifications and start/end/duration corrections. + add column-role dropdowns, row classifications and title/start/end/duration corrections. - [x] Save/overwrite/save-as portable resolution profiles and explicitly remember, reuse or forget validated resolutions matched to the complete sheet. - [x] Redesign Review into Resolve rows / Schedule preview / Columns, with one diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index c1752a2..7ec84c7 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -68,7 +68,7 @@ visually distinct from labels and ordinary actions; the active tab uses the stro table. Start/end/duration, titles, colored issues and row types are visible together. Click anywhere on a source row or inferred gap to select it; a subtle tint marks the selection while retaining its status color. **Edit row…** opens the selected source - row editor, including start, end and duration corrections. **Edit gap…** opens an inferred gap's timing, + row editor, including title, start, end and duration corrections. **Edit gap…** opens an inferred gap's timing, diagnostics and allocation choice even though it has no source cells. **All rows** includes ignored rows; **Included rows** hides ignored rows and rows containing only ignored columns, while keeping notes, markers and breaks; **Needs attention** shows rows with @@ -129,7 +129,7 @@ The row type selector shows the detected type in parentheses, such as **Auto (Ev Click **Apply & recheck** after corrections. Pending edits retain the issue list and previous preview so you can resolve several rows without losing your place; export and remembering a resolution remain blocked until validation succeeds. -Blank timing corrections restore source or calculated values. Start and end accept +Blank title and timing corrections restore source or calculated values. Start and end accept clock times such as `09:30` or `09:30:00`; duration accepts explicit values such as `2 min` or `00:02:00`. Missing timings, overlaps and untimed row decisions can be resolved here. Unsupported interpretations and unresolved conflicts retain explicit @@ -246,6 +246,7 @@ Pass `--profile mapping.json`, or load/edit the same JSON in the desktop app: "expected_headers": {"A": "Heure", "B": "Durée"}, "untimed_as_notes": true, "row_kinds": {"20": "marker"}, + "titles": {"8": "Opening remarks"}, "starts": {"8": "09:30"}, "ends": {"8": "09:32"}, "durations": {"8": "2 min"} @@ -258,7 +259,7 @@ roles are `start`, `end`, `duration` and `title`. `duration_unit` accepts `minut `seconds`, `hh:mm`, `mm:ss` or `excel`. Cell number formats establish Excel time units where available; otherwise units must be explicit or consistently supported by independent start/end pairs. Unknown profile keys and changed expected headers -are errors. `starts`, `ends` and `durations` are keyed by one-based source row; +are errors. `titles`, `starts`, `ends` and `durations` are keyed by one-based source row; corrected cells are excluded from whole-column validation while all remaining explicit mappings still undergo it.