fix(input): strip leading ! when entering bash mode (#662) - #947
Merged
Merged
Conversation
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
approved these changes
Apr 29, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsxhad two separate branches in the onChange handler for entering bash mode:!into empty input) — calledonModeChange('bash')andreturned without updating the input buffer.!gcloud auth login) — calledgetValueFromInput(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
detectModeEntryininputModes.tsthat returns the new mode plus the stripped buffer value (ornullwhen 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— addeddetectModeEntrypure helper +ModeEntryDecisiontype.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
detectModeEntry > strips the mode character when typing ! into empty inputbun test src/components/PromptInput/inputModes.test.ts— 13 pass, 0 failmain, no new regressionsManual
main: launch openclaude → press!→ bash mode prefix appears but!stays in the buffer.!→ bash mode prefix appears and the buffer is empty.!ls -la) still works: enters bash mode and buffer showsls -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