Skip to content

fix(cli): insert voice transcription at cursor position instead of ap…#26287

Merged
Abhijit-2592 merged 3 commits intogoogle-gemini:mainfrom
Zheyuan-Lin:fix/voice-transcription-cursor-insert
May 1, 2026
Merged

fix(cli): insert voice transcription at cursor position instead of ap…#26287
Abhijit-2592 merged 3 commits intogoogle-gemini:mainfrom
Zheyuan-Lin:fix/voice-transcription-cursor-insert

Conversation

@Zheyuan-Lin
Copy link
Copy Markdown
Contributor

Summary

Voice transcription text was always appended to the end of the input buffer, ignoring the cursor position.

Details

Capture the cursor offset (via getOffset()) when recording starts alongside the existing text baseline snapshot.
On each transcription event, splice the text at that fixed offset instead of appending.
On turnComplete, advance the baseline so subsequent speech turns chain correctly after the previous one.

Related Issues

Fixes #25494

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

@Zheyuan-Lin Zheyuan-Lin requested a review from a team as a code owner April 30, 2026 20:41
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the user experience for voice transcription in the CLI by respecting the cursor position during text input. By capturing the cursor offset at the start of a recording session and maintaining a baseline, the system now correctly splices transcribed text into the existing buffer rather than forcing it to the end. This ensures that users can insert voice-dictated text into the middle of existing content seamlessly.

Highlights

  • Cursor-Aware Transcription: Updated the voice transcription logic to insert text at the current cursor position instead of always appending to the end of the buffer.
  • Baseline Management: Introduced a baseline cursor offset to track the insertion point, ensuring that subsequent transcription turns correctly chain after the previous text.
  • Test Coverage: Added a new test case to verify correct insertion behavior when the buffer contains text both before and after the cursor.
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.

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

This pull request updates the voice mode transcription logic to support inserting text at the current cursor position rather than always appending to the end of the buffer. It introduces a new ref to track the cursor offset at the start of a turn and refactors the text construction logic to preserve any text following the cursor. Corresponding tests were updated to verify correct cursor placement and text insertion. Feedback was provided regarding the need for a separator space between the transcription and the trailing text, as well as suggestions for sanitizing the transcribed text to prevent prompt injection.

Note: Security Review is unavailable for this PR.

Comment thread packages/cli/src/ui/hooks/useVoiceMode.ts Outdated
@gemini-cli gemini-cli Bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Apr 30, 2026
Copy link
Copy Markdown
Contributor

@devr0306 devr0306 left a comment

Choose a reason for hiding this comment

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

The code changes look excellent. You correctly isolated the cursor offset and updated the text splicing logic instead of blind appending. I've run the related InputPrompt test suite and it passes locally, and I see you've included a specific new test for this behavior. Approved!

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request May 1, 2026
- BerriAI/litellm#26969: tool-permission guardrail tightening (merge-after-nits)
- BerriAI/litellm#26967: VCR Redis observability (merge-as-is)
- google-gemini/gemini-cli#26303: brain/critique role split + iteration (needs-discussion)
- google-gemini/gemini-cli#26287: voice transcription cursor-position insert (merge-after-nits)
- google-gemini/gemini-cli#26274: ssh:// extension install scheme (merge-as-is)
@devr0306 devr0306 added this pull request to the merge queue May 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 1, 2026
@Abhijit-2592 Abhijit-2592 added this pull request to the merge queue May 1, 2026
@Abhijit-2592 Abhijit-2592 removed this pull request from the merge queue due to a manual request May 1, 2026
@Abhijit-2592 Abhijit-2592 added this pull request to the merge queue May 1, 2026
Merged via the queue into google-gemini:main with commit 7213822 May 1, 2026
27 checks passed
TirthNaik-99 pushed a commit to TirthNaik-99/gemini-cli that referenced this pull request May 4, 2026
kimjune01 pushed a commit to kimjune01/gemini-cli-claude that referenced this pull request May 6, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Voice] Cursor-Aware Insertion

3 participants