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

Function maybe_share_remote_session

crates/opencode-cli/src/main.rs:1138–1162  ·  view source on GitHub ↗
(
    client: &reqwest::Client,
    base_url: &str,
    session_id: &str,
    share_requested: bool,
)

Source from the content-addressed store, hash-verified

1136}
1137
1138async fn maybe_share_remote_session(
1139 client: &reqwest::Client,
1140 base_url: &str,
1141 session_id: &str,
1142 share_requested: bool,
1143) -> anyhow::Result<()> {
1144 let auto_share_env = std::env::var("OPENCODE_AUTO_SHARE")
1145 .ok()
1146 .map(|v| parse_bool_env(&v))
1147 .unwrap_or(false);
1148 let config_endpoint = server_url(base_url, "/config");
1149 let config: RemoteConfigInfo =
1150 parse_http_json(client.get(config_endpoint).send().await?).await?;
1151 let config_auto = config.share.as_deref() == Some("auto");
1152
1153 if !(share_requested || auto_share_env || config_auto) {
1154 return Ok(());
1155 }
1156
1157 let share_endpoint = server_url(base_url, &format!("/session/{}/share", session_id));
1158 let shared: RemoteShareInfo =
1159 parse_http_json(client.post(share_endpoint).send().await?).await?;
1160 println!("~ {}", shared.url);
1161 Ok(())
1162}
1163
1164async fn consume_remote_sse(
1165 response: reqwest::Response,

Callers 1

Calls 5

parse_bool_envFunction · 0.85
server_urlFunction · 0.85
parse_http_jsonFunction · 0.85
sendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected