From 8da42ddee309732f6c9e64bbc85d9dbbc7b5b3ed Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Wed, 30 Sep 2026 16:04:16 +0000 Subject: [PATCH] extensions_ui: Show installed extensions when offline (#64766) Closes #12163 Supersedes https://github.com/zed-industries/zed/pull/56941 This PR changes the way we show installed extensions when offline - instead of basing it on the remote extensions list, we now compute a "displayed_extensions" list based on the local state and use that as the source of truth. This enables us to fix the issues listed below, as we are no longer depending on the remote info, but instead use what we have at our hands as the source of truth in cases where the server response is either not available or incomplete (we truncate currently and will add pagination at some point, so this is nice to have in either case). Release Notes: - Installed extensions will now also show in the extensions tab when offline. - Fixed a bug where some extensions would not show in the "Installed" tab despite being installed. --- crates/extension_host/src/extension_host.rs | 30 + crates/extensions_ui/src/components.rs | 2 +- .../src/components/extension_card.rs | 361 +++++----- crates/extensions_ui/src/extensions_ui.rs | 646 +++++++++++------- 4 files changed, 592 insertions(+), 447 deletions(-) diff --git a/crates/extension_host/src/extension_host.rs b/crates/extension_host/src/extension_host.rs index 36dd2943c45..0b8da455e6a 100644 --- a/crates/extension_host/src/extension_host.rs +++ b/crates/extension_host/src/extension_host.rs @@ -197,6 +197,15 @@ pub enum ExtensionOperation { Remove, } +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ExtensionStatus { + NotInstalled, + Installing, + Upgrading, + Installed(Arc), + Removing, +} + #[derive(Clone)] pub enum Event { ExtensionsUpdated, @@ -560,6 +569,27 @@ impl ExtensionStore { &self.extension_index.extensions } + /// Returns the status of the extension, where outstanding operations take + /// precedence over the installed state. + pub fn extension_status(&self, extension_id: &str) -> ExtensionStatus { + match self.outstanding_operations.get(extension_id) { + Some(ExtensionOperation::Install) => ExtensionStatus::Installing, + Some(ExtensionOperation::Remove) => ExtensionStatus::Removing, + Some(ExtensionOperation::Upgrade) => ExtensionStatus::Upgrading, + None => match self.extension_index.extensions.get(extension_id) { + Some(extension) => ExtensionStatus::Installed(extension.manifest.version.clone()), + None => ExtensionStatus::NotInstalled, + }, + } + } + + pub fn is_dev_extension(&self, extension_id: &str) -> bool { + self.extension_index + .extensions + .get(extension_id) + .is_some_and(|extension| extension.dev) + } + pub fn dev_extensions(&self) -> impl Iterator> { self.extension_index .extensions diff --git a/crates/extensions_ui/src/components.rs b/crates/extensions_ui/src/components.rs index 92f9c3cdfed..bfe081f1993 100644 --- a/crates/extensions_ui/src/components.rs +++ b/crates/extensions_ui/src/components.rs @@ -1,4 +1,4 @@ mod extension_card; pub use extension_card::ExtensionCard; -pub(crate) use extension_card::{extension_provides_label, remote_extension_status}; +pub(crate) use extension_card::extension_provides_label; diff --git a/crates/extensions_ui/src/components/extension_card.rs b/crates/extensions_ui/src/components/extension_card.rs index ce74c0cc888..5a117b742af 100644 --- a/crates/extensions_ui/src/components/extension_card.rs +++ b/crates/extensions_ui/src/components/extension_card.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeSet, sync::Arc}; use cloud_api_types::{ExtensionApiManifest, ExtensionMetadata, ExtensionProvides}; use extension::{ExtensionManifest, SchemaVersion}; -use extension_host::{ExtensionOperation, ExtensionStore}; +use extension_host::{ExtensionOperation, ExtensionStatus, ExtensionStore}; use gpui::{Anchor, ElementId, Entity, Point, SharedString, prelude::*}; use num_format::{Locale, ToFormattedString}; use release_channel::ReleaseChannel; @@ -13,52 +13,31 @@ type ContextMenuBuilder = Box< >; type ExtensionCardActions = [Option