Remove TUI plugin marketplace surface
This commit is contained in:
parent
b8a7a52107
commit
e8c66f32a7
23 changed files with 15 additions and 2936 deletions
1405
vendor/codex/codex-rs/tui/src/chatwidget/plugins.rs
vendored
1405
vendor/codex/codex-rs/tui/src/chatwidget/plugins.rs
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -364,9 +364,6 @@ impl ChatWidget {
|
|||
SlashCommand::Apps => {
|
||||
self.add_connectors_output();
|
||||
}
|
||||
SlashCommand::Plugins => {
|
||||
self.add_plugins_output();
|
||||
}
|
||||
SlashCommand::Rollout => {
|
||||
if let Some(path) = self.rollout_path() {
|
||||
self.add_info_message(
|
||||
|
|
@ -702,7 +699,6 @@ impl ChatWidget {
|
|||
slash_commands::BuiltinCommandFlags {
|
||||
collaboration_modes_enabled: self.collaboration_modes_enabled(),
|
||||
connectors_enabled: self.connectors_enabled(),
|
||||
plugins_command_enabled: self.config.features.enabled(Feature::Plugins),
|
||||
fast_command_enabled: self.fast_mode_enabled(),
|
||||
personality_command_enabled: self.config.features.enabled(Feature::Personality),
|
||||
realtime_conversation_enabled: self.realtime_conversation_enabled(),
|
||||
|
|
@ -726,7 +722,6 @@ impl ChatWidget {
|
|||
| SlashCommand::MemoryUpdate
|
||||
| SlashCommand::Mcp
|
||||
| SlashCommand::Apps
|
||||
| SlashCommand::Plugins
|
||||
| SlashCommand::Rollout
|
||||
| SlashCommand::Copy
|
||||
| SlashCommand::Diff
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ pub(super) use codex_app_server_protocol::AddCreditsNudgeEmailStatus;
|
|||
pub(super) use codex_app_server_protocol::AdditionalFileSystemPermissions as AppServerAdditionalFileSystemPermissions;
|
||||
pub(super) use codex_app_server_protocol::AdditionalNetworkPermissions as AppServerAdditionalNetworkPermissions;
|
||||
pub(super) use codex_app_server_protocol::AdditionalPermissionProfile as AppServerAdditionalPermissionProfile;
|
||||
pub(super) use codex_app_server_protocol::AppSummary;
|
||||
pub(super) use codex_app_server_protocol::AutoReviewDecisionSource as AppServerGuardianApprovalReviewDecisionSource;
|
||||
pub(super) use codex_app_server_protocol::CollabAgentState as AppServerCollabAgentState;
|
||||
pub(super) use codex_app_server_protocol::CollabAgentStatus as AppServerCollabAgentStatus;
|
||||
|
|
@ -65,25 +64,14 @@ pub(super) use codex_app_server_protocol::ItemCompletedNotification;
|
|||
pub(super) use codex_app_server_protocol::ItemGuardianApprovalReviewCompletedNotification;
|
||||
pub(super) use codex_app_server_protocol::ItemGuardianApprovalReviewStartedNotification;
|
||||
pub(super) use codex_app_server_protocol::ItemStartedNotification;
|
||||
pub(super) use codex_app_server_protocol::MarketplaceInterface;
|
||||
pub(super) use codex_app_server_protocol::McpServerStartupState;
|
||||
pub(super) use codex_app_server_protocol::McpServerStatusDetail;
|
||||
pub(super) use codex_app_server_protocol::McpServerStatusUpdatedNotification;
|
||||
pub(super) use codex_app_server_protocol::PatchApplyStatus as AppServerPatchApplyStatus;
|
||||
pub(super) use codex_app_server_protocol::PatchChangeKind;
|
||||
pub(super) use codex_app_server_protocol::PermissionsRequestApprovalParams as AppServerPermissionsRequestApprovalParams;
|
||||
pub(super) use codex_app_server_protocol::PluginAuthPolicy;
|
||||
pub(super) use codex_app_server_protocol::PluginDetail;
|
||||
pub(super) use codex_app_server_protocol::PluginInstallPolicy;
|
||||
pub(super) use codex_app_server_protocol::PluginInterface;
|
||||
pub(super) use codex_app_server_protocol::PluginListResponse;
|
||||
pub(super) use codex_app_server_protocol::PluginMarketplaceEntry;
|
||||
pub(super) use codex_app_server_protocol::PluginReadResponse;
|
||||
pub(super) use codex_app_server_protocol::PluginSource;
|
||||
pub(super) use codex_app_server_protocol::PluginSummary;
|
||||
pub(super) use codex_app_server_protocol::ReasoningSummaryTextDeltaNotification;
|
||||
pub(super) use codex_app_server_protocol::ServerNotification;
|
||||
pub(super) use codex_app_server_protocol::SkillSummary;
|
||||
pub(super) use codex_app_server_protocol::ThreadClosedNotification;
|
||||
pub(super) use codex_app_server_protocol::ThreadItem as AppServerThreadItem;
|
||||
pub(super) use codex_app_server_protocol::Turn as AppServerTurn;
|
||||
|
|
@ -225,7 +213,6 @@ pub(super) use tokio::sync::mpsc::error::TryRecvError;
|
|||
pub(super) use tokio::sync::mpsc::unbounded_channel;
|
||||
pub(super) use toml::Value as TomlValue;
|
||||
|
||||
pub(super) const OPENAI_CURATED_MARKETPLACE_NAME: &str = "openai-curated";
|
||||
|
||||
pub(super) fn chatwidget_snapshot_dir() -> PathBuf {
|
||||
let snapshot_file = codex_utils_cargo_bin::find_resource!(
|
||||
|
|
|
|||
|
|
@ -237,13 +237,8 @@ pub(super) async fn make_chatwidget_manual(
|
|||
mcp_startup_pending_next_round_saw_starting: false,
|
||||
connectors_cache: ConnectorsCacheState::default(),
|
||||
connectors_partial_snapshot: None,
|
||||
plugin_install_apps_needing_auth: Vec::new(),
|
||||
plugin_install_auth_flow: None,
|
||||
plugins_active_tab_id: None,
|
||||
connectors_prefetch_in_flight: false,
|
||||
connectors_force_refetch_pending: false,
|
||||
plugins_cache: PluginsCacheState::default(),
|
||||
plugins_fetch_state: PluginListFetchState::default(),
|
||||
interrupts: InterruptManager::new(),
|
||||
reasoning_buffer: String::new(),
|
||||
full_reasoning_buffer: String::new(),
|
||||
|
|
@ -845,162 +840,6 @@ pub(super) fn strip_osc8_for_snapshot(text: &str) -> String {
|
|||
|
||||
stripped
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_absolute_path(path: &str) -> AbsolutePathBuf {
|
||||
std::env::temp_dir()
|
||||
.join("codex-plugin-menu-tests")
|
||||
.join(path)
|
||||
.abs()
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_interface(
|
||||
display_name: Option<&str>,
|
||||
short_description: Option<&str>,
|
||||
long_description: Option<&str>,
|
||||
) -> PluginInterface {
|
||||
PluginInterface {
|
||||
display_name: display_name.map(str::to_string),
|
||||
short_description: short_description.map(str::to_string),
|
||||
long_description: long_description.map(str::to_string),
|
||||
developer_name: None,
|
||||
category: None,
|
||||
capabilities: Vec::new(),
|
||||
website_url: None,
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
composer_icon_url: None,
|
||||
logo: None,
|
||||
logo_url: None,
|
||||
screenshots: Vec::new(),
|
||||
screenshot_urls: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_summary(
|
||||
id: &str,
|
||||
name: &str,
|
||||
display_name: Option<&str>,
|
||||
description: Option<&str>,
|
||||
installed: bool,
|
||||
enabled: bool,
|
||||
install_policy: PluginInstallPolicy,
|
||||
) -> PluginSummary {
|
||||
PluginSummary {
|
||||
id: id.to_string(),
|
||||
name: name.to_string(),
|
||||
source: PluginSource::Local {
|
||||
path: plugins_test_absolute_path(&format!("plugins/{name}")),
|
||||
},
|
||||
installed,
|
||||
enabled,
|
||||
install_policy,
|
||||
auth_policy: PluginAuthPolicy::OnInstall,
|
||||
interface: Some(plugins_test_interface(
|
||||
display_name,
|
||||
description,
|
||||
/*long_description*/ None,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_curated_marketplace(
|
||||
plugins: Vec<PluginSummary>,
|
||||
) -> PluginMarketplaceEntry {
|
||||
PluginMarketplaceEntry {
|
||||
name: OPENAI_CURATED_MARKETPLACE_NAME.to_string(),
|
||||
path: Some(plugins_test_absolute_path("marketplaces/chatgpt")),
|
||||
interface: Some(MarketplaceInterface {
|
||||
display_name: Some("ChatGPT Marketplace".to_string()),
|
||||
}),
|
||||
plugins,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_repo_marketplace(plugins: Vec<PluginSummary>) -> PluginMarketplaceEntry {
|
||||
PluginMarketplaceEntry {
|
||||
name: "repo".to_string(),
|
||||
path: Some(plugins_test_absolute_path("marketplaces/repo")),
|
||||
interface: Some(MarketplaceInterface {
|
||||
display_name: Some("Repo Marketplace".to_string()),
|
||||
}),
|
||||
plugins,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_response(
|
||||
marketplaces: Vec<PluginMarketplaceEntry>,
|
||||
) -> PluginListResponse {
|
||||
PluginListResponse {
|
||||
marketplaces,
|
||||
marketplace_load_errors: Vec::new(),
|
||||
featured_plugin_ids: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn render_loaded_plugins_popup(
|
||||
chat: &mut ChatWidget,
|
||||
response: PluginListResponse,
|
||||
) -> String {
|
||||
let cwd = chat.config.cwd.clone();
|
||||
chat.on_plugins_loaded(cwd.to_path_buf(), Ok(response));
|
||||
chat.add_plugins_output();
|
||||
render_bottom_popup(chat, /*width*/ 100)
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_detail(
|
||||
summary: PluginSummary,
|
||||
description: Option<&str>,
|
||||
skills: &[&str],
|
||||
apps: &[(&str, bool)],
|
||||
mcp_servers: &[&str],
|
||||
) -> PluginDetail {
|
||||
PluginDetail {
|
||||
marketplace_name: "ChatGPT Marketplace".to_string(),
|
||||
marketplace_path: Some(plugins_test_absolute_path("marketplaces/chatgpt")),
|
||||
summary,
|
||||
description: description.map(str::to_string),
|
||||
skills: skills
|
||||
.iter()
|
||||
.map(|name| SkillSummary {
|
||||
name: (*name).to_string(),
|
||||
description: format!("{name} description"),
|
||||
short_description: None,
|
||||
interface: None,
|
||||
path: Some(plugins_test_absolute_path(&format!(
|
||||
"skills/{name}/SKILL.md"
|
||||
))),
|
||||
enabled: true,
|
||||
})
|
||||
.collect(),
|
||||
apps: apps
|
||||
.iter()
|
||||
.map(|(name, needs_auth)| AppSummary {
|
||||
id: format!("{name}-id"),
|
||||
name: (*name).to_string(),
|
||||
description: Some(format!("{name} app")),
|
||||
install_url: Some(format!("https://example.test/{name}")),
|
||||
needs_auth: *needs_auth,
|
||||
})
|
||||
.collect(),
|
||||
mcp_servers: mcp_servers.iter().map(|name| (*name).to_string()).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn plugins_test_popup_row_position(popup: &str, needle: &str) -> usize {
|
||||
popup
|
||||
.find(needle)
|
||||
.unwrap_or_else(|| panic!("expected popup to contain {needle}: {popup}"))
|
||||
}
|
||||
|
||||
pub(super) fn type_plugins_search_query(chat: &mut ChatWidget, query: &str) {
|
||||
for ch in query.chars() {
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Char(ch)));
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn assert_hook_events_snapshot(
|
||||
event_name: codex_protocol::protocol::HookEventName,
|
||||
run_id: &str,
|
||||
|
|
|
|||
|
|
@ -86,721 +86,6 @@ async fn experimental_mode_plan_is_ignored_on_startup() {
|
|||
assert_eq!(chat.current_model(), resolved_model);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_loading_state_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
chat.add_plugins_output();
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
popup.contains("Loading available plugins..."),
|
||||
"expected /plugins to open in a loading state before the marketplace arrives, got:\n{popup}"
|
||||
);
|
||||
assert_chatwidget_snapshot!("plugins_popup_loading_state", popup);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_snapshot_shows_all_marketplaces_and_sorts_installed_then_name() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let response = plugins_test_response(vec![
|
||||
plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-bravo",
|
||||
"bravo",
|
||||
Some("Bravo Search"),
|
||||
Some("Search docs and tickets."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-alpha",
|
||||
"alpha",
|
||||
Some("Alpha Sync"),
|
||||
Some("Already installed but disabled."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ false,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-starter",
|
||||
"starter",
|
||||
Some("Starter"),
|
||||
Some("Included by default."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::InstalledByDefault,
|
||||
),
|
||||
]),
|
||||
plugins_test_repo_marketplace(vec![plugins_test_summary(
|
||||
"plugin-hidden",
|
||||
"hidden",
|
||||
Some("Hidden Repo Plugin"),
|
||||
Some("Should not be shown in /plugins."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
)]),
|
||||
]);
|
||||
let popup = render_loaded_plugins_popup(&mut chat, response);
|
||||
assert_chatwidget_snapshot!("plugins_popup_curated_marketplace", popup);
|
||||
assert!(
|
||||
popup.contains("Hidden Repo Plugin"),
|
||||
"expected /plugins to include non-curated marketplaces, got:\n{popup}"
|
||||
);
|
||||
assert!(
|
||||
plugins_test_popup_row_position(&popup, "Alpha Sync")
|
||||
< plugins_test_popup_row_position(&popup, "Bravo Search")
|
||||
&& plugins_test_popup_row_position(&popup, "Bravo Search")
|
||||
< 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 sort installed plugins first, then alphabetically, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugin_detail_popup_snapshot_shows_install_actions_and_capability_summaries() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let summary = plugins_test_summary(
|
||||
"plugin-figma",
|
||||
"figma",
|
||||
Some("Figma"),
|
||||
Some("Design handoff."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
);
|
||||
let response = plugins_test_response(vec![plugins_test_curated_marketplace(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"],
|
||||
&[("Figma", true), ("Slack", false)],
|
||||
&["figma-mcp", "docs-mcp"],
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert_chatwidget_snapshot!(
|
||||
"plugin_detail_popup_installable",
|
||||
strip_osc8_for_snapshot(&popup)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugin_detail_popup_hides_disclosure_for_installed_plugins() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let summary = plugins_test_summary(
|
||||
"plugin-figma",
|
||||
"figma",
|
||||
Some("Figma"),
|
||||
Some("Design handoff."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
);
|
||||
let response = plugins_test_response(vec![plugins_test_curated_marketplace(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"],
|
||||
&[("Figma", true), ("Slack", false)],
|
||||
&["figma-mcp", "docs-mcp"],
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
!popup.contains("Data shared with this app is subject to the app's"),
|
||||
"expected installed plugin details to hide the disclosure line, got:\n{popup}"
|
||||
);
|
||||
assert_chatwidget_snapshot!(
|
||||
"plugin_detail_popup_installed",
|
||||
strip_osc8_for_snapshot(&popup)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_refresh_preserves_selected_row_position() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let initial = plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-notion",
|
||||
"notion",
|
||||
Some("Notion"),
|
||||
Some("Workspace docs."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-slack",
|
||||
"slack",
|
||||
Some("Slack"),
|
||||
Some("Team chat."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]);
|
||||
render_loaded_plugins_popup(&mut chat, initial);
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Down));
|
||||
|
||||
let before = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
before.contains("› [-] Slack"),
|
||||
"expected Slack to be selected before refresh, got:\n{before}"
|
||||
);
|
||||
|
||||
let refreshed = plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-airtable",
|
||||
"airtable",
|
||||
Some("Airtable"),
|
||||
Some("Structured records."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-notion",
|
||||
"notion",
|
||||
Some("Notion"),
|
||||
Some("Workspace docs."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-slack",
|
||||
"slack",
|
||||
Some("Slack"),
|
||||
Some("Team chat."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]);
|
||||
let cwd = chat.config.cwd.clone();
|
||||
chat.on_plugins_loaded(cwd.to_path_buf(), Ok(refreshed));
|
||||
|
||||
let after = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
after.contains("› [-] Notion"),
|
||||
"expected refresh to preserve the selected row position, got:\n{after}"
|
||||
);
|
||||
assert!(
|
||||
after.contains("Airtable"),
|
||||
"expected refreshed popup to include the updated plugin list, got:\n{after}"
|
||||
);
|
||||
assert!(
|
||||
after.contains("Slack"),
|
||||
"expected refreshed popup to include the updated plugin list, got:\n{after}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_refreshes_installed_counts_after_install() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let initial = plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-drive",
|
||||
"drive",
|
||||
Some("Drive"),
|
||||
Some("Document access."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]);
|
||||
let before = render_loaded_plugins_popup(&mut chat, initial);
|
||||
assert!(
|
||||
before.contains("Installed 1 of 2 available plugins."),
|
||||
"expected initial installed count before refresh, got:\n{before}"
|
||||
);
|
||||
assert!(
|
||||
before.contains("Available"),
|
||||
"expected pre-install popup copy before refresh, got:\n{before}"
|
||||
);
|
||||
|
||||
let refreshed = plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-drive",
|
||||
"drive",
|
||||
Some("Drive"),
|
||||
Some("Document access."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]);
|
||||
let cwd = chat.config.cwd.clone();
|
||||
chat.on_plugins_loaded(cwd.to_path_buf(), Ok(refreshed));
|
||||
|
||||
let after = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
after.contains("Installed 2 of 2 available plugins."),
|
||||
"expected /plugins to refresh installed counts after install, got:\n{after}"
|
||||
);
|
||||
assert!(
|
||||
after.contains("Installed Space to disable; Enter view details."),
|
||||
"expected refreshed selected row copy to reflect the installed plugin state, got:\n{after}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_space_toggles_installed_plugin_from_list() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let cwd = chat.config.cwd.to_path_buf();
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-drive",
|
||||
"drive",
|
||||
Some("Drive"),
|
||||
Some("Document access."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]),
|
||||
);
|
||||
|
||||
while rx.try_recv().is_ok() {}
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Down));
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
|
||||
|
||||
match rx.try_recv() {
|
||||
Ok(AppEvent::SetPluginEnabled {
|
||||
cwd: event_cwd,
|
||||
plugin_id,
|
||||
enabled,
|
||||
}) => {
|
||||
assert_eq!(event_cwd, cwd);
|
||||
assert_eq!(plugin_id, "plugin-drive");
|
||||
assert!(!enabled);
|
||||
}
|
||||
other => panic!("expected SetPluginEnabled event, got {other:?}"),
|
||||
}
|
||||
|
||||
chat.on_plugin_enabled_set(
|
||||
cwd,
|
||||
"plugin-drive".to_string(),
|
||||
/*enabled*/ false,
|
||||
Ok(()),
|
||||
);
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
popup.contains("› [ ] Drive"),
|
||||
"expected selected plugin row to stay selected after refresh, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_space_on_uninstalled_row_does_not_start_search() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-drive",
|
||||
"drive",
|
||||
Some("Drive"),
|
||||
Some("Document access."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]),
|
||||
);
|
||||
|
||||
while rx.try_recv().is_ok() {}
|
||||
let before = render_bottom_popup(&chat, /*width*/ 100);
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
|
||||
let after = render_bottom_popup(&chat, /*width*/ 100);
|
||||
|
||||
assert!(
|
||||
rx.try_recv().is_err(),
|
||||
"did not expect Space on an uninstalled plugin to emit an event"
|
||||
);
|
||||
assert_eq!(after, before);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_space_with_active_search_does_not_toggle_installed_plugin() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-drive",
|
||||
"drive",
|
||||
Some("Drive"),
|
||||
Some("Document access."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]),
|
||||
);
|
||||
|
||||
while rx.try_recv().is_ok() {}
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Down));
|
||||
type_plugins_search_query(&mut chat, "dr");
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE));
|
||||
|
||||
assert!(
|
||||
rx.try_recv().is_err(),
|
||||
"did not expect Space with an active plugin search to emit a toggle event"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_search_filters_visible_rows_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-slack",
|
||||
"slack",
|
||||
Some("Slack"),
|
||||
Some("Team chat."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-drive",
|
||||
"drive",
|
||||
Some("Drive"),
|
||||
Some("Document access."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]),
|
||||
);
|
||||
|
||||
type_plugins_search_query(&mut chat, "sla");
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert_chatwidget_snapshot!("plugins_popup_search_filtered", popup);
|
||||
assert!(
|
||||
!popup.contains("Calendar") && !popup.contains("Drive"),
|
||||
"expected search to leave only matching rows visible, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_installed_tab_filters_rows_and_clears_search() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ true,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-slack",
|
||||
"slack",
|
||||
Some("Slack"),
|
||||
Some("Team chat."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]),
|
||||
);
|
||||
|
||||
type_plugins_search_query(&mut chat, "sla");
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Right));
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
popup.contains("Installed plugins.") && popup.contains("Showing 1 installed plugins."),
|
||||
"expected Installed tab header, got:\n{popup}"
|
||||
);
|
||||
assert!(
|
||||
popup.contains("Calendar") && !popup.contains("Slack"),
|
||||
"expected Installed tab to show only installed plugins, got:\n{popup}"
|
||||
);
|
||||
assert!(
|
||||
!popup.contains("sla"),
|
||||
"expected tab switch to clear search query, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_openai_curated_tab_omits_marketplace_in_rows() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![
|
||||
plugins_test_curated_marketplace(vec![plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
)]),
|
||||
plugins_test_repo_marketplace(vec![plugins_test_summary(
|
||||
"plugin-repo",
|
||||
"repo",
|
||||
Some("Repo Plugin"),
|
||||
Some("Repo-only plugin."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
)]),
|
||||
]),
|
||||
);
|
||||
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Right));
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Right));
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
popup.contains("OpenAI Curated marketplace."),
|
||||
"expected OpenAI Curated tab header, got:\n{popup}"
|
||||
);
|
||||
assert!(
|
||||
popup.contains("Calendar") && !popup.contains("Repo Plugin"),
|
||||
"expected OpenAI Curated tab to show only official marketplace plugins, got:\n{popup}"
|
||||
);
|
||||
assert!(
|
||||
!popup.contains("ChatGPT Marketplace ·"),
|
||||
"expected marketplace-specific rows to omit marketplace labels, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_refresh_preserves_duplicate_marketplace_tab_by_path() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
let response = plugins_test_response(vec![
|
||||
PluginMarketplaceEntry {
|
||||
name: "duplicate".to_string(),
|
||||
path: Some(plugins_test_absolute_path(
|
||||
"marketplaces/home/marketplace.json",
|
||||
)),
|
||||
interface: Some(MarketplaceInterface {
|
||||
display_name: Some("Duplicate Marketplace".to_string()),
|
||||
}),
|
||||
plugins: vec![plugins_test_summary(
|
||||
"plugin-home",
|
||||
"home",
|
||||
Some("Home Plugin"),
|
||||
Some("Home marketplace plugin."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
)],
|
||||
},
|
||||
PluginMarketplaceEntry {
|
||||
name: "duplicate".to_string(),
|
||||
path: Some(plugins_test_absolute_path(
|
||||
"marketplaces/repo/marketplace.json",
|
||||
)),
|
||||
interface: Some(MarketplaceInterface {
|
||||
display_name: Some("Duplicate Marketplace".to_string()),
|
||||
}),
|
||||
plugins: vec![plugins_test_summary(
|
||||
"plugin-repo",
|
||||
"repo",
|
||||
Some("Repo Plugin"),
|
||||
Some("Repo marketplace plugin."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
)],
|
||||
},
|
||||
]);
|
||||
let cwd = chat.config.cwd.to_path_buf();
|
||||
chat.on_plugins_loaded(cwd.clone(), Ok(response.clone()));
|
||||
chat.add_plugins_output();
|
||||
|
||||
for _ in 0..4 {
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Right));
|
||||
}
|
||||
|
||||
chat.on_plugins_loaded(cwd, Ok(response));
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
popup.contains("Duplicate Marketplace (2/2)."),
|
||||
"expected refresh to preserve the second duplicate marketplace tab, got:\n{popup}"
|
||||
);
|
||||
assert!(
|
||||
popup.contains("Repo Plugin") && !popup.contains("Home Plugin"),
|
||||
"expected second duplicate marketplace rows after refresh, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugins_popup_search_no_matches_and_backspace_restores_results() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_feature_enabled(Feature::Plugins, /*enabled*/ true);
|
||||
|
||||
render_loaded_plugins_popup(
|
||||
&mut chat,
|
||||
plugins_test_response(vec![plugins_test_curated_marketplace(vec![
|
||||
plugins_test_summary(
|
||||
"plugin-calendar",
|
||||
"calendar",
|
||||
Some("Calendar"),
|
||||
Some("Schedule management."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
plugins_test_summary(
|
||||
"plugin-slack",
|
||||
"slack",
|
||||
Some("Slack"),
|
||||
Some("Team chat."),
|
||||
/*installed*/ false,
|
||||
/*enabled*/ true,
|
||||
PluginInstallPolicy::Available,
|
||||
),
|
||||
])]),
|
||||
);
|
||||
|
||||
type_plugins_search_query(&mut chat, "zzz");
|
||||
|
||||
let no_matches = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
no_matches.contains("zzz"),
|
||||
"expected popup to show the typed search query, got:\n{no_matches}"
|
||||
);
|
||||
assert!(
|
||||
no_matches.contains("no matches"),
|
||||
"expected popup to render the no-matches UX, got:\n{no_matches}"
|
||||
);
|
||||
|
||||
for _ in 0..3 {
|
||||
chat.handle_key_event(KeyEvent::from(KeyCode::Backspace));
|
||||
}
|
||||
|
||||
let restored = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert!(
|
||||
restored.contains("Calendar") && restored.contains("Slack"),
|
||||
"expected clearing the query to restore the plugin rows, got:\n{restored}"
|
||||
);
|
||||
assert!(
|
||||
!restored.contains("no matches"),
|
||||
"did not expect the no-matches state after clearing the query, got:\n{restored}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn apps_popup_stays_loading_until_final_snapshot_updates() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
|
|
|||
Reference in a new issue