docs/exit-confirmation-prompt-design.md
This document describes how exit, shutdown, and interruption work in the Rust TUI (codex-rs/tui).
It is intended for Codex developers and Codex itself when reasoning about future exit/shutdown
changes.
This doc replaces earlier separate history and design notes. High-level history is summarized below; full details are captured in PR #8936.
Op::Shutdown) and wait for
ShutdownComplete so cleanup can run.Op::Interrupt).Exit is coordinated via a single event with explicit modes:
AppEvent::Exit(ExitMode::ShutdownFirst)
AppEvent::Exit(ExitMode::Immediate)
App is the coordinator: it submits Op::Shutdown and it exits the UI loop only when
ExitMode::Immediate arrives (typically after ShutdownComplete).
Priority order in the UI layer:
BottomPane::on_ctrl_c).
ChatWidget arms Ctrl+C and shows the quit hint (ctrl + c again to quit) for
1 second.ChatWidget submits Op::Interrupt./quit, /exit, /logout request shutdown-first quit without a prompt,
because slash commands are harder to trigger accidentally and imply clear intent to quit.ShutdownComplete) so the app can
start a fresh session without terminating.ShutdownComplete is the signal that core cleanup has finished. The UI treats it as the boundary
for exit:
ChatWidget requests Exit(Immediate) on ShutdownComplete.App can suppress a single ShutdownComplete when shutdown is used as a
cleanup step (e.g., /new).At a minimum, we want coverage for:
/quit / /exit / /logout quit without prompt, but still shutdown-first.
Codex has historically mixed "exit immediately" and "shutdown-first" across quit gestures, largely due to incremental changes and regressions in state tracking. This doc reflects the current unified, shutdown-first approach. See PR #8936 for the detailed history and rationale.