From cb685d43291464949532002ff126714cb5fb53b2 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 27 Aug 2025 17:45:33 -0300 Subject: [PATCH] feat: set unused text outputs to null based on method options Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/meta_plugin/text.rs | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/meta_plugin/text.rs b/src/meta_plugin/text.rs index 59679c5..256a02b 100644 --- a/src/meta_plugin/text.rs +++ b/src/meta_plugin/text.rs @@ -223,6 +223,26 @@ impl TextMetaPlugin { metadata.push(meta_data); } + // If content is binary, set all text-related outputs to None + if is_binary_result { + let text_outputs = vec![ + "text_word_count", + "text_line_count", + "text_line_max_len", + "text_line_mean_len", + "text_line_median_len", + ]; + for output_name in text_outputs { + if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( + output_name, + serde_yaml::Value::Null, + self.base.outputs() + ) { + metadata.push(meta_data); + } + } + } + (metadata, is_binary_result) } @@ -489,6 +509,23 @@ impl MetaPlugin for TextMetaPlugin { if is_binary { self.buffer = None; // Drop the buffer self.is_finalized = true; + // Set all text-related outputs to None since content is binary + let text_outputs = vec![ + "text_word_count", + "text_line_count", + "text_line_max_len", + "text_line_mean_len", + "text_line_median_len", + ]; + for output_name in text_outputs { + if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( + output_name, + serde_yaml::Value::Null, + self.base.outputs() + ) { + metadata.push(meta_data); + } + } return MetaPluginResponse { metadata, is_finalized: true, @@ -504,6 +541,27 @@ impl MetaPlugin for TextMetaPlugin { metadata.extend(word_line_metadata); } + // Set disabled outputs to None + let outputs_to_check = vec![ + ("text_word_count", self.track_word_count), + ("text_line_count", self.track_line_count), + ("text_line_max_len", self.output_line_max_len), + ("text_line_mean_len", self.output_line_mean_len), + ("text_line_median_len", self.output_line_median_len), + ]; + + for (output_name, is_enabled) in outputs_to_check { + if !is_enabled { + if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs( + output_name, + serde_yaml::Value::Null, + self.base.outputs() + ) { + metadata.push(meta_data); + } + } + } + // Drop the buffer since we're done with it self.buffer = None;