Skip to content

Commit 296a46b

Browse files
author
kiran-garre
committed
fix: Minor UX improvements
Updates: - Calling the Lookup command shows the model the descriptions, statuses, and IDs of each todo list so it doesn't need to load each one to view them
1 parent 4f6a1ac commit 296a46b

File tree

1 file changed

+14
-18
lines changed
  • crates/chat-cli/src/cli/chat/tools

1 file changed

+14
-18
lines changed

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,28 +334,24 @@ impl TodoList {
334334
(state, id.clone())
335335
},
336336
TodoList::Lookup => {
337-
let path = get_todo_list_dir(os)?;
338337
queue!(output, style::Print("Finding existing todo lists...".yellow()))?;
339-
if os.fs.exists(&path) {
340-
let mut ids = Vec::new();
341-
let mut entries = os.fs.read_dir(&path).await?;
342-
while let Some(entry) = entries.next_entry().await? {
343-
let entry_path = entry.path();
344-
ids.push(
345-
entry_path
346-
.file_stem()
347-
.map(|f| f.to_string_lossy().to_string())
348-
.unwrap_or_default(),
349-
);
350-
}
351-
if !ids.is_empty() {
352-
return Ok(InvokeOutput {
353-
output: super::OutputKind::Text(format!("Existing todo IDs:\n {}", ids.join("\n"))),
354-
});
338+
let (todo_lists, _) = get_all_todos(os).await?;
339+
if !todo_lists.is_empty() {
340+
let mut displays = Vec::new();
341+
for list in todo_lists {
342+
let num_completed = list.tasks.iter().filter(|t| t.completed).count();
343+
let completion_status = format!("{}/{}", num_completed, list.tasks.len());
344+
displays.push(format!(
345+
"Description: {} \nStatus: {} \nID: {}",
346+
list.description, completion_status, list.id
347+
));
355348
}
349+
return Ok(InvokeOutput {
350+
output: super::OutputKind::Text(displays.join("\n\n")),
351+
});
356352
}
357353
return Ok(InvokeOutput {
358-
output: super::OutputKind::Text("No todo lists in the user's current directory.".to_string()),
354+
output: super::OutputKind::Text("No todo lists exist".to_string()),
359355
});
360356
},
361357
};

0 commit comments

Comments
 (0)