Skip to content

Commit 7493aa7

Browse files
author
kiran-garre
committed
fix: Make todo lists an experimental feature
1 parent fc7e8fd commit 7493aa7

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ static AVAILABLE_EXPERIMENTS: &[Experiment] = &[
4444
description: "Enables entering into a temporary mode for sending isolated conversations (/tangent)",
4545
setting_key: Setting::EnabledTangentMode,
4646
},
47+
Experiment {
48+
name: "Todo Lists",
49+
description: "Enables Q to create todo lists that can be viewed and managed using /todos",
50+
setting_key: Setting::EnabledTodoLists,
51+
},
4752
];
4853

4954
#[derive(Debug, PartialEq, Args)]

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::cli::chat::{
1717
ChatSession,
1818
ChatState,
1919
};
20+
use crate::database::settings::Setting;
2021
use crate::os::Os;
2122

2223
/// Defines subcommands that allow users to view and manage todo lists
@@ -65,6 +66,23 @@ impl std::fmt::Display for TodoDisplayEntry {
6566

6667
impl TodoSubcommand {
6768
pub async fn execute(self, os: &mut Os, session: &mut ChatSession) -> Result<ChatState, ChatError> {
69+
// Check if todo lists are enabled
70+
if !os
71+
.database
72+
.settings
73+
.get_bool(Setting::EnabledTodoLists)
74+
.unwrap_or(false)
75+
{
76+
execute!(
77+
session.stderr,
78+
style::SetForegroundColor(style::Color::Red),
79+
style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoLists true\n"),
80+
style::SetForegroundColor(style::Color::Reset)
81+
)?;
82+
return Ok(ChatState::PromptUser {
83+
skip_printing_tools: true,
84+
});
85+
}
6886
TodoListState::init_dir(os)
6987
.await
7088
.map_err(|e| ChatError::Custom(format!("Could not create todos directory: {e}").into()))?;

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use serde::{
2424
};
2525

2626
use super::InvokeOutput;
27+
use crate::database::settings::Setting;
2728
use crate::os::Os;
2829

2930
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
@@ -214,6 +215,23 @@ pub enum TodoList {
214215

215216
impl TodoList {
216217
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+
{
225+
queue!(
226+
output,
227+
style::SetForegroundColor(style::Color::Red),
228+
style::Print("Todo lists are disabled. Enable them with: q settings chat.enableTodoLists true"),
229+
style::SetForegroundColor(style::Color::Reset)
230+
)?;
231+
return Ok(InvokeOutput {
232+
output: super::OutputKind::Text("Todo lists are disabled.".to_string()),
233+
});
234+
}
217235
if let Some(id) = self.get_id() {
218236
if !os.fs.exists(id_to_path(os, &id)?) {
219237
let error_string = "No todo list exists with the given ID";

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ pub enum Setting {
7575
ChatDisableAutoCompaction,
7676
#[strum(message = "Show conversation history hints (boolean)")]
7777
ChatEnableHistoryHints,
78+
#[strum(message = "Enable the todo list feature (boolean)")]
79+
EnabledTodoLists,
7880
}
7981

8082
impl AsRef<str> for Setting {
@@ -109,6 +111,7 @@ impl AsRef<str> for Setting {
109111
Self::ChatDefaultAgent => "chat.defaultAgent",
110112
Self::ChatDisableAutoCompaction => "chat.disableAutoCompaction",
111113
Self::ChatEnableHistoryHints => "chat.enableHistoryHints",
114+
Self::EnabledTodoLists => "chat.enableTodoLists",
112115
}
113116
}
114117
}
@@ -153,6 +156,7 @@ impl TryFrom<&str> for Setting {
153156
"chat.defaultAgent" => Ok(Self::ChatDefaultAgent),
154157
"chat.disableAutoCompaction" => Ok(Self::ChatDisableAutoCompaction),
155158
"chat.enableHistoryHints" => Ok(Self::ChatEnableHistoryHints),
159+
"chat.enableTodoLists" => Ok(Self::EnabledTodoLists),
156160
_ => Err(DatabaseError::InvalidSetting(value.to_string())),
157161
}
158162
}

0 commit comments

Comments
 (0)