Skip to content

Commit 9af1334

Browse files
committed
fix(runloop): honor skip confirmations flag
1 parent 652951c commit 9af1334

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

src/agent/runloop/gemini.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use super::tool_output::render_tool_output;
2525
pub(crate) async fn run_single_agent_loop_gemini(
2626
config: &CoreAgentConfig,
2727
vt_cfg: Option<&VTAgentConfig>,
28+
skip_confirmations: bool,
2829
) -> Result<()> {
2930
let trim_config = load_context_trim_config(vt_cfg);
3031
let mut renderer = AnsiRenderer::stdout();
@@ -379,7 +380,8 @@ pub(crate) async fn run_single_agent_loop_gemini(
379380
}
380381

381382
if !modified_files.is_empty()
382-
&& confirm_changes_with_git_diff(&modified_files).await?
383+
&& confirm_changes_with_git_diff(&modified_files, skip_confirmations)
384+
.await?
383385
{
384386
renderer.line(MessageStyle::Info, "Changes applied successfully.")?;
385387
} else if !modified_files.is_empty() {

src/agent/runloop/git.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ fn is_git_repo() -> bool {
1111
.unwrap_or(false)
1212
}
1313

14-
pub(crate) async fn confirm_changes_with_git_diff(modified_files: &[String]) -> Result<bool> {
14+
pub(crate) async fn confirm_changes_with_git_diff(
15+
modified_files: &[String],
16+
skip_confirmations: bool,
17+
) -> Result<bool> {
18+
if skip_confirmations {
19+
return Ok(true);
20+
}
21+
1522
if !is_git_repo() {
1623
println!("Not in a git repository; skipping diff confirmation.");
1724
return Ok(true);

src/agent/runloop/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ mod text_tools;
1212
mod tool_output;
1313
mod unified;
1414

15-
pub async fn run_single_agent_loop(config: &CoreAgentConfig) -> Result<()> {
15+
pub async fn run_single_agent_loop(
16+
config: &CoreAgentConfig,
17+
skip_confirmations: bool,
18+
) -> Result<()> {
1619
let provider = config
1720
.model
1821
.parse::<ModelId>()
@@ -24,8 +27,10 @@ pub async fn run_single_agent_loop(config: &CoreAgentConfig) -> Result<()> {
2427
let vt_cfg = cfg_manager.as_ref().map(|manager| manager.config());
2528

2629
match provider {
27-
Provider::Gemini => gemini::run_single_agent_loop_gemini(config, vt_cfg).await,
28-
_ => unified::run_single_agent_loop_unified(config, vt_cfg).await,
30+
Provider::Gemini => {
31+
gemini::run_single_agent_loop_gemini(config, vt_cfg, skip_confirmations).await
32+
}
33+
_ => unified::run_single_agent_loop_unified(config, vt_cfg, skip_confirmations).await,
2934
}
3035
}
3136

src/agent/runloop/unified.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use super::tool_output::render_tool_output;
2424
pub(crate) async fn run_single_agent_loop_unified(
2525
config: &CoreAgentConfig,
2626
vt_cfg: Option<&VTAgentConfig>,
27+
skip_confirmations: bool,
2728
) -> Result<()> {
2829
let mut renderer = AnsiRenderer::stdout();
2930
renderer.line(MessageStyle::Info, "Interactive chat (tools)")?;
@@ -345,7 +346,11 @@ pub(crate) async fn run_single_agent_loop_unified(
345346
}
346347

347348
if !modified_files.is_empty()
348-
&& confirm_changes_with_git_diff(&modified_files).await?
349+
&& confirm_changes_with_git_diff(
350+
&modified_files,
351+
skip_confirmations,
352+
)
353+
.await?
349354
{
350355
renderer
351356
.line(MessageStyle::Info, "Changes applied successfully.")?;

src/cli/chat_tools.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use anyhow::Result;
22
use vtagent_core::config::types::AgentConfig as CoreAgentConfig;
33

4-
pub async fn handle_chat_command(
5-
config: &CoreAgentConfig,
6-
_skip_confirmations: bool,
7-
) -> Result<()> {
8-
crate::agent::runloop::run_single_agent_loop(config).await
4+
pub async fn handle_chat_command(config: &CoreAgentConfig, skip_confirmations: bool) -> Result<()> {
5+
crate::agent::runloop::run_single_agent_loop(config, skip_confirmations).await
96
}

0 commit comments

Comments
 (0)