Support bare `quit` and `exit` commands in TUI

Resolved 💬 1 comment Opened Mar 6, 2026 by Zeko369 Closed Apr 11, 2026

Summary

Typing quit or exit as plain input (without a leading slash) currently submits text instead of exiting Codex.

Other coding CLIs like claude-code and opencode support bare exit/quit keywords, so adding this improves cross-tool consistency and user ergonomics.

Current behavior

  • /quit and /exit work.
  • Bare quit / exit do not; they are treated as normal user messages.

Expected behavior

When the draft is exactly quit or exit (ignoring surrounding whitespace), pressing Enter should trigger the same behavior as /quit and /exit.

Proposed implementation

Route bare aliases through the existing slash-command dispatch path in the composer submit flow:

fn handle_submission_with_time(
    &mut self,
    should_queue: bool,
    now: Instant,
) -> (InputResult, bool) {
    if let Some(result) = self.try_dispatch_bare_slash_command() {
        return (result, true);
    }
    if let Some(result) = self.try_dispatch_bare_exit_alias() {
        return (result, true);
    }
    // ...existing submission logic...
}

/// Check if the input is a bare exit alias (`quit`/`exit`) and dispatch it.
fn try_dispatch_bare_exit_alias(&mut self) -> Option<InputResult> {
    if !self.slash_commands_enabled() {
        return None;
    }
    let text = self.textarea.text().trim();
    let cmd = match text {
        "quit" => SlashCommand::Quit,
        "exit" => SlashCommand::Exit,
        _ => return None,
    };
    self.textarea.set_text_clearing_elements("");
    Some(InputResult::Command(cmd))
}

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗