diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-17 16:08:43 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-17 16:08:43 +0300 |
| commit | 54490254f70469cd154ee630bc4bec84da178f0c (patch) | |
| tree | 450bf0397398b28932f636d33e37f73c011dd19d /src/app/mod.rs | |
| parent | d998753efe506a04c80306795efc72bff60bb0ec (diff) | |
feat: sort agent panel by priority
refs #318
Diffstat (limited to 'src/app/mod.rs')
| -rw-r--r-- | src/app/mod.rs | 61 |
1 files changed, 22 insertions, 39 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs index 1b90f157..ff1581cf 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -204,12 +204,12 @@ fn load_plugin_registry(no_session: bool) -> crate::app::state::InstalledPluginR .collect() } -fn agent_panel_scope_from_config( - scope: crate::config::AgentPanelScopeConfig, -) -> state::AgentPanelScope { - match scope { - crate::config::AgentPanelScopeConfig::Current => state::AgentPanelScope::CurrentWorkspace, - crate::config::AgentPanelScopeConfig::All => state::AgentPanelScope::AllWorkspaces, +fn agent_panel_sort_from_config( + sort: crate::config::AgentPanelSortConfig, +) -> state::AgentPanelSort { + match sort { + crate::config::AgentPanelSortConfig::Spaces => state::AgentPanelSort::Spaces, + crate::config::AgentPanelSortConfig::Priority => state::AgentPanelSort::Priority, } } @@ -289,7 +289,6 @@ impl App { workspaces, active, selected, - _restored_agent_panel_scope, sidebar_width, sidebar_width_source, sidebar_section_split, @@ -299,7 +298,6 @@ impl App { Vec::new(), None, 0, - state::AgentPanelScope::CurrentWorkspace, config.ui.sidebar_width, state::SidebarWidthSource::ConfigDefault, 0.5_f32, @@ -332,7 +330,6 @@ impl App { Vec::new(), None, 0, - snap.agent_panel_scope, snap.sidebar_width.unwrap_or(config.ui.sidebar_width), if snap.sidebar_width.is_some() { state::SidebarWidthSource::Persisted @@ -350,7 +347,6 @@ impl App { ws, active, selected, - snap.agent_panel_scope, snap.sidebar_width.unwrap_or(config.ui.sidebar_width), if snap.sidebar_width.is_some() { state::SidebarWidthSource::Persisted @@ -366,7 +362,6 @@ impl App { Vec::new(), None, 0, - state::AgentPanelScope::CurrentWorkspace, config.ui.sidebar_width, state::SidebarWidthSource::ConfigDefault, 0.5_f32, @@ -374,7 +369,7 @@ impl App { ) }; - let agent_panel_scope = agent_panel_scope_from_config(config.ui.agent_panel_scope); + let agent_panel_sort = agent_panel_sort_from_config(config.ui.agent_panel_sort); // Validate sidebar bounds before they reach any `u16::clamp(min, max)` // call: `clamp` panics when `min > max`. On bad config, fall back to @@ -519,7 +514,8 @@ impl App { sidebar_width_auto: false, sidebar_collapsed: false, sidebar_section_split, - agent_panel_scope, + agent_panel_sort, + next_agent_state_change_seq: 0, mouse_capture: config.ui.mouse_capture, right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(), right_click_passthrough: None, @@ -693,7 +689,6 @@ impl App { app.state.selected = snapshot .selected .min(app.state.workspaces.len().saturating_sub(1)); - app.state.agent_panel_scope = snapshot.agent_panel_scope; if let Some(width) = snapshot.sidebar_width { app.state.sidebar_width = width; app.state.sidebar_width_source = state::SidebarWidthSource::Persisted; @@ -1246,8 +1241,8 @@ impl App { self.state.prompt_new_tab_name = config.ui.prompt_new_tab_name; self.state.show_agent_labels_on_pane_borders = config.ui.show_agent_labels_on_pane_borders; - self.state.agent_panel_scope = - agent_panel_scope_from_config(config.ui.agent_panel_scope); + self.state.agent_panel_sort = + agent_panel_sort_from_config(config.ui.agent_panel_sort); self.state.agent_panel_scroll = 0; self.state.accent = crate::config::parse_color(&config.ui.accent); if !self.state.local_sound_playback && self.state.sound != config.ui.sound { @@ -2065,17 +2060,14 @@ mod tests { } #[test] - fn startup_uses_configured_agent_panel_scope() { + fn startup_uses_configured_agent_panel_sort() { let mut config = Config::default(); - config.ui.agent_panel_scope = crate::config::AgentPanelScopeConfig::Current; + config.ui.agent_panel_sort = crate::config::AgentPanelSortConfig::Priority; let (_api_tx, api_rx) = tokio::sync::mpsc::unbounded_channel(); let app = App::new(&config, true, None, api_rx, crate::api::EventHub::default()); - assert_eq!( - app.state.agent_panel_scope, - state::AgentPanelScope::CurrentWorkspace - ); + assert_eq!(app.state.agent_panel_sort, state::AgentPanelSort::Priority); } #[test] @@ -2199,7 +2191,7 @@ mod tests { std::fs::create_dir_all(path.parent().unwrap()).unwrap(); std::fs::write( &path, - "[terminal]\ndefault_shell = \"nu\"\nshell_mode = \"non_login\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+m\"\nprefix = \"ctrl+a\"\n[ui]\nagent_panel_scope = \"current\"\nredraw_on_focus_gained = false\nright_click_passthrough_modifier = \"ctrl\"\n[ui.toast]\ndelivery = \"herdr\"\n[experimental]\nswitch_ascii_input_source_in_prefix = true\n", + "[terminal]\ndefault_shell = \"nu\"\nshell_mode = \"non_login\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+m\"\nprefix = \"ctrl+a\"\n[ui]\nagent_panel_scope = \"current\"\nagent_panel_sort = \"priority\"\nredraw_on_focus_gained = false\nright_click_passthrough_modifier = \"ctrl\"\n[ui.toast]\ndelivery = \"herdr\"\n[experimental]\nswitch_ascii_input_source_in_prefix = true\n", ) .unwrap(); std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path); @@ -2219,10 +2211,7 @@ mod tests { app.state.toast_config.delivery, crate::config::ToastDelivery::Herdr ); - assert_eq!( - app.state.agent_panel_scope, - state::AgentPanelScope::CurrentWorkspace - ); + assert_eq!(app.state.agent_panel_sort, state::AgentPanelSort::Priority); assert!(!app.state.redraw_on_focus_gained); assert_eq!( app.state.right_click_passthrough_modifiers, @@ -2561,27 +2550,21 @@ mod tests { } #[test] - fn save_agent_panel_scope_persists_then_applies_live_config() { + fn save_agent_panel_sort_persists_then_applies_live_config() { let _guard = config_env_lock().lock().unwrap(); - let path = temp_config_path("save-agent-panel-scope"); + let path = temp_config_path("save-agent-panel-sort"); std::fs::create_dir_all(path.parent().unwrap()).unwrap(); std::fs::write(&path, "onboarding = false\n").unwrap(); std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path); let mut app = test_app(); - assert_eq!( - app.state.agent_panel_scope, - state::AgentPanelScope::AllWorkspaces - ); + assert_eq!(app.state.agent_panel_sort, state::AgentPanelSort::Spaces); - app.save_agent_panel_scope(state::AgentPanelScope::CurrentWorkspace); + app.save_agent_panel_sort(state::AgentPanelSort::Priority); - assert_eq!( - app.state.agent_panel_scope, - state::AgentPanelScope::CurrentWorkspace - ); + assert_eq!(app.state.agent_panel_sort, state::AgentPanelSort::Priority); let content = std::fs::read_to_string(&path).unwrap(); - assert!(content.contains("agent_panel_scope = \"current\"")); + assert!(content.contains("agent_panel_sort = \"priority\"")); assert!(app.state.config_diagnostic.is_none()); std::env::remove_var(crate::config::CONFIG_PATH_ENV_VAR); |
