Skip to content

fix(tui): enter bash mode for large pasted ! commands - #2331

Open
cipheraxat wants to merge 2 commits into
MoonshotAI:mainfrom
cipheraxat:fix/bash-mode-large-paste
Open

fix(tui): enter bash mode for large pasted ! commands#2331
cipheraxat wants to merge 2 commits into
MoonshotAI:mainfrom
cipheraxat:fix/bash-mode-large-paste

Conversation

@cipheraxat

Copy link
Copy Markdown

Related Issue

Resolve #2319

Problem

Pasting a shell command that starts with ! into an empty prompt only enters bash mode when the paste is small. Once it crosses the fold threshold (>1000 chars or >10 lines), pi-tui replaces it with a [paste #…] marker, and the editor was checking getText() for the leading ! — so it never saw it and submitted the whole thing as a normal prompt.

What changed

Switched that check to getExpandedText() so we look at the real pasted content, not the marker. Same strip-the-! behavior as a short paste. Added tests around both fold boundaries.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Large pastes get folded into a marker, so checking getText() for a
leading ! missed them. Use getExpandedText() instead.
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ed63e75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 420bcf4340

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (emptyPromptBeforeInput && this.inputMode === 'prompt' && this.getText().startsWith('!')) {
// Enter bash mode when `!...` is pasted into an empty prompt. Check
// getExpandedText() so folded large pastes still match on the leading `!`.
const expanded = this.getExpandedText();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid expanding folded pastes on every edit

When the editor already contains a folded paste marker, any subsequent keystroke reaches this line with emptyPromptBeforeInput === false, but getExpandedText() still expands every stored paste before the guard rejects the bash-mode path. For large pasted prompts, this re-materializes the hidden content on each edit and can make normal typing lag; compute the expanded text only after confirming the prompt was empty and still in prompt mode.

Useful? React with 👍 / 👎.

Addressing review feedback: getExpandedText() was running on every
keystroke, re-materializing folded paste content each time. Move it
inside the empty-prompt guard.
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.

Large or multiline pasted ! commands are routed as prompts

1 participant