diff --git a/crates/extension_host/src/wasm_host/oauth_callback_response.html b/crates/extension_host/src/wasm_host/oauth_callback_response.html
new file mode 100644
index 0000000000000000000000000000000000000000..f3872399e1c03b6f34c5594658a506976e872706
--- /dev/null
+++ b/crates/extension_host/src/wasm_host/oauth_callback_response.html
@@ -0,0 +1,12 @@
+
+
+
+ Authentication Complete
+
+
+
+
Authentication Complete
+
You can close this window and return to Zed.
+
+
+
diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs
index c1d819b7768ed895ec098f04682bb4f833c763c1..9c807d1376b09ecee7b9e8b0444c685e71ecae8d 100644
--- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs
+++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs
@@ -1312,13 +1312,15 @@ impl llm_provider::Host for WasmState {
let callback_url = if let Some(path_start) = request_line.find(' ') {
if let Some(path_end) = request_line[path_start + 1..].find(' ') {
let path = &request_line[path_start + 1..path_start + 1 + path_end];
- if path.starts_with(&callback_path) || path.starts_with(&format!("/{}", callback_path.trim_start_matches('/'))) {
+ if path.starts_with(&callback_path)
+ || path.starts_with(&format!(
+ "/{}",
+ callback_path.trim_start_matches('/')
+ ))
+ {
format!("http://localhost:{}{}", port, path)
} else {
- return Err(anyhow::anyhow!(
- "Unexpected callback path: {}",
- path
- ));
+ return Err(anyhow::anyhow!("Unexpected callback path: {}", path));
}
} else {
return Err(anyhow::anyhow!("Malformed HTTP request"));
@@ -1327,17 +1329,10 @@ impl llm_provider::Host for WasmState {
return Err(anyhow::anyhow!("Malformed HTTP request"));
};
- let response = "HTTP/1.1 200 OK\r\n\
- Content-Type: text/html\r\n\
- Connection: close\r\n\
- \r\n\
- \
- Authentication Complete\
- \
- \
-
Authentication Complete
\
-
You can close this window and return to Zed.
\
-
";
+ let response = format!(
+ "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n{}",
+ include_str!("../oauth_callback_response.html")
+ );
smol::io::AsyncWriteExt::write_all(&mut stream, response.as_bytes())
.await
@@ -1348,16 +1343,13 @@ impl llm_provider::Host for WasmState {
};
let timeout_duration = Duration::from_secs(timeout_secs as u64);
- let callback_url = smol::future::or(
- accept_future,
- async {
- smol::Timer::after(timeout_duration).await;
- Err(anyhow::anyhow!(
- "OAuth callback timed out after {} seconds",
- timeout_secs
- ))
- },
- )
+ let callback_url = smol::future::or(accept_future, async {
+ smol::Timer::after(timeout_duration).await;
+ Err(anyhow::anyhow!(
+ "OAuth callback timed out after {} seconds",
+ timeout_secs
+ ))
+ })
.await?;
Ok(llm_provider::OauthWebAuthResult {