Reorder tabs and migrate legacy keymap tab indices

Tabs are now 1 Library, 2 Playlists, 3 Queue, 4 Podcasts, 5 Settings,
6 Logs. The Podcasts tab is a placeholder that states podcasts are not
available in this build yet; it gets its own "podcasts" key context.

Keymap files gain an optional top-level `version`. The default keymap
declares `version = 2` and binds "6" to the Logs tab. Files without a
version (or with version 1) have their GoToTab indices remapped in
memory (3 -> 4, 4 -> 5, and 5 -> 3 for the prototype podcast build) with
a startup notice; the user's file is never rewritten. The help window
names the target tab instead of "Go to tab N".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-19 15:17:59 +02:00
1 parent 292f17fee1
commit e78f1627da
8 files changed
+487 -11

No files matched your search

+91
View File
@@ -186,6 +186,97 @@ fn tab_cycling_wraps() {
assert_eq!(state.active_tab, Tab::Global);
}
#[test]
fn tabs_follow_the_documented_order() {
use crate::config::keymap::KeyContext;
assert_eq!(
Tab::ALL,
[
Tab::Global,
Tab::Playlists,
Tab::Queue,
Tab::Podcasts,
Tab::Federation,
Tab::Logs,
]
);
let titles: Vec<_> = Tab::ALL.iter().map(|tab| tab.title()).collect();
assert_eq!(
titles,
[
"Library",
"Playlists",
"Queue",
"Podcasts",
"Settings",
"Logs"
]
);
for (index, tab) in Tab::ALL.iter().enumerate() {
assert_eq!(tab.index(), index);
assert_eq!(Tab::from_index(index), Some(*tab));
}
assert_eq!(Tab::from_index(Tab::ALL.len()), None);
assert_eq!(Tab::Podcasts.key_context(), KeyContext::Podcasts);
assert_eq!(Tab::Federation.key_context(), KeyContext::Federation);
}
#[test]
fn next_and_prev_tab_visit_every_tab_in_order() {
let mut state = AppState::default();
for expected in Tab::ALL.iter().cycle().skip(1).take(Tab::ALL.len()) {
update(&mut state, Action::NextTab);
assert_eq!(state.active_tab, *expected);
}
assert_eq!(state.active_tab, Tab::Global);
for expected in Tab::ALL.iter().rev() {
update(&mut state, Action::PrevTab);
assert_eq!(state.active_tab, *expected);
}
assert_eq!(state.active_tab, Tab::Global);
}
#[test]
fn go_to_tab_uses_the_new_numbering() {
let mut state = AppState::default();
for (index, tab) in [
(3, Tab::Podcasts),
(4, Tab::Federation),
(5, Tab::Logs),
(2, Tab::Queue),
] {
update(&mut state, Action::GoToTab(index));
assert_eq!(state.active_tab, tab);
}
// Out-of-range indices are ignored.
update(&mut state, Action::GoToTab(6));
assert_eq!(state.active_tab, Tab::Queue);
// Re-selecting the placeholder tab is a harmless reset.
update(&mut state, Action::GoToTab(3));
update(&mut state, Action::GoToTab(3));
assert_eq!(state.active_tab, Tab::Podcasts);
}
#[test]
fn help_names_tabs_for_go_to_tab() {
let labels: Vec<_> = (0..Tab::ALL.len())
.map(|index| Action::GoToTab(index).describe())
.collect();
assert_eq!(
labels,
[
"Go to Library",
"Go to Playlists",
"Go to Queue",
"Go to Podcasts",
"Go to Settings",
"Go to Logs",
]
);
assert_eq!(Action::GoToTab(6).describe(), "Go to tab 7");
}
#[test]
fn volume_clamps() {
let mut state = AppState::default();