Highlight ambiguous column candidates by default

This commit is contained in:
Dandaedre 2026-11-03 15:57:28 +01:00
parent 6777174beb
commit 93a5c75bd2
3 changed files with 54 additions and 11 deletions

View File

@ -52,6 +52,7 @@ struct App {
advanced_settings: bool,
mapping_focus: Option<(String, Vec<usize>)>,
mapping_focus_scroll: Option<usize>,
mapping_focus_until: Option<f64>,
review_view: ReviewView,
dirty: bool,
issue_index: usize,
@ -110,6 +111,7 @@ impl Default for App {
advanced_settings: false,
mapping_focus: None,
mapping_focus_scroll: None,
mapping_focus_until: None,
review_view: ReviewView::Rows,
dirty: false,
issue_index: 0,
@ -132,6 +134,7 @@ impl App {
self.analysis = None;
self.mapping_focus = None;
self.mapping_focus_scroll = None;
self.mapping_focus_until = None;
self.dirty = false;
self.issue_index = 0;
self.selected_row = None;
@ -263,6 +266,7 @@ impl App {
self.issue_index = 0;
self.mapping_focus = None;
self.mapping_focus_scroll = None;
self.mapping_focus_until = None;
self.selected_row = a.diagnostics.first().and_then(review::diagnostic_row);
self.selected_gap = None;
self.jump_row = self.selected_row;

View File

@ -828,8 +828,15 @@ impl App {
}
fn columns_view(&mut self, ui: &mut egui::Ui) {
let now = ui.input(|input| input.time);
let mut mapping_focus = self.mapping_focus.clone();
let mut mapping_focus_scroll = self.mapping_focus_scroll;
let mut mapping_focus_until = self.mapping_focus_until;
if mapping_focus_until.is_some_and(|until| now >= until) {
mapping_focus = None;
mapping_focus_until = None;
}
let mut ambiguities = Vec::new();
if let (Some(table), Ok(mut profile)) = (
self.tables.iter().find(|t| t.name == self.sheet),
serde_json::from_str::<Profile>(&self.profile),
@ -860,6 +867,7 @@ impl App {
);
for error in errors {
if let Some((role, candidates)) = ambiguous_columns(&error.message) {
ambiguities.push((role.clone(), candidates.clone()));
let letters = candidates
.iter()
.map(|column| column_name(*column))
@ -878,6 +886,7 @@ impl App {
{
mapping_focus_scroll = candidates.first().copied();
mapping_focus = Some((role, candidates));
mapping_focus_until = Some(now + 3.0);
}
ui.collapsing("Technical details", |ui| {
ui.add(egui::Label::new(&error.message).wrap());
@ -911,16 +920,33 @@ impl App {
let width = table.rows.iter().map(Vec::len).max().unwrap_or(0);
for c in 0..width {
ui.separator();
let highlighted_role = mapping_focus
.as_ref()
let highlighted_role = ambiguities
.iter()
.filter(|(_, candidates)| candidates.contains(&c))
.map(|(role, _)| role.clone());
.map(|(role, _)| role.as_str())
.collect::<Vec<_>>()
.join(" / ");
let focused = mapping_focus_until.is_some_and(|until| now < until)
&& mapping_focus
.as_ref()
.is_some_and(|(_, candidates)| candidates.contains(&c));
let mut frame = egui::Frame::new().inner_margin(6.0);
if highlighted_role.is_some() {
if !highlighted_role.is_empty() {
let pulse = if focused {
((now * std::f64::consts::TAU * 1.5).sin() * 0.5 + 0.5) as f32
} else {
0.0
};
let fill = Color32::from_rgb(54, 44, 26)
.lerp_to_gamma(Color32::from_rgb(91, 68, 24), pulse * 0.7);
frame = frame
.fill(Color32::from_rgb(54, 44, 26))
.stroke(egui::Stroke::new(1.0_f32, PREVIEW_AMBER))
.fill(fill)
.stroke(egui::Stroke::new(1.0_f32 + pulse, PREVIEW_AMBER))
.corner_radius(4.0);
if focused {
ui.ctx()
.request_repaint_after(std::time::Duration::from_millis(40));
}
}
let response = frame.show(ui, |ui| {
ui.horizontal_wrapped(|ui| {
@ -929,8 +955,11 @@ impl App {
column_name(c),
table.cell(header - 1, c).text
));
if let Some(role) = &highlighted_role {
ui.colored_label(PREVIEW_AMBER, format!("{role} candidate"));
if !highlighted_role.is_empty() {
ui.colored_label(
PREVIEW_AMBER,
format!("{highlighted_role} candidate"),
);
}
let col = column_name(c);
let mut chosen = profile
@ -1005,6 +1034,7 @@ impl App {
}
self.mapping_focus = mapping_focus;
self.mapping_focus_scroll = mapping_focus_scroll;
self.mapping_focus_until = mapping_focus_until;
}
fn schedule_preview(&mut self, ui: &mut egui::Ui) {
@ -1802,6 +1832,13 @@ mod tests {
.iter()
.any(|(s, _)| s.contains("parent and child timers"))
);
assert_eq!(
labels
.iter()
.filter(|(s, _)| s == "duration candidate")
.count(),
2
);
let choose = labels
.iter()
.find(|(s, _)| s == "Choose duration column…")
@ -1810,6 +1847,7 @@ mod tests {
.center();
click_size(&mut app, &ctx, choose, [860.0, 900.0]);
assert_eq!(app.mapping_focus, Some(("duration".into(), vec![1, 2])));
assert!(app.mapping_focus_until.is_some());
let labels = render(&mut app, &ctx, [860.0, 900.0], vec![]);
assert_eq!(
labels

View File

@ -54,9 +54,10 @@ available after the timing mapping is unambiguous and rechecked. Spreadsheet
cells marked as times display as `HH:MM:SS` in samples and the inspector; the
original stored value remains available in the inspector.
When several columns could have the same timing role, the error gives a short
instruction and a **Choose … column…** button. It scrolls to the candidate
columns and highlights them in amber; the original inference explanation remains
available under **Technical details**.
instruction and highlights all candidate columns in amber immediately. The
**Choose … column…** button scrolls to that candidate group and briefly pulses
its framing, which distinguishes the requested group when several mapping issues
are present. The original inference explanation remains under **Technical details**.
Review has two views:
The main navigation and Review view tabs use a subtle purple tint so they remain