feat: /prompts slash command (#1937)

- Shows several example prompts which include @-mentions 

------
https://chatgpt.com/codex/tasks/task_i_6894779ba8cc832ca0c871d17ee06aae
This commit is contained in:
ae
2025-08-07 03:55:59 -07:00
committed by GitHub
parent 1e4bf81653
commit 7c20160676
4 changed files with 33 additions and 0 deletions

View File

@@ -360,6 +360,11 @@ impl App<'_> {
widget.add_status_output();
}
}
SlashCommand::Prompts => {
if let AppState::Chat { widget } = &mut self.app_state {
widget.add_prompts_output();
}
}
#[cfg(debug_assertions)]
SlashCommand::TestApproval => {
use std::collections::HashMap;

View File

@@ -556,6 +556,10 @@ impl ChatWidget<'_> {
));
}
pub(crate) fn add_prompts_output(&mut self) {
self.add_to_history(HistoryCell::new_prompts_output());
}
/// Forward file-search results to the bottom pane.
pub(crate) fn apply_file_search_result(&mut self, query: String, matches: Vec<FileMatch>) {
self.bottom_pane.on_file_search_result(query, matches);

View File

@@ -110,6 +110,9 @@ pub(crate) enum HistoryCell {
/// Output from the `/status` command.
StatusOutput { view: TextBlock },
/// Output from the `/prompts` command.
PromptsOutput { view: TextBlock },
/// Error event from the backend.
ErrorEvent { view: TextBlock },
@@ -142,6 +145,7 @@ impl HistoryCell {
| HistoryCell::BackgroundEvent { view }
| HistoryCell::GitDiffOutput { view }
| HistoryCell::StatusOutput { view }
| HistoryCell::PromptsOutput { view }
| HistoryCell::ErrorEvent { view }
| HistoryCell::SessionInfo { view }
| HistoryCell::CompletedExecCommand { view }
@@ -201,6 +205,7 @@ impl HistoryCell {
Line::from(format!(" /init - {}", SlashCommand::Init.description()).dim()),
Line::from(format!(" /status - {}", SlashCommand::Status.description()).dim()),
Line::from(format!(" /diff - {}", SlashCommand::Diff.description()).dim()),
Line::from(format!(" /prompts - {}", SlashCommand::Prompts.description()).dim()),
Line::from("".dim()),
];
HistoryCell::WelcomeMessage {
@@ -525,6 +530,23 @@ impl HistoryCell {
}
}
pub(crate) fn new_prompts_output() -> Self {
let lines: Vec<Line<'static>> = vec![
Line::from("/prompts".magenta()),
Line::from(""),
Line::from(" 1. Explain this codebase"),
Line::from(" 2. Summarize recent commits"),
Line::from(" 3. Implement {feature}"),
Line::from(" 4. Find and fix a bug in @filename"),
Line::from(" 5. Write tests for @filename"),
Line::from(" 6. Improve documentation in @filename"),
Line::from(""),
];
HistoryCell::PromptsOutput {
view: TextBlock::new(lines),
}
}
pub(crate) fn new_error_event(message: String) -> Self {
let lines: Vec<Line<'static>> =
vec![vec!["🖐 ".red().bold(), message.into()].into(), "".into()];

View File

@@ -17,6 +17,7 @@ pub enum SlashCommand {
Compact,
Diff,
Status,
Prompts,
Logout,
Quit,
#[cfg(debug_assertions)]
@@ -33,6 +34,7 @@ impl SlashCommand {
SlashCommand::Quit => "exit Codex",
SlashCommand::Diff => "show git diff (including untracked files)",
SlashCommand::Status => "show current session configuration and token usage",
SlashCommand::Prompts => "show example prompts",
SlashCommand::Logout => "log out of Codex",
#[cfg(debug_assertions)]
SlashCommand::TestApproval => "test approval request",