Skip to content

Conversation

@aibrahim-oai
Copy link
Collaborator

Motivation

  • Provide a concise, helpful terminal/tab title derived from the first user request so the TUI session is easier to identify (similar to editors that set terminal titles).
  • Avoid persistent background requests by using a one-shot sub-conversation to generate a short title.
  • Keep the title generation unobtrusive and limited in scope (max 4 words).

Description

  • Add two new app events: AppEvent::GenerateTerminalTitle { request: String } and AppEvent::SetTerminalTitle(String) in tui/src/app_event.rs to request and apply titles.
  • Trigger a one-shot generation after the first user message by setting terminal_title_requested in chatwidget and sending GenerateTerminalTitle from codex-rs/tui/src/chatwidget.rs.
  • Implement generate_terminal_title in codex-rs/tui/src/app.rs to spawn a short-lived conversation with constrained instructions and extract a cleaned title (max 4 words) from the TaskComplete output.
  • Add an OSC-based ANSI command SetTerminalTitle and a helper Tui::set_terminal_title in codex-rs/tui/src/tui.rs to set the terminal/tab title using �]0;TITLE�.
  • Update test scaffolding in codex-rs/tui/src/chatwidget/tests.rs to initialize the new terminal_title_requested field.

Testing

  • Ran just fmt in codex-rs which completed but emitted warnings about imports_granularity requiring nightly; formatting otherwise ran.
  • Ran just fix -p codex-tui to apply Clippy fixes and auto-corrections and it completed successfully.
  • Ran cargo test -p codex-tui and the test suite passed; there were legacy snapshot format warnings that do not indicate failures.

Codex Task

@aibrahim-oai aibrahim-oai marked this pull request as draft January 7, 2026 08:40
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6e74b2c08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +127 to +128
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
write!(f, "\x1b]0;{}\x07", self.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Sanitize terminal title to prevent OSC/ANSI injection

The title text is written directly into an OSC sequence without filtering. Because the title comes from model output that is derived from user input, a user can prompt-inject control characters (e.g., ESC/BEL or OSC 52 sequences) into the generated title, which will then be interpreted by the terminal when SetTerminalTitle is emitted. In terminals that honor OSC, this can lead to unintended side effects such as clipboard writes or additional control sequences. Consider stripping control characters or whitelisting printable characters before writing the title.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants