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

@@ -0,0 +1,8 @@
---
source: tui/src/app/tests/background_exit_tests.rs
expression: output
---
Disconnected from this task. Any running work continues.
Reconnect: codex resume THREAD_ID
Stop the current turn: run codex agents, select this task, and press f10.
Token usage so far: total=12 input=10 output=2
@@ -0,0 +1,6 @@
---
source: tui/src/app/tests/background_exit_tests.rs
expression: output
---
Disconnected from this task. The current turn was stopped.
Reconnect: codex resume THREAD_ID
@@ -0,0 +1,7 @@
---
source: tui/src/app/tests/background_exit_tests.rs
expression: "lines.join(\"\\n\")"
---
Disconnected from this task. Work may still be running.
Reconnect: codex --remote wss://example.com:443/ resume 123e4567-e89b-12d3-a456-426614174000
Stop the current turn: run codex --remote wss://example.com:443/ agents, select this task, and press ctrl + x.