From 7c20160676d6fd584a01e09d22d371e106e4678f Mon Sep 17 00:00:00 2001 From: ae Date: Thu, 7 Aug 2025 03:55:59 -0700 Subject: [PATCH] feat: /prompts slash command (#1937) - Shows several example prompts which include @-mentions ------ https://chatgpt.com/codex/tasks/task_i_6894779ba8cc832ca0c871d17ee06aae --- codex-rs/tui/src/app.rs | 5 +++++ codex-rs/tui/src/chatwidget.rs | 4 ++++ codex-rs/tui/src/history_cell.rs | 22 ++++++++++++++++++++++ codex-rs/tui/src/slash_command.rs | 2 ++ 4 files changed, 33 insertions(+) diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 1ba8883b..0e38aba3 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -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; diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index d4872d37..2cadc13c 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -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) { self.bottom_pane.on_file_search_result(query, matches); diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index d0be52a4..bbf1d721 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -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> = 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> = vec![vec!["🖐 ".red().bold(), message.into()].into(), "".into()]; diff --git a/codex-rs/tui/src/slash_command.rs b/codex-rs/tui/src/slash_command.rs index ba24ead4..e58ab852 100644 --- a/codex-rs/tui/src/slash_command.rs +++ b/codex-rs/tui/src/slash_command.rs @@ -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",