Show reconnect guidance when disconnecting from tasks (#40629)

## Why

Exiting a TUI connected to a persistent app server can leave work running, so
the existing session-exit summary does not explain how to reconnect or stop the
active turn.

## What changed

- Distinguish disconnects, interrupted turns, and removed threads when building
  exit summaries.
- For daemon and remote sessions, report whether work may still be running and
  print commands to reconnect or stop the current turn.
- Sanitize remote WebSocket addresses in displayed commands and preserve the
  configured remote authentication environment-variable option.
- Keep the existing token-usage and resume summary for embedded sessions.

## Testing

Add coverage for daemon, remote, interrupted, embedded, archived, and deleted
session exits, including credential sanitization.

GitOrigin-RevId: 9cbbf9c7dd36423a5ed99909a2b4cb32e3e87712
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-25 15:55:35 +00:00
1 parent 0cdb1f1c83
commit a63cb33e8d
16 files changed
+408 -96

No files matched your search

+8
View File
@@ -217,6 +217,7 @@ mod background_requests;
mod config_persistence;
mod connector_mentions;
mod event_dispatch;
mod exit_summary;
mod file_change_approvals;
mod history_pagination;
mod history_ui;
@@ -421,6 +422,7 @@ pub struct AppExitInfo {
pub token_usage: TokenUsage,
pub thread_id: Option<ThreadId>,
pub resume_hint: Option<String>,
pub disconnect_info: Option<DisconnectInfo>,
pub update_action: Option<UpdateAction>,
pub exit_reason: ExitReason,
}
@@ -431,12 +433,15 @@ impl AppExitInfo {
token_usage: TokenUsage::default(),
thread_id: None,
resume_hint: None,
disconnect_info: None,
update_action: None,
exit_reason: ExitReason::Fatal(message.into()),
}
}
}
pub use exit_summary::DisconnectInfo;
#[derive(Debug)]
pub(crate) enum AppRunControl {
Continue,
@@ -446,6 +451,9 @@ pub(crate) enum AppRunControl {
#[derive(Debug, Clone)]
pub enum ExitReason {
UserRequested,
TurnInterrupted,
/// The current thread was archived or deleted, rather than disconnected.
ThreadRemoved,
Fatal(String),
}