(&self, session_id: &str, todo: TodoInfo)
| 130 | } |
| 131 | |
| 132 | pub async fn add(&self, session_id: &str, todo: TodoInfo) { |
| 133 | let mut state = self.state.write().await; |
| 134 | let todos = state.entry(session_id.to_string()).or_insert_with(Vec::new); |
| 135 | let position = todos.len(); |
| 136 | todos.push(todo.clone()); |
| 137 | |
| 138 | if let Some(ref db) = self.db { |
| 139 | let item = opencode_storage::TodoItem { |
| 140 | id: format!("{}_{}", session_id, position), |
| 141 | content: todo.content, |
| 142 | status: todo.status, |
| 143 | priority: todo.priority, |
| 144 | position: position as i64, |
| 145 | }; |
| 146 | let _ = db.upsert(session_id, &item).await; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | pub async fn remove(&self, session_id: &str, index: usize) -> bool { |
| 151 | let mut state = self.state.write().await; |
no test coverage detected