Custom prompts begin with /prompts: (#4476)

<img width="608" height="354" alt="Screenshot 2025-09-29 at 4 41 08 PM"
src="https://github.com/user-attachments/assets/162508eb-c1ac-4bc0-95f2-5e23cb4ae428"
/>
This commit is contained in:
dedrisian-oai
2025-09-29 17:58:16 -07:00
committed by GitHub
parent c64da4ff71
commit bf76258cdc
4 changed files with 61 additions and 19 deletions

View File

@@ -10,6 +10,7 @@ use crate::slash_command::SlashCommand;
use crate::slash_command::built_in_slash_commands;
use codex_common::fuzzy_match::fuzzy_match;
use codex_protocol::custom_prompts::CustomPrompt;
use codex_protocol::custom_prompts::PROMPTS_CMD_PREFIX;
use std::collections::HashSet;
/// A selectable item in the popup: either a built-in command or a user prompt.
@@ -120,8 +121,12 @@ impl CommandPopup {
out.push((CommandItem::Builtin(*cmd), Some(indices), score));
}
}
// Support both search styles:
// - Typing "name" should surface "/prompts:name" results.
// - Typing "prompts:name" should also work.
for (idx, p) in self.prompts.iter().enumerate() {
if let Some((indices, score)) = fuzzy_match(&p.name, filter) {
let display = format!("{PROMPTS_CMD_PREFIX}:{}", p.name);
if let Some((indices, score)) = fuzzy_match(&display, filter) {
out.push((CommandItem::UserPrompt(idx), Some(indices), score));
}
}
@@ -158,7 +163,7 @@ impl CommandPopup {
(format!("/{}", cmd.command()), cmd.description().to_string())
}
CommandItem::UserPrompt(i) => (
format!("/{}", self.prompts[i].name),
format!("/{PROMPTS_CMD_PREFIX}:{}", self.prompts[i].name),
"send saved prompt".to_string(),
),
};