Skip to main content

TodoManager

Struct TodoManager 

Source
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

Source

pub fn new() -> Self

Create a new, empty todo manager.

Source

pub fn from_steps(steps: &[String]) -> Self

Create a todo manager pre-populated from plan step strings.

Source

pub fn add(&mut self, title: String) -> usize

Add a new todo item. Returns its assigned ID.

Source

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.

Source

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.

Source

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.

Source

pub fn start(&mut self, id: usize) -> bool

Mark a todo as in-progress.

Source

pub fn complete(&mut self, id: usize) -> bool

Mark a todo as completed.

Source

pub fn get(&self, id: usize) -> Option<&TodoItem>

Get a todo item by ID.

Source

pub fn all(&self) -> Vec<&TodoItem>

Get all todo items in order.

Source

pub fn todos_mut(&mut self) -> &mut BTreeMap<usize, TodoItem>

Get mutable access to the internal map (for title updates etc.).

Source

pub fn has_todos(&self) -> bool

Check if there are any todos.

Source

pub fn total(&self) -> usize

Total number of todos.

Source

pub fn completed_count(&self) -> usize

Number of completed todos.

Source

pub fn in_progress_count(&self) -> usize

Number of in-progress todos.

Source

pub fn pending_count(&self) -> usize

Number of pending todos.

Source

pub fn next_pending(&self) -> Option<&TodoItem>

Get the next pending todo (lowest ID).

Source

pub fn all_completed(&self) -> bool

Whether all todos are completed.

Source

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 docs
Source

pub fn remove(&mut self, id: usize) -> bool

Remove a todo by ID. Returns true if it existed.

Source

pub fn clear(&mut self)

Clear all todos.

Source

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.

Source

pub fn get_active_todo_message(&self) -> Option<String>

Get the active_form of the currently “doing” item, if any.

Source

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.

Source

pub fn has_incomplete_todos(&self) -> bool

Whether there are any non-completed todos.

Source

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.

Source

pub fn format_status_sorted(&self) -> String

Format the todo list sorted by status: doing -> todo -> done.

Trait Implementations§

Source§

impl Clone for TodoManager

Source§

fn clone(&self) -> TodoManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TodoManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TodoManager

Source§

fn default() -> TodoManager

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more