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

Method child

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

Create a child session

(parent: &Session)

Source from the content-addressed store, hash-verified

344
345 /// Create a child session
346 pub fn child(parent: &Session) -> Self {
347 let now = Utc::now();
348 let slug = Self::generate_slug();
349
350 Self {
351 id: format!("ses_{}", Uuid::new_v4().simple()),
352 slug,
353 project_id: parent.project_id.clone(),
354 directory: parent.directory.clone(),
355 parent_id: Some(parent.id.clone()),
356 title: format!("Child session - {}", now.to_rfc3339()),
357 version: Self::VERSION.to_string(),
358 time: SessionTime::default(),
359 messages: Vec::new(),
360 summary: None,
361 share: None,
362 revert: None,
363 permission: parent.permission.clone(),
364 usage: None,
365 status: SessionStatus::Active,
366 metadata: HashMap::new(),
367 created_at: now,
368 updated_at: now,
369 }
370 }
371
372 fn generate_slug() -> String {
373 let uuid_part = &Uuid::new_v4().simple().to_string()[..8];

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected