Show a loading message when opening tasks from the agents overview (#45983)

## Why

Task attachment awaits server requests while the event handler cannot process scheduled frames. Prompts and chat widget replacement can also clear the terminal during loading.

## What changed

Draw a bold `Loading task…` message immediately when attaching a task, and redraw it after folder selection, trust prompts, and chat widget replacement. Schedule a frame to restore the normal view afterward.

## Testing

Extend the cold-resume test to verify that a loading message appears before server requests complete, survives widget replacement, and is replaced on the next draw.

GitOrigin-RevId: cb2e73efe38758025964aa53f52127a2b2609fca
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-16 16:56:18 +00:00
1 parent 53401a2808
commit 0666c12e78
3 files changed
+59

No files matched your search

+8
View File
@@ -8,6 +8,9 @@ pub(crate) use new::PendingWorktree;
#[path = "agents_overview_errors.rs"]
mod errors;
#[path = "agents_overview_loading.rs"]
mod loading;
use super::agents_overview_view::AgentsOverviewGroup;
use super::agents_overview_view::AgentsOverviewRow;
use super::agents_overview_view::AgentsOverviewView;
@@ -332,6 +335,7 @@ impl App {
self.chat_widget.pre_draw_tick();
return Ok(AppRunControl::Continue);
}
loading::draw(tui)?;
if self.primary_thread_id != Some(root_thread_id) {
let previous_displayed_thread_id = self.current_displayed_thread_id();
if let Some(id) = previous_displayed_thread_id
@@ -456,6 +460,8 @@ impl App {
}
local_settings = crate::local_settings::LocalSettings::from(&resume_config);
}
// Folder selection and trust prompts can replace or clear the loading frame.
loading::draw(tui)?;
let baseline_approval = resume_config.permissions.approval_policy.value();
let baseline_permissions =
RuntimePermissionProfileOverride::from_config(&resume_config);
@@ -608,6 +614,8 @@ impl App {
self.add_agents_overview_error(format!("Failed to attach to task: {error}"));
return Ok(AppRunControl::Continue);
}
// Replacing the widget clears the terminal before the remaining server requests.
loading::draw(tui)?;
if read_only {
self.ensure_thread_channel(root_thread_id)
.mark_external_writer();