From 7d57205d35166f6204ef39d4a8dff74b240c4018 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:31:55 +0000 Subject: [PATCH] Remove VS Code references from Copilot integration (#48528) (cherry-pick to stable) (#48531) Cherry-pick of #48528 to stable ---- Release Notes: - N/A Co-authored-by: Mikayla Maki --- crates/copilot_chat/src/copilot_chat.rs | 55 ++++++++++++++----------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/crates/copilot_chat/src/copilot_chat.rs b/crates/copilot_chat/src/copilot_chat.rs index 56b844ea6bc704a2fb5065222f4c356ecbeded5a..7f18e597ce0336d45a0d1183217e7863e6b0c223 100644 --- a/crates/copilot_chat/src/copilot_chat.rs +++ b/crates/copilot_chat/src/copilot_chat.rs @@ -704,19 +704,31 @@ async fn get_models( Ok(models) } +fn copilot_request_headers(builder: http_client::Builder, api_token: &str) -> http_client::Builder { + builder + .header("Authorization", format!("Bearer {}", api_token)) + .header("Content-Type", "application/json") + .header( + "Editor-Version", + format!( + "Zed/{}", + option_env!("CARGO_PKG_VERSION").unwrap_or("unknown") + ), + ) +} + async fn request_models( models_url: Arc, api_token: String, client: Arc, ) -> Result> { - let request_builder = HttpRequest::builder() - .method(Method::GET) - .uri(models_url.as_ref()) - .header("Authorization", format!("Bearer {}", api_token)) - .header("Content-Type", "application/json") - .header("Copilot-Integration-Id", "vscode-chat") - .header("Editor-Version", "vscode/1.103.2") - .header("x-github-api-version", "2025-05-01"); + let request_builder = copilot_request_headers( + HttpRequest::builder() + .method(Method::GET) + .uri(models_url.as_ref()), + &api_token, + ) + .header("x-github-api-version", "2025-05-01"); let request = request_builder.body(AsyncBody::empty())?; @@ -804,23 +816,16 @@ async fn stream_completion( let request_initiator = if is_user_initiated { "user" } else { "agent" }; - let request_builder = HttpRequest::builder() - .method(Method::POST) - .uri(completion_url.as_ref()) - .header( - "Editor-Version", - format!( - "Zed/{}", - option_env!("CARGO_PKG_VERSION").unwrap_or("unknown") - ), - ) - .header("Authorization", format!("Bearer {}", api_key)) - .header("Content-Type", "application/json") - .header("Copilot-Integration-Id", "vscode-chat") - .header("X-Initiator", request_initiator) - .when(is_vision_request, |builder| { - builder.header("Copilot-Vision-Request", is_vision_request.to_string()) - }); + let request_builder = copilot_request_headers( + HttpRequest::builder() + .method(Method::POST) + .uri(completion_url.as_ref()), + &api_key, + ) + .header("X-Initiator", request_initiator) + .when(is_vision_request, |builder| { + builder.header("Copilot-Vision-Request", is_vision_request.to_string()) + }); let is_streaming = request.stream;