fix: ensure outputs are properly disabled in constructors

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 18:11:32 -03:00
parent 324b96d1e1
commit 42a10cc2d5
2 changed files with 103 additions and 41 deletions

View File

@@ -39,21 +39,69 @@ impl HostnameMetaPlugin {
}
}
// Start with default outputs
// Determine which outputs are enabled based on options
let hostname_enabled = match final_options.get("hostname") {
Some(serde_yaml::Value::Bool(b)) => *b,
Some(serde_yaml::Value::String(s)) => match s.as_str() {
"true" => true,
"false" => false,
"full" => true,
"short" => true,
_ => true,
},
_ => true,
};
let hostname_full_enabled = final_options.get("hostname_full")
.and_then(|v| v.as_bool())
.unwrap_or(true);
let hostname_short_enabled = final_options.get("hostname_short")
.and_then(|v| v.as_bool())
.unwrap_or(true);
// Start with default outputs, setting disabled ones to None
let mut final_outputs = std::collections::HashMap::new();
let default_outputs = vec![
"hostname".to_string(),
"hostname_full".to_string(),
"hostname_short".to_string(),
];
for output_name in default_outputs {
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
// Handle hostname output
if hostname_enabled {
final_outputs.insert("hostname".to_string(), serde_yaml::Value::String("hostname".to_string()));
} else {
final_outputs.insert("hostname".to_string(), serde_yaml::Value::Null);
}
// Override with provided outputs
// Handle hostname_full output
if hostname_full_enabled {
final_outputs.insert("hostname_full".to_string(), serde_yaml::Value::String("hostname_full".to_string()));
} else {
final_outputs.insert("hostname_full".to_string(), serde_yaml::Value::Null);
}
// Handle hostname_short output
if hostname_short_enabled {
final_outputs.insert("hostname_short".to_string(), serde_yaml::Value::String("hostname_short".to_string()));
} else {
final_outputs.insert("hostname_short".to_string(), serde_yaml::Value::Null);
}
// Override with provided outputs, but only if they're enabled
if let Some(outs) = outputs {
for (key, value) in outs {
final_outputs.insert(key, value);
// Only add if the output is enabled
match key.as_str() {
"hostname" => if hostname_enabled {
final_outputs.insert(key, value);
},
"hostname_full" => if hostname_full_enabled {
final_outputs.insert(key, value);
},
"hostname_short" => if hostname_short_enabled {
final_outputs.insert(key, value);
},
_ => {
final_outputs.insert(key, value);
}
}
}
}