Feature request: zsh-style Ctrl+R reverse search in the TUI composer
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+Renters 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+Ragain moves to the next older match. Enteraccepts the current match into the composer.EscorCtrl+Gcancels 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+Rpresses 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+Renters reverse search mode. Correct footer position. Under score the matching. Enter gives the confirmation
<img width="478" height="70" alt="Image" src="https://github.com/user-attachments/assets/328ec244-53a7-44c4-a342-515fb84f4db5" />
- Typing updates the search incrementally:
<img width="478" height="70" alt="Image" src="https://github.com/user-attachments/assets/296cc56d-ce18-40f2-9d01-e2fc1cab3f26" />
- Matching using regex:
<img width="478" height="70" alt="Image" src="https://github.com/user-attachments/assets/3b643680-4d34-43ca-886c-d1f2b46dff41" />
- Pressing
ctrl-Rgoes to the earlier one:
<img width="1371" height="70" alt="Image" src="https://github.com/user-attachments/assets/030df7ae-98ed-45e2-beb7-bdc05aeb01cf" />
- Matching failure shows red failing and backspace gives matching
<img width="303" height="70" alt="Image" src="https://github.com/user-attachments/assets/ec2e0a7c-d05e-42f9-adab-fb9d74683815" />
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
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗