Skip to content

Commit ccf1dbb

Browse files
author
kiran-garre
committed
fix: Remove todo_list tool from tool spec when disabled
1 parent 7493aa7 commit ccf1dbb

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static AVAILABLE_EXPERIMENTS: &[Experiment] = &[
4747
Experiment {
4848
name: "Todo Lists",
4949
description: "Enables Q to create todo lists that can be viewed and managed using /todos",
50-
setting_key: Setting::EnabledTodoLists,
50+
setting_key: Setting::EnabledTodoList,
5151
},
5252
];
5353

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use dialoguer::Select;
88
use eyre::Result;
99

1010
use crate::cli::chat::tools::todo::{
11+
TodoList,
1112
TodoListState,
1213
delete_todo,
1314
get_all_todos,
@@ -17,7 +18,6 @@ use crate::cli::chat::{
1718
ChatSession,
1819
ChatState,
1920
};
20-
use crate::database::settings::Setting;
2121
use crate::os::Os;
2222

2323
/// Defines subcommands that allow users to view and manage todo lists
@@ -67,16 +67,11 @@ impl std::fmt::Display for TodoDisplayEntry {
6767
impl TodoSubcommand {
6868
pub async fn execute(self, os: &mut Os, session: &mut ChatSession) -> Result<ChatState, ChatError> {
6969
// Check if todo lists are enabled
70-
if !os
71-
.database
72-
.settings
73-
.get_bool(Setting::EnabledTodoLists)
74-
.unwrap_or(false)
75-
{
70+
if !TodoList::is_enabled(os) {
7671
execute!(
7772
session.stderr,
7873
style::SetForegroundColor(style::Color::Red),
79-
style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoLists true\n"),
74+
style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoList true\n"),
8075
style::SetForegroundColor(style::Color::Reset)
8176
)?;
8277
return Ok(ChatState::PromptUser {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@ impl ToolManager {
650650
if !crate::cli::chat::tools::knowledge::Knowledge::is_enabled(os) {
651651
tool_specs.remove("knowledge");
652652
}
653+
if !crate::cli::chat::tools::todo::TodoList::is_enabled(os) {
654+
tool_specs.remove("todo_list");
655+
}
653656

654657
#[cfg(windows)]
655658
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::cli::chat::line_tracker::FileLineTracker;
5858
use crate::os::Os;
5959

6060
pub const DEFAULT_APPROVE: [&str; 1] = ["fs_read"];
61-
pub const NATIVE_TOOLS: [&str; 7] = [
61+
pub const NATIVE_TOOLS: [&str; 8] = [
6262
"fs_read",
6363
"fs_write",
6464
#[cfg(windows)]
@@ -69,6 +69,7 @@ pub const NATIVE_TOOLS: [&str; 7] = [
6969
"gh_issue",
7070
"knowledge",
7171
"thinking",
72+
"todo_list",
7273
];
7374

7475
/// Represents an executable tool use.

crates/chat-cli/src/cli/chat/tools/todo.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,17 @@ pub enum TodoList {
214214
}
215215

216216
impl TodoList {
217+
/// Checks if todo lists are enabled
218+
pub fn is_enabled(os: &Os) -> bool {
219+
os.database.settings.get_bool(Setting::EnabledTodoList).unwrap_or(false)
220+
}
221+
217222
pub async fn invoke(&self, os: &Os, output: &mut impl Write) -> Result<InvokeOutput> {
218-
// Check if todo lists are enabled
219-
if !os
220-
.database
221-
.settings
222-
.get_bool(Setting::EnabledTodoLists)
223-
.unwrap_or(false)
224-
{
223+
if !Self::is_enabled(os) {
225224
queue!(
226225
output,
227226
style::SetForegroundColor(style::Color::Red),
228-
style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoLists true"),
227+
style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoList true"),
229228
style::SetForegroundColor(style::Color::Reset)
230229
)?;
231230
return Ok(InvokeOutput {

crates/chat-cli/src/database/settings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub enum Setting {
7676
#[strum(message = "Show conversation history hints (boolean)")]
7777
ChatEnableHistoryHints,
7878
#[strum(message = "Enable the todo list feature (boolean)")]
79-
EnabledTodoLists,
79+
EnabledTodoList,
8080
}
8181

8282
impl AsRef<str> for Setting {
@@ -111,7 +111,7 @@ impl AsRef<str> for Setting {
111111
Self::ChatDefaultAgent => "chat.defaultAgent",
112112
Self::ChatDisableAutoCompaction => "chat.disableAutoCompaction",
113113
Self::ChatEnableHistoryHints => "chat.enableHistoryHints",
114-
Self::EnabledTodoLists => "chat.enableTodoLists",
114+
Self::EnabledTodoList => "chat.enableTodoList",
115115
}
116116
}
117117
}
@@ -156,7 +156,7 @@ impl TryFrom<&str> for Setting {
156156
"chat.defaultAgent" => Ok(Self::ChatDefaultAgent),
157157
"chat.disableAutoCompaction" => Ok(Self::ChatDisableAutoCompaction),
158158
"chat.enableHistoryHints" => Ok(Self::ChatEnableHistoryHints),
159-
"chat.enableTodoLists" => Ok(Self::EnabledTodoLists),
159+
"chat.enableTodoList" => Ok(Self::EnabledTodoList),
160160
_ => Err(DatabaseError::InvalidSetting(value.to_string())),
161161
}
162162
}

0 commit comments

Comments
 (0)