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.
This commit is contained in:
Dandaedre 2026-10-16 19:34:19 +02:00
parent 2e03e8f60c
commit 33798eeb6e
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
5 changed files with 50 additions and 25 deletions

View File

@ -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

View File

@ -924,14 +924,8 @@ fn validate_mixer_layout(
}
(fader, true)
}
MixerLayoutEntry::Separator { id, label, .. } => {
MixerLayoutEntry::Separator { id, .. } => {
parse_id::<FaderId>(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)
}
};

View File

@ -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};

View File

@ -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;

View File

@ -1711,11 +1711,6 @@ impl<C: MixerClient> LiveTui<C> {
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<C: MixerClient> LiveTui<C> {
} 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<C: MixerClient> LiveTui<C> {
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<C: MixerClient> LiveTui<C> {
.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::<Vec<_>>();
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()));