pub struct TodoManager { /* private fields */ }Expand description
Manager for tracking todos during plan execution.
Holds an ordered map of todo items and provides CRUD operations. The manager is session-scoped (not persisted to disk by default).
Implementations§
Source§impl TodoManager
impl TodoManager
Sourcepub fn from_steps(steps: &[String]) -> Self
pub fn from_steps(steps: &[String]) -> Self
Create a todo manager pre-populated from plan step strings.
Sourcepub fn add_with_status(
&mut self,
title: String,
status: TodoStatus,
active_form: String,
children: Vec<SubTodoItem>,
) -> usize
pub fn add_with_status( &mut self, title: String, status: TodoStatus, active_form: String, children: Vec<SubTodoItem>, ) -> usize
Add a new todo item with initial status, active_form, and children. Returns its assigned ID.
Sourcepub fn write_todos(
&mut self,
items: Vec<(String, TodoStatus, String, Vec<SubTodoItem>)>,
)
pub fn write_todos( &mut self, items: Vec<(String, TodoStatus, String, Vec<SubTodoItem>)>, )
Replace the entire todo list with new items. Resets IDs starting from 1.
Sourcepub fn set_status(&mut self, id: usize, status: TodoStatus) -> bool
pub fn set_status(&mut self, id: usize, status: TodoStatus) -> bool
Update the status of a todo item by ID.
Enforces single “doing” constraint: when setting InProgress, auto-reverts other “doing” items to Pending.
Returns true if the item was found and updated.
Sourcepub fn todos_mut(&mut self) -> &mut BTreeMap<usize, TodoItem>
pub fn todos_mut(&mut self) -> &mut BTreeMap<usize, TodoItem>
Get mutable access to the internal map (for title updates etc.).
Sourcepub fn completed_count(&self) -> usize
pub fn completed_count(&self) -> usize
Number of completed todos.
Sourcepub fn in_progress_count(&self) -> usize
pub fn in_progress_count(&self) -> usize
Number of in-progress todos.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of pending todos.
Sourcepub fn next_pending(&self) -> Option<&TodoItem>
pub fn next_pending(&self) -> Option<&TodoItem>
Get the next pending todo (lowest ID).
Sourcepub fn all_completed(&self) -> bool
pub fn all_completed(&self) -> bool
Whether all todos are completed.
Sourcepub fn format_status(&self) -> String
pub fn format_status(&self) -> String
Format a status display string suitable for inclusion in prompts.
Example output:
Todos (2/5 done):
[done] 1. Set up project structure
[done] 2. Add config parser
[doing] 3. Implement core logic
[todo] 4. Write tests
[todo] 5. Update docsSourcepub fn find_todo(&self, id_str: &str) -> Option<(usize, &TodoItem)>
pub fn find_todo(&self, id_str: &str) -> Option<(usize, &TodoItem)>
Fuzzy-find a todo by ID string.
Supports formats: "todo-3", "3", "todo_3", exact title match,
or partial title match.
Sourcepub fn get_active_todo_message(&self) -> Option<String>
pub fn get_active_todo_message(&self) -> Option<String>
Get the active_form of the currently “doing” item, if any.
Sourcepub fn reset_stuck_todos(&mut self) -> usize
pub fn reset_stuck_todos(&mut self) -> usize
Reset all “doing” (in-progress) todos back to “pending”.
Called when the agent loop exits (interrupt, error, timeout, or normal completion) to ensure no todos remain spinning in “doing” state. Returns the number of items reset.
Sourcepub fn has_incomplete_todos(&self) -> bool
pub fn has_incomplete_todos(&self) -> bool
Whether there are any non-completed todos.
Sourcepub fn has_work_in_progress(&self) -> bool
pub fn has_work_in_progress(&self) -> bool
Whether any todo has been started (moved beyond Pending). Returns true if at least one todo is InProgress or Completed.
Sourcepub fn format_status_sorted(&self) -> String
pub fn format_status_sorted(&self) -> String
Format the todo list sorted by status: doing -> todo -> done.
Trait Implementations§
Source§impl Clone for TodoManager
impl Clone for TodoManager
Source§fn clone(&self) -> TodoManager
fn clone(&self) -> TodoManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more