Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions codex-rs/tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use crate::onboarding::onboarding_screen::OnboardingScreenArgs;
use crate::should_show_login_screen;
use crate::slash_command::SlashCommand;
use crate::tui;
use clap::CommandFactory;
use clap::Parser as ClapParser;
use codex_core::config::Config;
use codex_core::protocol::Event;
use codex_core::protocol::EventMsg;
Expand Down Expand Up @@ -371,6 +373,24 @@ impl App<'_> {
widget.add_status_output();
}
}
SlashCommand::Help => {
if let AppState::Chat { widget } = &mut self.app_state {
#[derive(ClapParser, Debug)]
#[command(version)]
struct HelpCli {
#[clap(flatten)]
config_overrides: codex_common::CliConfigOverrides,
#[clap(flatten)]
inner: crate::Cli,
}

let mut cmd = HelpCli::command();
let mut buf: Vec<u8> = Vec::new();
let _ = cmd.write_help(&mut buf);
let help_text = String::from_utf8_lossy(&buf).to_string();
widget.add_help_output(help_text);
}
}
SlashCommand::Prompts => {
if let AppState::Chat { widget } = &mut self.app_state {
widget.add_prompts_output();
Expand Down
4 changes: 4 additions & 0 deletions codex-rs/tui/src/chatwidget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ impl ChatWidget<'_> {
self.add_to_history(HistoryCell::new_prompts_output());
}

pub(crate) fn add_help_output(&mut self, help_text: String) {
self.add_to_history(HistoryCell::new_help_output(help_text));
}

/// 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);
Expand Down
16 changes: 16 additions & 0 deletions codex-rs/tui/src/history_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ pub(crate) enum HistoryCell {
view: TextBlock,
},

/// Output from the `/help` command.
HelpOutput { view: TextBlock },

/// Error event from the backend.
ErrorEvent {
view: TextBlock,
Expand Down Expand Up @@ -194,6 +197,7 @@ impl HistoryCell {
| HistoryCell::GitDiffOutput { view }
| HistoryCell::StatusOutput { view }
| HistoryCell::PromptsOutput { view }
| HistoryCell::HelpOutput { view }
| HistoryCell::ErrorEvent { view }
| HistoryCell::SessionInfo { view }
| HistoryCell::CompletedMcpToolCall { view }
Expand Down Expand Up @@ -705,6 +709,18 @@ impl HistoryCell {
}
}

pub(crate) fn new_help_output(help_text: String) -> Self {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push(Line::from("/help".magenta()));
for l in help_text.lines() {
lines.push(Line::from(l.to_string()));
}
lines.push(Line::from(""));
HistoryCell::HelpOutput {
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()];
Expand Down
2 changes: 2 additions & 0 deletions codex-rs/tui/src/slash_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum SlashCommand {
Diff,
Status,
Prompts,
Help,
Logout,
Quit,
#[cfg(debug_assertions)]
Expand All @@ -35,6 +36,7 @@ impl SlashCommand {
SlashCommand::Diff => "show git diff (including untracked files)",
SlashCommand::Status => "show current session configuration and token usage",
SlashCommand::Prompts => "show example prompts",
SlashCommand::Help => "show command help",
SlashCommand::Logout => "log out of Codex",
#[cfg(debug_assertions)]
SlashCommand::TestApproval => "test approval request",
Expand Down