-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix IDE Companion Connection in Proxy Environments #6308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix IDE Companion Connection in Proxy Environments #6308
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Blackoutta, 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 resolves critical connection issues between the Gemini CLI and its IDE companion extension, specifically in environments configured with HTTP/HTTPS proxies. The core of the solution involves implementing proper proxy handling, including support for the NO_PROXY
environment variable and automatic bypass for localhost connections. This ensures that users in corporate or restricted network settings can seamlessly utilize IDE integration features, improving compatibility and user experience without impacting non-proxy environments.
Highlights
- Proxy Agent Integration: The
EnvHttpProxyAgent
from theundici
library has been integrated to provide robust and environment-aware proxy management. - Proxy-Aware Fetch Implementation: A new method,
createProxyAwareFetch()
, has been implemented to configure an HTTP client that respects system-wide proxy settings. - IDE Connection Update: The process for establishing a connection with the IDE companion extension has been updated to leverage the new proxy-aware fetch mechanism.
- Localhost Bypass: The system is now configured to automatically bypass proxy routing for connections to
localhost
, aligning with standardNO_PROXY
patterns. - Enhanced Error Handling: Error messages for connection failures have been improved to provide clearer and more actionable feedback to the user.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this 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 effectively addresses connection issues in proxy environments by integrating undici
's EnvHttpProxyAgent
. The approach of using a proxy-aware fetch implementation is sound. My review includes one high-severity suggestion to improve type safety and prevent potential runtime errors by replacing an unsafe type cast with proper Response
object construction, enhancing the overall robustness of the solution.
b83f39f
to
a3aac89
Compare
/gemini review |
There was a problem hiding this 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 adds proxy support for IDE connections, which is a great improvement for users in corporate environments. The implementation correctly uses undici
's EnvHttpProxyAgent
. However, I've identified a critical issue where the current implementation overrides the user's NO_PROXY
environment variable, and a high-severity performance issue due to repeated dynamic imports. My review includes a single comment with a code suggestion that addresses both of these issues to make the proxy handling more robust and efficient.
/gemini review |
There was a problem hiding this 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 introduces proxy support for the IDE companion connection by using undici
's EnvHttpProxyAgent
. The changes are well-structured, adding a createProxyAwareFetch
method to encapsulate the proxy logic and updating the connection establishment to use it. The error handling for connection failures has also been improved. My review includes one suggestion to simplify the implementation in createProxyAwareFetch
for better performance and maintainability.
38f8da6
to
7f6b9e5
Compare
Hi @jacob314 , just a gentle ping to see if you’ve had a chance to look at this PR. Happy to address any feedback—thanks again for your time :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Amnat-auyana1998, thank you for reviewing, happy to help, let me know if there is anything I can do :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a test for this to avoid regressions. Aside from that change looks good to approve. Thanks for the bug fix!
packages/core/src/ide/ide-client.ts
Outdated
`Failed to connect to IDE companion extension for ${this.currentIdeDisplayName}. Please ensure the extension is running and try restarting your terminal. To install the extension, run /ide install.`, | ||
true, | ||
); | ||
logger.debug('Failed to connect to IDE companion extension. Error:\n', _error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already log an error at line 428. Is this extra log message needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, jacob, thanks for reviewing! I needed the raw error object '_error' when I was debugging for the issue, I'll remove these two lines in my next commit, which is adding tests ;)
e60bfdf
to
a357302
Compare
57bb770
to
9c7a6fa
Compare
Hi @jacob314, |
…add one-click integration test debug cmd in .vscode/launch.json;
c2af554
to
0e2e2a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Blackoutta Please Let me try it.I'll come back and review it for you later.
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
TLDR
Fixes #6307
Summary
This PR resolves connection issues between the Gemini CLI and IDE companion extension when running in proxy-configured environments by implementing proper proxy handling with support for NO_PROXY configuration.
Screenshot after the fix
Changes Made
EnvHttpProxyAgent
from the undici library to handle proxy configurationcreateProxyAwareFetch()
method that configures proxy-aware HTTP clientTechnical Details
Proxy Configuration
Connection Establishment Updates
Updated the
establishConnection
method to use the new proxy-aware fetch:Benefits
Testing
Breaking Changes
None - this change is fully backward compatible.
Dive Deeper
Reviewer Test Plan
Testing Matrix
Linked issues / bugs