Show a retryable error when the apps popup fails to load (#43074)

## 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
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-05 18:38:41 +00:00
1 parent dfea985976
commit 51c97f3a67
3 files changed
+98

No files matched your search

+44
View File
@@ -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);
}
}
@@ -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
@@ -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;