Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

TUI Plugin Sharing 3 - render remote plugin catalog sections (#26703)

canvrno-oaif6fa2593126d
diff --git a/codex-rs/tui/src/app/event_dispatch.rs b/codex-rs/tui/src/app/event_dispatch.rs
index 181e60d963..0830c69b0f 100644
--- a/codex-rs/tui/src/app/event_dispatch.rs
+++ b/codex-rs/tui/src/app/event_dispatch.rs
@@ -507,6 +507,9 @@ impl App {
AppEvent::PluginsLoaded { cwd, result } => {
self.chat_widget.on_plugins_loaded(cwd, result);
}
+ AppEvent::OpenPluginsList { cwd, response } => {
+ self.chat_widget.open_plugins_list(cwd, response);
+ }
AppEvent::PluginRemoteSectionsLoaded {
cwd,
marketplaces,
diff --git a/codex-rs/tui/src/app_event.rs b/codex-rs/tui/src/app_event.rs
index 643cd9e2d8..26686c3b53 100644
--- a/codex-rs/tui/src/app_event.rs
+++ b/codex-rs/tui/src/app_event.rs
@@ -450,6 +450,12 @@ pub(crate) enum AppEvent {
result: Result<PluginListResponse, String>,
},
+ /// Open the plugin list from an already cached response.
+ OpenPluginsList {
+ cwd: PathBuf,
+ response: PluginListResponse,
+ },
+
/// Result of explicitly fetching remote-backed plugin sections.
PluginRemoteSectionsLoaded {
cwd: PathBuf,
diff --git a/codex-rs/tui/src/chatwidget/plugin_catalog.rs b/codex-rs/tui/src/chatwidget/plugin_catalog.rs
index c51e2e8ea9..a19ede3ab5 100644
--- a/codex-rs/tui/src/chatwidget/plugin_catalog.rs
+++ b/codex-rs/tui/src/chatwidget/plugin_catalog.rs
@@ -1,3 +1,4 @@
+use std::collections::HashMap;
use std::path::Path;
use std::time::Duration;
use std::time::Instant;
@@ -9,6 +10,7 @@ use super::plugins::PLUGINS_SELECTION_VIEW_ID;
use super::plugins::PluginsCacheState;
use crate::app_event::AppEvent;
use crate::app_event::PluginLocation;
+use crate::app_event::PluginRemoteSectionError;
use crate::bottom_pane::ColumnWidthMode;
use crate::bottom_pane::SelectionAction;
use crate::bottom_pane::SelectionItem;
@@ -24,18 +26,24 @@ use crate::onboarding::mark_url_hyperlink;
use crate::render::renderable::ColumnRenderable;
use crate::render::renderable::Renderable;
use crate::tui::FrameRequester;
+use codex_app_server_protocol::PluginAuthPolicy;
use codex_app_server_protocol::PluginAvailability;
use codex_app_server_protocol::PluginDetail;
use codex_app_server_protocol::PluginInstallPolicy;
use codex_app_server_protocol::PluginListResponse;
use codex_app_server_protocol::PluginMarketplaceEntry;
+use codex_app_server_protocol::PluginShareContext;
+use codex_app_server_protocol::PluginShareDiscoverability;
+use codex_app_server_protocol::PluginSharePrincipal;
use codex_app_server_protocol::PluginSource;
use codex_app_server_protocol::PluginSummary;
use codex_core_plugins::is_openai_curated_marketplace_name;
+use codex_core_plugins::remote::REMOTE_GLOBAL_MARKETPLACE_NAME;
use codex_core_plugins::remote::REMOTE_WORKSPACE_MARKETPLACE_NAME;
use codex_core_plugins::remote::REMOTE_WORKSPACE_SHARED_WITH_ME_MARKETPLACE_NAME;
use codex_core_plugins::remote::REMOTE_WORKSPACE_SHARED_WITH_ME_PRIVATE_MARKETPLACE_NAME;
use codex_core_plugins::remote::REMOTE_WORKSPACE_SHARED_WITH_ME_UNLISTED_MARKETPLACE_NAME;
+use codex_utils_absolute_path::AbsolutePathBuf;
use crossterm::event::KeyCode;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
@@ -55,6 +63,179 @@ const PLUGIN_ROW_PREFIX_WIDTH: usize = 6;
const LOADING_ANIMATION_DELAY: Duration = Duration::from_secs(1);
const LOADING_ANIMATION_INTERVAL: Duration = Duration::from_millis(100);
const APPS_HELP_ARTICLE_URL: &str = "https://help.openai.com/en/articles/11487775-apps-in-chatgpt";
+const PERSONAL_MARKETPLACE_RELATIVE_PATH: &str = ".agents/plugins/marketplace.json";
+const REMOTE_LOADING_TAB_ID_PREFIX: &str = "remote-loading:";
+const REMOTE_EMPTY_TAB_ID_PREFIX: &str = "remote-empty:";
+const REMOTE_ERROR_TAB_ID_PREFIX: &str = "remote-error:";
+const WORKSPACE_SECTION_TAB_ORDER: u8 = 0;
+const SHARED_WITH_ME_SECTION_TAB_ORDER: u8 = 1;
+const SHARED_WITH_ME_LINK_SECTION_TAB_ORDER: u8 = 2;
+const LOCAL_MARKETPLACE_TAB_ORDER: u8 = 3;
+const OTHER_MARKETPLACE_TAB_ORDER: u8 = 4;
+
+#[derive(Debug, Clone)]
+struct PreferredLocalPluginSource {
+ marketplace_path: AbsolutePathBuf,
+ plugin_name: String,
+ installed: bool,
+}
+
+#[derive(Debug, Clone, Copy)]
+enum MarketplaceProduct {
+ OpenAiCurated,
+ Workspace,
+ SharedWithMe,
+ SharedWithMeLink,
+ Local,
+ Other,
+}
+
+impl MarketplaceProduct {
+ fn from_marketplace(marketplace: &PluginMarketplaceEntry) -> Self {
+ Self::from_marketplace_parts(&marketplace.name, marketplace.path.as_ref())
+ }
+
+ fn from_marketplace_parts(
+ marketplace_name: &str,
+ marketplace_path: Option<&AbsolutePathBuf>,
+ ) -> Self {
+ if marketplace_path.is_some_and(is_personal_marketplace_path) {
+ return Self::Local;
+ }
+
+ Self::from_marketplace_name(marketplace_name)
+ }
+
+ fn from_marketplace_name(marketplace_name: &str) -> Self {
+ if is_openai_curated_marketplace_name(marketplace_name)
+ || marketplace_name == REMOTE_GLOBAL_MARKETPLACE_NAME
+ {
+ return Self::OpenAiCurated;
+ }
+
+ match marketplace_name {
+ REMOTE_WORKSPACE_MARKETPLACE_NAME => Self::Workspace,
+ REMOTE_WORKSPACE_SHARED_WITH_ME_MARKETPLACE_NAME
+ | REMOTE_WORKSPACE_SHARED_WITH_ME_PRIVATE_MARKETPLACE_NAME => Self::SharedWithMe,
+ REMOTE_WORKSPACE_SHARED_WITH_ME_UNLISTED_MARKETPLACE_NAME => Self::SharedWithMeLink,
+ _ => Self::Other,
+ }
+ }
+
+ fn label(self) -> Option<&'static str> {
+ match self {
+ Self::OpenAiCurated => Some("OpenAI Curated"),
+ Self::Workspace => Some("Workspace"),
+ Self::SharedWithMe => Some("Shared with me"),
+ Self::SharedWithMeLink => Some("Shared with me (link)"),
+ Self::Local => Some("Local"),
+ Self::Other => None,
+ }
+ }
+
+ fn tab_order(self) -> u8 {
+ match self {
+ Self::Workspace => WORKSPACE_SECTION_TAB_ORDER,
+ Self::SharedWithMe => SHARED_WITH_ME_SECTION_TAB_ORDER,
+ Self::SharedWithMeLink => SHARED_WITH_ME_LINK_SECTION_TAB_ORDER,
+ Self::Local => LOCAL_MARKETPLACE_TAB_ORDER,
+ Self::OpenAiCurated | Self::Other => OTHER_MARKETPLACE_TAB_ORDER,
+ }
+ }
+
+ fn is_by_openai(self) -> bool {
+ matches!(self, Self::OpenAiCurated)
+ }
+}
+
+#[derive(Debug, Clone, Copy)]
+struct RemoteMarketplaceSection {
+ id: &'static str,
+ label: &'static str,
+ loading_tab_id: &'static str,
+ marketplace_names: &'static [&'static str],
+ empty_item_name: &'static str,
+ empty_item_description: &'static str,
+ tab_order: u8,
+}
+
+const REMOTE_MARKETPLACE_SECTIONS: [RemoteMarketplaceSection; 2] = [
+ RemoteMarketplaceSection {
+ id: "workspace",
+ label: "Workspace",
+ loading_tab_id: "workspace-loading",
+ marketplace_names: &[REMOTE_WORKSPACE_MARKETPLACE_NAME],
+ empty_item_name: "No workspace plugins available",
+ empty_item_description: "No workspace directory plugins are available.",
+ tab_order: WORKSPACE_SECTION_TAB_ORDER,
+ },
+ RemoteMarketplaceSection {
+ id: "shared-with-me",
+ label: "Shared with me",
+ loading_tab_id: "shared-with-me-loading",
+ marketplace_names: &[
+ REMOTE_WORKSPACE_SHARED_WITH_ME_MARKETPLACE_NAME,
+ REMOTE_WORKSPACE_SHARED_WITH_ME_PRIVATE_MARKETPLACE_NAME,
+ REMOTE_WORKSPACE_SHARED_WITH_ME_UNLISTED_MARKETPLACE_NAME,
+ ],
+ empty_item_name: "No shared plugins available",
+ empty_item_description: "No plugins have been shared with you.",
+ tab_order: SHARED_WITH_ME_SECTION_TAB_ORDER,
+ },
+];
+
+impl RemoteMarketplaceSection {
+ fn fallback_tab(
+ self,
+ marketplaces: &[PluginMarketplaceEntry],
+ remote_sections_loading: bool,
+ remote_sections_loaded: bool,
+ section_errors: &[PluginRemoteSectionError],
+ ) -> Option<(u8, SelectionTab)> {
+ if marketplaces
+ .iter()
+ .any(|marketplace| self.contains_marketplace(&marketplace.name))
+ {
+ return None;
+ }
+
+ let tab = if remote_sections_loading {
+ remote_section_loading_tab(self.loading_tab_id, self.label)
+ } else if remote_sections_loaded {
+ if let Some(section_error) = plugin_remote_section_error(section_errors, self.id) {
+ remote_section_error_tab(section_error)
+ } else {
+ remote_section_empty_tab(
+ self.id,
+ self.label,
+ self.empty_item_name,
+ self.empty_item_description,
+ )
+ }
+ } else {
+ return None;
+ };
+
+ Some((self.tab_order, tab))
+ }
+
+ fn contains_marketplace(self, marketplace_name: &str) -> bool {
+ self.marketplace_names.contains(&marketplace_name)
+ }
+
+ fn is_fallback_tab_id(self, tab_id: &str) -> bool {
+ tab_id.strip_prefix(REMOTE_LOADING_TAB_ID_PREFIX) == Some(self.loading_tab_id)
+ || tab_id.strip_prefix(REMOTE_EMPTY_TAB_ID_PREFIX) == Some(self.id)
+ || tab_id.strip_prefix(REMOTE_ERROR_TAB_ID_PREFIX) == Some(self.id)
+ }
+
+ fn contains_tab_id(self, tab_id: &str) -> bool {
+ self.is_fallback_tab_id(tab_id)
+ || tab_id
+ .strip_prefix(MARKETPLACE_TAB_ID_PREFIX)
+ .is_some_and(|marketplace_name| self.contains_marketplace(marketplace_name))
+ }
+}
struct DelayedLoadingHeader {
started_at: Instant,
@@ -237,18 +418,18 @@ impl ChatWidget {
description: Some("Keep this marketplace installed.".to_string()),
selected_description: Some("Keep this marketplace installed.".to_string()),
actions: vec![Box::new(move |tx| {
- tx.send(AppEvent::PluginsLoaded {
+ tx.send(AppEvent::OpenPluginsList {
cwd: cwd_for_cancel.clone(),
- result: Ok(plugins_response_for_cancel.clone()),
+ response: plugins_response_for_cancel.clone(),
});
})],
..Default::default()
},
],
on_cancel: Some(Box::new(move |tx| {
- tx.send(AppEvent::PluginsLoaded {
+ tx.send(AppEvent::OpenPluginsList {
cwd: cwd_for_on_cancel.clone(),
- result: Ok(plugins_response_for_on_cancel.clone()),
+ response: plugins_response_for_on_cancel.clone(),
});
})),
..Default::default()
@@ -421,9 +602,9 @@ impl ChatWidget {
description: Some("Return to the plugin list.".to_string()),
selected_description: Some("Return to the plugin list.".to_string()),
actions: vec![Box::new(move |tx| {
- tx.send(AppEvent::PluginsLoaded {
+ tx.send(AppEvent::OpenPluginsList {
cwd: cwd.clone(),
- result: Ok(plugins_response.clone()),
+ response: plugins_response.clone(),
});
})],
..Default::default()
@@ -478,9 +659,9 @@ impl ChatWidget {
description: Some("Return to the plugin list.".to_string()),
selected_description: Some("Return to the plugin list.".to_string()),
actions: vec![Box::new(move |tx| {
- tx.send(AppEvent::PluginsLoaded {
+ tx.send(AppEvent::OpenPluginsList {
cwd: cwd.clone(),
- result: Ok(plugins_response.clone()),
+ response: plugins_response.clone(),
});
})],
..Default::default()
@@ -518,9 +699,9 @@ impl ChatWidget {
description: Some("Return to the plugin list.".to_string()),
selected_description: Some("Return to the plugin list.".to_string()),
actions: vec![Box::new(move |tx| {
- tx.send(AppEvent::PluginsLoaded {
+ tx.send(AppEvent::OpenPluginsList {
cwd: cwd.clone(),
- result: Ok(plugins_response.clone()),
+ response: plugins_response.clone(),
});
})],
..Default::default()
@@ -542,19 +723,15 @@ impl ChatWidget {
active_tab_id: Option<String>,
initial_selected_idx: Option<usize>,
) -> SelectionViewParams {
- let marketplaces: Vec<&PluginMarketplaceEntry> = response.marketplaces.iter().collect();
+ let marketplaces = &response.marketplaces;
+ let preferred_local_sources = preferred_local_plugin_sources(marketplaces);
- let total: usize = marketplaces
+ let all_entries = plugin_entries_for_marketplaces(marketplaces);
+ let total = all_entries.len();
+ let installed = all_entries
.iter()
- .map(|marketplace| marketplace.plugins.len())
- .sum();
- let installed = marketplaces
- .iter()
- .flat_map(|marketplace| marketplace.plugins.iter())
- .filter(|plugin| plugin.installed)
+ .filter(|(_, plugin, _)| plugin.installed)
.count();
-
- let all_entries = plugin_entries_for_marketplaces(marketplaces.iter().copied());
let name_column_width = all_entries
.iter()
.map(|(_, _, display_name)| {
@@ -570,6 +747,14 @@ impl ChatWidget {
let mut tabs = Vec::new();
let mut tab_footer_hints = Vec::new();
+ let all_items = self.plugin_selection_items(
+ all_entries,
+ &preferred_local_sources,
+ /*include_marketplace_names*/ true,
+ "No marketplace plugins available",
+ "No plugins are available in the discovered marketplaces.",
+ );
+
tabs.push(SelectionTab {
id: ALL_PLUGINS_TAB_ID.to_string(),
label: "All Plugins".to_string(),
@@ -577,12 +762,7 @@ impl ChatWidget {
"Browse plugins from available marketplaces.".to_string(),
format!("Installed {installed} of {total} available plugins."),
),
- items: self.plugin_selection_items(
- all_entries,
- /*include_marketplace_names*/ true,
- "No marketplace plugins available",
- "No plugins are available in the discovered marketplaces.",
- ),
+ items: all_items,
});
tabs.push(SelectionTab {
@@ -594,24 +774,61 @@ impl ChatWidget {
),
items: self.plugin_selection_items(
installed_entries,
+ &preferred_local_sources,
/*include_marketplace_names*/ true,
"No installed plugins",
"No installed plugins.",
),
});
- let curated_marketplace = marketplaces
- .iter()
- .find(|marketplace| is_openai_curated_marketplace_name(&marketplace.name))
- .copied();
- let curated_entries = curated_marketplace
- .map(|marketplace| plugin_entries_for_marketplaces([marketplace]))
- .unwrap_or_default();
+ let curated_entries =
+ plugin_entries_for_marketplaces(marketplaces.iter().filter(|marketplace| {
+ MarketplaceProduct::from_marketplace(marketplace).is_by_openai()
+ }));
let curated_total = curated_entries.len();
let curated_installed = curated_entries
.iter()
.filter(|(_, plugin, _)| plugin.installed)
.count();
+ let curated_has_entries = !curated_entries.is_empty();
+ let curated_loading = self.plugin_remote_sections_loading
+ && self.plugins_fetch_state.vertical_section_requested;
+ let by_openai_section_error =
+ plugin_remote_section_error(&self.plugin_remote_section_errors, "vertical");
+ let (curated_empty_name, curated_empty_description) =
+ if curated_loading && !curated_has_entries {
+ (
+ "Loading OpenAI Curated plugins...",
+ "This section updates when app-server returns it.",
+ )
+ } else if let Some(section_error) = by_openai_section_error
+ && !curated_has_entries
+ {
+ ("OpenAI Curated unavailable", section_error.message.as_str())
+ } else {
+ (
+ "No OpenAI Curated plugins available",
+ "No OpenAI Curated plugins available.",
+ )
+ };
+ let mut curated_items = self.plugin_selection_items(
+ curated_entries,
+ &preferred_local_sources,
+ /*include_marketplace_names*/ false,
+ curated_empty_name,
+ curated_empty_description,
+ );
+ if curated_loading && curated_has_entries {
+ curated_items.push(remote_section_loading_item("OpenAI Curated"));
+ }
+ if let Some(section_error) = by_openai_section_error
+ && curated_has_entries
+ {
+ curated_items.push(remote_section_error_item(
+ &section_error.label,
+ &section_error.message,
+ ));
+ }
tabs.push(SelectionTab {
id: OPENAI_CURATED_TAB_ID.to_string(),
label: "OpenAI Curated".to_string(),
@@ -619,27 +836,35 @@ impl ChatWidget {
"OpenAI Curated marketplace.".to_string(),
format!("Installed {curated_installed} of {curated_total} OpenAI Curated plugins."),
),
- items: self.plugin_selection_items(
- curated_entries,
- /*include_marketplace_names*/ false,
- "No OpenAI Curated plugins available",
- "No OpenAI Curated plugins available.",
- ),
+ items: curated_items,
});
let mut additional_marketplaces: Vec<&PluginMarketplaceEntry> = marketplaces
.iter()
- .copied()
- .filter(|marketplace| !is_openai_curated_marketplace_name(&marketplace.name))
+ .filter(|marketplace| !MarketplaceProduct::from_marketplace(marketplace).is_by_openai())
.collect();
- additional_marketplaces.sort_by(|left, right| {
- marketplace_display_name(left)
- .to_ascii_lowercase()
- .cmp(&marketplace_display_name(right).to_ascii_lowercase())
- .then_with(|| marketplace_display_name(left).cmp(&marketplace_display_name(right)))
- .then_with(|| left.name.cmp(&right.name))
+ additional_marketplaces.sort_by_cached_key(|marketplace| {
+ let display_name = marketplace_display_name(marketplace);
+ (
+ MarketplaceProduct::from_marketplace(marketplace).tab_order(),
+ display_name.to_ascii_lowercase(),
+ display_name,
+ marketplace.name.clone(),
+ )
});
+ let mut additional_tabs = Vec::new();
+ for section in REMOTE_MARKETPLACE_SECTIONS {
+ if let Some(fallback_tab) = section.fallback_tab(
+ marketplaces,
+ self.plugin_remote_sections_loading,
+ self.plugin_remote_sections_loaded,
+ &self.plugin_remote_section_errors,
+ ) {
+ additional_tabs.push(fallback_tab);
+ }
+ }
+
let labels = disambiguate_duplicate_tab_labels(
additional_marketplaces
.iter()
@@ -681,20 +906,28 @@ impl ChatWidget {
),
)
};
- tabs.push(SelectionTab {
- id: tab_id,
- label: label.clone(),
- header,
- items: self.plugin_selection_items(
- entries,
- /*include_marketplace_names*/ false,
- "No plugins available in this marketplace",
- "No plugins available in this marketplace.",
- ),
- });
+ additional_tabs.push((
+ MarketplaceProduct::from_marketplace(marketplace).tab_order(),
+ SelectionTab {
+ id: tab_id,
+ label: label.clone(),
+ header,
+ items: self.plugin_selection_items(
+ entries,
+ &preferred_local_sources,
+ /*include_marketplace_names*/ false,
+ "No plugins available in this marketplace",
+ "No plugins available in this marketplace.",
+ ),
+ },
+ ));
}
+ additional_tabs.sort_by_key(|(tab_order, _)| *tab_order);
+ tabs.extend(additional_tabs.into_iter().map(|(_, tab)| tab));
tabs.push(self.marketplace_add_tab());
+ let initial_tab_id =
+ active_tab_id.and_then(|tab_id| plugin_tab_id_matching_saved_id(&tab_id, &tabs));
SelectionViewParams {
view_id: Some(PLUGINS_SELECTION_VIEW_ID),
@@ -704,7 +937,7 @@ impl ChatWidget {
)),
tab_footer_hints,
tabs,
- initial_tab_id: active_tab_id,
+ initial_tab_id,
is_searchable: true,
search_placeholder: Some("Type to search plugins".to_string()),
col_width_mode: ColumnWidthMode::AutoAllRows,
@@ -744,24 +977,15 @@ impl ChatWidget {
plugins_response: &PluginListResponse,
plugin: &PluginDetail,
) -> SelectionViewParams {
- let marketplace_label = plugin.marketplace_name.clone();
+ let marketplace_label = MarketplaceProduct::from_marketplace_parts(
+ &plugin.marketplace_name,
+ plugin.marketplace_path.as_ref(),
+ )
+ .label()
+ .map(str::to_string)
+ .unwrap_or_else(|| plugin.marketplace_name.clone());
let display_name = plugin_display_name(&plugin.summary);
- let detail_status_label =
- if plugin.summary.availability == PluginAvailability::DisabledByAdmin {
- "Disabled by admin"
- } else if plugin.summary.installed {
- if plugin.summary.enabled {
- "Installed"
- } else {
- "Disabled"
- }
- } else {
- match plugin.summary.install_policy {
- PluginInstallPolicy::NotAvailable => "Not installable",
- PluginInstallPolicy::Available => "Can be installed",
- PluginInstallPolicy::InstalledByDefault => "Available by default",
- }
- };
+ let detail_status_label = plugin_detail_status_label(&plugin.summary);
let mut header = ColumnRenderable::new();
header.push(Line::from("Plugins".bold()));
header.push(Line::from(
@@ -791,9 +1015,9 @@ impl ChatWidget {
description: Some("Return to the plugin list.".to_string()),
selected_description: Some("Return to the plugin list.".to_string()),
actions: vec![Box::new(move |tx| {
- tx.send(AppEvent::PluginsLoaded {
+ tx.send(AppEvent::OpenPluginsList {
cwd: cwd.clone(),
- result: Ok(plugins_response.clone()),
+ response: plugins_response.clone(),
});
})],
..Default::default()
@@ -875,6 +1099,8 @@ impl ChatWidget {
});
}
+ items.extend(plugin_metadata_items(plugin));
+
items.push(SelectionItem {
name: "Skills".to_string(),
description: Some(plugin_skill_summary(plugin)),
@@ -913,6 +1139,7 @@ impl ChatWidget {
fn plugin_selection_items<'a>(
&self,
mut plugin_entries: Vec<(&'a PluginMarketplaceEntry, &'a PluginSummary, String)>,
+ preferred_local_sources: &HashMap<String, PreferredLocalPluginSource>,
include_marketplace_names: bool,
empty_name: &str,
empty_description: &str,
@@ -933,7 +1160,8 @@ impl ChatWidget {
} else {
plugin_brief_description_without_marketplace(plugin, status_label_width)
};
- let plugin_detail_request = plugin_detail_request_for_entry(marketplace, plugin);
+ let plugin_detail_request =
+ plugin_detail_request_for_entry(marketplace, plugin, preferred_local_sources);
let can_view_details = plugin_detail_request.is_some();
let disabled_by_admin = plugin.availability == PluginAvailability::DisabledByAdmin;
let can_toggle_plugin = plugin.installed && !disabled_by_admin;
@@ -1049,7 +1277,7 @@ pub(super) fn plugin_detail_hint_line() -> Line<'static> {
Line::from("Press esc to close.")
}
-fn plugins_header(subtitle: String, count_line: String) -> Box<dyn Renderable> {
+pub(super) fn plugins_header(subtitle: String, count_line: String) -> Box<dyn Renderable> {
let mut header = ColumnRenderable::new();
header.push(Line::from("Plugins".bold()));
header.push(Line::from(subtitle.dim()));
@@ -1057,10 +1285,225 @@ fn plugins_header(subtitle: String, count_line: String) -> Box<dyn Renderable> {
Box::new(header)
}
+fn dedupe_plugin_entries<'a>(
+ entries: Vec<(&'a PluginMarketplaceEntry, &'a PluginSummary, String)>,
+) -> Vec<(&'a PluginMarketplaceEntry, &'a PluginSummary, String)> {
+ // App-server should eventually normalize local/remote duplicates. Keep this
+ // display-only pass narrow so shared plugins do not appear twice meanwhile.
+ let mut deduped: Vec<(&PluginMarketplaceEntry, &PluginSummary, String)> = Vec::new();
+ let mut remote_entry_indexes = HashMap::new();
+ for entry in entries {
+ let Some(remote_plugin_id) = plugin_remote_identity(entry.1) else {
+ deduped.push(entry);
+ continue;
+ };
+ if let Some(existing_index) = remote_entry_indexes.get(&remote_plugin_id).copied() {
+ if plugin_entry_preferred(&entry, &deduped[existing_index]) {
+ deduped[existing_index] = entry;
+ }
+ } else {
+ remote_entry_indexes.insert(remote_plugin_id, deduped.len());
+ deduped.push(entry);
+ }
+ }
+ deduped
+}
+
+fn plugin_entry_preferred(
+ candidate: &(&PluginMarketplaceEntry, &PluginSummary, String),
+ existing: &(&PluginMarketplaceEntry, &PluginSummary, String),
+) -> bool {
+ if candidate.1.installed != existing.1.installed {
+ return candidate.1.installed;
+ }
+
+ let candidate_is_local_share =
+ candidate.1.share_context.is_some() && !matches!(&candidate.1.source, PluginSource::Remote);
+ let existing_is_local_share =
+ existing.1.share_context.is_some() && !matches!(&existing.1.source, PluginSource::Remote);
+ if candidate_is_local_share != existing_is_local_share {
+ return candidate_is_local_share;
+ }
+
+ !matches!(&candidate.1.source, PluginSource::Remote)
+ && matches!(&existing.1.source, PluginSource::Remote)
+}
+
+fn preferred_local_plugin_sources(
+ marketplaces: &[PluginMarketplaceEntry],
+) -> HashMap<String, PreferredLocalPluginSource> {
+ let mut sources = HashMap::new();
+ for marketplace in marketplaces {
+ let Some(marketplace_path) = marketplace.path.as_ref() else {
+ continue;
+ };
+ for plugin in &marketplace.plugins {
+ if matches!(&plugin.source, PluginSource::Remote) {
+ continue;
+ }
+ let Some(share_context) = plugin.share_context.as_ref() else {
+ continue;
+ };
+ sources
+ .entry(share_context.remote_plugin_id.clone())
+ .or_insert_with(|| PreferredLocalPluginSource {
+ marketplace_path: marketplace_path.clone(),
+ plugin_name: plugin.name.clone(),
+ installed: plugin.installed,
+ });
+ }
+ }
+ sources
+}
+
+fn plugin_detail_status_label(plugin: &PluginSummary) -> &'static str {
+ if plugin.availability == PluginAvailability::DisabledByAdmin {
+ return "Disabled by admin";
+ }
+ if plugin.installed {
+ if plugin.enabled {
+ "Installed"
+ } else {
+ "Disabled"
+ }
+ } else {
+ match plugin.install_policy {
+ PluginInstallPolicy::NotAvailable => "Not installable",
+ PluginInstallPolicy::Available => "Can be installed",
+ PluginInstallPolicy::InstalledByDefault => "Available by default",
+ }
+ }
+}
+
+fn plugin_metadata_items(plugin: &PluginDetail) -> Vec<SelectionItem> {
+ let mut items = Vec::new();
+ items.push(SelectionItem {
+ name: "Source".to_string(),
+ description: Some(plugin_source_summary(plugin)),
+ is_disabled: true,
+ ..Default::default()
+ });
+ items.push(SelectionItem {
+ name: "Auth".to_string(),
+ description: Some(plugin_auth_policy_summary(plugin.summary.auth_policy)),
+ is_disabled: true,
+ ..Default::default()
+ });
+ if let Some(version) = plugin_version_summary(&plugin.summary) {
+ items.push(SelectionItem {
+ name: "Version".to_string(),
+ description: Some(version),
+ is_disabled: true,
+ ..Default::default()
+ });
+ }
+ if let Some(share_context) = &plugin.summary.share_context {
+ items.push(SelectionItem {
+ name: "Sharing".to_string(),
+ description: Some(plugin_share_context_summary(share_context)),
+ is_disabled: true,
+ ..Default::default()
+ });
+ }
+ items
+}
+
+fn plugin_source_summary(plugin: &PluginDetail) -> String {
+ match &plugin.summary.source {
+ PluginSource::Local { .. } => "Local".to_string(),
+ PluginSource::Git { url, ref_name, .. } => match ref_name {
+ Some(ref_name) => format!("Git · {url}@{ref_name}"),
+ None => format!("Git · {url}"),
+ },
+ PluginSource::Remote => {
+ let marketplace_label =
+ MarketplaceProduct::from_marketplace_name(&plugin.marketplace_name)
+ .label()
+ .unwrap_or(plugin.marketplace_name.as_str());
+ format!("Remote · {marketplace_label}")
+ }
+ }
+}
+
+fn plugin_auth_policy_summary(auth_policy: PluginAuthPolicy) -> String {
+ match auth_policy {
+ PluginAuthPolicy::OnInstall => "Auth on install".to_string(),
+ PluginAuthPolicy::OnUse => "Auth on use".to_string(),
+ }
+}
+
+fn plugin_version_summary(plugin: &PluginSummary) -> Option<String> {
+ let mut parts = Vec::new();
+ if let Some(local_version) = plugin.local_version.as_deref() {
+ parts.push(format!("local {local_version}"));
+ }
+ if let Some(remote_version) = plugin
+ .share_context
+ .as_ref()
+ .and_then(|context| context.remote_version.as_deref())
+ {
+ parts.push(format!("remote {remote_version}"));
+ }
+ (!parts.is_empty()).then(|| parts.join(" · "))
+}
+
+fn plugin_share_context_summary(context: &PluginShareContext) -> String {
+ let mut parts = Vec::new();
+ if let Some(discoverability) = context.discoverability {
+ parts.push(plugin_share_discoverability_label(discoverability).to_string());
+ }
+ if let Some(creator_summary) = plugin_share_creator_summary(context) {
+ parts.push(creator_summary);
+ }
+ if let Some(principals) = context.share_principals.as_ref() {
+ parts.push(plugin_share_principals_summary(principals));
+ }
+ if let Some(share_url) = context
+ .share_url
+ .as_deref()
+ .filter(|url| !url.trim().is_empty())
+ {
+ parts.push(share_url.to_string());
+ }
+ if parts.is_empty() {
+ format!("Remote ID {}", context.remote_plugin_id)
+ } else {
+ parts.join(" · ")
+ }
+}
+
+fn plugin_share_discoverability_label(discoverability: PluginShareDiscoverability) -> &'static str {
+ match discoverability {
+ PluginShareDiscoverability::Listed => "Listed",
+ PluginShareDiscoverability::Unlisted => "Workspace link",
+ PluginShareDiscoverability::Private => "Private",
+ }
+}
+
+fn plugin_share_creator_summary(context: &PluginShareContext) -> Option<String> {
+ match (
+ context.creator_name.as_deref(),
+ context.creator_account_user_id.as_deref(),
+ ) {
+ (Some(name), Some(account_id)) => Some(format!("creator {name} ({account_id})")),
+ (Some(name), None) => Some(format!("creator {name}")),
+ (None, Some(account_id)) => Some(format!("creator account {account_id}")),
+ (None, None) => None,
+ }
+}
+
+fn plugin_share_principals_summary(principals: &[PluginSharePrincipal]) -> String {
+ match principals.len() {
+ 0 => "No explicit principals".to_string(),
+ 1 => format!("1 principal: {}", principals[0].name),
+ count => format!("{count} principals"),
+ }
+}
+
fn plugin_entries_for_marketplaces<'a>(
marketplaces: impl IntoIterator<Item = &'a PluginMarketplaceEntry>,
) -> Vec<(&'a PluginMarketplaceEntry, &'a PluginSummary, String)> {
- marketplaces
+ let entries = marketplaces
.into_iter()
.flat_map(|marketplace| {
marketplace
@@ -1068,7 +1511,8 @@ fn plugin_entries_for_marketplaces<'a>(
.iter()
.map(move |plugin| (marketplace, plugin, plugin_display_name(plugin)))
})
- .collect()
+ .collect::<Vec<_>>();
+ dedupe_plugin_entries(entries)
}
fn sort_plugin_entries(entries: &mut [(&PluginMarketplaceEntry, &PluginSummary, String)]) {
@@ -1103,6 +1547,10 @@ pub(super) fn marketplace_tab_id_matching_saved_id(
saved_tab_id: &str,
marketplaces: &[PluginMarketplaceEntry],
) -> Option<String> {
+ if let Some(tab_id) = remote_section_marketplace_tab_id(saved_tab_id, marketplaces) {
+ return Some(tab_id);
+ }
+
if let Some(tab_id) = marketplaces.iter().find_map(|marketplace| {
let tab_id = marketplace_tab_id(marketplace);
(tab_id == saved_tab_id).then_some(tab_id)
@@ -1124,6 +1572,43 @@ pub(super) fn marketplace_tab_id_matching_saved_id(
})
}
+fn remote_section_marketplace_tab_id(
+ saved_tab_id: &str,
+ marketplaces: &[PluginMarketplaceEntry],
+) -> Option<String> {
+ let section = REMOTE_MARKETPLACE_SECTIONS
+ .into_iter()
+ .find(|section| section.is_fallback_tab_id(saved_tab_id))?;
+
+ section
+ .marketplace_names
+ .iter()
+ .find_map(|marketplace_name| {
+ marketplaces
+ .iter()
+ .find(|marketplace| marketplace.name.as_str() == *marketplace_name)
+ .map(marketplace_tab_id)
+ })
+}
+
+fn plugin_tab_id_matching_saved_id(saved_tab_id: &str, tabs: &[SelectionTab]) -> Option<String> {
+ if let Some(tab_id) = tabs
+ .iter()
+ .find(|tab| tab.id.as_str() == saved_tab_id)
+ .map(|tab| tab.id.clone())
+ {
+ return Some(tab_id);
+ }
+
+ let section = REMOTE_MARKETPLACE_SECTIONS
+ .into_iter()
+ .find(|section| section.contains_tab_id(saved_tab_id))?;
+
+ tabs.iter()
+ .find(|tab| section.contains_tab_id(&tab.id))
+ .map(|tab| tab.id.clone())
+}
+
pub(super) fn merge_remote_marketplaces(
response: &mut PluginListResponse,
remote_marketplaces: Vec<PluginMarketplaceEntry>,
@@ -1132,62 +1617,134 @@ pub(super) fn merge_remote_marketplaces(
.iter()
.map(|marketplace| marketplace.name.clone())
.collect::<std::collections::HashSet<_>>();
+ let remote_curated_present = remote_names.contains(REMOTE_GLOBAL_MARKETPLACE_NAME);
response.marketplaces.retain(|marketplace| {
+ if remote_curated_present
+ && marketplace.path.is_some()
+ && is_openai_curated_marketplace_name(&marketplace.name)
+ {
+ return false;
+ }
+
marketplace.path.is_some()
- || !remote_marketplace_is_remote_section(marketplace)
+ || !REMOTE_MARKETPLACE_SECTIONS
+ .into_iter()
+ .any(|section| section.contains_marketplace(&marketplace.name))
&& !remote_names.contains(marketplace.name.as_str())
});
response.marketplaces.extend(remote_marketplaces);
}
-fn remote_marketplace_is_remote_section(marketplace: &PluginMarketplaceEntry) -> bool {
- matches!(
- marketplace.name.as_str(),
- REMOTE_WORKSPACE_MARKETPLACE_NAME
- | REMOTE_WORKSPACE_SHARED_WITH_ME_MARKETPLACE_NAME
- | REMOTE_WORKSPACE_SHARED_WITH_ME_PRIVATE_MARKETPLACE_NAME
- | REMOTE_WORKSPACE_SHARED_WITH_ME_UNLISTED_MARKETPLACE_NAME
- )
+fn is_personal_marketplace_path(marketplace_path: &AbsolutePathBuf) -> bool {
+ dirs::home_dir()
+ .and_then(|home| {
+ AbsolutePathBuf::try_from(home.join(PERSONAL_MARKETPLACE_RELATIVE_PATH)).ok()
+ })
+ .is_some_and(|personal_path| personal_path.as_path() == marketplace_path.as_path())
+}
+
+fn remote_section_loading_item(label: &str) -> SelectionItem {
+ SelectionItem {
+ name: format!("Loading {label} plugins..."),
+ description: Some("This section updates when app-server returns it.".to_string()),
+ is_disabled: true,
+ ..Default::default()
+ }
+}
+
+fn remote_section_error_item(label: &str, message: &str) -> SelectionItem {
+ SelectionItem {
+ name: format!("{label} unavailable"),
+ description: Some(message.to_string()),
+ is_disabled: true,
+ ..Default::default()
+ }
+}
+
+fn plugin_remote_section_error<'a>(
+ section_errors: &'a [PluginRemoteSectionError],
+ section_id: &str,
+) -> Option<&'a PluginRemoteSectionError> {
+ section_errors
+ .iter()
+ .find(|section_error| section_error.section_id == section_id)
+}
+
+fn remote_section_loading_tab(id: &str, label: &str) -> SelectionTab {
+ SelectionTab {
+ id: format!("{REMOTE_LOADING_TAB_ID_PREFIX}{id}"),
+ label: label.to_string(),
+ header: plugins_header(
+ format!("Loading {label} plugins."),
+ "Local plugin functionality is already available.".to_string(),
+ ),
+ items: vec![remote_section_loading_item(label)],
+ }
+}
+
+fn remote_section_empty_tab(
+ id: &str,
+ label: &str,
+ item_name: &str,
+ item_description: &str,
+) -> SelectionTab {
+ SelectionTab {
+ id: format!("{REMOTE_EMPTY_TAB_ID_PREFIX}{id}"),
+ label: label.to_string(),
+ header: plugins_header(
+ format!("{label}."),
+ "This section loaded successfully.".to_string(),
+ ),
+ items: vec![SelectionItem {
+ name: item_name.to_string(),
+ description: Some(item_description.to_string()),
+ is_disabled: true,
+ ..Default::default()
+ }],
+ }
+}
+
+fn remote_section_error_tab(section_error: &PluginRemoteSectionError) -> SelectionTab {
+ SelectionTab {
+ id: format!("{REMOTE_ERROR_TAB_ID_PREFIX}{}", section_error.section_id),
+ label: section_error.label.clone(),
+ header: plugins_header(
+ format!("{} unavailable.", section_error.label),
+ "Local plugin functionality is still available.".to_string(),
+ ),
+ items: vec![remote_section_error_item(
+ &section_error.label,
+ &section_error.message,
+ )],
+ }
}
fn disambiguate_duplicate_tab_labels(labels: Vec<String>) -> Vec<String> {
- let mut counts: Vec<(String, usize)> = Vec::new();
+ let mut counts = HashMap::new();
for label in &labels {
- if let Some((_, count)) = counts.iter_mut().find(|(existing, _)| existing == label) {
- *count += 1;
- } else {
- counts.push((label.clone(), 1));
- }
+ *counts.entry(label.clone()).or_insert(0) += 1;
}
- let mut seen: Vec<(String, usize)> = Vec::new();
+ let mut seen = HashMap::new();
labels
.into_iter()
.map(|label| {
- let total = counts
- .iter()
- .find(|(existing, _)| existing == &label)
- .map(|(_, count)| *count)
- .unwrap_or(1);
+ let total = counts[&label];
if total == 1 {
return label;
}
- let current = if let Some((_, seen_count)) =
- seen.iter_mut().find(|(existing, _)| existing == &label)
- {
- *seen_count += 1;
- *seen_count
- } else {
- seen.push((label.clone(), 1));
- 1
- };
+ let current = seen.entry(label.clone()).or_insert(0);
+ *current += 1;
format!("{label} ({current}/{total})")
})
.collect()
}
pub(super) fn marketplace_display_name(marketplace: &PluginMarketplaceEntry) -> String {
+ if let Some(label) = MarketplaceProduct::from_marketplace(marketplace).label() {
+ return label.to_string();
+ }
marketplace
.interface
.as_ref()
@@ -1271,7 +1828,7 @@ fn plugin_status_label(plugin: &PluginSummary) -> &'static str {
match plugin.install_policy {
PluginInstallPolicy::NotAvailable => "Not installable",
PluginInstallPolicy::Available => "Available",
- PluginInstallPolicy::InstalledByDefault => "Available",
+ PluginInstallPolicy::InstalledByDefault => "Available by default",
}
}
}
@@ -1300,7 +1857,21 @@ fn plugin_detail_location(plugin: &PluginDetail) -> Option<PluginLocation> {
fn plugin_detail_request_for_entry(
marketplace: &PluginMarketplaceEntry,
plugin: &PluginSummary,
+ preferred_local_sources: &HashMap<String, PreferredLocalPluginSource>,
) -> Option<(PluginLocation, String)> {
+ if matches!(&plugin.source, PluginSource::Remote)
+ && let Some(remote_plugin_id) = plugin_remote_identity(plugin)
+ && let Some(preferred_source) = preferred_local_sources.get(remote_plugin_id)
+ && preferred_source.installed == plugin.installed
+ {
+ return Some((
+ PluginLocation::Local {
+ marketplace_path: preferred_source.marketplace_path.clone(),
+ },
+ preferred_source.plugin_name.clone(),
+ ));
+ }
+
plugin_location_for_marketplace(marketplace, plugin)
.map(|location| (location, plugin_request_name(plugin)))
}
@@ -1309,22 +1880,22 @@ fn plugin_request_name(plugin: &PluginSummary) -> String {
if matches!(&plugin.source, PluginSource::Remote)
&& let Some(remote_plugin_id) = plugin_remote_identity(plugin)
{
- return remote_plugin_id;
+ return remote_plugin_id.to_string();
}
plugin.name.clone()
}
-fn plugin_remote_identity(plugin: &PluginSummary) -> Option<String> {
+fn plugin_remote_identity(plugin: &PluginSummary) -> Option<&str> {
plugin
.share_context
.as_ref()
- .map(|context| context.remote_plugin_id.clone())
- .or_else(|| plugin.remote_plugin_id.clone())
+ .map(|context| context.remote_plugin_id.as_str())
+ .or(plugin.remote_plugin_id.as_deref())
}
fn plugin_uninstall_id(plugin: &PluginSummary) -> Option<String> {
if matches!(&plugin.source, PluginSource::Remote) {
- return plugin_remote_identity(plugin);
+ return plugin_remote_identity(plugin).map(str::to_string);
}
Some(plugin.id.clone())
}
diff --git a/codex-rs/tui/src/chatwidget/plugins.rs b/codex-rs/tui/src/chatwidget/plugins.rs
index 8c259856fb..0ff8333ffc 100644
--- a/codex-rs/tui/src/chatwidget/plugins.rs
+++ b/codex-rs/tui/src/chatwidget/plugins.rs
@@ -42,6 +42,7 @@ pub(super) const ADD_MARKETPLACE_TAB_ID: &str = "add-marketplace";
pub(super) struct PluginListFetchState {
pub(super) cache_cwd: Option<PathBuf>,
pub(super) in_flight_cwd: Option<PathBuf>,
+ pub(super) vertical_section_requested: bool,
}
#[derive(Debug, Clone)]
@@ -147,6 +148,7 @@ impl ChatWidget {
Err(err) => {
self.plugin_remote_sections_loading = false;
self.plugin_remote_sections_loaded = false;
+ self.plugins_fetch_state.vertical_section_requested = false;
if should_refresh_plugins_popup {
self.plugins_fetch_state.cache_cwd = None;
self.plugins_cache = PluginsCacheState::Failed(err.clone());
@@ -175,6 +177,7 @@ impl ChatWidget {
.is_some();
self.plugin_remote_sections_loading = false;
self.plugin_remote_sections_loaded = true;
+ self.plugins_fetch_state.vertical_section_requested = false;
let refreshed_response = match &mut self.plugins_cache {
PluginsCacheState::Ready(response)
if self.plugins_fetch_state.cache_cwd.as_deref() == Some(cwd.as_path()) =>
@@ -212,6 +215,8 @@ impl ChatWidget {
}
self.plugins_fetch_state.in_flight_cwd = Some(cwd.clone());
+ self.plugins_fetch_state.vertical_section_requested =
+ !self.config.features.enabled(Feature::RemotePlugin);
if self.plugins_fetch_state.cache_cwd.as_deref() != Some(cwd.as_path()) {
self.plugins_cache = PluginsCacheState::Loading;
}
@@ -245,6 +250,36 @@ impl ChatWidget {
));
}
+ pub(crate) fn open_plugins_list(&mut self, cwd: PathBuf, response: PluginListResponse) {
+ if self.config.cwd.as_path() != cwd.as_path() {
+ return;
+ }
+
+ let response = match self.plugins_cache_for_current_cwd() {
+ PluginsCacheState::Ready(current_response) => current_response,
+ PluginsCacheState::Uninitialized
+ | PluginsCacheState::Loading
+ | PluginsCacheState::Failed(_) => response,
+ };
+ self.plugins_fetch_state.cache_cwd = Some(cwd);
+ self.plugins_cache = PluginsCacheState::Ready(response.clone());
+ let active_tab_id = self
+ .bottom_pane
+ .active_tab_id_for_active_view(PLUGINS_SELECTION_VIEW_ID)
+ .map(str::to_string)
+ .or_else(|| self.plugins_active_tab_id.clone())
+ .or_else(|| Some(ALL_PLUGINS_TAB_ID.to_string()));
+ self.plugins_active_tab_id = active_tab_id.clone();
+ let params =
+ self.plugins_popup_params(&response, active_tab_id, /*initial_selected_idx*/ None);
+ if !self
+ .bottom_pane
+ .replace_selection_view_if_active(PLUGINS_SELECTION_VIEW_ID, params)
+ {
+ self.open_plugins_popup(&response);
+ }
+ }
+
pub(crate) fn open_marketplace_add_prompt(&mut self) {
self.plugins_active_tab_id = Some(ADD_MARKETPLACE_TAB_ID.to_string());
let tx = self.app_event_tx.clone();
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installable.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installable.snap
index c7edae1714..e5d14a4c51 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installable.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installable.snap
@@ -3,13 +3,15 @@ source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: strip_osc8_for_snapshot(&popup)
---
Plugins
- Figma · Can be installed · ChatGPT Marketplace
+ Figma · Can be installed · Local
Data shared with this app is subject to the app's terms of service and privacy policy. Learn
more.
Turn Figma files into implementation context.
› 1. Back to plugins Return to the plugin list.
2. Install plugin Install this plugin now.
+ Source Local
+ Auth Auth on install
Skills design-review, extract-copy
Hooks PreToolUse (1), Stop (2)
Apps Figma, Slack
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installed.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installed.snap
index 4d91b17f34..2b69864cc5 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installed.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugin_detail_popup_installed.snap
@@ -8,6 +8,8 @@ expression: strip_osc8_for_snapshot(&popup)
› 1. Back to plugins Return to the plugin list.
2. Uninstall plugin Remove this plugin now.
+ Source Local
+ Auth Auth on install
Skills design-review, extract-copy
Hooks PreToolUse (1), Stop (2)
Apps Figma, Slack
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_curated_marketplace.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_curated_marketplace.snap
index 40d26d3c9d..9f828ab3bc 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_curated_marketplace.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_curated_marketplace.snap
@@ -9,9 +9,9 @@ expression: popup
[All Plugins] Installed (1) OpenAI Curated Repo Marketplace Add Marketplace
Type to search plugins
-› [ ] Alpha Sync Disabled Space to enable; Enter view details.
- [-] Bravo Search Available · ChatGPT Marketplace · Search docs and tickets.
- [-] Hidden Repo Plugin Available · Repo Marketplace · Should not be shown in /plugins.
- [-] Starter Available · ChatGPT Marketplace · Included by default.
+› [ ] Alpha Sync Disabled Space to enable; Enter view details.
+ [-] Bravo Search Available · OpenAI Curated · Search docs and tickets.
+ [-] Hidden Repo Plugin Available · Repo Marketplace · Should not be shown in /plugi…
+ [-] Starter Available by default · OpenAI Curated · Included by default.
space enable/disable · ←/→ select marketplace · enter view details · esc close
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_newly_installed_marketplace.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_newly_installed_marketplace.snap
index 515b700925..803ff9fbe6 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_newly_installed_marketplace.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__plugins_popup_newly_installed_marketplace.snap
@@ -1,13 +1,13 @@
---
source: tui/src/chatwidget/tests/popups_and_settings.rs
-assertion_line: 339
expression: popup
---
Plugins
Debug Marketplace installed successfully.
Select the plugins you want to use and press Enter to install or view details.
- All Plugins Installed (0) OpenAI Curated [Debug Marketplace] Add Marketplace
+ All Plugins Installed (0) OpenAI Curated Workspace Shared with me [Debug Marketplace]
+ Add Marketplace
Type to search plugins
› [-] Debug Plugin Available Press Enter to install or view plugin details.
diff --git a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs
index 4c225b3318..281d97305e 100644
--- a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs
+++ b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs
@@ -7,6 +7,7 @@ use codex_app_server_protocol::HooksListEntry;
use codex_app_server_protocol::HooksListResponse;
use codex_app_server_protocol::MarketplaceRemoveResponse;
use codex_app_server_protocol::PluginAvailability;
+use codex_app_server_protocol::PluginShareContext;
use codex_features::Stage;
use pretty_assertions::assert_eq;
@@ -250,7 +251,7 @@ async fn plugins_popup_truncates_long_descriptions_in_list_rows() {
.expect("expected verbose plugin row in popup");
insta::assert_snapshot!(
verbose_row,
- @" [-] Verbose Plugin Available · ChatGPT Marketplace · This descri…"
+ @" [-] Verbose Plugin Available · OpenAI Curated · This description…"
);
assert!(
!popup
@@ -459,11 +460,20 @@ async fn marketplace_add_success_refreshes_to_new_marketplace_tab() {
chat.handle_key_event(KeyEvent::from(KeyCode::Esc));
chat.add_plugins_output();
- for _ in 0..3 {
- chat.handle_key_event(KeyEvent::from(KeyCode::Right));
- }
-
- let reopened_popup = render_bottom_popup(&chat, /*width*/ 100);
+ let reopened_popup = (0..8)
+ .find_map(|_| {
+ let popup = render_bottom_popup(&chat, /*width*/ 100);
+ if popup.contains("[Debug Marketplace]") {
+ Some(popup)
+ } else {
+ chat.handle_key_event(KeyEvent::from(KeyCode::Right));
+ None
+ }
+ })
+ .unwrap_or_else(|| {
+ let popup = render_bottom_popup(&chat, /*width*/ 100);
+ panic!("expected Debug Marketplace tab after reopening, got:\n{popup}");
+ });
assert!(
reopened_popup.contains("Installed 0 of 1 Debug Marketplace plugins.")
&& !reopened_popup.contains("installed successfully"),
@@ -584,10 +594,17 @@ async fn plugins_popup_removes_user_configured_marketplace_flow() {
}
#[tokio::test]
-async fn plugin_detail_popup_snapshot_shows_install_actions_and_capability_summaries() {
+async fn plugin_detail_popup_snapshot_labels_personal_marketplace_as_local() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
+ let marketplace_name = "personal-marketplace";
+ let personal_marketplace_path = AbsolutePathBuf::try_from(
+ dirs::home_dir()
+ .expect("home directory")
+ .join(".agents/plugins/marketplace.json"),
+ )
+ .expect("absolute personal marketplace path");
let summary = plugins_test_summary(
"plugin-figma",
"figma",
@@ -597,28 +614,29 @@ async fn plugin_detail_popup_snapshot_shows_install_actions_and_capability_summa
/*enabled*/ true,
PluginInstallPolicy::Available,
);
- let response = plugins_test_response(vec![plugins_test_curated_marketplace(vec![
- summary.clone(),
- ])]);
+ let response = plugins_test_response(vec![PluginMarketplaceEntry {
+ name: marketplace_name.to_string(),
+ path: Some(personal_marketplace_path.clone()),
+ interface: None,
+ plugins: vec![summary.clone()],
+ }]);
let cwd = chat.config.cwd.clone();
chat.on_plugins_loaded(cwd.to_path_buf(), Ok(response));
chat.add_plugins_output();
- chat.on_plugin_detail_loaded(
- cwd.to_path_buf(),
- Ok(PluginReadResponse {
- plugin: plugins_test_detail(
- summary,
- Some("Turn Figma files into implementation context."),
- &["design-review", "extract-copy"],
- &[
- (codex_app_server_protocol::HookEventName::PreToolUse, 1),
- (codex_app_server_protocol::HookEventName::Stop, 2),
- ],
- &["Figma", "Slack"],
- &["figma-mcp", "docs-mcp"],
- ),
- }),
+ let mut plugin = plugins_test_detail(
+ summary,
+ Some("Turn Figma files into implementation context."),
+ &["design-review", "extract-copy"],
+ &[
+ (codex_app_server_protocol::HookEventName::PreToolUse, 1),
+ (codex_app_server_protocol::HookEventName::Stop, 2),
+ ],
+ &["Figma", "Slack"],
+ &["figma-mcp", "docs-mcp"],
);
+ plugin.marketplace_name = marketplace_name.to_string();
+ plugin.marketplace_path = Some(personal_marketplace_path);
+ chat.on_plugin_detail_loaded(cwd.to_path_buf(), Ok(PluginReadResponse { plugin }));
let popup = render_bottom_popup(&chat, /*width*/ 100);
assert_chatwidget_snapshot!(
@@ -1022,6 +1040,222 @@ async fn plugins_popup_admin_disabled_installed_plugin_has_no_toggle_hint() {
assert_eq!(after, before);
}
+#[tokio::test]
+async fn plugins_popup_admin_disabled_available_plugin_has_view_only_hint() {
+ let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
+ chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
+
+ let summary = PluginSummary {
+ availability: PluginAvailability::DisabledByAdmin,
+ ..plugins_test_summary(
+ "plugin-admin-blocked",
+ "admin-blocked",
+ Some("Admin Blocked"),
+ Some("Blocked by policy."),
+ /*installed*/ false,
+ /*enabled*/ true,
+ PluginInstallPolicy::Available,
+ )
+ };
+ render_loaded_plugins_popup(
+ &mut chat,
+ plugins_test_response(vec![plugins_test_curated_marketplace(vec![summary])]),
+ );
+
+ let popup = render_bottom_popup(&chat, /*width*/ 100);
+ let admin_blocked_row = popup
+ .lines()
+ .find(|line| line.contains("Admin Blocked"))
+ .expect("expected admin-disabled plugin row");
+ assert!(
+ admin_blocked_row.contains("Press Enter to view plugin details.")
+ && !admin_blocked_row.contains("install or view"),
+ "expected admin-disabled available plugin to stay view-only, got:\n{admin_blocked_row}"
+ );
+}
+
+#[tokio::test]
+async fn plugins_popup_remote_section_fallback_states_snapshot() {
+ let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
+ chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
+
+ let select_tab_containing = |chat: &mut ChatWidget, visible_text: &str| -> String {
+ for _ in 0..8 {
+ let popup = render_bottom_popup(chat, /*width*/ 100);
+ if popup.contains(visible_text) {
+ return popup;
+ }
+ chat.handle_key_event(KeyEvent::from(KeyCode::Right));
+ }
+
+ let popup = render_bottom_popup(chat, /*width*/ 100);
+ panic!("expected plugins tab containing {visible_text:?}, got:\n{popup}");
+ };
+ let remote_section_state = |popup: &str| -> String {
+ let header = popup
+ .lines()
+ .map(str::trim)
+ .filter(|line| !line.is_empty())
+ .nth(1)
+ .expect("expected remote section header");
+ let item = popup
+ .lines()
+ .find_map(|line| line.trim_start().strip_prefix('›'))
+ .expect("expected selected remote section item")
+ .trim();
+ format!("{header}\n{item}")
+ };
+
+ chat.add_plugins_output();
+ let cwd = chat.config.cwd.clone();
+ chat.on_plugins_loaded(
+ cwd.to_path_buf(),
+ Ok(plugins_test_response(vec![
+ plugins_test_curated_marketplace(Vec::new()),
+ ])),
+ );
+ let curated_loading_popup =
+ select_tab_containing(&mut chat, "Loading OpenAI Curated plugins...");
+ let workspace_loading_popup = select_tab_containing(&mut chat, "Loading Workspace plugins.");
+
+ chat.on_plugin_remote_sections_loaded(cwd.to_path_buf(), Vec::new(), Vec::new());
+ let shared_empty_popup = select_tab_containing(&mut chat, "Shared with me.");
+
+ chat.on_plugin_remote_sections_loaded(
+ cwd.to_path_buf(),
+ Vec::new(),
+ vec![crate::app_event::PluginRemoteSectionError {
+ section_id: "workspace".to_string(),
+ label: "Workspace".to_string(),
+ message: "Sign in to ChatGPT to load workspace plugins.".to_string(),
+ }],
+ );
+ let workspace_error_popup = select_tab_containing(&mut chat, "Workspace unavailable.");
+
+ let (mut remote_chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
+ remote_chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
+ remote_chat.set_feature_enabled(Feature::RemotePlugin, /*enabled*/ true);
+ remote_chat.add_plugins_output();
+ let remote_cwd = remote_chat.config.cwd.clone();
+ remote_chat.on_plugins_loaded(
+ remote_cwd.to_path_buf(),
+ Ok(plugins_test_response(vec![
+ plugins_test_curated_marketplace(Vec::new()),
+ ])),
+ );
+ let remote_curated_empty_popup =
+ select_tab_containing(&mut remote_chat, "No OpenAI Curated plugins available");
+
+ insta::assert_snapshot!(
+ [
+ remote_section_state(&curated_loading_popup),
+ remote_section_state(&workspace_loading_popup),
+ remote_section_state(&shared_empty_popup),
+ remote_section_state(&workspace_error_popup),
+ remote_section_state(&remote_curated_empty_popup),
+ ]
+ .join("\n\n"),
+ @r###"
+ OpenAI Curated marketplace.
+ Loading OpenAI Curated plugins... This section updates when app-server returns it.
+
+ Loading Workspace plugins.
+ Loading Workspace plugins... This section updates when app-server returns it.
+
+ Shared with me.
+ No shared plugins available No plugins have been shared with you.
+
+ Workspace unavailable.
+ Workspace unavailable Sign in to ChatGPT to load workspace plugins.
+
+ OpenAI Curated marketplace.
+ No OpenAI Curated plugins available No OpenAI Curated plugins available.
+ "###
+ );
+}
+
+#[tokio::test]
+async fn plugins_popup_installed_remote_row_keeps_remote_detail_when_local_share_is_uninstalled() {
+ let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
+ chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
+
+ let remote_plugin_id = "plugins~Plugin_docs";
+ let remote_marketplace_name = "workspace-shared-with-me-private";
+ let local_summary = PluginSummary {
+ share_context: Some(PluginShareContext {
+ remote_plugin_id: remote_plugin_id.to_string(),
+ remote_version: None,
+ discoverability: None,
+ share_url: None,
+ creator_account_user_id: None,
+ creator_name: None,
+ share_principals: None,
+ }),
+ ..plugins_test_summary(
+ "plugin-docs",
+ "docs",
+ Some("Docs"),
+ Some("Local editable docs plugin."),
+ /*installed*/ false,
+ /*enabled*/ true,
+ PluginInstallPolicy::Available,
+ )
+ };
+ let popup = render_loaded_plugins_popup(
+ &mut chat,
+ plugins_test_response(vec![
+ plugins_test_curated_marketplace(vec![local_summary]),
+ PluginMarketplaceEntry {
+ name: remote_marketplace_name.to_string(),
+ path: None,
+ interface: Some(MarketplaceInterface {
+ display_name: Some("Shared with me".to_string()),
+ }),
+ plugins: vec![plugins_test_remote_summary(
+ remote_plugin_id,
+ "docs",
+ Some("Docs"),
+ Some("Shared docs plugin."),
+ /*installed*/ true,
+ )],
+ },
+ ]),
+ );
+ let all_plugins_row = popup
+ .lines()
+ .find(|line| line.contains("Docs"))
+ .expect("expected all-plugins row");
+ assert!(
+ popup.contains("Installed 1 of 1 available plugins.")
+ && all_plugins_row.contains("Installed")
+ && !all_plugins_row.contains("Available"),
+ "expected installed remote duplicate to win over local mapped share, got:\n{popup}"
+ );
+
+ while rx.try_recv().is_ok() {}
+ chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
+
+ match rx.try_recv() {
+ Ok(AppEvent::OpenPluginDetailLoading {
+ plugin_display_name,
+ }) => {
+ assert_eq!(plugin_display_name, "Docs");
+ }
+ other => panic!("expected OpenPluginDetailLoading event, got {other:?}"),
+ }
+ match rx.try_recv() {
+ Ok(AppEvent::FetchPluginDetail { params, .. }) => {
+ assert_eq!(params.marketplace_path, None);
+ assert_eq!(
+ params.remote_marketplace_name,
+ Some(remote_marketplace_name.to_string())
+ );
+ assert_eq!(params.plugin_name, remote_plugin_id);
+ }
+ other => panic!("expected FetchPluginDetail event, got {other:?}"),
+ }
+}
+
#[tokio::test]
async fn plugin_detail_error_popup_skips_disabled_row_numbering() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;