Print TUI session info on fatal exits (#27417)

## Summary

TUI exits printed the resume/session summary only after checking the
exit reason. On fatal exits, both CLI wrappers wrote the error and
called `process::exit(1)` immediately, so an active session that ended
on a fatal error could skip the session information entirely.

This change prints the normal exit summary before returning the fatal
nonzero exit code. If a fatal exit has a known thread id but no
resumable rollout hint, it prints `Session ID: <id>` instead of staying
silent. It also flushes stdout before `process::exit(1)` so the summary
line is not lost during process teardown.

## Implementation

- Apply the fatal-exit ordering fix in both `codex` and standalone
`codex-tui`.
- Keep normal user-requested exit behavior unchanged.
- Preserve the existing resume hint when a rollout is resumable, and use
the raw thread id only as a fatal-exit fallback.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-06-11 09:56:09 -07:00
1 parent df9dd22248
commit 9d88e299a7
5 files changed
+92 -36

No files matched your search

+1 -1
View File
@@ -343,7 +343,7 @@ pub(super) async fn handle_model_migration_prompt_if_needed(
return Some(AppExitInfo {
token_usage: TokenUsage::default(),
thread_id: None,
thread_name: None,
resume_hint: None,
update_action: None,
exit_reason: ExitReason::UserRequested,
});