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

Method read_from_session

crates/opencode-server/src/pty.rs:269–286  ·  view source on GitHub ↗
(&self, id: &str)

Source from the content-addressed store, hash-verified

267 }
268
269 pub async fn read_from_session(&self, id: &str) -> Result<PtyOutput, PtyError> {
270 let sessions = self.sessions.read().await;
271 let (_, inner) = sessions
272 .get(id)
273 .ok_or_else(|| PtyError::SessionNotFound(id.to_string()))?;
274
275 let data = {
276 let mut buf = inner.output_buffer.lock().unwrap();
277 let bytes: Vec<u8> = buf.drain(..).collect();
278 String::from_utf8_lossy(&bytes).into_owned()
279 };
280
281 Ok(PtyOutput {
282 session_id: id.to_string(),
283 data,
284 is_error: false,
285 })
286 }
287
288 /// Returns a snapshot of the current output buffer, the cumulative cursor
289 /// position, a broadcast receiver for live output, and a clone of the PTY

Callers

nothing calls this directly

Calls 2

readMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected