Show source row previews in untimed row errors

This commit is contained in:
Dandaedre 2026-11-03 14:00:08 +01:00
parent 9c23645df8
commit 1499e45add
3 changed files with 42 additions and 6 deletions

View File

@ -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::<Vec<_>>().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::<Vec<_>>()
.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;
}

View File

@ -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())]),

View File

@ -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.