Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Hide /debug slash commands from popup menu (#11974)

jif-oaib994b5299412
diff --git a/codex-rs/tui/src/bottom_pane/command_popup.rs b/codex-rs/tui/src/bottom_pane/command_popup.rs
index 48cf255ee0..1c2291465e 100644
--- a/codex-rs/tui/src/bottom_pane/command_popup.rs
+++ b/codex-rs/tui/src/bottom_pane/command_popup.rs
@@ -45,12 +45,15 @@ pub(crate) struct CommandPopupFlags {
impl CommandPopup {
pub(crate) fn new(mut prompts: Vec<CustomPrompt>, flags: CommandPopupFlags) -> Self {
// Keep built-in availability in sync with the composer.
- let builtins = slash_commands::builtins_for_input(
+ let builtins: Vec<(&'static str, SlashCommand)> = slash_commands::builtins_for_input(
flags.collaboration_modes_enabled,
flags.connectors_enabled,
flags.personality_command_enabled,
flags.windows_degraded_sandbox_active,
- );
+ )
+ .into_iter()
+ .filter(|(name, _)| !name.starts_with("debug"))
+ .collect();
// Exclude prompts that collide with builtin command names and sort by name.
let exclude: HashSet<String> = builtins.iter().map(|(n, _)| (*n).to_string()).collect();
prompts.retain(|p| !exclude.contains(&p.name));
@@ -566,4 +569,22 @@ mod tests {
other => panic!("expected personality to be selected for exact match, got {other:?}"),
}
}
+
+ #[test]
+ fn debug_commands_are_hidden_from_popup() {
+ let popup = CommandPopup::new(Vec::new(), CommandPopupFlags::default());
+ let cmds: Vec<&str> = popup
+ .filtered_items()
+ .into_iter()
+ .filter_map(|item| match item {
+ CommandItem::Builtin(cmd) => Some(cmd.command()),
+ CommandItem::UserPrompt(_) => None,
+ })
+ .collect();
+
+ assert!(
+ !cmds.iter().any(|name| name.starts_with("debug")),
+ "expected no /debug* command in popup menu, got {cmds:?}"
+ );
+ }
}
diff --git a/codex-rs/tui/src/bottom_pane/slash_commands.rs b/codex-rs/tui/src/bottom_pane/slash_commands.rs
index cdd0ba8f7d..4613161f2f 100644
--- a/codex-rs/tui/src/bottom_pane/slash_commands.rs
+++ b/codex-rs/tui/src/bottom_pane/slash_commands.rs
@@ -63,3 +63,15 @@ pub(crate) fn has_builtin_prefix(
.into_iter()
.any(|(command_name, _)| fuzzy_match(command_name, name).is_some())
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use pretty_assertions::assert_eq;
+
+ #[test]
+ fn debug_command_still_resolves_for_dispatch() {
+ let cmd = find_builtin_command("debug-config", true, true, true, false);
+ assert_eq!(cmd, Some(SlashCommand::DebugConfig));
+ }
+}