mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Hide /debug slash commands from popup menu (#11974)
Summary - filter command popup builtins to remove any `/debug*` entries so they stay usable but are not listed - added regression tests to ensure the popup hides debug commands while dispatch still resolves them
This commit is contained in:
@@ -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:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user