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

Method create

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

Create a new session

(
        &mut self,
        project_id: impl Into<String>,
        directory: impl Into<String>,
    )

Source from the content-addressed store, hash-verified

829
830 /// Create a new session
831 pub fn create(
832 &mut self,
833 project_id: impl Into<String>,
834 directory: impl Into<String>,
835 ) -> Session {
836 let session = Session::new(project_id, directory);
837 self.sessions.insert(session.id.clone(), session.clone());
838 self.events.push(SessionEvent::Created {
839 info: session.clone(),
840 });
841
842 // Publish to Bus
843 self.publish_session_event(&SESSION_CREATED_EVENT, &session);
844
845 // Plugin hook: session.start — notify plugins of new session
846 if let Ok(handle) = tokio::runtime::Handle::try_current() {
847 let session_id = session.id.clone();
848 handle.spawn(async move {
849 opencode_plugin::trigger(
850 HookContext::new(HookEvent::SessionStart).with_session(&session_id),
851 )
852 .await;
853 });
854 }
855
856 session
857 }
858
859 /// Create a child session
860 pub fn create_child(&mut self, parent_id: &str) -> Option<Session> {

Calls 6

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

Tested by 1

test_session_managerFunction · 0.36