diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index fde0883..51d0548 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -2000,7 +2000,7 @@ impl App { ); } if compact { - ui.push_id((row.row, row.gap_key.as_deref(), "compact_timing"), |ui| { + ui.push_id((row_index, row.row, row.gap_key.as_deref(), "compact_timing"), |ui| { ui.vertical(|ui| { ui.set_width(105.0); ui.set_min_height(row_height); @@ -2026,7 +2026,7 @@ impl App { ("end", &row.end, row.inferred_end), ("duration", &row.duration, row.inferred_duration), ] { - ui.push_id((row.row, row.gap_key.as_deref(), role), |ui| { + ui.push_id((row_index, row.row, row.gap_key.as_deref(), role), |ui| { ui.vertical(|ui| { ui.set_min_height(row_height); ui.add( @@ -2104,7 +2104,7 @@ impl App { if let Some(key) = &row.gap_key { Self::gap_resolution_control(ui, &mut profile, key); } else { - ui.push_id(("schedule_kind", row.row), |ui| { + ui.push_id(("schedule_kind", row_index, row.row), |ui| { let detected = if self.dirty { None } else if ignored { @@ -2857,6 +2857,56 @@ mod tests { })); } + #[test] + fn split_entries_have_distinct_row_type_widget_ids() { + let mut app = sample(); + app.tables[0].rows.truncate(2); + app.tables[0].rows[1][1].text = "2 min\n3 min".into(); + let profile = Profile { + duration_split: true, + duration_mode: Some("sum".into()), + ..Default::default() + }; + app.analysis = Some(pipeline::analyze( + &app.tables[0], + &profile, + &AtomicBool::new(false), + |_, _| {}, + )); + app.profile = serde_json::to_string(&profile).unwrap(); + app.analyzed_profile = Some(profile); + let ctx = egui::Context::default(); + configure_style(&ctx); + let size = [1100.0, 900.0]; + render(&mut app, &ctx, size, vec![]); + let labels = render(&mut app, &ctx, size, vec![]); + let controls: Vec<_> = labels + .iter() + .filter(|(text, _)| text == "Auto (Event)") + .collect(); + assert_eq!(controls.len(), 2); + let second = controls[1].1.center(); + let labels = render( + &mut app, + &ctx, + size, + vec![egui::Event::PointerMoved(second)], + ); + assert!( + !labels + .iter() + .any(|(text, _)| text.contains("use of widget ID") + || text.contains("Widget is above this text")) + ); + click_size(&mut app, &ctx, second, size); + let labels = render(&mut app, &ctx, size, vec![]); + assert!( + !labels + .iter() + .any(|(text, _)| text.contains("use of widget ID")) + ); + } + #[test] fn repeated_diagnostic_groups_expand_independently_without_id_clashes() { let mut app = sample(); diff --git a/crates/rundown-converter/src/pipeline.rs b/crates/rundown-converter/src/pipeline.rs index f1998d8..bb55485 100644 --- a/crates/rundown-converter/src/pipeline.rs +++ b/crates/rundown-converter/src/pipeline.rs @@ -465,12 +465,12 @@ pub fn construct( let plan = duration_plan.as_ref().expect("checked above"); if let Some(end) = given_end { let selected: i64 = plan.events.iter().sum::() + plan.margin; - if end - start != selected { + if start + selected > end { errors.push(Diagnostic::new( 4, "CONFLICTING_TIMES", at(table, r), - "The selected split durations do not match the explicit start–end window.", + "The sum of split durations and margins exceeds the start–end window. Shorten the durations or extend the window.", )); } } @@ -517,7 +517,22 @@ pub fn construct( } part_start = part_end + margin; } - cursor = Some(part_start); + if let Some(end) = given_end { + if part_start < end { + gaps.push(Gap { + after_row: Some(r + 1), + before_row: None, + start_ms: Some(part_start), + end_ms: Some(end), + title: "Unallocated time within split block".into(), + source_rows: vec![], + display_timer: false, + }); + } + cursor = Some(end.max(part_start)); + } else { + cursor = Some(part_start); + } continue; } // A shared clock window with per-row durations represents bounded child cues. diff --git a/crates/rundown-converter/tests/conversion.rs b/crates/rundown-converter/tests/conversion.rs index 850bce0..30f4fff 100644 --- a/crates/rundown-converter/tests/conversion.rs +++ b/crates/rundown-converter/tests/conversion.rs @@ -1471,3 +1471,51 @@ fn secondary_title_fallback_respects_empty_cells_and_explicit_corrections() { .any(|d| d.code == "INVALID_SECONDARY_TITLE_MODE") ); } + +#[test] +fn split_window_bounds_the_total_and_preserves_slack() { + let t = table(&[ + &["Start–end", "Duration", "Title"], + &["10:00-10:30", "10 min + 5 min\n10 min + 5 min", "Talks"], + &["10:30-10:40", "10 min", "Next"], + ]); + let profile = Profile { + header_row: Some(1), + columns: BTreeMap::from([ + ("start_end".into(), "A".into()), + ("duration".into(), "B".into()), + ("title".into(), "C".into()), + ]), + duration_split: true, + duration_mode: Some("maximum".into()), + ..Default::default() + }; + for mode in ["maximum", "sum", "margin"] { + let p = Profile { + duration_mode: Some(mode.into()), + ..profile.clone() + }; + let a = analyze(&t, &p); + assert!(a.diagnostics.is_empty(), "{mode}: {:?}", a.diagnostics); + let r = a.rundown.unwrap(); + assert_eq!(r.entries.len(), 3); + assert_eq!(r.entries[2].start_ms, (10 * 60 + 30) * 60_000); + if mode == "maximum" { + assert!( + r.gaps + .iter() + .any(|g| g.start_ms == Some((10 * 60 + 20) * 60_000) + && g.end_ms == Some((10 * 60 + 30) * 60_000)) + ); + } + assert!(export::ontime(&r).is_ok()); + } + let mut overflow = t; + overflow.rows[1][1].text = "20 min\n20 min".into(); + let a = analyze(&overflow, &profile); + assert!( + a.diagnostics + .iter() + .any(|d| d.code == "CONFLICTING_TIMES" && d.message.contains("sum of split")) + ); +} diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index b569fac..40fdbed 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -221,7 +221,7 @@ values from calculated values, unresolved values and gaps. | Start–end cell `08h00 - 08h30` | Use 08:00 and 08:30 directly and derive a 30-minute duration | | Start cell `08h45 - 09h10`, duration `20 min + 5 min` with Maximum | Use 08:45 and a 20-minute timer; the unused end in the Start cell does not constrain it | | Duration `20 min + 5 min` with Add margin | Create a 20-minute event followed by a five-minute untimed gap | -| Multiline duration with Split | Create sequential virtual entries, one for each separated duration group | +| Multiline duration with Split | Create sequential virtual entries, one for each separated duration group; a start–end range bounds their combined durations and margins, with remaining time kept as a gap | | Named lunch row from 12:00 to 13:30 | Preserve an explicit break with its original label | | Cue at 11:45; next cue at 13:30; no end or duration | Event duration versus break is unknown; do not invent a lunch break | | Start 11:45, end 12:00, duration 20 minutes | Report conflicting timing and request clarification |