fix: reset hunt state for user commands
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
use std::collections::HashSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::tui::app::{App, AppAction};
|
||||
use crate::tui::app::{App, AppAction, HuntVerdict};
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
@@ -194,6 +194,8 @@ pub fn try_dispatch_user_command(app: &mut App, input: &str) -> Option<CommandRe
|
||||
let (metadata, body) = parse_frontmatter(content);
|
||||
app.hunt.quarry = None;
|
||||
app.hunt.started_at = None;
|
||||
app.hunt.verdict = HuntVerdict::Hunting;
|
||||
app.hunt.token_budget = None;
|
||||
app.active_allowed_tools = None;
|
||||
for (key, value) in &metadata {
|
||||
match key.as_str() {
|
||||
@@ -605,11 +607,17 @@ mod tests {
|
||||
let _ = try_dispatch_user_command(&mut app, "/described").unwrap();
|
||||
assert_eq!(app.hunt.quarry.as_deref(), Some("Scan repos"));
|
||||
assert!(app.hunt.started_at.is_some());
|
||||
assert_eq!(app.hunt.verdict, crate::tui::app::HuntVerdict::Hunting);
|
||||
assert_eq!(app.hunt.token_budget, None);
|
||||
assert_eq!(app.active_allowed_tools, Some(vec!["bash".to_string()]));
|
||||
|
||||
app.hunt.verdict = crate::tui::app::HuntVerdict::Escaped;
|
||||
app.hunt.token_budget = Some(42);
|
||||
let _ = try_dispatch_user_command(&mut app, "/plain").unwrap();
|
||||
assert_eq!(app.hunt.quarry, None);
|
||||
assert_eq!(app.hunt.started_at, None);
|
||||
assert_eq!(app.hunt.verdict, crate::tui::app::HuntVerdict::Hunting);
|
||||
assert_eq!(app.hunt.token_budget, None);
|
||||
assert_eq!(app.active_allowed_tools, None);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user