| 461 | Lazy::new(opencode_session::TodoManager::new); |
| 462 | |
| 463 | async fn get_session_todos( |
| 464 | State(state): State<Arc<ServerState>>, |
| 465 | Path(id): Path<String>, |
| 466 | ) -> Result<Json<Vec<TodoInfo>>> { |
| 467 | let sessions = state.sessions.lock().await; |
| 468 | if sessions.get(&id).is_none() { |
| 469 | return Err(ApiError::SessionNotFound(id)); |
| 470 | } |
| 471 | drop(sessions); |
| 472 | |
| 473 | let todos = TODO_MANAGER.get(&id).await; |
| 474 | let items = todos |
| 475 | .into_iter() |
| 476 | .enumerate() |
| 477 | .map(|(idx, todo)| TodoInfo { |
| 478 | id: format!("{}_{}", id, idx), |
| 479 | content: todo.content, |
| 480 | status: todo.status, |
| 481 | priority: todo.priority, |
| 482 | }) |
| 483 | .collect(); |
| 484 | Ok(Json(items)) |
| 485 | } |
| 486 | |
| 487 | #[derive(Debug, Deserialize)] |
| 488 | pub struct ForkSessionRequest { |