mirror of
https://github.com/openai/codex.git
synced 2026-11-24 07:20:27 +00:00
[Codex TUI] - Sort /plugins TUI menu by installed status first, alpha second (#15558)
Updates plugin ordering so installed plugins are listed first, with alphabetical sorting applied within the installed and uninstalled groups. The behavior is now consistent across both `tui` and `tui_app_server`, and related tests/snapshots were updated.
This commit is contained in:
1 parent
68baac7cf4
commit
2d5a3bfe76
6 files changed
+144
-100
No files matched your search
@@ -649,44 +649,66 @@ impl ChatWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut items: Vec<SelectionItem> = Vec::new();
|
let mut plugin_entries: Vec<(&PluginMarketplaceEntry, &PluginSummary, String)> =
|
||||||
for marketplace in marketplaces {
|
marketplaces
|
||||||
let marketplace_label = marketplace_display_name(marketplace);
|
.iter()
|
||||||
for plugin in &marketplace.plugins {
|
.flat_map(|marketplace| {
|
||||||
let display_name = plugin_display_name(plugin);
|
marketplace
|
||||||
let status_label = plugin_status_label(plugin);
|
.plugins
|
||||||
let description = plugin_brief_description(plugin, &marketplace_label);
|
.iter()
|
||||||
let selected_description =
|
.map(move |plugin| (*marketplace, plugin, plugin_display_name(plugin)))
|
||||||
format!("{status_label}. Press Enter to view plugin details.");
|
})
|
||||||
let search_value = format!(
|
.collect();
|
||||||
"{display_name} {} {} {}",
|
plugin_entries.sort_by(|left, right| {
|
||||||
plugin.id, plugin.name, marketplace_label
|
right
|
||||||
);
|
.1
|
||||||
let cwd = self.config.cwd.clone();
|
.installed
|
||||||
let plugin_display_name = display_name.clone();
|
.cmp(&left.1.installed)
|
||||||
let marketplace_path = marketplace.path.clone();
|
.then_with(|| {
|
||||||
let plugin_name = plugin.name.clone();
|
left.2
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.cmp(&right.2.to_ascii_lowercase())
|
||||||
|
})
|
||||||
|
.then_with(|| left.2.cmp(&right.2))
|
||||||
|
.then_with(|| left.1.name.cmp(&right.1.name))
|
||||||
|
.then_with(|| left.1.id.cmp(&right.1.id))
|
||||||
|
});
|
||||||
|
|
||||||
items.push(SelectionItem {
|
let mut items: Vec<SelectionItem> = Vec::new();
|
||||||
name: format!("{display_name} · {marketplace_label}"),
|
for (marketplace, plugin, display_name) in plugin_entries {
|
||||||
description: Some(description),
|
let marketplace_label = marketplace_display_name(marketplace);
|
||||||
selected_description: Some(selected_description),
|
let status_label = plugin_status_label(plugin);
|
||||||
search_value: Some(search_value),
|
let description = plugin_brief_description(plugin, &marketplace_label);
|
||||||
actions: vec![Box::new(move |tx| {
|
let selected_description =
|
||||||
tx.send(AppEvent::OpenPluginDetailLoading {
|
format!("{status_label}. Press Enter to view plugin details.");
|
||||||
plugin_display_name: plugin_display_name.clone(),
|
let search_value = format!(
|
||||||
});
|
"{display_name} {} {} {}",
|
||||||
tx.send(AppEvent::FetchPluginDetail {
|
plugin.id, plugin.name, marketplace_label
|
||||||
cwd: cwd.clone(),
|
);
|
||||||
params: codex_app_server_protocol::PluginReadParams {
|
let cwd = self.config.cwd.clone();
|
||||||
marketplace_path: marketplace_path.clone(),
|
let plugin_display_name = display_name.clone();
|
||||||
plugin_name: plugin_name.clone(),
|
let marketplace_path = marketplace.path.clone();
|
||||||
},
|
let plugin_name = plugin.name.clone();
|
||||||
});
|
|
||||||
})],
|
items.push(SelectionItem {
|
||||||
..Default::default()
|
name: format!("{display_name} · {marketplace_label}"),
|
||||||
});
|
description: Some(description),
|
||||||
}
|
selected_description: Some(selected_description),
|
||||||
|
search_value: Some(search_value),
|
||||||
|
actions: vec![Box::new(move |tx| {
|
||||||
|
tx.send(AppEvent::OpenPluginDetailLoading {
|
||||||
|
plugin_display_name: plugin_display_name.clone(),
|
||||||
|
});
|
||||||
|
tx.send(AppEvent::FetchPluginDetail {
|
||||||
|
cwd: cwd.clone(),
|
||||||
|
params: codex_app_server_protocol::PluginReadParams {
|
||||||
|
marketplace_path: marketplace_path.clone(),
|
||||||
|
plugin_name: plugin_name.clone(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})],
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if items.is_empty() {
|
if items.is_empty() {
|
||||||
|
|||||||
+5
-5
@@ -9,12 +9,12 @@ expression: popup
|
|||||||
Using cached marketplace data: remote sync timed out
|
Using cached marketplace data: remote sync timed out
|
||||||
|
|
||||||
Type to search plugins
|
Type to search plugins
|
||||||
› Bravo Search · ChatGPT Marketplace Can be installed. Press Enter to view plugin details.
|
› Alpha Sync · ChatGPT Marketplace Installed · Disabled. Press Enter to view plugin details.
|
||||||
Alpha Sync · ChatGPT Marketplace Installed · Disabled · ChatGPT Marketplace · Already
|
Bravo Search · ChatGPT Marketplace Can be installed · ChatGPT Marketplace · Search docs and
|
||||||
installed but disabled.
|
tickets.
|
||||||
Starter · ChatGPT Marketplace Available by default · ChatGPT Marketplace · Included by
|
|
||||||
default.
|
|
||||||
Hidden Repo Plugin · Repo Marketplace Can be installed · Repo Marketplace · Should not be shown
|
Hidden Repo Plugin · Repo Marketplace Can be installed · Repo Marketplace · Should not be shown
|
||||||
in /plugins.
|
in /plugins.
|
||||||
|
Starter · ChatGPT Marketplace Available by default · ChatGPT Marketplace · Included by
|
||||||
|
default.
|
||||||
|
|
||||||
Press esc to close.
|
Press esc to close.
|
||||||
@@ -7239,7 +7239,7 @@ async fn plugins_popup_loading_state_snapshot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn plugins_popup_snapshot_shows_all_marketplaces_and_preserves_response_order() {
|
async fn plugins_popup_snapshot_shows_all_marketplaces_and_sorts_installed_then_name() {
|
||||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
||||||
chat.set_feature_enabled(Feature::Plugins, true);
|
chat.set_feature_enabled(Feature::Plugins, true);
|
||||||
|
|
||||||
@@ -7292,13 +7292,13 @@ async fn plugins_popup_snapshot_shows_all_marketplaces_and_preserves_response_or
|
|||||||
"expected /plugins to include non-curated marketplaces, got:\n{popup}"
|
"expected /plugins to include non-curated marketplaces, got:\n{popup}"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
plugins_test_popup_row_position(&popup, "Bravo Search")
|
plugins_test_popup_row_position(&popup, "Alpha Sync")
|
||||||
< plugins_test_popup_row_position(&popup, "Alpha Sync")
|
< plugins_test_popup_row_position(&popup, "Bravo Search")
|
||||||
&& plugins_test_popup_row_position(&popup, "Alpha Sync")
|
&& plugins_test_popup_row_position(&popup, "Bravo Search")
|
||||||
< plugins_test_popup_row_position(&popup, "Starter")
|
< plugins_test_popup_row_position(&popup, "Hidden Repo Plugin")
|
||||||
&& plugins_test_popup_row_position(&popup, "Starter")
|
&& plugins_test_popup_row_position(&popup, "Hidden Repo Plugin")
|
||||||
< plugins_test_popup_row_position(&popup, "Hidden Repo Plugin"),
|
< plugins_test_popup_row_position(&popup, "Starter"),
|
||||||
"expected /plugins rows to keep response order, got:\n{popup}"
|
"expected /plugins rows to sort installed plugins first, then alphabetically, got:\n{popup}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -649,44 +649,66 @@ impl ChatWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut items: Vec<SelectionItem> = Vec::new();
|
let mut plugin_entries: Vec<(&PluginMarketplaceEntry, &PluginSummary, String)> =
|
||||||
for marketplace in marketplaces {
|
marketplaces
|
||||||
let marketplace_label = marketplace_display_name(marketplace);
|
.iter()
|
||||||
for plugin in &marketplace.plugins {
|
.flat_map(|marketplace| {
|
||||||
let display_name = plugin_display_name(plugin);
|
marketplace
|
||||||
let status_label = plugin_status_label(plugin);
|
.plugins
|
||||||
let description = plugin_brief_description(plugin, &marketplace_label);
|
.iter()
|
||||||
let selected_description =
|
.map(move |plugin| (*marketplace, plugin, plugin_display_name(plugin)))
|
||||||
format!("{status_label}. Press Enter to view plugin details.");
|
})
|
||||||
let search_value = format!(
|
.collect();
|
||||||
"{display_name} {} {} {}",
|
plugin_entries.sort_by(|left, right| {
|
||||||
plugin.id, plugin.name, marketplace_label
|
right
|
||||||
);
|
.1
|
||||||
let cwd = self.config.cwd.clone();
|
.installed
|
||||||
let plugin_display_name = display_name.clone();
|
.cmp(&left.1.installed)
|
||||||
let marketplace_path = marketplace.path.clone();
|
.then_with(|| {
|
||||||
let plugin_name = plugin.name.clone();
|
left.2
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.cmp(&right.2.to_ascii_lowercase())
|
||||||
|
})
|
||||||
|
.then_with(|| left.2.cmp(&right.2))
|
||||||
|
.then_with(|| left.1.name.cmp(&right.1.name))
|
||||||
|
.then_with(|| left.1.id.cmp(&right.1.id))
|
||||||
|
});
|
||||||
|
|
||||||
items.push(SelectionItem {
|
let mut items: Vec<SelectionItem> = Vec::new();
|
||||||
name: format!("{display_name} · {marketplace_label}"),
|
for (marketplace, plugin, display_name) in plugin_entries {
|
||||||
description: Some(description),
|
let marketplace_label = marketplace_display_name(marketplace);
|
||||||
selected_description: Some(selected_description),
|
let status_label = plugin_status_label(plugin);
|
||||||
search_value: Some(search_value),
|
let description = plugin_brief_description(plugin, &marketplace_label);
|
||||||
actions: vec![Box::new(move |tx| {
|
let selected_description =
|
||||||
tx.send(AppEvent::OpenPluginDetailLoading {
|
format!("{status_label}. Press Enter to view plugin details.");
|
||||||
plugin_display_name: plugin_display_name.clone(),
|
let search_value = format!(
|
||||||
});
|
"{display_name} {} {} {}",
|
||||||
tx.send(AppEvent::FetchPluginDetail {
|
plugin.id, plugin.name, marketplace_label
|
||||||
cwd: cwd.clone(),
|
);
|
||||||
params: codex_app_server_protocol::PluginReadParams {
|
let cwd = self.config.cwd.clone();
|
||||||
marketplace_path: marketplace_path.clone(),
|
let plugin_display_name = display_name.clone();
|
||||||
plugin_name: plugin_name.clone(),
|
let marketplace_path = marketplace.path.clone();
|
||||||
},
|
let plugin_name = plugin.name.clone();
|
||||||
});
|
|
||||||
})],
|
items.push(SelectionItem {
|
||||||
..Default::default()
|
name: format!("{display_name} · {marketplace_label}"),
|
||||||
});
|
description: Some(description),
|
||||||
}
|
selected_description: Some(selected_description),
|
||||||
|
search_value: Some(search_value),
|
||||||
|
actions: vec![Box::new(move |tx| {
|
||||||
|
tx.send(AppEvent::OpenPluginDetailLoading {
|
||||||
|
plugin_display_name: plugin_display_name.clone(),
|
||||||
|
});
|
||||||
|
tx.send(AppEvent::FetchPluginDetail {
|
||||||
|
cwd: cwd.clone(),
|
||||||
|
params: codex_app_server_protocol::PluginReadParams {
|
||||||
|
marketplace_path: marketplace_path.clone(),
|
||||||
|
plugin_name: plugin_name.clone(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})],
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if items.is_empty() {
|
if items.is_empty() {
|
||||||
|
|||||||
+5
-5
@@ -8,12 +8,12 @@ expression: popup
|
|||||||
Using cached marketplace data: remote sync timed out
|
Using cached marketplace data: remote sync timed out
|
||||||
|
|
||||||
Type to search plugins
|
Type to search plugins
|
||||||
› Bravo Search · ChatGPT Marketplace Can be installed. Press Enter to view plugin details.
|
› Alpha Sync · ChatGPT Marketplace Installed · Disabled. Press Enter to view plugin details.
|
||||||
Alpha Sync · ChatGPT Marketplace Installed · Disabled · ChatGPT Marketplace · Already
|
Bravo Search · ChatGPT Marketplace Can be installed · ChatGPT Marketplace · Search docs and
|
||||||
installed but disabled.
|
tickets.
|
||||||
Starter · ChatGPT Marketplace Available by default · ChatGPT Marketplace · Included by
|
|
||||||
default.
|
|
||||||
Hidden Repo Plugin · Repo Marketplace Can be installed · Repo Marketplace · Should not be shown
|
Hidden Repo Plugin · Repo Marketplace Can be installed · Repo Marketplace · Should not be shown
|
||||||
in /plugins.
|
in /plugins.
|
||||||
|
Starter · ChatGPT Marketplace Available by default · ChatGPT Marketplace · Included by
|
||||||
|
default.
|
||||||
|
|
||||||
Press esc to close.
|
Press esc to close.
|
||||||
@@ -7836,7 +7836,7 @@ async fn plugins_popup_loading_state_snapshot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn plugins_popup_snapshot_shows_all_marketplaces_and_preserves_response_order() {
|
async fn plugins_popup_snapshot_shows_all_marketplaces_and_sorts_installed_then_name() {
|
||||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
||||||
chat.set_feature_enabled(Feature::Plugins, true);
|
chat.set_feature_enabled(Feature::Plugins, true);
|
||||||
|
|
||||||
@@ -7889,13 +7889,13 @@ async fn plugins_popup_snapshot_shows_all_marketplaces_and_preserves_response_or
|
|||||||
"expected /plugins to include non-curated marketplaces, got:\n{popup}"
|
"expected /plugins to include non-curated marketplaces, got:\n{popup}"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
plugins_test_popup_row_position(&popup, "Bravo Search")
|
plugins_test_popup_row_position(&popup, "Alpha Sync")
|
||||||
< plugins_test_popup_row_position(&popup, "Alpha Sync")
|
< plugins_test_popup_row_position(&popup, "Bravo Search")
|
||||||
&& plugins_test_popup_row_position(&popup, "Alpha Sync")
|
&& plugins_test_popup_row_position(&popup, "Bravo Search")
|
||||||
< plugins_test_popup_row_position(&popup, "Starter")
|
< plugins_test_popup_row_position(&popup, "Hidden Repo Plugin")
|
||||||
&& plugins_test_popup_row_position(&popup, "Starter")
|
&& plugins_test_popup_row_position(&popup, "Hidden Repo Plugin")
|
||||||
< plugins_test_popup_row_position(&popup, "Hidden Repo Plugin"),
|
< plugins_test_popup_row_position(&popup, "Starter"),
|
||||||
"expected /plugins rows to keep response order, got:\n{popup}"
|
"expected /plugins rows to sort installed plugins first, then alphabetically, got:\n{popup}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user