Skip to content

Commit cc66436

Browse files
authored
fix(/tools reset): add existence check before resetting tool permissions (#1234)
1 parent 6363716 commit cc66436

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,13 +1807,25 @@ where
18071807
)?;
18081808
},
18091809
Some(ToolsSubcommand::ResetSingle { tool_name }) => {
1810-
self.tool_permissions.reset_tool(&tool_name);
1811-
queue!(
1812-
self.output,
1813-
style::SetForegroundColor(Color::Green),
1814-
style::Print(format!("\nReset tool '{}' to the default permission level.", tool_name)),
1815-
style::SetForegroundColor(Color::Reset),
1816-
)?;
1810+
if self.tool_permissions.has(&tool_name) {
1811+
self.tool_permissions.reset_tool(&tool_name);
1812+
queue!(
1813+
self.output,
1814+
style::SetForegroundColor(Color::Green),
1815+
style::Print(format!("\nReset tool '{}' to the default permission level.", tool_name)),
1816+
style::SetForegroundColor(Color::Reset),
1817+
)?;
1818+
} else {
1819+
queue!(
1820+
self.output,
1821+
style::SetForegroundColor(Color::Red),
1822+
style::Print(format!(
1823+
"\nTool '{}' does not exist or is already in default settings.",
1824+
tool_name
1825+
)),
1826+
style::SetForegroundColor(Color::Reset),
1827+
)?;
1828+
}
18171829
},
18181830
Some(ToolsSubcommand::Help) => {
18191831
queue!(

crates/q_cli/src/cli/chat/tools/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use fs_read::FsRead;
2727
use fs_write::FsWrite;
2828
use gh_issue::GhIssue;
2929
use serde::Deserialize;
30-
use tracing::warn;
3130
use use_aws::UseAws;
3231

3332
use super::parser::ToolUse;
@@ -196,10 +195,6 @@ impl ToolPermissions {
196195
}
197196

198197
pub fn reset_tool(&mut self, tool_name: &str) {
199-
if !self.permissions.contains_key(tool_name) {
200-
warn!("No custom permissions set for tool '{tool_name}' to reset");
201-
return;
202-
}
203198
self.permissions.remove(tool_name);
204199
}
205200

0 commit comments

Comments
 (0)