Restore agent navigation after TUI reconnects (#41918)

## What changed

- Keep the agent command center visible with its cached inventory and draft while reconnecting, then refresh it without losing the selected task.
- Allow cached, unavailable conversations to reattach when selected while preserving their drafts, recap progress, and runtime permissions.
- Report an unsubmitted rename when its target disappears during refresh, and continue to quarantine queued input instead of resending it automatically.

## Testing

- Add a Unix socket replacement test covering command-center recovery with and without an active conversation, failed reconnects, inventory changes, and subsequent live task input.

GitOrigin-RevId: 774aca2dfb8358e9abd6a2e2ef0d509646648f66
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-31 21:59:56 +00:00
1 parent 0a2e2bf957
commit 746798b2f7
11 files changed
+752 -43

No files matched your search

+19 -3
View File
@@ -34,6 +34,7 @@ pub(super) struct AgentsOverviewState {
pub(super) refresh_pending: bool,
pub(super) rendered_full_screen: bool,
pub(super) visible_thread_ids: Vec<ThreadId>,
pub(super) threads: Vec<Thread>,
pub(super) view_state:
Arc<std::sync::Mutex<super::agents_overview_view::AgentsOverviewViewState>>,
pub(super) input_states: HashMap<ThreadId, ThreadInputState>,
@@ -93,7 +94,10 @@ impl App {
self.agents_overview.request_id = None;
self.agents_overview.refresh_pending = false;
let view = self.agents_overview_view(Vec::new(), /*selected_thread_id*/ None);
let view = self.agents_overview_view(
self.agents_overview.threads.clone(),
/*selected_thread_id*/ None,
);
self.agents_overview.visible_thread_ids = view.thread_ids();
self.chat_widget.show_bottom_pane_view(Box::new(view));
self.refresh_agents_overview_threads(app_server);
@@ -240,6 +244,7 @@ impl App {
return;
}
};
self.agents_overview.threads = threads.clone();
let view = self.agents_overview_view(threads, selected_thread_id);
self.agents_overview.visible_thread_ids = view.thread_ids();
if selected_thread_id
@@ -247,6 +252,13 @@ impl App {
&& let Ok(mut state) = self.agents_overview.view_state.lock()
&& state.renaming
{
self.chat_widget.add_info_message(
format!(
"The rename target disappeared. Unsubmitted title: {}",
state.input
),
/*hint*/ None,
);
state.renaming = false;
state.input.clear();
}
@@ -320,7 +332,9 @@ impl App {
app_server: &mut AppServerSession,
root_thread_id: ThreadId,
) -> color_eyre::Result<AppRunControl> {
if self.current_displayed_thread_id() == Some(root_thread_id) {
if self.current_displayed_thread_id() == Some(root_thread_id)
&& !self.thread_unavailable(root_thread_id)
{
return Ok(AppRunControl::Continue);
}
@@ -505,7 +519,9 @@ impl App {
}
}
if self.current_displayed_thread_id() != Some(root_thread_id) {
if self.current_displayed_thread_id() != Some(root_thread_id)
|| self.thread_unavailable(root_thread_id)
{
self.select_agent_thread_and_discard_side(tui, app_server, root_thread_id)
.await?;
}