diff --git a/codex-rs/tui/src/chatwidget/plugins.rs b/codex-rs/tui/src/chatwidget/plugins.rs index 800280ed4c..7f0d98721e 100644 --- a/codex-rs/tui/src/chatwidget/plugins.rs +++ b/codex-rs/tui/src/chatwidget/plugins.rs @@ -1127,7 +1127,7 @@ fn sort_plugin_entries(entries: &mut [(&PluginMarketplaceEntry, &PluginSummary, } fn marketplace_tab_id(marketplace: &PluginMarketplaceEntry) -> String { - format!("marketplace:{}", marketplace.name) + format!("marketplace:{}", marketplace.path.display()) } fn disambiguate_duplicate_tab_labels(labels: Vec) -> Vec { 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 6396b5844a..218b7fb637 100644 --- a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs +++ b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs @@ -535,6 +535,66 @@ async fn plugins_popup_openai_curated_tab_omits_marketplace_in_rows() { ); } +#[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: 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: 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;