Skip to content

Commit 6da4a8e

Browse files
authored
fix: slash command bugs (#275)
1 parent 14491bf commit 6da4a8e

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,8 +1277,6 @@ impl ChatSession {
12771277
})
12781278
} else {
12791279
// Check for a pending tool approval
1280-
let tool_denied_without_reason = ["n", "N"].contains(&input);
1281-
12821280
if let Some(index) = self.pending_tool_index {
12831281
let is_trust = ["t", "T"].contains(&input);
12841282
let tool_use = &mut self.tool_uses[index];
@@ -1289,21 +1287,6 @@ impl ChatSession {
12891287
tool_use.accepted = true;
12901288

12911289
return Ok(ChatState::ExecuteTools);
1292-
// Prompt reason if no selected
1293-
} else if tool_denied_without_reason {
1294-
tool_use.accepted = false;
1295-
execute!(
1296-
self.output,
1297-
style::SetForegroundColor(Color::DarkGrey),
1298-
style::Print(
1299-
"\nPlease provide a reason for denying this tool use, or otherwise continue your conversation:\n\n"
1300-
),
1301-
style::SetForegroundColor(Color::Reset),
1302-
)?;
1303-
1304-
return Ok(ChatState::PromptUser {
1305-
skip_printing_tools: true,
1306-
});
13071290
}
13081291
} else if !self.pending_prompts.is_empty() {
13091292
let prompts = self.pending_prompts.drain(0..).collect();
@@ -1378,6 +1361,8 @@ impl ChatSession {
13781361
continue;
13791362
}
13801363

1364+
self.pending_tool_index = Some(i);
1365+
13811366
return Ok(ChatState::PromptUser {
13821367
skip_printing_tools: false,
13831368
});
@@ -1871,6 +1856,7 @@ impl ChatSession {
18711856
}
18721857

18731858
self.tool_uses = queued_tools;
1859+
self.pending_tool_index = Some(0);
18741860
Ok(ChatState::ExecuteTools)
18751861
}
18761862

@@ -2393,13 +2379,11 @@ mod tests {
23932379
"/tools untrust fs_write".to_string(),
23942380
"create a file".to_string(), // prompt again due to untrust
23952381
"n".to_string(), // cancel
2396-
"no reason".to_string(), // dummy reason
23972382
"/tools trust fs_write".to_string(),
23982383
"create a file".to_string(), // again without prompting due to '/tools trust'
23992384
"/tools reset".to_string(),
24002385
"create a file".to_string(), // prompt again due to reset
24012386
"n".to_string(), // cancel
2402-
"no reason".to_string(), // dummy reason
24032387
"exit".to_string(),
24042388
]),
24052389
false,
@@ -2413,7 +2397,7 @@ mod tests {
24132397
)
24142398
.await
24152399
.unwrap()
2416-
.next(&mut ctx, &mut database, &telemetry)
2400+
.spawn(&mut ctx, &mut database, &telemetry)
24172401
.await
24182402
.unwrap();
24192403

@@ -2512,7 +2496,7 @@ mod tests {
25122496
)
25132497
.await
25142498
.unwrap()
2515-
.next(&mut ctx, &mut database, &telemetry)
2499+
.spawn(&mut ctx, &mut database, &telemetry)
25162500
.await
25172501
.unwrap();
25182502

@@ -2573,7 +2557,7 @@ mod tests {
25732557
SharedWriter::stdout(),
25742558
None,
25752559
InputSource::new_mock(vec![
2576-
"/tools trustall".to_string(),
2560+
"/tools trust-all".to_string(),
25772561
"create a new file".to_string(),
25782562
"/tools reset".to_string(),
25792563
"create a new file".to_string(),
@@ -2590,7 +2574,7 @@ mod tests {
25902574
)
25912575
.await
25922576
.unwrap()
2593-
.next(&mut ctx, &mut database, &telemetry)
2577+
.spawn(&mut ctx, &mut database, &telemetry)
25942578
.await
25952579
.unwrap();
25962580

@@ -2646,7 +2630,7 @@ mod tests {
26462630
)
26472631
.await
26482632
.unwrap()
2649-
.next(&mut ctx, &mut database, &telemetry)
2633+
.spawn(&mut ctx, &mut database, &telemetry)
26502634
.await
26512635
.unwrap();
26522636

crates/chat-cli/src/cli/mcp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ mod tests {
414414
use crate::cli::chat::util::shared_writer::NullWriter;
415415
use crate::util::test::assert_parse;
416416

417-
#[test]
418-
fn test_scope_and_profile_defaults_to_workspace() {
417+
#[tokio::test]
418+
async fn test_scope_and_profile_defaults_to_workspace() {
419419
let ctx = Context::new();
420420
let path = resolve_scope_profile(&ctx, None).unwrap();
421421
assert_eq!(
@@ -425,8 +425,8 @@ mod tests {
425425
);
426426
}
427427

428-
#[test]
429-
fn test_resolve_paths() {
428+
#[tokio::test]
429+
async fn test_resolve_paths() {
430430
let ctx = Context::new();
431431
// workspace
432432
let p = resolve_scope_profile(&ctx, Some(Scope::Workspace)).unwrap();

crates/chat-cli/src/cli/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ mod test {
433433
input: None,
434434
profile: Some("my-profile".to_string()),
435435
model: None,
436-
trust_all_tools: false,
436+
trust_all_tools: true,
437437
trust_tools: None,
438438
non_interactive: false
439439
})
@@ -451,7 +451,7 @@ mod test {
451451
model: None,
452452
trust_all_tools: false,
453453
trust_tools: None,
454-
non_interactive: false
454+
non_interactive: true
455455
})
456456
);
457457
assert_parse!(
@@ -463,7 +463,7 @@ mod test {
463463
model: None,
464464
trust_all_tools: false,
465465
trust_tools: None,
466-
non_interactive: false
466+
non_interactive: true
467467
})
468468
);
469469
}

0 commit comments

Comments
 (0)