From 33798eeb6e446d9a939994e23bf42c7b97e54355 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 16 Oct 2026 19:34:19 +0200 Subject: [PATCH] fix(M9.4): accept unnamed separators and spacers Allow empty labels in profile validation and the separator popup; retain unique stable IDs and draw unnamed rules without a label gap. PASS: failing-first empty-label config/TUI regressions; cargo fmt --all -- --check; cargo check --workspace --all-targets --all-features; cargo test --workspace --all-targets --all-features --quiet (2 opt-in tests ignored); cargo test --workspace --doc --all-features; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo build --workspace --release --all-features; default/no-default workspace and independent MIDI/Pulse feature checks. --- architecture.md | 4 +++- config/src/profile.rs | 8 +------ config/tests/editor.rs | 13 ++++++++++++ task.md | 2 ++ tui/src/lib.rs | 48 +++++++++++++++++++++++++++--------------- 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/architecture.md b/architecture.md index 77ccd25..ae20917 100644 --- a/architecture.md +++ b/architecture.md @@ -503,7 +503,9 @@ so the common help key does not perform a destructive presentation edit. The selected main-list entry can be moved directly, and separators can be added, renamed, moved, or removed. A centered separator dialog edits its name, -size, and decoration. Separator size is independent of fader density: +size, and decoration. Names may be empty; the stable ID still identifies each separator. Plain with +an empty name creates a spacer, and an unnamed Line/Double separator draws an +unbroken rule. Separator size is independent of fader density: `slim`, `standard` (default), `thick`, or `fill`. Size controls height in the stacked layout and width in the side-by-side layout. Decorations are `plain`, `line` (default), `double`, or `box`. A slim stacked separator occupies one diff --git a/config/src/profile.rs b/config/src/profile.rs index f46981b..4628a43 100644 --- a/config/src/profile.rs +++ b/config/src/profile.rs @@ -924,14 +924,8 @@ fn validate_mixer_layout( } (fader, true) } - MixerLayoutEntry::Separator { id, label, .. } => { + MixerLayoutEntry::Separator { id, .. } => { parse_id::(id, &format!("mixer_layout[{index}].id"))?; - if label.trim().is_empty() { - return Err(ConfigError::validation( - format!("mixer_layout[{index}].label"), - "must not be empty", - )); - } (id, false) } }; diff --git a/config/tests/editor.rs b/config/tests/editor.rs index 338ba86..a2e8de2 100644 --- a/config/tests/editor.rs +++ b/config/tests/editor.rs @@ -5,6 +5,19 @@ use fader_config::{ const PROFILE: &str = include_str!("../../examples/profiles/desktop.toml"); +#[test] +fn unnamed_separators_can_be_created_renamed_and_reloaded() { + let mut draft = ProfileDocument::parse(PROFILE).unwrap(); + draft.add_separator("spacer", "", 0).unwrap(); + draft.add_separator("divider", "Divider", 1).unwrap(); + draft.set_separator_label("divider", "").unwrap(); + let reloaded = ProfileDocument::parse(&draft.finish().unwrap()).unwrap(); + let profile = reloaded.preview().unwrap(); + for entry in &profile.mixer_layout()[..2] { + assert!(matches!(entry, MixerLayoutEntry::Separator { label, .. } if label.is_empty())); + } +} + #[test] fn separator_presentation_round_trips_without_changing_order() { use fader_config::{SeparatorDecoration, SeparatorSize}; diff --git a/task.md b/task.md index b76ae06..ab08c6e 100644 --- a/task.md +++ b/task.md @@ -410,6 +410,8 @@ Dependencies: M8, M2, M1. viewport space after fitting the other entries. Profile round trips, server save/snapshot, popup accept/cancel, both orientations, and tiny viewports are covered by regression tests. + Empty separator names are accepted in profile validation and the popup; + unnamed spacers retain unique stable IDs and survive save/reload. - [x] **M9.5 Guided fader editor:** replace pipe-delimited table commands with a selected-fader form. Application faders edit capture field/mode/pattern; groups select eligible application faders and show the absolute group mode; diff --git a/tui/src/lib.rs b/tui/src/lib.rs index 87c7aa7..c3b4436 100644 --- a/tui/src/lib.rs +++ b/tui/src/lib.rs @@ -1711,11 +1711,6 @@ impl LiveTui { return; }; let label = editor.value.trim(); - if label.is_empty() { - self.client_error = Some("separator name must not be empty".to_owned()); - self.editor = Some(editor); - return; - } let id = editor.target.clone().unwrap_or_else(|| { unique_separator_id(label, &self.snapshot.configuration.mixer_layout) }); @@ -3116,16 +3111,7 @@ impl LiveTui { } else { " Add separator " }; - let validation = self - .client_error - .as_deref() - .filter(|error| *error == "separator name must not be empty"); - let guidance = validation.unwrap_or("Choose a short, recognizable section name."); - let guidance_style = if validation.is_some() { - Style::default().fg(theme.error).bold() - } else { - Style::default().fg(theme.muted) - }; + let guidance = "Name is optional. Use Plain + Fill for an empty spacer."; Clear.render(popup, buf); Paragraph::new(Text::from(vec![ @@ -3148,7 +3134,7 @@ impl LiveTui { if editor.selected == 2 { "▶" } else { " " }, editor.decoration.label() )), - Line::from(guidance).style(guidance_style), + Line::from(guidance).fg(theme.muted), ])) .alignment(Alignment::Center) .block( @@ -4115,7 +4101,7 @@ impl LiveTui { .style(style) .render(line_area, buf); } - let label = if *decoration == SeparatorDecoration::Plain { + let label = if label.is_empty() || *decoration == SeparatorDecoration::Plain { (*label).to_owned() } else { format!(" {label} ") @@ -4686,6 +4672,34 @@ mod tests { assert!(question_rendered.contains("Keyboard help")); } + #[test] + fn unnamed_separators_are_accepted_with_unique_ids() { + let edits = Arc::new(Mutex::new(Vec::new())); + let mut app = LiveTui::new(LayoutClient { + snapshot: DemoClient::default().view(), + edits: Arc::clone(&edits), + }) + .unwrap(); + for _ in 0..2 { + app.handle_key_event(press(KeyCode::Char('a'))); + app.handle_key_event(press(KeyCode::Enter)); + assert!(app.editor.is_none(), "blank name must be accepted"); + } + let edits = edits.lock().unwrap(); + let ids = edits + .iter() + .filter_map(|edit| match edit { + ConfigurationEdit::AddSeparator { id, label, .. } => { + assert!(label.is_empty()); + Some(id) + } + _ => None, + }) + .collect::>(); + assert_eq!(ids.len(), 2); + assert_ne!(ids[0], ids[1]); + } + #[test] fn separator_popup_edits_size_and_decoration_and_cancel_discards_changes() { let edits = Arc::new(Mutex::new(Vec::new()));