Show schedule gaps inline with distinct preview colors
This commit is contained in:
parent
f04c774101
commit
58aeb56a36
|
|
@ -41,6 +41,7 @@ fn short(text: &str, count: usize) -> String {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
fn needs_information(d: &Diagnostic) -> bool {
|
||||
|
|
@ -62,6 +63,7 @@ struct PreviewRow {
|
|||
issues: Vec<usize>,
|
||||
decisions: String,
|
||||
kind: String,
|
||||
gap: bool,
|
||||
}
|
||||
|
||||
/// Combine timed draft entries and omitted problem rows without changing the IR.
|
||||
|
|
@ -97,6 +99,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
.collect(),
|
||||
decisions: e.decisions.join("\n"),
|
||||
kind: e.kind.clone(),
|
||||
gap: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -154,6 +157,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
.map(|(i, _)| i)
|
||||
.collect(),
|
||||
decisions: String::new(),
|
||||
gap: false,
|
||||
kind: a
|
||||
.rundown
|
||||
.as_ref()
|
||||
|
|
@ -182,11 +186,41 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
{
|
||||
row.start = gap.start_ms.map(display).unwrap_or_else(|| "?".into());
|
||||
row.end = gap.end_ms.map(display).unwrap_or_else(|| "?".into());
|
||||
row.duration = "—".into();
|
||||
row.gap = true;
|
||||
row.duration = gap
|
||||
.start_ms
|
||||
.zip(gap.end_ms)
|
||||
.map(|(start, end)| display(end - start))
|
||||
.unwrap_or_else(|| "?".into());
|
||||
}
|
||||
}
|
||||
}
|
||||
rows.sort_by_key(|r| r.row);
|
||||
if let Some(rundown) = &a.rundown {
|
||||
for gap in rundown.gaps.iter().filter(|gap| gap.source_rows.is_empty()) {
|
||||
let position = rows
|
||||
.iter()
|
||||
.position(|row| {
|
||||
row.row > 0
|
||||
&& (gap.before_row.is_some_and(|before| row.row >= before)
|
||||
|| (gap.before_row.is_none()
|
||||
&& gap.after_row.is_some_and(|after| row.row > after)))
|
||||
})
|
||||
.unwrap_or(rows.len());
|
||||
rows.insert(position, PreviewRow {
|
||||
row: 0,
|
||||
start: gap.start_ms.map(display).unwrap_or_else(|| "?".into()),
|
||||
end: gap.end_ms.map(display).unwrap_or_else(|| "?".into()),
|
||||
duration: gap.start_ms.zip(gap.end_ms).map(|(start, end)| display(end - start)).unwrap_or_else(|| "?".into()),
|
||||
title: gap.title.clone(),
|
||||
source_only: true,
|
||||
issues: a.diagnostics.iter().enumerate().filter(|(_, d)| d.location == format!("{} gap {:?}–{:?}", rundown.title, gap.after_row, gap.before_row)).map(|(i, _)| i).collect(),
|
||||
decisions: "Unallocated time between scheduled events. This interval does not display a timer; clarify nearby unresolved rows to explain it.".into(),
|
||||
kind: "Gap · no timer".into(),
|
||||
gap: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
rows
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +235,7 @@ fn show_row(row: &PreviewRow, filter: RowFilter, table: Option<&Table>, profile:
|
|||
match filter {
|
||||
RowFilter::All => true,
|
||||
RowFilter::Included => !ignored_row(row.row, table, profile),
|
||||
RowFilter::Attention => !row.issues.is_empty(),
|
||||
RowFilter::Attention => row.gap || !row.issues.is_empty(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -579,6 +613,7 @@ impl App {
|
|||
ui.horizontal_wrapped(|ui| {
|
||||
ui.colored_label(PREVIEW_AMBER, "Unresolved");
|
||||
ui.colored_label(PREVIEW_RED, "Error");
|
||||
ui.colored_label(PREVIEW_GAP, "Gap · no timer");
|
||||
ui.weak("Ignored");
|
||||
ui.small("? unknown · * inferred · edits require recheck");
|
||||
});
|
||||
|
|
@ -616,6 +651,8 @@ impl App {
|
|||
Some(Color32::from_rgb(58, 30, 33))
|
||||
} else if !row.issues.is_empty() {
|
||||
Some(Color32::from_rgb(52, 43, 27))
|
||||
} else if row.gap {
|
||||
Some(Color32::from_rgb(25, 49, 55))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
@ -660,14 +697,16 @@ impl App {
|
|||
PREVIEW_RED
|
||||
} else if !row.issues.is_empty() {
|
||||
PREVIEW_AMBER
|
||||
} else if row.gap {
|
||||
PREVIEW_GAP
|
||||
} else {
|
||||
ui.visuals().text_color()
|
||||
};
|
||||
let response = ui.add(
|
||||
egui::Label::new(RichText::new(row.row.to_string()).color(color))
|
||||
egui::Label::new(RichText::new(if row.row == 0 { "Gap".into() } else { row.row.to_string() }).color(color))
|
||||
.sense(egui::Sense::click()),
|
||||
);
|
||||
if response.double_clicked() {
|
||||
if response.double_clicked() && row.row > 0 {
|
||||
details = Some(row.row);
|
||||
}
|
||||
if jump == Some(row.row) {
|
||||
|
|
@ -732,7 +771,7 @@ impl App {
|
|||
.sense(egui::Sense::click()),
|
||||
)
|
||||
.on_hover_text(&explanation)
|
||||
.double_clicked()
|
||||
.double_clicked() && row.row > 0
|
||||
{
|
||||
details = Some(row.row);
|
||||
}
|
||||
|
|
@ -760,6 +799,10 @@ impl App {
|
|||
});
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(105.0);
|
||||
if row.row == 0 {
|
||||
ui.small("Inferred gap").on_hover_text("No source row to edit. Resolve adjacent rows and recheck to update this interval. Duration is elapsed time, not a timer.");
|
||||
return;
|
||||
}
|
||||
ui.push_id(("schedule_kind", row.row), |ui| {
|
||||
let detected = if self.dirty {
|
||||
None
|
||||
|
|
@ -798,16 +841,7 @@ impl App {
|
|||
ui.end_row();
|
||||
}
|
||||
});
|
||||
if let Some(r) = &a.rundown {
|
||||
for g in &r.gaps {
|
||||
ui.label(format!(
|
||||
"Gap: {} → {} · {} (no timer)",
|
||||
g.start_ms.map(display).unwrap_or("?".into()),
|
||||
g.end_ms.map(display).unwrap_or("?".into()),
|
||||
g.title
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
if jump_visible {
|
||||
self.jump_row = None;
|
||||
|
|
@ -942,6 +976,46 @@ mod tests {
|
|||
render(app, ctx, size, events)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gaps_appear_between_source_rows_without_becoming_editable_events() {
|
||||
let mut app = sample();
|
||||
app.tables[0].rows.last_mut().unwrap()[0].text = "09:15".into();
|
||||
let analyze = |profile: &Profile| {
|
||||
pipeline::analyze(&app.tables[0], profile, &AtomicBool::new(false), |_, _| {})
|
||||
};
|
||||
let analysis = analyze(&Profile::default());
|
||||
let rows = preview_rows(&analysis, Some(&app.tables[0]));
|
||||
let gap = rows.iter().position(|r| r.gap).unwrap();
|
||||
assert_eq!(rows[gap].row, 0);
|
||||
assert_eq!(rows[gap + 1].row, 15);
|
||||
assert_eq!(rows[gap].start, display(9 * 3_600_000 + 5 * 60_000));
|
||||
assert_eq!(rows[gap].duration, display(10 * 60_000));
|
||||
assert!(show_row(
|
||||
&rows[gap],
|
||||
RowFilter::Attention,
|
||||
Some(&app.tables[0]),
|
||||
&Profile::default()
|
||||
));
|
||||
assert_eq!(analysis.rundown.as_ref().unwrap().entries.len(), 2);
|
||||
let profile = Profile {
|
||||
row_kinds: [(3, "gap".into())].into_iter().collect(),
|
||||
..Default::default()
|
||||
};
|
||||
let named = analyze(&profile);
|
||||
let rows = preview_rows(&named, Some(&app.tables[0]));
|
||||
assert_eq!(rows.iter().filter(|r| r.row == 3).count(), 1);
|
||||
assert!(rows.iter().find(|r| r.row == 3).unwrap().gap);
|
||||
app.analysis = Some(analysis);
|
||||
app.row_filter = RowFilter::Included;
|
||||
app.review_scroll = Some(10_000.0);
|
||||
let ctx = egui::Context::default();
|
||||
configure_style(&ctx);
|
||||
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 == "Inferred gap"));
|
||||
assert!(!app.dirty);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_cells_require_double_click_and_hover_explains_issues() {
|
||||
let mut app = sample();
|
||||
|
|
|
|||
|
|
@ -40,10 +40,13 @@ click **Analyze rundown**. Review has two views:
|
|||
duration corrections are visible together. **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
|
||||
diagnostics from the last analysis. Ignored rows can be restored using All rows.
|
||||
diagnostics from the last analysis and gaps for context. Ignored rows can be restored using All rows.
|
||||
Notes attached to another event keep their own source row and identify their
|
||||
parent timer instead of duplicating it. Amber means unresolved, red means an
|
||||
error, and gray means ignored. Unknown values show `?`.
|
||||
error, gray means ignored, and teal marks gaps. Gaps appear in schedule order
|
||||
with their start, end and elapsed duration (no timer). Named breaks use their
|
||||
source row; inferred gaps have no editable source row and update after recheck.
|
||||
Unknown values show `?`.
|
||||
Hover over a title or issue button for row status and full diagnostic explanations.
|
||||
Double-click a row number/title to read all original cells. **Issues** opens the issue
|
||||
navigator, including sheet-level and gap errors; row issue buttons open the
|
||||
|
|
|
|||
Loading…
Reference in New Issue