Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: /prompts slash command (#1937)

ae7c20160676d6
diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs
index 1ba8883b0b..0e38aba3d7 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 d4872d377e..2cadc13c49 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<FileMatch>) {
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 d0be52a472..bbf1d7210c 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<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()];
diff --git a/codex-rs/tui/src/slash_command.rs b/codex-rs/tui/src/slash_command.rs
index ba24ead4f9..e58ab8521e 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",