MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / update

Method update

crates/opencode-session/src/todo.rs:47–80  ·  view source on GitHub ↗
(&self, session_id: &str, todos: Vec<TodoInfo>)

Source from the content-addressed store, hash-verified

45 }
46
47 pub async fn update(&self, session_id: &str, todos: Vec<TodoInfo>) {
48 let todos_payload = todos.clone();
49 if let Some(ref db) = self.db {
50 let _ = db.delete_for_session(session_id).await;
51 for (i, todo) in todos.iter().enumerate() {
52 let item = opencode_storage::TodoItem {
53 id: format!("{}_{}", session_id, i),
54 content: todo.content.clone(),
55 status: todo.status.clone(),
56 priority: todo.priority.clone(),
57 position: i as i64,
58 };
59 let _ = db.upsert(session_id, &item).await;
60 }
61 }
62
63 let mut state = self.state.write().await;
64 if todos.is_empty() {
65 state.remove(session_id);
66 } else {
67 state.insert(session_id.to_string(), todos);
68 }
69
70 if let Some(ref bus) = self.bus {
71 bus.publish(
72 &TODO_UPDATED_EVENT,
73 serde_json::json!({
74 "sessionID": session_id,
75 "todos": todos_payload,
76 }),
77 )
78 .await;
79 }
80 }
81
82 pub async fn get(&self, session_id: &str) -> Vec<TodoInfo> {
83 if let Some(ref db) = self.db {

Callers 7

session_promptFunction · 0.45
import_session_dataFunction · 0.45
hmac_sha256Method · 0.45
sha256Function · 0.45

Calls 6

delete_for_sessionMethod · 0.80
upsertMethod · 0.80
is_emptyMethod · 0.80
publishMethod · 0.80
cloneMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected