Skip to content

feat: multi-line text answers in ask-user tool#18741

Merged
jackwotherspoon merged 14 commits into
mainfrom
ask-user/multi-line-text-question
Feb 11, 2026
Merged

feat: multi-line text answers in ask-user tool#18741
jackwotherspoon merged 14 commits into
mainfrom
ask-user/multi-line-text-question

Conversation

@jackwotherspoon

Copy link
Copy Markdown
Collaborator

Summary

This PR enables multi-line text input for the ask_user tool for text questions, allowing users to provide more detailed answers.

Review page for ask user shows full answer, success tool call truncates after 5 lines to keep output concise.

mult-line.text.ask.user.mp4

Details

  • Multi-line Input Support:
    • Updated AskUserDialog to support multi-line buffers for text questions by setting singleLine: false and increasing the viewport height to 3 so three lines are shown.
    • Refined TextInput submission logic to use Command.SUBMIT matcher. Enter now submits, while shortcuts like Shift+Enter,Ctrl+Enter, and Ctrl+J correctly insert newlines.
  • Formatting & Alignment:
    • Implemented logic to calculate indentation for subsequent lines in the ask_user tool output (Core), ensuring they align with the first line's starting position (after the header and arrow).
  • Truncation & Semantic Styling:
    • Implemented truncation for answers exceeding 5 lines in the terminal display. The full text is preserved for the model, but the UI shows a ... x more lines hidden message.
    • Introduced a <secondary> tag in the InlineMarkdownRenderer to support themed dimmed text.

Related Issues

Fixes #18328

How to Validate

  1. Test Multi-line Input:
    • Trigger an ask_user call with a text type question.
    • Type text and use Shift+Enter or Ctrl+J to insert multiple newlines.
    • Verify the input field shows multiple lines and allows navigation between them.
  2. Verify Formatting:
    • On the Review tab, verify multi-line answers are correctly aligned.
    • Submit the dialog and verify the tool success message in the chat history is properly indented.
  3. Verify Truncation:
    • Submit an answer with 7 lines.
    • Verify only the first 5 lines are visible, followed by a greyed-out ... 2 more lines hidden message.
  4. Run Automated Tests:
    • npm test -w @google/gemini-cli-core -- src/tools/ask-user.test.ts
    • npm test -w @google/gemini-cli -- src/ui/utils/InlineMarkdownRenderer.test.ts src/ui/utils/MarkdownDisplay.test.tsx

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
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@jackwotherspoon jackwotherspoon requested a review from a team as a code owner February 10, 2026 17:25
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @jackwotherspoon, 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 significantly enhances the ask_user tool by introducing support for multi-line text answers. It refines the user input experience, ensures correct formatting and alignment of multi-line responses in the terminal, and implements intelligent truncation for lengthy answers to maintain UI conciseness while retaining full data for the underlying model. Additionally, it introduces a new markdown tag for secondary-colored text.

Highlights

  • Multi-line Text Input: Enabled multi-line text input for the ask_user tool, allowing users to provide more detailed answers.
  • Improved Input Submission: Refined TextInput submission logic to differentiate Enter for submission from Shift+Enter, Ctrl+Enter, and Ctrl+J for inserting newlines.
  • Multi-line Answer Formatting: Implemented proper indentation for subsequent lines in multi-line answers displayed in the ask_user tool output.
  • Answer Truncation: Introduced truncation for ask_user answers exceeding 5 lines in the terminal display, showing a '... x more lines hidden' message while preserving the full text for the model.
  • Secondary Text Styling: Added a new <secondary> tag to InlineMarkdownRenderer to support themed dimmed text, used for the truncation message.
Changelog
  • packages/cli/src/ui/components/AskUserDialog.tsx
    • Refactored answer mapping for clarity in the review view.
    • Configured TextQuestionView to support multi-line input by setting singleLine to false and increasing viewport height to 3.
    • Removed conditional check for val.trim() before calling onAnswer in handleSubmit.
  • packages/cli/src/ui/components/shared/TextInput.tsx
    • Updated text input submission logic to use keyMatchers for Command.SUBMIT, allowing for more nuanced handling of Enter key presses.
  • packages/cli/src/ui/utils/InlineMarkdownRenderer.test.ts
    • Added a test case to verify the plain text length calculation for the new <secondary> markdown tag.
  • packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx
    • Defined constants for <secondary> tag lengths.
    • Modified the markdown parsing regex to recognize and render content within <secondary> tags with a dimmed color.
    • Updated getPlainTextLength to correctly account for <secondary> tags.
  • packages/cli/src/ui/utils/MarkdownDisplay.test.tsx
    • Added a test to confirm that text enclosed in <secondary> tags is rendered with the secondary color.
  • packages/cli/src/ui/utils/snapshots/MarkdownDisplay.test.tsx.snap
    • Updated snapshot tests to reflect the rendering of <secondary> tags.
  • packages/core/src/tools/ask-user.test.ts
    • Added a new test to verify that multi-line answers are truncated in the returnDisplay but fully preserved in llmContent.
  • packages/core/src/tools/ask-user.ts
    • Implemented logic to format multi-line answers with proper indentation and to truncate them after five lines, displaying a 'more lines hidden' message using the new <secondary> tag.
Activity
  • The pull request author has provided a detailed summary, specific implementation details, related issues, and comprehensive validation steps.
  • A pre-merge checklist has been completed, indicating that documentation, tests, and platform validations have been addressed.
  • No human comments or reviews have been posted yet.
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.

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

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.

Code Review

This pull request successfully introduces multi-line text input capabilities for the ask_user tool, enhancing user interaction by allowing more detailed responses. It also includes proper truncation for terminal display and semantic styling for hidden lines, which improves readability. The changes are well-tested with new unit tests covering the multi-line input and truncation logic. The refactoring of TextInput submission logic to use keyMatchers is a good step towards consistency and configurability.

Comment thread packages/cli/src/ui/components/AskUserDialog.tsx
@github-actions

github-actions Bot commented Feb 10, 2026

Copy link
Copy Markdown

Size Change: +824 B (0%)

Total Size: 24.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.3 MB +824 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@gemini-cli gemini-cli Bot added area/core Issues related to User Interface, OS Support, Core Functionality area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 10, 2026
@jerop jerop requested a review from jacob314 February 10, 2026 21:42
keypressHandler({
name: keyName,
shift: false,
alt: false,

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.

why is this line in the PR? seems unrelated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

because i moved text input to look for keymatcher submit vs just "Enter" key.

So all the combos need to be set to false otherwise it thinks its a newline and not a submission.

https://github.com/google-gemini/gemini-cli/pull/18741/changes#diff-d3850bd5301440e01adfd6d34bfd3b6fbbfd546bad49cf15860c8c7051c7fab4L48

}}
/>
{isChecked && !question.multiSelect && (
{isChecked && !question.multiSelect && !context.isSelected && (

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this fixes checkmark appearing during typing. Now only shows if you stop focus on answer (arrow up to different answer or submit to another question)

Approves plan and allows tools to run automatically
2. Yes, manually accept edits
Approves plan but requires confirmation for each tool
● 3. Add tests

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.

nice to see this confusing check box gone.

Comment thread packages/cli/src/ui/components/AskUserDialog.tsx Outdated
Comment thread packages/core/src/tools/ask-user.ts Outdated
const indent = ' '.repeat(prefix.length);

const lines = answer.split('\n');
if (lines.length > 5) {

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.

why are we truncating here? we should use MaxSizedBox at the UI layer if we really need to truncate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Was to keep successful tool calls in history concise and truncated, but removed it. Will follow up with proper truncation PR.

@jacob314 jacob314 left a comment

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.

lgtm
This is good enough to land. Next steps:

  1. Make the mouse work to click to move the cursor.
  2. Consider doing something about escape. Perhaps we should prevent having escape immediately cancel as pressing escape twice clears in the input prompt.

@jackwotherspoon jackwotherspoon added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 5baad10 Feb 11, 2026
27 checks passed
@jackwotherspoon jackwotherspoon deleted the ask-user/multi-line-text-question branch February 11, 2026 14:24
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multi-line custom input in AskUser tool

3 participants