From 4c2b1fcbf140406277378e754d10d1fc3f8f0987 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 5 Nov 2026 07:38:50 +0100 Subject: [PATCH] Unify warning and error cards with visible next steps --- crates/rundown-converter/src/gui.rs | 14 +- crates/rundown-converter/src/gui/review.rs | 186 ++++++++++++--------- docs/rundown-converter.md | 3 + 3 files changed, 123 insertions(+), 80 deletions(-) diff --git a/crates/rundown-converter/src/gui.rs b/crates/rundown-converter/src/gui.rs index 5b3ecc5..f2f0bd2 100644 --- a/crates/rundown-converter/src/gui.rs +++ b/crates/rundown-converter/src/gui.rs @@ -995,7 +995,19 @@ impl App { }); egui::TopBottomPanel::bottom("action").show(ctx, |ui| { if let Some(e) = &self.error { - ui.colored_label(Color32::from_rgb(230, 120, 90), e); + let color = Color32::from_rgb(245, 125, 120); + review::issue_frame(color).show(ui, |ui| { + ui.label( + egui::RichText::new("! Action could not be completed") + .color(color) + .strong(), + ); + ui.indent("operation_error", |ui| { + ui.add(egui::Label::new(e).wrap()); + ui.strong("Next step"); + ui.label("Resolve the problem described above, then try again."); + }); + }); } ui.horizontal(|ui| { if busy { diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index 797ecef..7a83f07 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -108,6 +108,20 @@ fn ambiguous_columns(message: &str) -> Option<(String, Vec)> { (!columns.is_empty()).then(|| (role.to_owned(), columns)) } +pub(super) fn issue_frame(color: Color32) -> egui::Frame { + egui::Frame::new() + .fill(color.gamma_multiply(0.08)) + .inner_margin(10.0) + .corner_radius(5.0) +} + +fn next_step(ui: &mut egui::Ui, id: impl std::hash::Hash, action: &str) { + ui.indent(id, |ui| { + ui.strong("Next step"); + ui.add(egui::Label::new(action).wrap()); + }); +} + fn diagnostic_column(diagnostic: &Diagnostic, table: &Table) -> Option { let cell = diagnostic .location @@ -948,13 +962,14 @@ impl App { }); let compact = ui.available_height() < 360.0; let d = a.diagnostics[selected].clone(); + let preview = preview_rows(a, self.tables.iter().find(|table| table.name == a.sheet)); if selected != self.issue_index { self.choose_issue(selected); } - egui::Frame::new().fill(Color32::from_rgb(47, 40, 31)).inner_margin(8.0).corner_radius(5.0).show(ui, |ui| { + issue_frame(if needs_information(&d) { PREVIEW_AMBER } else { PREVIEW_RED }).show(ui, |ui| { ui.set_width(ui.available_width()); ui.horizontal_wrapped(|ui| { - ui.strong(diagnostic_name(&d.code).to_lowercase()); + ui.label(RichText::new(diagnostic_name(&d.code).to_lowercase()).strong().color(if needs_information(&d) { PREVIEW_AMBER } else { PREVIEW_RED })); if let Some(row) = diagnostic_row(&d) { if ui.small_button(format!("Show row {row}")).clicked() { self.selected_row = Some(row); @@ -975,8 +990,13 @@ impl App { if compact { "Choose a row type below, or enter an event duration." } else { "This row has no timing. Choose Note, Marker or Gap below, or supply a duration if it is an event." } } else { explanation }; - egui::ScrollArea::vertical() - .scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible).id_salt("issue_explanation").max_height(48.0).show(ui, |ui| { ui.label(explanation); }); + if let Some(row) = preview.iter().find(|row| row.issues.contains(&selected)) { + next_step(ui, "selected_issue_action", diagnostic_resolution(row, selected, &d)); + egui::CollapsingHeader::new(RichText::new("Technical details").weak()) + .id_salt(("selected_issue_details", selected)).show(ui, |ui| { ui.label(explanation); }); + } else { + next_step(ui, "selected_issue_action", explanation); + } }); ui.add_space(4.0); } @@ -1240,11 +1260,15 @@ impl App { for index in &preview.issues { let d = &a.diagnostics[*index]; let color = if needs_information(d) { PREVIEW_AMBER } else { PREVIEW_RED }; - egui::Frame::group(ui.style()).show(ui, |ui| { - ui.colored_label(color, if preview.related_issues.contains(index) { + issue_frame(color).show(ui, |ui| { + ui.label(RichText::new(if preview.related_issues.contains(index) { "RELATED OVERLAP".into() - } else { diagnostic_name(&d.code) }); - ui.add(egui::Label::new(row_diagnostic_message(preview, *index, d)).wrap()); + } else { diagnostic_name(&d.code) }).color(color).strong()); + next_step(ui, ("row_issue_action", index), diagnostic_resolution(preview, *index, d)); + egui::CollapsingHeader::new(RichText::new("Technical details").weak()) + .id_salt(("row_issue_details", index)).show(ui, |ui| { + ui.add(egui::Label::new(row_diagnostic_message(preview, *index, d)).wrap()); + }); }); } } @@ -1384,8 +1408,11 @@ impl App { } else { PREVIEW_RED }; - egui::Frame::group(ui.style()).show(ui, |ui| { - ui.colored_label(color, diagnostic_name(&d.code)); + issue_frame(color).show(ui, |ui| { + ui.label(RichText::new(diagnostic_name(&d.code)).color(color).strong()); + next_step(ui, ("gap_issue_action", index), diagnostic_resolution(&preview, *index, d)); + egui::CollapsingHeader::new(RichText::new("Technical details").weak()) + .id_salt(("gap_issue_details", index)).show(ui, |ui| { ui.add( egui::Label::new( d.message @@ -1395,6 +1422,7 @@ impl App { ) .wrap(), ); + }); }); } } @@ -1516,7 +1544,7 @@ impl App { let code = error.code.as_str(); let message = error.message.as_str(); - { + issue_frame(PREVIEW_AMBER).show(ui, |ui| { ambiguities.push((role.clone(), candidates.clone())); let letters = candidates .iter() @@ -1540,6 +1568,7 @@ impl App { mapping_focus_until = Some(now + COLUMN_FOCUS_PULSE_SECONDS); } }); + next_step(ui, ("ambiguous_action", code, message), "Choose the intended column using the button above, then apply and recheck."); egui::CollapsingHeader::new(RichText::new("Technical details").weak()) .id_salt(("column_details", &table.name, code, message)) .show(ui, |ui| { @@ -1548,7 +1577,8 @@ impl App { .wrap(), ); }); - } + }); + ui.add_space(6.0); } for (column, occurrences) in grouped { if let Some(column) = column { @@ -1577,24 +1607,17 @@ impl App { }) .collect(); if missing { - egui::Frame::new() - .fill(PREVIEW_AMBER.gamma_multiply(0.08)) - .inner_margin(10.0) - .corner_radius(5.0) - .show(ui, |ui| { - ui.set_min_width(ui.available_width()); - for (reason, action) in &advice { - ui.label( - RichText::new(format!("! {reason}")) - .color(PREVIEW_AMBER) - .strong(), - ); - ui.indent(("missing_column_action", reason), |ui| { - ui.label(RichText::new("Next step").strong()); - ui.label(*action); - }); - } - }); + issue_frame(PREVIEW_AMBER).show(ui, |ui| { + ui.set_min_width(ui.available_width()); + for (reason, action) in &advice { + ui.label( + RichText::new(format!("! {reason}")) + .color(PREVIEW_AMBER) + .strong(), + ); + next_step(ui, ("missing_column_action", reason), action); + } + }); ui.add_space(6.0); continue; } @@ -1602,55 +1625,60 @@ impl App { || "Sheet / settings".into(), |c| format!("Column {}", column_name(c)), ); - ui.horizontal_wrapped(|ui| { - ui.colored_label( - PREVIEW_AMBER, - format!("{title} · {} issues", occurrences.len()), - ); - if let Some(column) = column { - if ui - .button( - if duration - && occurrences.iter().any(|error| { - matches!( - error.code.as_str(), - "INCONSISTENT_COLUMN_MEANING" - | "INVALID_DURATION_MODE" - ) - }) - { - "Choose duration handling…" - } else { - "Review column…" - }, - ) - .clicked() - { - mapping_focus_scroll = Some(column); - mapping_focus = Some(("warning".into(), vec![column])); - mapping_focus_until = Some(now + COLUMN_FOCUS_PULSE_SECONDS); + issue_frame(PREVIEW_AMBER).show(ui, |ui| { + ui.horizontal_wrapped(|ui| { + ui.colored_label( + PREVIEW_AMBER, + format!("{title} · {} issues", occurrences.len()), + ); + if let Some(column) = column { + if ui + .button( + if duration + && occurrences.iter().any(|error| { + matches!( + error.code.as_str(), + "INCONSISTENT_COLUMN_MEANING" + | "INVALID_DURATION_MODE" + ) + }) + { + "Choose duration handling…" + } else { + "Review column…" + }, + ) + .clicked() + { + mapping_focus_scroll = Some(column); + mapping_focus = Some(("warning".into(), vec![column])); + mapping_focus_until = + Some(now + COLUMN_FOCUS_PULSE_SECONDS); + } + } else if !missing && ui.button("Open Setup…").clicked() { + self.tab = Tab::Setup; + self.settings = true; } - } else if !missing && ui.button("Open Setup…").clicked() { - self.tab = Tab::Setup; - self.settings = true; + }); + for (reason, action) in advice { + ui.label(RichText::new(reason).color(PREVIEW_AMBER).strong()); + next_step(ui, ("column_action", column, reason), action); + } + if column.is_some() { + egui::CollapsingHeader::new(RichText::new("Affected cells").weak()) + .id_salt(("column_locations", &table.name, column)) + .show(ui, |ui| { + ui.weak( + occurrences + .iter() + .map(|error| error.location.as_str()) + .collect::>() + .join(", "), + ); + }); } }); - for (reason, action) in advice { - ui.label(format!("{reason}. {action}")); - } - if column.is_some() { - egui::CollapsingHeader::new(RichText::new("Affected cells").weak()) - .id_salt(("column_locations", &table.name, column)) - .show(ui, |ui| { - ui.weak( - occurrences - .iter() - .map(|error| error.location.as_str()) - .collect::>() - .join(", "), - ); - }); - } + ui.add_space(6.0); } } } @@ -3122,7 +3150,7 @@ mod tests { assert_eq!( labels .iter() - .filter(|(text, _)| text.starts_with("Formula results unavailable.")) + .filter(|(text, _)| text == "Formula results unavailable") .count(), 1 ); @@ -3246,7 +3274,7 @@ mod tests { assert_eq!( labels .iter() - .filter(|(text, _)| text.starts_with("Mixed or unclear durations.")) + .filter(|(text, _)| text == "Mixed or unclear durations") .count(), 1 ); @@ -4086,7 +4114,7 @@ mod tests { egui::Event::PointerMoved(egui::pos2(size[0] / 2.0, size[1] / 2.0)), egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Page, - delta: egui::vec2(0.0, -1.0), + delta: egui::vec2(0.0, -2.0), modifiers: Default::default(), }, ], diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index b8eaa05..9d585e3 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -129,6 +129,9 @@ visually distinct from labels and ordinary actions; the active tab uses the stro highlighted, and existing role suggestions remain available. A missing-column warning uses an amber card with an indented **Next step** explaining which role to choose, without duplicate summary headings. + Column problems, ambiguous mappings, row and gap diagnostics, and operation + errors share this card layout. Warnings use amber and errors use red, with + corrective steps visible and technical diagnostic details expandable. When detection is blocked, recognised headers still provide hints; these do not replace validation. Expand **Detection evidence** for full inference and validation details; hover the **Columns** tab for a compact