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

Method fork_session

crates/opencode-tui/src/api.rs:692–719  ·  view source on GitHub ↗
(
        &self,
        session_id: &str,
        message_id: Option<&str>,
    )

Source from the content-addressed store, hash-verified

690 }
691
692 pub fn fork_session(
693 &self,
694 session_id: &str,
695 message_id: Option<&str>,
696 ) -> anyhow::Result<SessionInfo> {
697 let mut params: Vec<(&str, String)> = Vec::new();
698 if let Some(msg_id) = message_id {
699 params.push(("message_id", msg_id.to_string()));
700 }
701 let url = format!("{}/session/{}/fork", self.base_url, session_id);
702 let request = if params.is_empty() {
703 self.client.post(&url)
704 } else {
705 self.client.post(&url).query(&params)
706 };
707 let response = request.send()?;
708 if !response.status().is_success() {
709 let status = response.status();
710 let text = response.text().unwrap_or_default();
711 anyhow::bail!(
712 "Failed to fork session `{}`: {} - {}",
713 session_id,
714 status,
715 text
716 );
717 }
718 Ok(response.json::<SessionInfo>()?)
719 }
720
721 pub fn set_current_session(&self, session: SessionInfo) {
722 let mut current = futures::executor::block_on(self.current_session.write());

Callers 1

handle_dialog_keyMethod · 0.80

Calls 6

newFunction · 0.85
is_emptyMethod · 0.80
queryMethod · 0.45
sendMethod · 0.45
statusMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected