Skip to content

Feature request: zsh-style Ctrl+R reverse search in the TUI composer #16249

Closed as duplicate

Description

@PanJason

Summary

I’d like the Codex TUI composer to support a zsh-style backward incremental search for prior prompts, triggered by Ctrl+R.

Motivation

When working in long-running conversations or forked sessions, I found that the up-and-down movement to look for commands is not very convenient. Basically, I asked the codex to run some experiments, then performed analysis with other prompts, and then reran the experiments with a similar old command with small tweaks to the condition. I need to scroll up and down many times to look for the cmd. I know I can dump this as a markdown file, but doing small trial experiments makes dumping to a file each time cumbersome.
zsh allows me to use ctrl+R to reverse search previous commands, we can do the same thing here, even better with regex matching

Proposed behavior

While focus is in the composer:

  • Ctrl+R enters reverse search mode.
  • The footer shows bck-i-search.
  • Typing updates the search incrementally.
  • Matching uses regex.
  • Search starts from the current open session, newest prompt first.
  • Search then continues through related forked sessions.
  • Pressing Ctrl+R again moves to the next older match.
  • Enter accepts the current match into the composer.
  • Esc or Ctrl+G cancels search and restores the original draft.
  • When a match is visible, the cursor moves to the start of the matched text and the matched region is underlined, similar to zsh.

Expected UX details

  • Empty query should keep the original draft visible instead of immediately replacing it with the most recent prompt.
  • Repeated Ctrl+R presses should advance one visible match at a time.
  • If the underlying history format contains mirrored copies of the same submitted prompt, search should avoid surfacing those as duplicate adjacent results.

Why this would help

This would make it much faster to:

  • reuse older prompts
  • iterate on prompts across forks
  • edit without manually scrolling

Screenshots

I actually have already implemented the feature (with codex itself), tested a bit directly from TUI:
Prompt history:

Hello world! I am going to chat with you to test some functionalities. Now you act as a travel planner agent. I want to discuss my summer travel plan with you
FORK
I am going to do a summer internship in US. Tight budget, where do you recommend me to go? Better somewhere with beach and sunshine, somewhere i can lie down and relax.
I am going to do an internship at Sunnyvale california.
  • Ctrl+R enters reverse search mode. Correct footer position. Under score the matching. Enter gives the confirmation
Image
  • Typing updates the search incrementally:
Image
  • Matching using regex:
Image
  • Pressing ctrl-R goes to the earlier one:
Image
  • Matching failure shows red failing and backspace gives matching
Image

Environment

  • Codex TUI
  • Docker Ubuntu 24.04 dev environment on Apple Silicon Mac

Offer to contribute

I have a working implementation and tests locally, if this is something the team would want as an invited PR. The impl is here on my github https://github.com/PanJason/codex/tree/main

Activity

  1. added
    enhancement
    CLI
    TUI
    on Mar 30, 2026
  2. removed
    CLI
    on Mar 30, 2026
  3. PanJason commented on Mar 30, 2026

    @PanJason
    Author

    Anyone interested in this feature?

  4. PanJason commented on Mar 31, 2026

    @PanJason
    Author

    @etraut-openai I have the code. Is it possible to create a pr for this?

  5. etraut-openai commented on Mar 31, 2026

    @etraut-openai
    Contributor

    @PanJason, we prioritize feature requests based on community upvotes. This issue hasn't received any upvotes yet, so it's very far down on the priority list at the moment.

  6. PanJason commented on Mar 31, 2026

    @PanJason
    Author

    @etraut-openai Thanks for the response. I found a previous feature request with 26 upvotes. This functionality is very useful for me. Before acceptance, I will keep rebasing it over the current main so it is always in a mergeable state.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions