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

Function get_session_diff

crates/opencode-server/src/routes.rs:2108–2132  ·  view source on GitHub ↗
(
    State(state): State<Arc<ServerState>>,
    Path(id): Path<String>,
)

Source from the content-addressed store, hash-verified

2106}
2107
2108async fn get_session_diff(
2109 State(state): State<Arc<ServerState>>,
2110 Path(id): Path<String>,
2111) -> Result<Json<Vec<FileDiffInfo>>> {
2112 let sessions = state.sessions.lock().await;
2113 let session = sessions
2114 .get(&id)
2115 .ok_or_else(|| ApiError::SessionNotFound(id))?;
2116 let diffs = session
2117 .summary
2118 .as_ref()
2119 .and_then(|summary| summary.diffs.as_ref())
2120 .map(|items| {
2121 items
2122 .iter()
2123 .map(|diff| FileDiffInfo {
2124 path: diff.path.clone(),
2125 additions: diff.additions,
2126 deletions: diff.deletions,
2127 })
2128 .collect::<Vec<_>>()
2129 })
2130 .unwrap_or_default();
2131 Ok(Json(diffs))
2132}
2133
2134#[derive(Debug, Serialize)]
2135pub struct FileDiffInfo {

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected