From 3a90a112c479545394694e8337cc6030219df434 Mon Sep 17 00:00:00 2001 From: "kh.ai" Date: Fri, 17 Oct 2025 10:24:45 -0700 Subject: [PATCH] Detect abbreviations in auto-scope prompts --- codex-rs/tui/src/chatwidget.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 1e739322ab..1f4a8dacc8 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -308,6 +308,25 @@ fn create_initial_user_message(text: String, image_paths: Vec) -> Optio } } +fn annotate_scope_prompt(prompt: &str) -> String { + let abbreviations: Vec<&str> = prompt + .split(|ch: char| !ch.is_ascii_alphanumeric()) + .filter(|token| { + let len = token.chars().count(); + len >= 2 && token.chars().all(|c| c.is_ascii_uppercase()) + }) + .collect(); + + if abbreviations.is_empty() { + return prompt.to_string(); + } + + let abbreviations_list = abbreviations.join(", "); + format!( + "{prompt}\n\nAbbreviations detected: {abbreviations_list}. If you can infer their meaning from the repository context, state your assumption; otherwise highlight that clarification is needed." + ) +} + struct SecurityReviewContext { mode: SecurityReviewMode, include_paths: Vec, @@ -2249,6 +2268,10 @@ impl ChatWidget { last_log: None, }); + let annotated_scope_prompt = scope_prompt + .as_ref() + .map(|prompt| annotate_scope_prompt(prompt.as_str())); + let request = SecurityReviewRequest { repo_path, include_paths: resolved_paths, @@ -2260,7 +2283,7 @@ impl ChatWidget { provider: self.config.model_provider.clone(), auth: self.auth_manager.auth(), progress_sender: Some(self.app_event_tx.clone()), - auto_scope_prompt: scope_prompt, + auto_scope_prompt: annotated_scope_prompt, }; let tx = self.app_event_tx.clone();