openai / openai/codex

Shell mode should only be triggered when "!" is typed with the cursor at position 0

Open
#41,530 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI TUI
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

v0.151.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.6-sol high

What platform is your computer?

Linux 7.1.10-arch1-1 x86_64 unknown

What terminal emulator and version are you using (if applicable)?

Kitty

Codex doctor report
Not relevant.
What issue are you seeing?

Shell mode is triggered any time a "!" touches the left side of the command prompt, regardless of whether it was due to a user typing "!" at that position, or them deleting text in front of a "!".

Once shell mode is triggered, even via this unintentional route, it persists, even after the "!" is deleted, and requires stopping and hitting backspace at position 0 to return to normal input mode.

What steps can reproduce the bug?

Starting from an empty input:

  1. Write "Yes! I agree."
  2. Press <home> or <ctrl-a> to position the cursor at 0
  3. Press <del><del><del><del>

At step 3, after deleting the first 3 characters, the "!" touches the left side and codex enters shell mode.
9/10 times, this is due to editing text with "!", not an attempt to enter shell mode.

If I then press <del> again, I would expect that shell mode would exit and codex would resume normal text editing, but it doesn't -- shell mode persists for the remainder of the input until I explicit press <backspace> from position 0.

The net effect:

  • shell mode works great when I trigger it intentionally, by starting a prompt with "!"
  • any time I'm editing text that contains a "!" and that "!" accidentally touches the left side of the input field, I end up in command mode and have to jump through some extra hoops before I can actually enter the edited prompt.
What is the expected behavior?
  • "!" entered by a user at position 0 triggers shell mode
  • deleting characters preceding a "!" either (a) does not trigger shell mode, or (b) triggers shell mode unless a user deletes another character, which is a good sign they were just editing text.
Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the editing sequence in the Codex CLI: type “Yes! I agree.”, move to position 0, and delete characters until the exclamation mark reaches the prompt start. Trace the input-handling entry point that switches to shell mode, then verify that typing “!” at position 0 still works while deletion does not leave shell mode active after the exclamation mark is removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.