Skip to content

Commit b6c1831

Browse files
charley-oaicodex
andcommitted
tui: centralize slash command serialization
Introduce a small slash command invocation serializer and consolidate built-in command metadata behind a single spec table without changing slash command runtime behavior. Co-authored-by: Codex <noreply@openai.com>
1 parent 2aa4873 commit b6c1831

File tree

5 files changed

+377
-117
lines changed

5 files changed

+377
-117
lines changed

codex-rs/tui/src/bottom_pane/chat_composer.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ use crate::render::Insets;
192192
use crate::render::RectExt;
193193
use crate::render::renderable::Renderable;
194194
use crate::slash_command::SlashCommand;
195+
use crate::slash_command_invocation::SlashCommandInvocation;
195196
use crate::style::user_message_style;
196197
use codex_protocol::custom_prompts::CustomPrompt;
197198
use codex_protocol::custom_prompts::PROMPTS_CMD_PREFIX;
@@ -1416,12 +1417,13 @@ impl ChatComposer {
14161417
return (InputResult::Command(cmd), true);
14171418
}
14181419

1419-
let starts_with_cmd = first_line
1420-
.trim_start()
1421-
.starts_with(&format!("/{}", cmd.command()));
1420+
let bare_command =
1421+
SlashCommandInvocation::bare(cmd).into_prefixed_string();
1422+
let starts_with_cmd =
1423+
first_line.trim_start().starts_with(&bare_command);
14221424
if !starts_with_cmd {
14231425
self.textarea
1424-
.set_text_clearing_elements(&format!("/{} ", cmd.command()));
1426+
.set_text_clearing_elements(&format!("{bare_command} "));
14251427
}
14261428
if !self.textarea.text().is_empty() {
14271429
cursor_target = Some(self.textarea.text().len());

codex-rs/tui/src/bottom_pane/command_popup.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ use codex_protocol::custom_prompts::CustomPrompt;
1414
use codex_protocol::custom_prompts::PROMPTS_CMD_PREFIX;
1515
use std::collections::HashSet;
1616

17-
// Hide alias commands in the default popup list so each unique action appears once.
18-
// `quit` is an alias of `exit`, so we skip `quit` here.
19-
// `approvals` is an alias of `permissions`.
20-
const ALIAS_COMMANDS: &[SlashCommand] = &[SlashCommand::Quit, SlashCommand::Approvals];
21-
2217
/// A selectable item in the popup: either a built-in command or a user prompt.
2318
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2419
pub(crate) enum CommandItem {
@@ -143,7 +138,7 @@ impl CommandPopup {
143138
if filter.is_empty() {
144139
// Built-ins first, in presentation order.
145140
for (_, cmd) in self.builtins.iter() {
146-
if ALIAS_COMMANDS.contains(cmd) {
141+
if !cmd.show_in_command_popup() {
147142
continue;
148143
}
149144
out.push((CommandItem::Builtin(*cmd), None));

codex-rs/tui/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ mod session_log;
122122
mod shimmer;
123123
mod skills_helpers;
124124
mod slash_command;
125+
mod slash_command_invocation;
125126
mod status;
126127
mod status_indicator_widget;
127128
mod streaming;

0 commit comments

Comments
 (0)