Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions codex-rs/tui/src/chatwidget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl ChatWidget {
}

fn on_shutdown_complete(&mut self) {
self.app_event_tx.send(AppEvent::ExitRequest);
self.request_exit();
}

fn on_turn_diff(&mut self, unified_diff: String) {
Expand Down Expand Up @@ -1229,8 +1229,8 @@ impl ChatWidget {
SlashCommand::Approvals => {
self.open_approvals_popup();
}
SlashCommand::Quit => {
self.app_event_tx.send(AppEvent::ExitRequest);
SlashCommand::Quit | SlashCommand::Exit => {
self.request_exit();
}
SlashCommand::Logout => {
if let Err(e) = codex_core::auth::logout(
Expand All @@ -1239,7 +1239,7 @@ impl ChatWidget {
) {
tracing::error!("failed to logout: {e}");
}
self.app_event_tx.send(AppEvent::ExitRequest);
self.request_exit();
}
SlashCommand::Undo => {
self.app_event_tx.send(AppEvent::CodexOp(Op::Undo));
Expand Down Expand Up @@ -1593,6 +1593,10 @@ impl ChatWidget {
}
}

fn request_exit(&self) {
self.app_event_tx.send(AppEvent::ExitRequest);
}

fn request_redraw(&mut self) {
self.frame_requester.schedule_frame();
}
Expand Down
18 changes: 18 additions & 0 deletions codex-rs/tui/src/chatwidget/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,24 @@ fn slash_init_skips_when_project_doc_exists() {
);
}

#[test]
fn slash_quit_requests_exit() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();

chat.dispatch_command(SlashCommand::Quit);

assert_matches!(rx.try_recv(), Ok(AppEvent::ExitRequest));
}

#[test]
fn slash_exit_requests_exit() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();

chat.dispatch_command(SlashCommand::Exit);

assert_matches!(rx.try_recv(), Ok(AppEvent::ExitRequest));
}

#[test]
fn slash_undo_sends_op() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
Expand Down
6 changes: 4 additions & 2 deletions codex-rs/tui/src/slash_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum SlashCommand {
Mcp,
Logout,
Quit,
Exit,
Feedback,
Rollout,
TestApproval,
Expand All @@ -40,7 +41,7 @@ impl SlashCommand {
SlashCommand::Compact => "summarize conversation to prevent hitting the context limit",
SlashCommand::Review => "review my current changes and find issues",
SlashCommand::Undo => "ask Codex to undo a turn",
SlashCommand::Quit => "exit Codex",
SlashCommand::Quit | SlashCommand::Exit => "exit Codex",
SlashCommand::Diff => "show git diff (including untracked files)",
SlashCommand::Mention => "mention a file",
SlashCommand::Status => "show current session configuration and token usage",
Expand Down Expand Up @@ -75,7 +76,8 @@ impl SlashCommand {
| SlashCommand::Status
| SlashCommand::Mcp
| SlashCommand::Feedback
| SlashCommand::Quit => true,
| SlashCommand::Quit
| SlashCommand::Exit => true,
SlashCommand::Rollout => true,
SlashCommand::TestApproval => true,
}
Expand Down
Loading