feat: display filter plugin information in status output

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-03 09:05:49 -03:00
parent 99656ea048
commit a7b46658ac
2 changed files with 58 additions and 11 deletions

View File

@@ -122,7 +122,7 @@ fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
compression_table compression_table
} }
fn build_filter_plugin_table() -> Table { fn build_filter_plugin_table(filter_plugins: &Vec<String>) -> Table {
let mut filter_plugin_table = Table::new(); let mut filter_plugin_table = Table::new();
if std::io::stdout().is_terminal() { if std::io::stdout().is_terminal() {
filter_plugin_table.set_format(*FORMAT_BOX_CHARS); filter_plugin_table.set_format(*FORMAT_BOX_CHARS);
@@ -135,13 +135,57 @@ fn build_filter_plugin_table() -> Table {
b->"Options", b->"Options",
b->"Description")); b->"Description"));
// For now, we'll use a placeholder since we don't have access to filter plugin information // Sort plugins by name
// In a real implementation, you would query the available filter plugins let mut sorted_plugin_names = filter_plugins.clone();
filter_plugin_table.add_row(Row::new(vec![ sorted_plugin_names.sort();
Cell::new("No filter plugins available"),
Cell::new("{}"), for plugin_name in sorted_plugin_names {
Cell::new(""), // Get the plugin creator
])); let filter_plugins_map = crate::filter_plugin::get_available_filter_plugins();
if let Some(plugin_creator) = filter_plugins_map.get(&plugin_name) {
// Create a temporary instance to get options
let plugin = plugin_creator();
// Get options
let options = plugin.options();
// Format options as YAML string
let options_str = if options.is_empty() {
"{}".to_string()
} else {
let options_map: std::collections::BTreeMap<_, _> = options
.iter()
.map(|opt| (opt.name.clone(), serde_yaml::to_value(opt).unwrap()))
.collect();
serde_yaml::to_string(&options_map)
.unwrap_or_else(|_| "Unable to serialize options".to_string())
.trim()
.to_string()
};
// Get description from the first option or use a default
let description = if let Some(first_opt) = options.first() {
first_opt.description.clone().unwrap_or_else(|| "Filter plugin".to_string())
} else {
"Filter plugin".to_string()
};
filter_plugin_table.add_row(Row::new(vec![
Cell::new(&plugin_name),
Cell::new(&options_str),
Cell::new(&description),
]));
}
}
// If no filter plugins are available, add a row indicating that
if filter_plugins.is_empty() {
filter_plugin_table.add_row(Row::new(vec![
Cell::new("No filter plugins available"),
Cell::new("{}"),
Cell::new(""),
]));
}
filter_plugin_table filter_plugin_table
} }

View File

@@ -31,10 +31,13 @@ impl StatusService {
Some(crate::compression_engine::default_compression_type()) Some(crate::compression_engine::default_compression_type())
}; };
let status_info = generate_status_info(data_path, db_path, &meta_plugin_types, enabled_compression_type); let mut status_info = generate_status_info(data_path, db_path, &meta_plugin_types, enabled_compression_type);
// The options are now populated directly in generate_status_info // Add filter plugins information
// No need to modify them here status_info.filter_plugins = filter_plugin::get_available_filter_plugins()
.keys()
.map(|name| name.clone())
.collect();
status_info status_info
} }