Fix multiple bugs with auth flow including using the implemented but unused restart support.#13565
Conversation
Summary of ChangesHello @jacob314, 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 refactors and enhances the CLI's authentication process and terminal interaction logic. It centralizes terminal control functions into a shared core module, leading to more consistent behavior across the application. The authentication flow, especially for non-browser environments, is improved with a dedicated restart mechanism and better user feedback, addressing several underlying bugs and improving the overall user experience. 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. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces several valuable improvements, primarily fixing bugs in the authentication flow and implementing restart support. The refactoring to centralize terminal control logic into @google/gemini-cli-core is a great step towards better code organization and maintainability. The user experience for the non-interactive authentication flow is also significantly enhanced. However, I've identified a critical issue where the application can hang if the user cancels the authentication code prompt.
|
Size Change: +3.34 kB (+0.02%) Total Size: 21.1 MB
ℹ️ View Unchanged
|
| '\nFailed to authenticate with user code.', | ||
| i === maxRetries - 1 ? '' : 'Retrying...\n', | ||
| ); | ||
| // Enter alternate buffer |
There was a problem hiding this comment.
Rendering this in the alternate buffer is perhaps overkill but depending on if Gemini CLI was already rendering it is better if we ensure this is rendered in the alternate buffer than clear the main buffer as would be needed to ensure this UI doesn't conflict with Gemini CLI
| writeToStdout('\u001B[2J\u001B[H'); | ||
| disableMouseEvents(); | ||
| disableKittyKeyboardProtocol(); | ||
| enableLineWrapping(); |
There was a problem hiding this comment.
enabling line wrapping is key so the URL is copyable/clickable
| debugLogger.log( | ||
| 'Please visit the following URL to authorize the application:', | ||
| ); | ||
| debugLogger.log(''); |
There was a problem hiding this comment.
the fact that these were debugLogger was very strange this was always UI written to stdout.
…unused restart support.
| } | ||
|
|
||
| export function disableKittyKeyboardProtocol() { | ||
| writeToStdout('\x1b[<u'); |
There was a problem hiding this comment.
I've switched these back to the standard writeToStdout method as the sync version wasn't fixing issues anyway.
…sing the implemented but unused restart support. (google-gemini#13565)
…unused restart support. (google-gemini#13565)
…unused restart support. (#13565)
|
/patch stable |
|
✅ Patch workflow(s) dispatched successfully! 📋 Details:
🔗 Track Progress: |
…unused restart support. (#13565) # Conflicts: # packages/cli/src/gemini.tsx # packages/cli/src/ui/AppContainer.test.tsx # packages/cli/src/ui/AppContainer.tsx # packages/cli/src/ui/utils/mouse.ts # packages/core/src/index.ts
|
🚀 Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
…unused restart support. (#13565)
|
🚀 Patch Release Started! 📋 Release Details:
⏳ Status: The patch release is now running. You'll receive another update when it completes. 🔗 Track Progress: |
|
✅ Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
…unused restart support. (google-gemini#13565)
Summary
The auth flow was hard to read with important information sent to the debug console rather than displayed on the screen so users would have little indication of what was going on.
We were also neglecting to use the functionality @shrutip90 added to support restarting the IDE and so we were forcing users to restart manually in multiple places. Audited all places we were exiting adding the proper cleanup logic and calling the appropriate command to restart for cases where it was intended the user would restart.
Details
packages/clito a new sharedpackages/core/src/utils/terminal.tsmodule for improved reusability and consistency across the application.NO_BROWSER=true) has been enhanced by utilizing the alternate screen buffer for a cleaner user experience and providing clearer feedback messages directly to the terminal.process.exit(0)calls for scenarios requiring a CLI restart (e.g., after Google login when browser launch is suppressed) have been replaced with a specificRELAUNCH_EXIT_CODEandrunExitCleanup(), enabling better external process management and a more graceful restart.writeToStderrfor critical errors, and informational/error messages during authentication are communicated viaCoreEvent.UserFeedback, improving user communication.Related Issues
Fixes: #12893
How to Validate
Demo of auth flow with browser:
https://screencast.googleplex.com/cast/NjQyNzU5Mjg4MTA3ODI3Mnw3NzQ1OGIxZC05Nw
Demo of auth flow with browser disabled:
https://screencast.googleplex.com/cast/NjIxNzg5Nzg2NDA2OTEyMHxkNWFiMGQxZC1mOA
Disable authentication with the browser via config and verify you can still authenticate seeing the whole auth string with correct line wrap in the console.
Validate cancelling the auth flow.
Validate that editing.a setting requiring restart now restarts automatically when you press r rather than making you do it.
The one known issue I wasn't able to fix is that ctrl-C does not work to exit with the readline based security code entry logic in core.