refactor: update meta plugins structure to use map and vector
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -13,7 +13,8 @@ use crate::meta_plugin;
|
||||
pub struct StatusInfo {
|
||||
pub paths: PathInfo,
|
||||
pub compression: Vec<CompressionInfo>,
|
||||
pub meta_plugins: Vec<MetaPluginInfo>,
|
||||
pub meta_plugins: std::collections::HashMap<String, MetaPluginInfo>,
|
||||
pub enabled_meta_plugins: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@@ -36,10 +37,6 @@ pub struct CompressionInfo {
|
||||
#[derive(serde::Serialize, serde::Deserialize, ToSchema, Clone)]
|
||||
pub struct MetaPluginInfo {
|
||||
pub meta_name: String,
|
||||
pub found: bool,
|
||||
pub enabled: bool,
|
||||
pub binary: String,
|
||||
pub args: String,
|
||||
pub outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
pub options: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
}
|
||||
@@ -93,7 +90,8 @@ pub fn generate_status_info(
|
||||
});
|
||||
}
|
||||
|
||||
let mut meta_plugin_info = Vec::new();
|
||||
let mut meta_plugins_map = std::collections::HashMap::new();
|
||||
let mut enabled_meta_plugins_vec = Vec::new();
|
||||
|
||||
// Sort meta plugin types by their string representation to avoid creating plugins just for sorting
|
||||
let mut sorted_meta_plugins: Vec<MetaPluginType> = MetaPluginType::iter().collect();
|
||||
@@ -104,34 +102,18 @@ pub fn generate_status_info(
|
||||
log::debug!("STATUS: About to call get_meta_plugin");
|
||||
let meta_plugin = meta_plugin::get_meta_plugin(meta_plugin_type.clone(), None, None);
|
||||
log::debug!("STATUS: Created meta plugin instance");
|
||||
let is_supported = meta_plugin.is_supported();
|
||||
log::debug!("STATUS: Checked is_supported: {}", is_supported);
|
||||
let is_enabled = enabled_meta_plugins.contains(&meta_plugin_type);
|
||||
log::debug!("STATUS: Checked is_enabled: {}", is_enabled);
|
||||
|
||||
// Get meta name first to avoid borrowing issues
|
||||
log::debug!("STATUS: Getting meta name...");
|
||||
let meta_name = meta_plugin.meta_type().to_string();
|
||||
log::debug!("STATUS: Got meta name: {}", meta_name);
|
||||
|
||||
// Note: In status mode we don't have access to actual settings,
|
||||
// so we can't configure plugins with their settings here.
|
||||
// Plugin configuration happens during save operations.
|
||||
// Check if this plugin is enabled
|
||||
let is_enabled = enabled_meta_plugins.contains(&meta_plugin_type);
|
||||
if is_enabled {
|
||||
enabled_meta_plugins_vec.push(meta_name.clone());
|
||||
}
|
||||
|
||||
let (binary_display, args_display) = if !is_supported {
|
||||
("<NOT FOUND>".to_string(), "".to_string())
|
||||
} else {
|
||||
if meta_plugin.is_internal() {
|
||||
("<INTERNAL>".to_string(), "".to_string())
|
||||
} else {
|
||||
if let Some((program, args)) = meta_plugin.program_info() {
|
||||
(program.to_string(), args.join(" "))
|
||||
} else {
|
||||
("<NOT FOUND>".to_string(), "".to_string())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Create a display of outputs for status - use configured outputs if available, otherwise defaults
|
||||
let outputs_display = if meta_plugin.outputs().is_empty() {
|
||||
// No configured outputs, use defaults
|
||||
@@ -145,20 +127,20 @@ pub fn generate_status_info(
|
||||
meta_plugin.outputs().clone()
|
||||
};
|
||||
|
||||
meta_plugin_info.push(MetaPluginInfo {
|
||||
// Get options
|
||||
let options = meta_plugin.options().clone();
|
||||
|
||||
meta_plugins_map.insert(meta_name.clone(), MetaPluginInfo {
|
||||
meta_name,
|
||||
found: is_supported,
|
||||
enabled: is_enabled,
|
||||
binary: binary_display,
|
||||
args: args_display,
|
||||
outputs: outputs_display,
|
||||
options: std::collections::HashMap::new(),
|
||||
options,
|
||||
});
|
||||
}
|
||||
|
||||
StatusInfo {
|
||||
paths: path_info,
|
||||
compression: compression_info,
|
||||
meta_plugins: meta_plugin_info,
|
||||
meta_plugins: meta_plugins_map,
|
||||
enabled_meta_plugins: enabled_meta_plugins_vec,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user