From 51b23b8b2517f63a42f0cbf063c42cb989c5d1fb Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 16 Oct 2026 00:08:20 +0200 Subject: [PATCH] fix: expose configuration save in fader editor Test: cargo test -p tui --all-targets --all-features --locked Test: cargo clippy -p tui --all-targets --all-features --locked -- -D warnings Test: cargo fmt --all -- --check --- tui/src/lib.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tui/src/lib.rs b/tui/src/lib.rs index c7045dd..a9a364c 100644 --- a/tui/src/lib.rs +++ b/tui/src/lib.rs @@ -968,6 +968,7 @@ enum FaderEditorRow { Density { density: FaderDensity, }, + Save, } enum MixerRow<'a> { @@ -1746,6 +1747,9 @@ impl LiveTui { .unwrap_or((false, FaderDensity::Standard)); rows.push(FaderEditorRow::Density { density }); rows.push(FaderEditorRow::Visibility { hidden }); + if self.snapshot.configuration.dirty { + rows.push(FaderEditorRow::Save); + } rows } @@ -1907,6 +1911,12 @@ impl LiveTui { density: density.next(), }); } + FaderEditorRow::Save => { + self.save_configuration(); + if !self.snapshot.configuration.dirty { + self.fader_editor = None; + } + } _ => {} } } @@ -2660,6 +2670,9 @@ impl LiveTui { FaderEditorRow::Density { density } => { format!("{marker} Size {} [Enter to cycle]", density.label()) } + FaderEditorRow::Save => { + format!("{marker} Save changes [Enter to activate]") + } }; Line::from(text).style(if index == editor.selected { Style::default().fg(theme.accent).bold() @@ -3792,6 +3805,12 @@ mod tests { self.snapshot.configuration.learning = None; Ok(self.snapshot.clone()) } + + fn save_configuration(&mut self, expected_revision: u64) -> io::Result { + self.snapshot.configuration.dirty = false; + self.snapshot.configuration.applied_revision = expected_revision; + Ok(self.snapshot.clone()) + } } #[test] @@ -4451,6 +4470,44 @@ mod tests { ); } + #[test] + fn dirty_fader_editor_exposes_save_and_activates_the_draft() { + let mut snapshot = DemoClient::default().view(); + snapshot.items[0].id.id = "music".into(); + snapshot.configuration.faders = vec![ConfiguredFader { + id: "music-fader".into(), + target: snapshot.items[0].id.clone(), + pickup: true, + pickup_tolerance: 0.02, + }]; + snapshot.configuration.mixer_layout = vec![MixerLayoutEntry::Fader { + fader: "music-fader".into(), + hidden: false, + density: FaderDensity::Standard, + }]; + snapshot.configuration.dirty = true; + snapshot.configuration.revision = 4; + let edits = Arc::new(Mutex::new(Vec::new())); + let mut app = LiveTui::new(LayoutClient { snapshot, edits }).unwrap(); + + app.handle_key_event(press(KeyCode::Char('e'))); + let area = Rect::new(0, 0, 100, 22); + let mut buffer = Buffer::empty(area); + (&app).render(area, &mut buffer); + let rendered = buffer + .content + .iter() + .map(|cell| cell.symbol()) + .collect::(); + assert!(rendered.contains("Save changes")); + + app.fader_editor.as_mut().unwrap().selected = app.fader_editor_rows().len() - 1; + app.handle_key_event(press(KeyCode::Enter)); + + assert!(!app.snapshot.configuration.dirty); + assert_eq!(app.snapshot.configuration.applied_revision, 4); + } + #[test] fn fader_density_cycles_and_compact_rows_render_at_their_exact_heights() { assert_eq!(FaderDensity::Slim.next(), FaderDensity::BorderedSlim);