Skip to content

feat(tui): add /title terminal title configuration#12334

Merged
joshka-oai merged 2 commits intomainfrom
codex/title-command
Mar 19, 2026
Merged

feat(tui): add /title terminal title configuration#12334
joshka-oai merged 2 commits intomainfrom
codex/title-command

Conversation

@yvolovich-cyber
Copy link
Copy Markdown
Contributor

@yvolovich-cyber yvolovich-cyber commented Feb 20, 2026

Problem

When multiple Codex sessions are open at once, terminal tabs and windows are hard to distinguish from each other. The existing status line only helps once the TUI is already focused, so it does not solve the "which tab is this?" problem.

This PR adds a first-class /title command so the terminal window or tab title can carry a short, configurable summary of the current session.

Screenshot

image

Mental model

/statusline and /title are separate status surfaces with different constraints. The status line is an in-app footer that can be denser and more detailed. The terminal title is external terminal metadata, so it needs short, stable segments that still make multiple sessions easy to tell apart.

The /title configuration is an ordered list of compact items. By default it renders spinner,project, so active sessions show lightweight progress first while idle sessions still stay easy to disambiguate. Each configured item is omitted when its value is not currently available rather than forcing a placeholder.

Non-goals

This does not merge /title into /statusline, and it does not add an arbitrary free-form title string. The feature is intentionally limited to a small set of structured items so the title stays short and reviewable.

This also does not attempt to restore whatever title the terminal or shell had before Codex started. When Codex clears the title, it clears the title Codex last wrote.

Tradeoffs

A separate /title command adds some conceptual overlap with /statusline, but it keeps title-specific constraints explicit instead of forcing the status line model to cover two different surfaces.

Title refresh can happen frequently, so the implementation now shares parsing and git-branch orchestration between the status line and title paths, and caches the derived project-root name by cwd. That keeps the hot path cheap without introducing background polling.

Architecture

The TUI gets a new /title slash command and a dedicated picker UI for selecting and ordering terminal-title items. The chosen ids are persisted in tui.terminal_title, with spinner and project as the default when the config is unset. status remains available as a separate text item, so configurations like spinner,status render compact progress like ⠋ Working.

ChatWidget now refreshes both status surfaces through a shared refresh_status_surfaces() path. That shared path parses configured items once, warns on invalid ids once, synchronizes shared cached state such as git-branch lookup, then renders the footer status line and terminal title from the same snapshot.

Low-level OSC title writes live in codex-rs/tui/src/terminal_title.rs, which owns the terminal write path and last-mile sanitization before emitting OSC 0.

Security

Terminal-title text is treated as untrusted display content before Codex emits it. The write path strips control characters, removes invisible and bidi formatting characters that can make the title visually misleading, normalizes whitespace, and caps the emitted length.

References used while implementing this:

Observability

Unknown configured title item ids are warned about once instead of repeatedly spamming the transcript. Live preview applies immediately while the /title picker is open, and cancel rolls the in-memory title selection back to the pre-picker value.

If terminal title writes fail, the TUI emits debug logs around set and clear attempts. The rendered status label intentionally collapses richer internal states into compact title text such as Starting..., Ready, Thinking..., Working..., Waiting..., and Undoing... when status is configured.

Tests

Ran:

  • just fmt
  • cargo test -p codex-tui

At the moment, the red Windows rust-ci failures are due to existing codex-core apply_patch_cli stack-overflow tests that also reproduce on main. The /title-specific codex-tui suite is green.

@yvolovich-cyber yvolovich-cyber changed the title Add /title command for secure terminal title configuration feat(tui): add /title terminal title configuration Feb 20, 2026
@yvolovich-cyber
Copy link
Copy Markdown
Contributor Author

@codex review

@yvolovich-cyber
Copy link
Copy Markdown
Contributor Author

@codex review

@yvolovich-cyber
Copy link
Copy Markdown
Contributor Author

@codex review security in codex-rs/tui/src/terminal_title.rs

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a first-class /title configuration flow to the TUI so terminal tabs/windows can be distinguished across concurrent Codex sessions, including secure OSC 0 title rendering and persisted ordering of title “items”. Also includes an app-server fix to make running-thread resume status reporting consistent.

Changes:

  • Introduces terminal-title OSC writer with sanitization + tests, and wires dynamic title refresh into ChatWidget.
  • Adds /title slash command + bottom-pane picker UI (with live preview + rollback on cancel) and persists config via tui.terminal_title.
  • Fixes a thread resume race in app-server so a running thread reliably reports Active when an active turn snapshot exists.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
codex-rs/tui/src/terminal_title.rs Implements OSC 0 title writing with sanitization and unit tests.
codex-rs/tui/src/slash_command.rs Adds /title to the slash-command set and help text.
codex-rs/tui/src/lib.rs Registers the new terminal_title module.
codex-rs/tui/src/chatwidget.rs Adds terminal title config/defaults, live rendering, preview/rollback mechanics, and refresh hooks.
codex-rs/tui/src/chatwidget/tests.rs Adds tests for preview rollback and status text mapping for title rendering.
codex-rs/tui/src/bottom_pane/title_setup.rs Adds the terminal title picker UI (multi-select + ordering + live preview events).
codex-rs/tui/src/bottom_pane/mod.rs Exposes terminal title picker view + item enum.
codex-rs/tui/src/bottom_pane/snapshots/...terminal_title_setup_basic.snap Adds snapshot coverage for the new picker UI.
codex-rs/tui/src/app_event.rs Adds events for terminal title setup/preview/cancel.
codex-rs/tui/src/app.rs Handles new events and persists tui.terminal_title edits.
codex-rs/core/src/config/types.rs Adds tui.terminal_title to typed config.
codex-rs/core/src/config/mod.rs Plumbs config field into runtime Config and defaults/tests.
codex-rs/core/src/config/edit.rs Adds a config edit helper to persist terminal title items.
codex-rs/core/config.schema.json Adds schema documentation for tui.terminal_title.
codex-rs/app-server/src/codex_message_processor.rs Fixes resume-status race by preferring active turn snapshot over idle watch status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yvolovich-cyber
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown
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

let (items, _) = self.status_line_items_with_invalids();
if items.is_empty() || !items.contains(&StatusLineItem::GitBranch) {
return;

P2 Badge Refresh git-branch title when only /title enables it

Update request_status_line_branch_refresh to consider terminal-title config too. It currently returns unless the status line includes git-branch, but terminal titles now also use the same cached branch value. If a user enables git-branch in /title only, branch lookup is never re-triggered after turn completion, so the title can show a stale branch after git checkout/branch-changing commands.

ℹ️ 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".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Feb 20, 2026
Copy link
Copy Markdown
Contributor Author

@yvolovich-cyber yvolovich-cyber 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

let (items, _) = self.status_line_items_with_invalids();
if items.is_empty() || !items.contains(&StatusLineItem::GitBranch) {
return;

P2 Badge Refresh git-branch title when only /title enables it
Update request_status_line_branch_refresh to consider terminal-title config too. It currently returns unless the status line includes git-branch, but terminal titles now also use the same cached branch value. If a user enables git-branch in /title only, branch lookup is never re-triggered after turn completion, so the title can show a stale branch after git checkout/branch-changing commands.

Addressed it in 2cf7abd05.

What changed:

  • request_status_line_branch_refresh() now refreshes when git-branch is configured in either /statusline or /title
  • added a regression test for the title-only git-branch case after TurnComplete

@yvolovich-cyber
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
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: 2cf7abd055

ℹ️ 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".

@yvolovich-cyber yvolovich-cyber force-pushed the codex/title-command branch 2 times, most recently from 800268f to 9f62b39 Compare February 23, 2026 11:54
@fcoury
Copy link
Copy Markdown
Contributor

fcoury commented Feb 23, 2026

@yvolovich-cyber really great to see the MultiSelectPicker being used in the wild.

I just took this branch for a test drive and it worked beautifully with tmux. I use a configuration where I explicitly show the pane titles and it's so much easier to spot what's happening with this feature in place:

image

Specially for someone who has ten thousand codex worktrees like myself, and I'm pretty sure I'm not the only one 😄

I also did a pass on the code changes and they look good to me 👍

Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

I don't see anything that reset the title after a CMD + C. Can you make sure the title always get reset when we exit Codex?

@yvolovich-cyber
Copy link
Copy Markdown
Contributor Author

yvolovich-cyber commented Feb 23, 2026

I don't see anything that reset the title after a CMD + C. Can you make sure the title always get reset when we exit Codex?

Handled. Terminal-title cleanup now happens in App::drop, so Codex clears the terminal title once on exit, including Ctrl+C / Ctrl+D quit paths and shutdown-complete exit. clear_terminal_title() stays best-effort, TTY-gated, and debug-only on failure.

Copy link
Copy Markdown
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: 6969c2d5a2

ℹ️ 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".

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

Copy link
Copy Markdown
Contributor Author

@joshka-oai CI is green and @codex review came back clean. Could you please redo review?

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

yvolovich-cyber added a commit that referenced this pull request Mar 19, 2026
yvolovich-cyber added a commit that referenced this pull request Mar 19, 2026
@joshka-oai joshka-oai enabled auto-merge (squash) March 19, 2026 17:24
@joshka-oai joshka-oai merged commit 60cd0cf into main Mar 19, 2026
33 checks passed
@joshka-oai joshka-oai deleted the codex/title-command branch March 19, 2026 19:26
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants