tui: fix auto-scope detection + confirmation

- Default include=true when omitted in auto-scope JSON
- Run folder detection + confirmation only for options 3 & 4
- Lock auto-scope model to fast gpt-5-codex
- Use exact confirmed paths for collection/specs
- Add unit test for missing include flag

Also ran fmt, clippy (tui), and tests (tui).
This commit is contained in:
kh.ai
2025-11-03 10:30:20 -08:00
parent 883a108624
commit 40f38ddb4e
2 changed files with 24 additions and 15 deletions
+5 -7
View File
@@ -2872,13 +2872,11 @@ impl ChatWidget {
progress_percent: Some(0),
});
let annotated_scope_prompt = if matches!(mode, SecurityReviewMode::Bugs) {
scope_prompt
.as_ref()
.map(|prompt| annotate_scope_prompt(prompt.as_str()))
} else {
None
};
// Enable auto-scope when a scope prompt is provided (options 3 and 4).
// We annotate the prompt for both Full and Bugs modes.
let annotated_scope_prompt = scope_prompt
.as_ref()
.map(|prompt| annotate_scope_prompt(prompt.as_str()));
let request = SecurityReviewRequest {
repo_path,
+19 -8
View File
@@ -1429,8 +1429,7 @@ pub(crate) async fn run_security_review(
let mut include_paths = request.include_paths.clone();
let git_link_info = build_git_link_info(&repo_path).await;
if matches!(request.mode, SecurityReviewMode::Bugs)
&& include_paths.is_empty()
if include_paths.is_empty()
&& let Some(prompt) = request.auto_scope_prompt.as_ref().and_then(|value| {
let trimmed = value.trim();
if trimmed.is_empty() {
@@ -1440,11 +1439,8 @@ pub(crate) async fn run_security_review(
}
})
{
let auto_scope_model = if request.triage_model.trim().is_empty() {
AUTO_SCOPE_MODEL
} else {
request.triage_model.as_str()
};
// Always use the fast model for auto-scope regardless of triage_model.
let auto_scope_model = AUTO_SCOPE_MODEL;
record(format!(
"Auto-detecting review scope from user prompt: {prompt}"
@@ -3168,10 +3164,13 @@ fn parse_include_flag(value: &Value) -> Option<bool> {
}
fn parse_raw_auto_scope_selection(map: &Map<String, Value>) -> Option<RawAutoScopeSelection> {
// Be tolerant: default to include=true when the model omits the flag.
// Older prompts mandated an explicit include flag, but newer responses
// often omit it when the intent is clearly to include the path.
let include = map
.get("include")
.and_then(parse_include_flag)
.unwrap_or(false);
.unwrap_or(true);
if !include {
return None;
}
@@ -3862,6 +3861,18 @@ ALL
let result = parse_paths(input).expect("expected selections");
assert_eq!(result, vec![("backend".to_string(), None)],);
}
#[test]
fn defaults_to_include_when_flag_missing() {
// Model may omit `include`; treat as include=true.
let input = r#"
{"path": "api"}
{"path": "docs", "include": false}
"#;
let result = parse_paths(input).expect("expected selections");
assert_eq!(result, vec![("api".to_string(), None)],);
}
}
#[cfg(test)]