feat(ide ext): Write workspace path to port file#6659
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!
The pull request refactors the handling of VS Code workspace paths by centralizing the logic within the IDEServer. Previously, workspace paths were managed directly by the extension. Now, the IDEServer is responsible for writing the active workspace paths, alongside its port, to a dedicated JSON state file, improving separation of concerns and making the server setup more robust.
Highlights
- Centralized Workspace Path Management: The logic for updating workspace paths has been moved from extension.ts to a new public method updateWorkspacePath within the IDEServer class.
- Enhanced Server State File: The IDEServer's state file (e.g., /tmp/gemini-ide-server-*.json) now includes a workspacePaths field, storing the active workspace folders in addition to the server port.
- Event-Driven Updates: The onDidOpenWorkspaceFolders event in extension.ts now triggers the ideServer.updateWorkspacePath() method, ensuring the state file is updated whenever workspace folders change.
- Updated Test Suite: An outdated multi-folder test has been removed, and a new dedicated test for ide-server.ts has been added to validate the new centralized workspace path handling logic.
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 refactors the handling of workspace paths by moving the logic into the IDEServer class and writing the paths to the server's state file along with the port. This is a good change that improves separation of concerns. The test suite has been updated accordingly by removing an old test file and adding a new one for the IDEServer. My main feedback is regarding a potential race condition in how the state file is written, which could be made more robust. I've provided specific suggestions to address this.
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 effectively refactors the workspace path handling by moving the logic into the IDEServer class, improving separation of concerns. The new tests for IDEServer are comprehensive. However, I've identified some critical issues with asynchronous error handling in the new implementation. Specifically, errors during the writing of the server's state file are swallowed, and the server startup logic can lead to unhandled promise rejections or cause the extension to hang on failure. I've also noted a potential unhandled promise rejection when workspace folders change. Please see my detailed comments for suggestions on how to fix these issues.
feat(ide): Write workspace paths to JSON file
TLDR
IDEServernow also writes the active workspace paths to its JSON state file (alongside the port). This will improve the /ide install flow. Previously, users were required to open a new terminal after installation of the extension but now they'll be able to enable IDE mode in the same terminal once the corresponding changes in the CLI are merged.Dive Deeper
Key changes:
updateWorkspacePathlogic has been moved fromextension.tsinto a new public methodupdateWorkspacePathon theIDEServerclass./tmp/gemini-ide-server-*.json) has been updated to include aworkspacePathsfield, in addition to theport.onDidOpenWorkspaceFoldersevent inextension.tsnow callsideServer.updateWorkspacePath()to trigger an update.ide-server.tscreated to validate the new, centralized logic.This change improves separation of concerns and makes the server's setup more self-contained and robust.