(
client: &reqwest::Client,
base_url: &str,
session_id: &str,
share_requested: bool,
)
| 1136 | } |
| 1137 | |
| 1138 | async 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 | |
| 1164 | async fn consume_remote_sse( |
| 1165 | response: reqwest::Response, |
no test coverage detected