From 51c97f3a67621aab788fb83d6ef90cf795f12177 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 5 Sep 2026 18:25:27 +0000 Subject: [PATCH] Show a retryable error when the apps popup fails to load (#43074) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Why An initial `/apps` request failure with no cached or partial app list left the popup showing “Loading apps...”. ## What changed Replace the loading popup with a generic failure message and a `Retry` action. Retrying forces a refresh and restores the loading state while the request runs. ## Testing Add a regression test and snapshot covering the error display, omission of raw request errors, and retry transition back to loading. GitOrigin-RevId: 9b1974dbc5065a6d3695d881f216f8060d4381a9 --- codex-rs/tui/src/chatwidget/connectors.rs | 44 +++++++++++++++++++ ...widget__tests__apps_popup_error_state.snap | 13 ++++++ .../chatwidget/tests/popups_and_settings.rs | 41 +++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__apps_popup_error_state.snap diff --git a/codex-rs/tui/src/chatwidget/connectors.rs b/codex-rs/tui/src/chatwidget/connectors.rs index 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.snap new file mode 100644 index 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 back 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 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;