Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions crates/chat-cli/src/cli/chat/tools/todo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ impl TodoList {
}
for i in completed_indices.iter() {
if *i >= state.tasks.len() {
bail!("Index {i} is out of bounds for length {}, ", state.tasks.len());
bail!(
"Index {i} is out of bounds — valid indices are 0..{} (current list has {} tasks)",
state.tasks.len(),
state.tasks.len()
);
}
}
},
Expand All @@ -428,15 +432,23 @@ impl TodoList {
if new_tasks.iter().any(|task| task.trim().is_empty()) {
bail!("New tasks cannot be empty");
} else if has_duplicates(insert_indices) {
bail!("Insertion indices must be unique")
bail!("Insertion indices must be unique — each task must have a distinct index")
} else if new_tasks.len() != insert_indices.len() {
bail!("Must provide an index for every new task");
bail!(
"Must provide an index for every new task — got {} tasks but {} indices",
new_tasks.len(),
insert_indices.len()
);
} else if new_description.is_some() && new_description.as_ref().unwrap().trim().is_empty() {
bail!("New description cannot be empty");
}
for i in insert_indices.iter() {
if *i > state.tasks.len() {
bail!("Index {i} is out of bounds for length {}, ", state.tasks.len());
bail!(
"Index {i} is out of bounds — valid insertion indices are 0..={} (current list has {} tasks)",
state.tasks.len(),
state.tasks.len()
);
}
}
},
Expand All @@ -447,13 +459,17 @@ impl TodoList {
} => {
let state = TodoListState::load(os, id).await?;
if has_duplicates(remove_indices) {
bail!("Removal indices must be unique")
bail!("Removal indices must be unique — each index must appear only once")
} else if new_description.is_some() && new_description.as_ref().unwrap().trim().is_empty() {
bail!("New description cannot be empty");
}
for i in remove_indices.iter() {
if *i >= state.tasks.len() {
bail!("Index {i} is out of bounds for length {}, ", state.tasks.len());
bail!(
"Index {i} is out of bounds — valid indices are 0..{} (current list has {} tasks)",
state.tasks.len(),
state.tasks.len()
);
}
}
},
Expand Down