mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
Show marketplace add errors in TUI popup
This commit is contained in:
@@ -451,15 +451,15 @@ impl ChatWidget {
|
||||
)),
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
Err(err) => {
|
||||
self.plugins_active_tab_id = Some(ADD_MARKETPLACE_TAB_ID.to_string());
|
||||
let params = self.marketplace_add_error_popup_params();
|
||||
let params = self.marketplace_add_error_popup_params(&err);
|
||||
if !self
|
||||
.bottom_pane
|
||||
.replace_selection_view_if_active(PLUGINS_SELECTION_VIEW_ID, params)
|
||||
{
|
||||
self.bottom_pane
|
||||
.show_selection_view(self.marketplace_add_error_popup_params());
|
||||
.show_selection_view(self.marketplace_add_error_popup_params(&err));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -863,7 +863,7 @@ impl ChatWidget {
|
||||
}
|
||||
}
|
||||
|
||||
fn marketplace_add_error_popup_params(&self) -> SelectionViewParams {
|
||||
fn marketplace_add_error_popup_params(&self, err: &str) -> SelectionViewParams {
|
||||
let mut header = ColumnRenderable::new();
|
||||
header.push(Line::from("Plugins".bold()));
|
||||
header.push(Line::from("Failed to add marketplace.".dim()));
|
||||
@@ -871,9 +871,7 @@ impl ChatWidget {
|
||||
let mut items = vec![
|
||||
SelectionItem {
|
||||
name: "Marketplace add failed".to_string(),
|
||||
description: Some(
|
||||
"Failed to add marketplace from the provided source.".to_string(),
|
||||
),
|
||||
description: Some(err.to_string()),
|
||||
is_disabled: true,
|
||||
..Default::default()
|
||||
},
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/popups_and_settings.rs
|
||||
expression: popup
|
||||
---
|
||||
Plugins
|
||||
Failed to add marketplace.
|
||||
|
||||
Marketplace add failed Failed to add marketplace: invalid marketplace source format;
|
||||
expected owner/repo, a git URL, or a local marketplace path
|
||||
› 1. Try again Enter a marketplace source.
|
||||
2. Back to plugins Return to the plugin list.
|
||||
|
||||
Press esc to close.
|
||||
@@ -274,6 +274,34 @@ async fn plugins_popup_add_marketplace_tab_opens_prompt_and_submits_source() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn marketplace_add_error_popup_shows_server_error() {
|
||||
let (mut chat, _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::new())]),
|
||||
);
|
||||
chat.open_marketplace_add_loading_popup("bad-source");
|
||||
chat.on_marketplace_add_loaded(
|
||||
cwd,
|
||||
"bad-source".to_string(),
|
||||
Err(
|
||||
"Failed to add marketplace: invalid marketplace source format; expected owner/repo, a git URL, or a local marketplace path"
|
||||
.to_string(),
|
||||
),
|
||||
);
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 100);
|
||||
assert_chatwidget_snapshot!("plugins_popup_marketplace_add_error", popup);
|
||||
assert!(
|
||||
popup.contains("invalid marketplace source format"),
|
||||
"expected marketplace add error popup to show server error, got:\n{popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn marketplace_add_success_refreshes_to_new_marketplace_tab() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
Reference in New Issue
Block a user