Lightweight coding agent that runs in your terminal
Rust
Show a retryable error when the apps popup fails to load (#43074)
Eric Traut51c97f3a6762
diff --git a/codex-rs/tui/src/chatwidget/connectors.rs b/codex-rs/tui/src/chatwidget/connectors.rsindex b2a76470df..2f8bbf06c5 100644--- a/codex-rs/tui/src/chatwidget/connectors.rs+++ b/codex-rs/tui/src/chatwidget/connectors.rs@@ -116,6 +116,12 @@ impl ChatWidget {fn queue_connectors_refresh(&mut self, force_refetch: bool) {if self.begin_connectors_refresh(force_refetch) {+ if matches!(self.connectors.cache, ConnectorsCacheState::Loading) {+ let _ = self.bottom_pane.replace_selection_view_if_active(+ CONNECTORS_SELECTION_VIEW_ID,+ self.connectors_loading_popup_params(),+ );+ }self.app_event_tx.send(AppEvent::FetchConnectorsList {force_refetch,generation: self.connectors.generation,@@ -224,6 +230,40 @@ impl ChatWidget {}}+ fn connectors_error_popup_params(&self) -> SelectionViewParams {+ let mut header = ColumnRenderable::new();+ header.push(Line::from("Apps".bold()));+ header.push(Line::from("Failed to load apps.".dim()));++ SelectionViewParams {+ view_id: Some(CONNECTORS_SELECTION_VIEW_ID),+ header: Box::new(header),+ footer_hint: Some(self.bottom_pane.standard_popup_hint_line()),+ items: vec![+ SelectionItem {+ name: "App directory unavailable".to_string(),+ description: Some(+ "The app directory request failed. Retry, or press Esc to continue."+ .to_string(),+ ),+ is_disabled: true,+ ..Default::default()+ },+ SelectionItem {+ name: "Retry".to_string(),+ description: Some("Reload installed and available apps.".to_string()),+ actions: vec![Box::new(|tx| {+ tx.send(AppEvent::RefreshConnectors {+ force_refetch: true,+ });+ })],+ ..Default::default()+ },+ ],+ ..Default::default()+ }+ }+fn connectors_popup_params(&self,connectors: &[AppInfo],@@ -435,6 +475,10 @@ impl ChatWidget {self.refresh_connectors_popup_if_open(&snapshot.connectors);self.connectors.cache = ConnectorsCacheState::Ready(snapshot);} else {+ let _ = self.bottom_pane.replace_selection_view_if_active(+ CONNECTORS_SELECTION_VIEW_ID,+ self.connectors_error_popup_params(),+ );self.connectors.cache = ConnectorsCacheState::Failed(err);}}diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__apps_popup_error_state.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__apps_popup_error_state.snapnew file mode 100644index 0000000000..c669150bb5--- /dev/null+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__apps_popup_error_state.snap@@ -0,0 +1,13 @@+---+source: tui/src/chatwidget/tests/popups_and_settings.rs+assertion_line: 2796+expression: popup+---+ Apps+ Failed to load apps.++ App directory unavailable The app directory request failed. Retry, or+ press Esc to continue.+› 1. Retry Reload installed and available apps.++ Press enter to confirm or esc to go backdiff --git a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rsindex 801ee925b8..55703496e5 100644--- a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs+++ b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs@@ -2768,6 +2768,47 @@ async fn apps_popup_keeps_existing_full_snapshot_while_partial_refresh_loads() {);}+#[tokio::test]+async fn apps_popup_replaces_loading_state_after_initial_refresh_failure() {+ let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;+ chat.thread_id = Some(ThreadId::new());+ set_chatgpt_auth(&mut chat);+ chat.config+ .features+ .enable(Feature::Apps)+ .expect("test config should allow feature update");+ chat.bottom_pane.set_connectors_enabled(/*enabled*/ true);++ chat.add_connectors_output();+ assert!(render_bottom_popup(&chat, /*width*/ 80).contains("Loading apps..."));+ assert_matches!(rx.try_recv(), Ok(AppEvent::FetchConnectorsList { .. }));+ assert_matches!(+ rx.try_recv(),+ Ok(AppEvent::FetchInstalledConnectorMentions { .. })+ );++ chat.on_connectors_loaded(+ Err("app/list failed: 403 Forbidden".to_string()),+ /*is_final*/ true,+ );++ let popup = render_bottom_popup(&chat, /*width*/ 80);+ assert!(!popup.contains("Loading apps..."), "{popup}");+ assert!(!popup.contains("403 Forbidden"), "{popup}");+ assert!(popup.contains("Failed to load apps."), "{popup}");+ assert_chatwidget_snapshot!("apps_popup_error_state", popup);++ chat.handle_key_event(KeyEvent::from(KeyCode::Enter));+ assert_matches!(+ rx.try_recv(),+ Ok(AppEvent::RefreshConnectors {+ force_refetch: true+ })+ );+ chat.refresh_connectors(/*force_refetch*/ true);+ assert!(render_bottom_popup(&chat, /*width*/ 80).contains("Loading apps..."));+}+#[tokio::test]async fn apps_refresh_failure_without_full_snapshot_falls_back_to_installed_apps() {let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;