Skip to content

fix(input): strip leading ! when entering bash mode (#662) - #947

Merged
kevincodex1 merged 1 commit into
mainfrom
fix/issue-662-bash-mode-clear-input
Apr 29, 2026
Merged

kevincodex1 merged 1 commit into
mainfrom
fix/issue-662-bash-mode-clear-input

Conversation

@gnanam1990

Copy link
Copy Markdown
Collaborator

Summary

Strip the leading ! from the prompt buffer when typing a bare ! enters bash mode, so the mode character does not stick around as visible text.

Closes #662

Problem

When a user typed ! into an empty prompt, OpenClaude entered bash mode (the prompt prefix turned into the bash indicator) but the literal ! was still in the input buffer. Bash mode was already implied by the prefix, so the extra character was both visually wrong and meant the user had to backspace before typing a command.

Root Cause

src/components/PromptInput/PromptInput.tsx had two separate branches in the onChange handler for entering bash mode:

  1. Single-char insertion (typing ! into empty input) — called onModeChange('bash') and returned without updating the input buffer.
  2. Multi-char insertion into empty input (e.g. tab-accepting !gcloud auth login) — called getValueFromInput(value) to strip the leading ! and updated the buffer.

Only path #2 actually stripped the mode character, so the bare-! case left the ! in place.

Fix

Consolidated both paths through a new pure helper detectModeEntry in inputModes.ts that returns the new mode plus the stripped buffer value (or null when no mode change applies). The PromptInput onChange runs a single update path, so the mode character cannot leak into the buffer.

Files Changed

  • src/components/PromptInput/inputModes.ts — added detectModeEntry pure helper + ModeEntryDecision type.
  • src/components/PromptInput/PromptInput.tsx — onChange uses the helper, replacing the two-branch single-char/multi-char logic.
  • src/components/PromptInput/inputModes.test.ts — new test file with a regression case for bare-! into empty input.

Verification

Automated

  • New regression test added: detectModeEntry > strips the mode character when typing ! into empty input
  • bun test src/components/PromptInput/inputModes.test.ts — 13 pass, 0 fail
  • Full suite: same 4 pre-existing failures as main, no new regressions
  • Typecheck: no new errors in the changed files

Manual

  • Repro on main: launch openclaude → press ! → bash mode prefix appears but ! stays in the buffer.
  • With this fix: press ! → bash mode prefix appears and the buffer is empty.
  • Multi-char paste path (!ls -la) still works: enters bash mode and buffer shows ls -la.

Risk / Side Effects

Behavior change is limited to the input mode-entry path. The single-char-into-non-empty edge case (typing ! at the start of existing text) now also strips the !, matching the multi-char branch and bash mode semantics. No provider routing, network, or fingerprint surfaces touched.

How to Test This PR Locally

gh pr checkout <PR-number>
bun install
bun run build
bun start
# In the prompt, press `!` — bash mode should engage and the buffer should be empty.

The PromptInput onChange handler had two branches for entering bash
mode: a single-char path that just toggled the mode and a multi-char
paste path that also stripped the leading `!` from the buffer. The
single-char path returned without stripping, so typing a bare `!` into
empty input switched modes but left the literal `!` visible.

Consolidated both paths through a new pure helper `detectModeEntry`
that returns the new mode plus the stripped buffer value, so there is
no longer a branch where the mode character can leak into the buffer.

Fixes #662
@kevincodex1
kevincodex1 merged commit 5943c5c into main Apr 29, 2026
7 checks passed
hotmanxp pushed a commit to hotmanxp/openclaude that referenced this pull request May 1, 2026
The PromptInput onChange handler had two branches for entering bash
mode: a single-char path that just toggled the mode and a multi-char
paste path that also stripped the leading `!` from the buffer. The
single-char path returned without stripping, so typing a bare `!` into
empty input switched modes but left the literal `!` visible.

Consolidated both paths through a new pure helper `detectModeEntry`
that returns the new mode plus the stripped buffer value, so there is
no longer a branch where the mode character can leak into the buffer.

Fixes Twigpine#662
The-FOOL-00 pushed a commit to The-FOOL-00/openclaude that referenced this pull request May 24, 2026
The PromptInput onChange handler had two branches for entering bash
mode: a single-char path that just toggled the mode and a multi-char
paste path that also stripped the leading `!` from the buffer. The
single-char path returned without stripping, so typing a bare `!` into
empty input switched modes but left the literal `!` visible.

Consolidated both paths through a new pure helper `detectModeEntry`
that returns the new mode plus the stripped buffer value, so there is
no longer a branch where the mode character can leak into the buffer.

Fixes Twigpine#662
discopops pushed a commit to discopops/openclaude that referenced this pull request May 28, 2026
The PromptInput onChange handler had two branches for entering bash
mode: a single-char path that just toggled the mode and a multi-char
paste path that also stripped the leading `!` from the buffer. The
single-char path returned without stripping, so typing a bare `!` into
empty input switched modes but left the literal `!` visible.

Consolidated both paths through a new pure helper `detectModeEntry`
that returns the new mode plus the stripped buffer value, so there is
no longer a branch where the mode character can leak into the buffer.

Fixes Twigpine#662
@jatmn
jatmn deleted the fix/issue-662-bash-mode-clear-input branch September 9, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bash mode doesn't clear '!'

2 participants