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

Resolved 💬 2 comments Opened Mar 6, 2026 by Zeko369 Closed Apr 11, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

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 ↗

2 Comments

etraut-openai contributor · 4 months ago

This feature request hasn't received enough upvotes, so I'm going to close it.

c3Vu · 23 days ago

@etraut-openai Would you consider reopening this feature request?

I frequently switch between Claude Code and Codex, and I personally prefer :q because it is quick to type and fits naturally into a keyboard-driven terminal workflow.

I’d like to extend the original proposal to cover the Claude Code-compatible exit aliases:

  • Recognize exact, trimmed exit, quit, :q, :q!, :wq, and :wq! input.
  • Enable this only in command-enabled TUI composers; plain-text composers should remain unchanged.

I have a working prototype and I would like to submit the PR.