extension_api: Add `digest` to `GithubReleaseAsset` (#44399)

Finn Evers created

Release Notes:

- N/A

Change summary

crates/extension_api/wit/since_v0.8.0/github.wit        | 2 ++
crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs | 1 +
crates/project/src/agent_server_store.rs                | 6 +++---
3 files changed, 6 insertions(+), 3 deletions(-)

Detailed changes

crates/extension_api/wit/since_v0.8.0/github.wit 🔗

@@ -13,6 +13,8 @@ interface github {
         name: string,
         /// The download URL for the asset.
         download-url: string,
+        /// The SHA-256 of the release asset if provided by the GitHub API.
+        digest: option<string>,
     }
 
     /// The options used to filter down GitHub releases.

crates/project/src/agent_server_store.rs 🔗

@@ -1495,7 +1495,7 @@ impl ExternalAgentServer for LocalCodex {
                             let digest = asset
                                 .digest
                                 .as_deref()
-                                .and_then(|d| d.strip_prefix("sha256:").or(Some(d)));
+                                .map(|d| d.strip_prefix("sha256:").unwrap_or(d));
                             match ::http_client::github_download::download_server_binary(
                                 &*http,
                                 &asset.browser_download_url,
@@ -1727,10 +1727,10 @@ impl ExternalAgentServer for LocalExtensionArchiveAgent {
                                     release.assets.iter().find(|a| a.name == filename)
                                 {
                                     // Strip "sha256:" prefix if present
-                                    asset.digest.as_ref().and_then(|d| {
+                                    asset.digest.as_ref().map(|d| {
                                         d.strip_prefix("sha256:")
                                             .map(|s| s.to_string())
-                                            .or_else(|| Some(d.clone()))
+                                            .unwrap_or_else(|| d.clone())
                                     })
                                 } else {
                                     None