From 1499e45add6272232ad0a2d04f9b8876006b7170 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 3 Nov 2026 14:00:08 +0100 Subject: [PATCH] Show source row previews in untimed row errors --- crates/rundown-converter/src/pipeline.rs | 31 +++++++++++++++++++- crates/rundown-converter/tests/conversion.rs | 14 ++++++--- docs/rundown-converter.md | 3 +- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/crates/rundown-converter/src/pipeline.rs b/crates/rundown-converter/src/pipeline.rs index 833fda8..f243484 100644 --- a/crates/rundown-converter/src/pipeline.rs +++ b/crates/rundown-converter/src/pipeline.rs @@ -9,6 +9,27 @@ use uuid::Uuid; fn at(table: &Table, row: usize) -> String { format!("{}!row {}", table.name, row + 1) } +fn row_preview(table: &Table, row: usize, header: usize) -> String { + table.rows[row] + .iter() + .enumerate() + .filter(|(_, cell)| !cell.text.trim().is_empty()) + .map(|(col, cell)| { + let label = table.cell(header, col).text; + let text = cell.text.split_whitespace().collect::>().join(" "); + let mut excerpt: String = text.chars().take(200).collect(); + if excerpt.len() < text.len() { + excerpt.push('…'); + } + if label.trim().is_empty() { + format!("{}: {excerpt}", column_name(col)) + } else { + format!("{} ({label}): {excerpt}", column_name(col)) + } + }) + .collect::>() + .join("\n") +} fn is_gap(title: &str) -> bool { let s = normalize(title); ["pause", "dejeuner", "lunch", "break", "coffee break"] @@ -264,7 +285,15 @@ pub fn construct( errors.push(Diagnostic::new(3,"ORPHAN_NOTE",at(table,r),"No preceding event to receive this note; classify or exclude it explicitly")); } } else { - errors.push(Diagnostic::new(3,"UNTIMED_ROW",at(table,r),"This row has content but no timing. Clarify whether it is a note, marker, untimed break or event; use row_kinds or untimed_as_notes in a profile.")); + errors.push(Diagnostic::new( + 3, + "UNTIMED_ROW", + at(table, r), + format!( + "This row has content but no timing. Clarify whether it is a note, marker, untimed break or event; use row_kinds or untimed_as_notes in a profile.\nRow preview:\n{}", + row_preview(table, r, map.header_row - 1) + ), + )); } continue; } diff --git a/crates/rundown-converter/tests/conversion.rs b/crates/rundown-converter/tests/conversion.rs index 3818482..6fd41d7 100644 --- a/crates/rundown-converter/tests/conversion.rs +++ b/crates/rundown-converter/tests/conversion.rs @@ -240,12 +240,18 @@ fn notes_and_markers_require_explicit_choices() { &["", "", "Stage movement"], &["09:10", "", "Thanks"], ]); + let unresolved = analyze(&t, &Profile::default()); + let error = unresolved + .diagnostics + .iter() + .find(|d| d.code == "UNTIMED_ROW") + .unwrap(); assert!( - analyze(&t, &Profile::default()) - .diagnostics - .iter() - .any(|d| d.code == "UNTIMED_ROW") + error + .message + .contains("Row preview:\nC (Title): Stage movement") ); + assert!(!error.message.contains("Thanks")); let p = Profile { untimed_as_notes: true, row_kinds: BTreeMap::from([(4, "marker".into())]), diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index 4bc3add..8592094 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -46,7 +46,8 @@ In the source table, choose each row's meaning or enter a duration correction with units, such as `2 min`. Blank corrections restore the source value. Click **Apply & recheck** to rebuild and validate the schedule; editing decisions blocks export until validation succeeds. Missing durations and untimed-row decisions -can be resolved here. Unsupported interpretations, invalid start/end values, +can be resolved here. Untimed-row errors include a preview of nonempty source +cells, labeled with their column letters and headers (long values are shortened). Unsupported interpretations, invalid start/end values, conflicting timings and unresolved overlaps still produce explicit errors; correct the source when the available controls cannot express the intended fix. The schedule preview below the source table shows the resulting timers and gaps.