MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / add_message_part

Function add_message_part

crates/opencode-server/src/routes.rs:1197–1223  ·  view source on GitHub ↗
(
    State(state): State<Arc<ServerState>>,
    Path((session_id, msg_id)): Path<(String, String)>,
    Json(req): Json<AddPartRequest>,
)

Source from the content-addressed store, hash-verified

1195}
1196
1197async fn add_message_part(
1198 State(state): State<Arc<ServerState>>,
1199 Path((session_id, msg_id)): Path<(String, String)>,
1200 Json(req): Json<AddPartRequest>,
1201) -> Result<Json<serde_json::Value>> {
1202 let mut sessions = state.sessions.lock().await;
1203 let session = sessions
1204 .get_mut(&session_id)
1205 .ok_or_else(|| ApiError::SessionNotFound(session_id.clone()))?;
1206 let message = session
1207 .get_message_mut(&msg_id)
1208 .ok_or_else(|| ApiError::NotFound(format!("Message not found: {}", msg_id)))?;
1209
1210 let part = build_message_part(req, &msg_id)?;
1211 let part_id = part.id.clone();
1212 message.parts.push(part);
1213 session.touch();
1214 drop(sessions);
1215 persist_sessions_if_enabled(&state).await;
1216
1217 Ok(Json(serde_json::json!({
1218 "added": true,
1219 "session_id": session_id,
1220 "message_id": msg_id,
1221 "part_id": part_id,
1222 })))
1223}
1224
1225async fn delete_part(
1226 State(state): State<Arc<ServerState>>,

Callers

nothing calls this directly

Calls 6

build_message_partFunction · 0.85
get_message_mutMethod · 0.80
get_mutMethod · 0.45
cloneMethod · 0.45
touchMethod · 0.45

Tested by

no test coverage detected