Skip to content

fix: expand paste placeholders in TextInput on submit#19946

Merged
jackwotherspoon merged 5 commits intogoogle-gemini:mainfrom
Jefftree:paste-fix
Mar 7, 2026
Merged

fix: expand paste placeholders in TextInput on submit#19946
jackwotherspoon merged 5 commits intogoogle-gemini:mainfrom
Jefftree:paste-fix

Conversation

@Jefftree
Copy link
Copy Markdown
Contributor

@Jefftree Jefftree commented Feb 22, 2026

Summary

Fixes large pastes in TextInput (used by action-required dialogs like "suggest changes") being submitted as literal placeholder strings (e.g. [Pasted Text: 9 lines]) instead of the actual pasted content.

Details

When a paste exceeds 5 lines or 500 chars, gemini-cli stores the real content in buffer.pastedContent and shows a compact placeholder in the input. InputPrompt already expanded these placeholders before submit, but TextInput was calling onSubmit(text) directly, sending the raw placeholder string to the model.

The fix expands placeholders in TextInput.handleKeyPress before calling onSubmit, using the keys from buffer.pastedContent directly — no new imports or shared utilities needed.

Related Issues

Closes #19944
Closes #19238

How to Validate

  1. npm run build && npm start
  2. Ask gemini to edit a file, wait for the action-required approval prompt
  3. Choose "suggest changes"
  4. Paste 5+ lines into the input and submit
  5. Gemini should receive and respond to the actual pasted content, not [Pasted Text: N lines]

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run

@Jefftree Jefftree requested a review from a team as a code owner February 22, 2026 19:52
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Jefftree, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the TextInput component where large pasted content was not correctly processed upon submission. The change ensures that any placeholder text representing a larger paste is expanded to its original content before being passed to the onSubmit handler, thereby maintaining data integrity and improving user experience in interactive prompts.

Highlights

  • Paste Placeholder Expansion: Implemented logic within the TextInput component to expand paste placeholders (e.g., '[Pasted Text: 9 lines]') into their actual content before submission, preventing literal placeholder strings from being sent.
  • Bug Fix: Resolved an issue where large pastes in TextInput were submitted as placeholder strings instead of the intended content, particularly affecting action-required dialogs like 'suggest changes'.
  • Test Coverage: Added new unit tests to TextInput.test.tsx to ensure that paste placeholders are correctly expanded on submit and that normal text submission remains unaffected.
Changelog
  • packages/cli/src/ui/components/shared/TextInput.test.tsx
    • Added a test case to verify that paste placeholders are expanded to their real content on submit.
    • Added a test case to confirm that text is submitted unchanged when no pasted content is present.
  • packages/cli/src/ui/components/shared/TextInput.tsx
    • Modified the handleKeyPress function to process and expand paste placeholders before calling the onSubmit callback.
    • Updated the dependency array for the useKeypress hook to include buffer.pastedContent.
Activity
  • The author has added new tests to validate the fix.
  • The author has validated the changes on MacOS using npm run.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request correctly addresses the issue where large pastes in TextInput were being submitted as literal placeholder strings. However, the expansion logic in TextInput.tsx has a potential bug when multiple pastes are present due to placeholder string overlapping. I've suggested a regex-based approach that is more robust and efficient, following patterns already established in the codebase.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Feb 22, 2026
Copy link
Copy Markdown
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

I think a small shared helper for the paste expansion will help reduce the tests and make sure things don't drift in the future.

@Jefftree Jefftree force-pushed the paste-fix branch 2 times, most recently from 1e62cb7 to 57b71b2 Compare February 25, 2026 20:36
@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 26, 2026
Copy link
Copy Markdown
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

Feedback on plan worked great and expanded! 👍

I think we may be missing one spot though. The ask user tool is not expanding the pastes... @Jefftree can you see if there is one more call site that needs to use the new helper function?

The file in question is AskUserDialog.tsx to update.

Image

@Jefftree
Copy link
Copy Markdown
Contributor Author

Jefftree commented Mar 5, 2026

Feedback on plan worked great and expanded! 👍

I think we may be missing one spot though. The ask user tool is not expanding the pastes... @Jefftree can you see if there is one more call site that needs to use the new helper function?

The file in question is AskUserDialog.tsx to update.

Image

Found the code path. Same target as #19286, fixed!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

need to expand here as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and expand here

@SandyTao520
Copy link
Copy Markdown
Contributor

Overall LGTM, please fix the tests and the 2 remaining spots we're not expanding the placeholder.

@Jefftree
Copy link
Copy Markdown
Contributor Author

Jefftree commented Mar 6, 2026

Fixed.

Overall LGTM, please fix the tests and the 2 remaining spots we're not expanding the placeholder.

@jackwotherspoon
Copy link
Copy Markdown
Collaborator

Looks like there may be a related test failure to take a look at @Jefftree

@Jefftree
Copy link
Copy Markdown
Contributor Author

Jefftree commented Mar 6, 2026

Looks like there may be a related test failure to take a look at @Jefftree

Done.

Jefftree and others added 2 commits March 6, 2026 16:43
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@SandyTao520 SandyTao520 enabled auto-merge March 6, 2026 22:44
@SandyTao520 SandyTao520 dismissed stale reviews from jackwotherspoon and scidomino March 6, 2026 22:55

done

@SandyTao520 SandyTao520 added this pull request to the merge queue Mar 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 6, 2026
@jackwotherspoon jackwotherspoon added this pull request to the merge queue Mar 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 6, 2026
@SandyTao520 SandyTao520 added this pull request to the merge queue Mar 7, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 7, 2026
@jackwotherspoon jackwotherspoon added this pull request to the merge queue Mar 7, 2026
Merged via the queue into google-gemini:main with commit 0fd09e0 Mar 7, 2026
27 checks passed
kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 12, 2026
…19946)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…19946)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
…19946)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
SUNDRAM07 pushed a commit to SUNDRAM07/gemini-cli that referenced this pull request Mar 30, 2026
…19946)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
warrenzhu25 pushed a commit to warrenzhu25/gemini-cli that referenced this pull request Apr 9, 2026
…19946)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large pastes in TextInput dialogs are not replaced and [Pasted Text: X lines] is sent to Gemini Collapsed paste doesn't work in Ask User

4 participants