From 1e4bf816531b233af0880c5492c30b951720321f Mon Sep 17 00:00:00 2001 From: Ed Bayes Date: Thu, 7 Aug 2025 03:29:33 -0700 Subject: [PATCH 1/3] Update copy (#1935) Updated copy --------- Co-authored-by: pap-openai --- .../components/chat/terminal-chat-input.tsx | 2 +- codex-cli/src/components/help-overlay.tsx | 2 +- .../src/utils/get-api-key-components.tsx | 2 +- codex-rs/tui/src/bottom_pane/chat_composer.rs | 2 +- ...tom_pane__chat_composer__tests__empty.snap | 2 +- codex-rs/tui/src/history_cell.rs | 9 ++-- codex-rs/tui/src/onboarding/auth.rs | 52 +++++++++++++------ codex-rs/tui/src/onboarding/welcome.rs | 4 +- codex-rs/tui/src/slash_command.rs | 16 +++--- codex-rs/tui/src/status_indicator_widget.rs | 2 +- 10 files changed, 57 insertions(+), 36 deletions(-) diff --git a/codex-cli/src/components/chat/terminal-chat-input.tsx b/codex-cli/src/components/chat/terminal-chat-input.tsx index c8c5bf8216..66428f8463 100644 --- a/codex-cli/src/components/chat/terminal-chat-input.tsx +++ b/codex-cli/src/components/chat/terminal-chat-input.tsx @@ -854,7 +854,7 @@ export default function TerminalChatInput({ /> ) : ( - ctrl+c to exit | "/" to see commands | enter to send + Ctrl+C to exit | "/" to see commands | Enter to send {contextLeftPercent > 25 && ( <> {" — "} diff --git a/codex-cli/src/components/help-overlay.tsx b/codex-cli/src/components/help-overlay.tsx index d302f7551e..1c24ad9c72 100644 --- a/codex-cli/src/components/help-overlay.tsx +++ b/codex-cli/src/components/help-overlay.tsx @@ -96,7 +96,7 @@ export default function HelpOverlay({ - esc or q to close + Esc or q to close ); diff --git a/codex-cli/src/utils/get-api-key-components.tsx b/codex-cli/src/utils/get-api-key-components.tsx index 45346632c4..d23b661126 100644 --- a/codex-cli/src/utils/get-api-key-components.tsx +++ b/codex-cli/src/utils/get-api-key-components.tsx @@ -68,7 +68,7 @@ export function WaitingForAuth(): JSX.Element { {" "} - Waiting for authentication… ctrl + c to quit + Waiting for authentication… Ctrl + C to quit ); diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index e53fe03676..3be3f14d6f 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -31,7 +31,7 @@ use crate::bottom_pane::textarea::TextAreaState; use codex_file_search::FileMatch; use std::cell::RefCell; -const BASE_PLACEHOLDER_TEXT: &str = "..."; +const BASE_PLACEHOLDER_TEXT: &str = "Ask Codex to do anything"; /// If the pasted content exceeds this number of characters, replace it with a /// placeholder in the UI. const LARGE_PASTE_CHAR_THRESHOLD: usize = 1000; diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__empty.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__empty.snap index 7a1a7f4ef3..de227a3071 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__empty.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__empty.snap @@ -2,7 +2,7 @@ source: tui/src/bottom_pane/chat_composer.rs expression: terminal.backend() --- -"▌ ... " +"▌ Ask Codex to do anything " "▌ " "▌ " "▌ " diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index 903e3087aa..d0be52a472 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -196,12 +196,11 @@ impl HistoryCell { Span::raw(format!(" {cwd_str}")).dim(), ]), Line::from("".dim()), - Line::from(" Try one of the following commands to get started:".dim()), + Line::from(" To get started, describe a task or try one of these commands:".dim()), Line::from("".dim()), - Line::from(format!(" 1. /init - {}", SlashCommand::Init.description()).dim()), - Line::from(format!(" 2. /status - {}", SlashCommand::Status.description()).dim()), - Line::from(format!(" 3. /compact - {}", SlashCommand::Compact.description()).dim()), - Line::from(format!(" 4. /new - {}", SlashCommand::New.description()).dim()), + 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("".dim()), ]; HistoryCell::WelcomeMessage { diff --git a/codex-rs/tui/src/onboarding/auth.rs b/codex-rs/tui/src/onboarding/auth.rs index b91bf4a0d9..397ba76890 100644 --- a/codex-rs/tui/src/onboarding/auth.rs +++ b/codex-rs/tui/src/onboarding/auth.rs @@ -104,7 +104,14 @@ impl AuthModeWidget { Line::from(vec![ Span::raw("> "), Span::styled( - "Sign in with your ChatGPT account?", + "Sign in with ChatGPT to use Codex as part of your paid plan", + Style::default().add_modifier(Modifier::BOLD), + ), + ]), + Line::from(vec![ + Span::raw(" "), + Span::styled( + "or connect an API key for usage-based billing", Style::default().add_modifier(Modifier::BOLD), ), ]), @@ -145,18 +152,18 @@ impl AuthModeWidget { lines.extend(create_mode_item( 0, AuthMode::ChatGPT, - "Sign in with ChatGPT or create a new account", - "Leverages your plan, starting at $20 a month for Plus", + "Sign in with ChatGPT", + "Usage included with Plus, Pro, and Team plans", )); lines.extend(create_mode_item( 1, AuthMode::ApiKey, "Provide your own API key", - "Pay only for what you use", + "Pay for what you use", )); lines.push(Line::from("")); lines.push( - Line::from("Press Enter to continue") + Line::from(" Press Enter to continue") .style(Style::default().add_modifier(Modifier::DIM)), ); if let Some(err) = &self.error { @@ -179,8 +186,7 @@ impl AuthModeWidget { let lines = vec![ Line::from(spans), Line::from(""), - Line::from(" Press Escape to cancel") - .style(Style::default().add_modifier(Modifier::DIM)), + Line::from(" Press Esc to cancel").style(Style::default().add_modifier(Modifier::DIM)), ]; Paragraph::new(lines) .wrap(Wrap { trim: false }) @@ -194,17 +200,30 @@ impl AuthModeWidget { Line::from(""), Line::from("> Before you start:"), Line::from(""), - Line::from(" Codex can make mistakes"), - Line::from(" Check important info") - .style(Style::default().add_modifier(Modifier::DIM)), + Line::from(" Decide how much autonomy you want to grant Codex"), + Line::from(vec![ + Span::raw(" For more details see the "), + Span::styled( + "\u{1b}]8;;https://github.com/openai/codex\u{7}Codex docs\u{1b}]8;;\u{7}", + Style::default().add_modifier(Modifier::UNDERLINED), + ), + ]) + .style(Style::default().add_modifier(Modifier::DIM)), Line::from(""), - Line::from(" Due to prompt injection risks, only use it with code you trust"), - Line::from(" For more details see https://github.com/openai/codex") + Line::from(" Codex can make mistakes") + .style(Style::default().fg(Color::White)), + Line::from(" Review the code it writes and commands it runs") .style(Style::default().add_modifier(Modifier::DIM)), Line::from(""), Line::from(" Powered by your ChatGPT account"), - Line::from(" Uses your plan's rate limits and training data preferences") - .style(Style::default().add_modifier(Modifier::DIM)), + Line::from(vec![ + Span::raw(" Uses your plan's rate limits and "), + Span::styled( + "\u{1b}]8;;https://chatgpt.com/#settings\u{7}training data preferences\u{1b}]8;;\u{7}", + Style::default().add_modifier(Modifier::UNDERLINED), + ), + ]) + .style(Style::default().add_modifier(Modifier::DIM)), Line::from(""), Line::from(" Press Enter to continue").style(Style::default().fg(LIGHT_BLUE)), ]; @@ -236,7 +255,10 @@ impl AuthModeWidget { fn render_env_var_missing(&self, area: Rect, buf: &mut Buffer) { let lines = vec![ - Line::from("✘ OPENAI_API_KEY not found").style(Style::default().fg(Color::Red)), + Line::from( + " To use Codex with the OpenAI API, set OPENAI_API_KEY in your environment", + ) + .style(Style::default().fg(Color::Blue)), Line::from(""), Line::from(" Press Enter to return") .style(Style::default().add_modifier(Modifier::DIM)), diff --git a/codex-rs/tui/src/onboarding/welcome.rs b/codex-rs/tui/src/onboarding/welcome.rs index a35f6528ab..bcdc5c9aae 100644 --- a/codex-rs/tui/src/onboarding/welcome.rs +++ b/codex-rs/tui/src/onboarding/welcome.rs @@ -18,9 +18,9 @@ pub(crate) struct WelcomeWidget { impl WidgetRef for &WelcomeWidget { fn render_ref(&self, area: Rect, buf: &mut Buffer) { let line = Line::from(vec![ - Span::raw("> "), + Span::raw(">_ "), Span::styled( - "Welcome to Codex, OpenAI's coding agent that runs in your terminal", + "Welcome to Codex, OpenAI's command-line coding agent", Style::default().add_modifier(Modifier::BOLD), ), ]); diff --git a/codex-rs/tui/src/slash_command.rs b/codex-rs/tui/src/slash_command.rs index 0513d64443..ba24ead4f9 100644 --- a/codex-rs/tui/src/slash_command.rs +++ b/codex-rs/tui/src/slash_command.rs @@ -27,15 +27,15 @@ impl SlashCommand { /// User-visible description shown in the popup. pub fn description(self) -> &'static str { match self { - SlashCommand::New => "Start a new chat", - SlashCommand::Init => "Create an AGENTS.md file with instructions for Codex", - SlashCommand::Compact => "Compact the chat history", - SlashCommand::Quit => "Exit the application", - SlashCommand::Diff => "Show git diff (including untracked files)", - SlashCommand::Status => "Show current session configuration and token usage", - SlashCommand::Logout => "Log out of Codex", + SlashCommand::New => "start a new chat during a conversation", + SlashCommand::Init => "create an AGENTS.md file with instructions for Codex", + SlashCommand::Compact => "summarize conversation to prevent hitting the context limit", + SlashCommand::Quit => "exit Codex", + SlashCommand::Diff => "show git diff (including untracked files)", + SlashCommand::Status => "show current session configuration and token usage", + SlashCommand::Logout => "log out of Codex", #[cfg(debug_assertions)] - SlashCommand::TestApproval => "Test approval request", + SlashCommand::TestApproval => "test approval request", } } diff --git a/codex-rs/tui/src/status_indicator_widget.rs b/codex-rs/tui/src/status_indicator_widget.rs index dcb8a5fdbe..513422bb4c 100644 --- a/codex-rs/tui/src/status_indicator_widget.rs +++ b/codex-rs/tui/src/status_indicator_widget.rs @@ -238,7 +238,7 @@ impl WidgetRef for StatusIndicatorWidget { Style::default().fg(Color::Gray).add_modifier(Modifier::DIM), )); spans.push(Span::styled( - "Ctrl c", + "Ctrl C", Style::default() .fg(Color::Gray) .add_modifier(Modifier::DIM | Modifier::BOLD), From 7c20160676d6fd584a01e09d22d371e106e4678f Mon Sep 17 00:00:00 2001 From: ae Date: Thu, 7 Aug 2025 03:55:59 -0700 Subject: [PATCH 2/3] 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 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) { 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> = 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 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", From c4dc6a80bf349641a0270cb2ac78668ebade1849 Mon Sep 17 00:00:00 2001 From: ae Date: Thu, 7 Aug 2025 04:02:58 -0700 Subject: [PATCH 3/3] feat: improve output of /status (#1936) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now it looks like this: ``` /status 📂 Workspace • Path: ~/code/codex/codex-rs • Approval Mode: on-request • Sandbox: workspace-write 👤 Account • Signed in with ChatGPT • Login: example@example.com • Plan: Pro 🧠 Model • Name: ?!?!?!?!?! • Provider: OpenAI 📊 Token Usage • Input: 11940 (+ 7999 cached) • Output: 2639 • Total: 14579 ``` --- codex-rs/tui/src/history_cell.rs | 148 ++++++++++++++++++++++++------- 1 file changed, 118 insertions(+), 30 deletions(-) diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index bbf1d7210c..5d2ea35c4f 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -13,6 +13,7 @@ use codex_core::plan_tool::StepStatus; use codex_core::plan_tool::UpdatePlanArgs; use codex_core::protocol::FileChange; use codex_core::protocol::McpInvocation; +use codex_core::protocol::SandboxPolicy; use codex_core::protocol::SessionConfiguredEvent; use codex_core::protocol::TokenUsage; use codex_login::get_auth_file; @@ -134,6 +135,27 @@ pub(crate) enum HistoryCell { const TOOL_CALL_MAX_LINES: usize = 3; +fn title_case(s: &str) -> String { + if s.is_empty() { + return String::new(); + } + let mut chars = s.chars(); + let first = match chars.next() { + Some(c) => c, + None => return String::new(), + }; + let rest: String = chars.as_str().to_ascii_lowercase(); + first.to_uppercase().collect::() + &rest +} + +fn pretty_provider_name(id: &str) -> String { + if id.eq_ignore_ascii_case("openai") { + "OpenAI".to_string() + } else { + title_case(id) + } +} + impl HistoryCell { /// Return a cloned, plain representation of the cell's lines suitable for /// one‑shot insertion into the terminal scrollback. Image cells are @@ -471,35 +493,65 @@ impl HistoryCell { let mut lines: Vec> = Vec::new(); lines.push(Line::from("/status".magenta())); - // Config - for (key, value) in create_config_summary_entries(config) { - lines.push(Line::from(vec![format!("{key}: ").bold(), value.into()])); - } + let config_entries = create_config_summary_entries(config); + let lookup = |k: &str| -> String { + config_entries + .iter() + .find(|(key, _)| *key == k) + .map(|(_, v)| v.clone()) + .unwrap_or_default() + }; + + // 📂 Workspace + lines.push(Line::from(vec!["📂 ".into(), "Workspace".bold()])); + // Path (home-relative, e.g., ~/code/project) + let cwd_str = match relativize_to_home(&config.cwd) { + Some(rel) if !rel.as_os_str().is_empty() => format!("~/{}", rel.display()), + Some(_) => "~".to_string(), + None => config.cwd.display().to_string(), + }; + lines.push(Line::from(vec![" • Path: ".into(), cwd_str.into()])); + // Approval mode (as-is) + lines.push(Line::from(vec![ + " • Approval Mode: ".into(), + lookup("approval").into(), + ])); + // Sandbox (simplified name only) + let sandbox_name = match &config.sandbox_policy { + SandboxPolicy::DangerFullAccess => "danger-full-access", + SandboxPolicy::ReadOnly => "read-only", + SandboxPolicy::WorkspaceWrite { .. } => "workspace-write", + }; + lines.push(Line::from(vec![ + " • Sandbox: ".into(), + sandbox_name.into(), + ])); lines.push(Line::from("")); - // Auth + // 👤 Account (only if ChatGPT tokens exist), shown under the first block let auth_file = get_auth_file(&config.codex_home); if let Ok(auth) = try_read_auth_json(&auth_file) { - if auth.tokens.as_ref().is_some() { - lines.push(Line::from("signed in with chatgpt".bold())); + if let Some(tokens) = auth.tokens.clone() { + lines.push(Line::from(vec!["👤 ".into(), "Account".bold()])); + lines.push(Line::from(" • Signed in with ChatGPT")); - if let Some(tokens) = auth.tokens.as_ref() { - let info = tokens.id_token.clone(); - if let Some(email) = info.email { - lines.push(Line::from(vec![" login: ".bold(), email.into()])); + let info = tokens.id_token; + if let Some(email) = info.email { + lines.push(Line::from(vec![" • Login: ".into(), email.into()])); + } + + match auth.openai_api_key.as_deref() { + Some(key) if !key.is_empty() => { + lines.push(Line::from(" • Using API key")); } - - match auth.openai_api_key.as_deref() { - Some(key) if !key.is_empty() => { - lines.push(Line::from(" using api key")); - } - _ => { - let plan_text = info - .chatgpt_plan_type - .unwrap_or_else(|| "Unknown".to_string()); - lines.push(Line::from(vec![" plan: ".bold(), plan_text.into()])); - } + _ => { + let plan_text = info + .chatgpt_plan_type + .as_deref() + .map(title_case) + .unwrap_or_else(|| "Unknown".to_string()); + lines.push(Line::from(vec![" • Plan: ".into(), plan_text.into()])); } } @@ -507,20 +559,56 @@ impl HistoryCell { } } - // Token usage - lines.push(Line::from("token usage".bold())); + // 🧠 Model + lines.push(Line::from(vec!["🧠 ".into(), "Model".bold()])); lines.push(Line::from(vec![ - " input: ".bold(), - usage.non_cached_input().to_string().into(), - " ".into(), - format!("(+ {} cached)", usage.cached_input()).into(), + " • Name: ".into(), + config.model.clone().into(), ])); + let provider_disp = pretty_provider_name(&config.model_provider_id); lines.push(Line::from(vec![ - " output: ".bold(), + " • Provider: ".into(), + provider_disp.into(), + ])); + // Only show Reasoning fields if present in config summary + let reff = lookup("reasoning effort"); + if !reff.is_empty() { + lines.push(Line::from(vec![ + " • Reasoning Effort: ".into(), + title_case(&reff).into(), + ])); + } + let rsum = lookup("reasoning summaries"); + if !rsum.is_empty() { + lines.push(Line::from(vec![ + " • Reasoning Summaries: ".into(), + title_case(&rsum).into(), + ])); + } + + lines.push(Line::from("")); + + // 📊 Token Usage + lines.push(Line::from(vec!["📊 ".into(), "Token Usage".bold()])); + // Input: [+ cached] + let mut input_line_spans: Vec> = vec![ + " • Input: ".into(), + usage.non_cached_input().to_string().into(), + ]; + if let Some(cached) = usage.cached_input_tokens { + if cached > 0 { + input_line_spans.push(format!(" (+ {cached} cached)").into()); + } + } + lines.push(Line::from(input_line_spans)); + // Output: + lines.push(Line::from(vec![ + " • Output: ".into(), usage.output_tokens.to_string().into(), ])); + // Total: lines.push(Line::from(vec![ - " total: ".bold(), + " • Total: ".into(), usage.blended_total().to_string().into(), ]));