feat(ide): Update context filtering to be done CLI-side + update port discovery logic#8107
feat(ide): Update context filtering to be done CLI-side + update port discovery logic#8107
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @skeshive, 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 introduces significant architectural improvements aimed at enhancing the stability and extensibility of the IDE integration. By centralizing critical logic like context filtering and refining the port discovery mechanism within the CLI, the system becomes more resilient and provides a clearer, more reliable interface for developing community-authored extensions. The changes lay the groundwork for a more robust and scalable IDE ecosystem.
Highlights
- Context Filtering Centralization: The responsibility for filtering IDE context, such as open files and selected text, has been moved from extensions to the CLI. This ensures that the CLI always operates on correctly processed and constrained information, improving overall system stability. New constants (IDE_MAX_OPEN_FILES, IDE_MAX_SELECTED_TEXT_LENGTH) have been introduced to enforce these limits.
- Enhanced Port Discovery Logic: The mechanism for discovering the IDE server port has been significantly updated. It now supports a new file naming convention (gemini-ide-server-{pid}-{port}.json) which includes the process ID (PID) and port, preventing conflicts when multiple IDE instances are running. The CLI will now search for these PID-specific files, validate workspace paths, and prioritize connections based on environment variables, providing a more robust connection method.
- Foundational Changes for Extensions: These architectural changes establish a more robust and stable contract for future community-authored IDE extensions by centralizing complex logic within the CLI, isolating it from potential issues in companion extensions.
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.
Code Review
This pull request effectively moves context filtering to the CLI and updates the port discovery logic for IDE extensions, backed by a comprehensive set of new tests. My review identifies two high-severity issues. The first is a potential for non-deterministic behavior in port discovery when multiple IDE instances are running, which can be resolved by sorting the discovered configuration files. The second issue concerns the direct mutation of an input object within the context store, a practice that could lead to bugs; I've suggested creating a deep copy of the object to ensure safer handling.
|
Size Change: +3.51 kB (+0.03%) Total Size: 13.2 MB
ℹ️ View Unchanged
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces significant architectural improvements by moving context filtering to the CLI and updating the IDE port discovery logic to support multiple IDE instances. The changes are well-implemented and include comprehensive tests for the new functionality. The new context filtering logic in ideContext.ts effectively sanitizes and normalizes data from the IDE, enhancing robustness. The updated port discovery in ide-client.ts is more flexible and handles various edge cases correctly. I have one piece of feedback regarding some unreachable code in ide-client.ts that should be addressed to improve code correctness.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces significant foundational changes to improve the IDE integration. Moving the context filtering logic to the CLI and establishing a new port discovery file naming convention are excellent steps towards a more robust and stable system. The new logic for handling multiple IDE instances and validating workspaces is well-implemented, and the accompanying tests are thorough. I have one high-severity suggestion regarding argument mutation in packages/core/src/ide/ideContext.ts to enhance code safety and prevent potential side-effect-related bugs.
… discovery logic (#8107)
TLDR
This pull request introduces foundational changes to support community-authored IDE extensions. It establishes a robust and stable contract by centralizing complex logic, such as context filtering, within the CLI. This architectural change isolates the CLI from potential issues in companion extensions, improving overall system stability.
Dive Deeper
Linked issues / bugs
#4800, #6848