Add running-task exit choices to local daemon sessions (#38447)

## What changed

When `Ctrl-C` is pressed with an empty composer while a task is running in a local daemon session, show a menu that lets the user:

- cancel the task and stay in Codex;
- exit Codex while leaving the task running; or
- stop the task and exit Codex.

Do not offer background execution for side-thread tasks or when follow-up messages are queued. Preserve existing `Ctrl-C` behavior for non-daemon sessions, drafts, paste bursts, MCP startup, and returning from an active side thread.

## Testing

Add TUI tests for each exit action, menu dismissal, side threads, queued follow-ups, composer input, MCP startup, and non-daemon sessions.

GitOrigin-RevId: 539c33d3a4ff288a015bddbe9465d2bbdbe018d0
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-13 22:38:46 +00:00
1 parent 6344a655a5
commit ca83f7908c
9 files changed
+593 -11

No files matched your search

+14
View File
@@ -342,6 +342,12 @@ pub(crate) enum AppEvent {
/// background tasks, rollout flush, or child process cleanup).
Exit(ExitMode),
/// Apply a choice from the running-task exit menu to its originating thread.
RunningTaskExit {
action: RunningTaskExitAction,
thread_id: ThreadId,
},
/// Request app-server account logout, then exit after it succeeds.
Logout,
@@ -1213,6 +1219,14 @@ pub(crate) enum ExitMode {
Immediate,
}
/// Choice made when leaving a daemon-backed task that is still running.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum RunningTaskExitAction {
CancelTask,
RunInBackground,
Exit,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum FeedbackCategory {
BadResult,