fix(cli): resolve Ghostty/raw-mode False Cancellation in oauth flow#25026
fix(cli): resolve Ghostty/raw-mode False Cancellation in oauth flow#25026DavidAPierce merged 5 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello, 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 CLI's OAuth authentication flow that caused premature cancellations in certain terminal environments. By refining the detection mechanism for user-initiated cancellations, the change ensures a more reliable and stable authentication experience, particularly for users of Ghostty and VS Code WSL terminals. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the OAuth2 authentication process where Ctrl+C signals were being misinterpreted, leading to false cancellations in certain terminal environments (e.g., Ghostty, VS Code WSL). The stdinHandler in oauth2.ts has been updated to only trigger cancellation when a lone 0x03 byte (Ctrl+C) is received, ignoring 0x03 when it's part of a multi-byte escape sequence. A new test case has been added to oauth2.test.ts to specifically verify this corrected behavior. There is no feedback to provide on the review comments, as none were provided.
DavidAPierce
left a comment
There was a problem hiding this comment.
LGTM.
Thank you for your contribution!
…oogle-gemini#25026) Co-authored-by: David Pierce <davidapierce@google.com>
…oogle-gemini#25026) Co-authored-by: David Pierce <davidapierce@google.com>
Summary
This PR resolves a blocking bug where the
/authOAuth flow prematurely aborts with a "cancelled by user" error when running Gemini CLI inside the Ghostty terminal or VS Code WSL terminal.Details
When running the CLI in a raw TTY, the
oauth2process listens to standard input to catch a validCtrl+Cinterrupt (0x03, ETX) and safely cancel out of the browser flow.Previously, the stdin handler used
data.includes(0x03)to evaluate this. Terminals like Ghostty and VS Code emit complex multi-byte escape sequences during initialization or resize events. Sometimes, these background sequences coincidentally embed0x03within them, triggering a false-positive cancellation.This PR simply restricts the check to
data.length === 1 && data[0] === 0x03to confidently guarantee we only abort the flow when the user actually types a standaloneCtrl+C. Additional unit test coverage has been added explicitly for multi-byte escape sequences to prevent regression.Related Issues
Fixes #24745
Pre-Merge Checklist