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

Method delete

crates/opencode-session/src/session.rs:1074–1100  ·  view source on GitHub ↗

Delete a session

(&mut self, id: &str)

Source from the content-addressed store, hash-verified

1072
1073 /// Delete a session
1074 pub fn delete(&mut self, id: &str) -> Option<Session> {
1075 let children: Vec<String> = self.children(id).iter().map(|s| s.id.clone()).collect();
1076 for child_id in children {
1077 self.delete(&child_id);
1078 }
1079
1080 let session = self.sessions.remove(id)?;
1081 self.events.push(SessionEvent::Deleted {
1082 info: session.clone(),
1083 });
1084
1085 // Publish to Bus
1086 self.publish_session_event(&SESSION_DELETED_EVENT, &session);
1087
1088 // Plugin hook: session.end — notify plugins of session deletion
1089 if let Ok(handle) = tokio::runtime::Handle::try_current() {
1090 let session_id = session.id.clone();
1091 handle.spawn(async move {
1092 opencode_plugin::trigger(
1093 HookContext::new(HookEvent::SessionEnd).with_session(&session_id),
1094 )
1095 .await;
1096 });
1097 }
1098
1099 Some(session)
1100 }
1101
1102 /// Update a session
1103 pub fn update(&mut self, session: Session) {

Callers 15

routerFunction · 0.45
session_routesFunction · 0.45
delete_sessionFunction · 0.45
mcp_routesFunction · 0.45
pty_routesFunction · 0.45
experimental_routesFunction · 0.45
handle_session_commandFunction · 0.45
handle_mcp_commandFunction · 0.45
test_session_managerFunction · 0.45
removeMethod · 0.45

Calls 8

triggerFunction · 0.85
newFunction · 0.85
childrenMethod · 0.80
publish_session_eventMethod · 0.80
spawnMethod · 0.80
with_sessionMethod · 0.80
cloneMethod · 0.45
removeMethod · 0.45

Tested by 1

test_session_managerFunction · 0.36