fix: support XDG paths on Windows for opencode compatibility#37
fix: support XDG paths on Windows for opencode compatibility#37well0nez wants to merge 1 commit intoiHildy:mainfrom
Conversation
opencode uses XDG-style paths (~/.config, ~/.local/share, ~/.local/state) on Windows instead of standard AppData paths. This causes the sync plugin to look in the wrong locations for sessions, secrets, state, and config data. The fix adds XDG path detection to resolveXdgPaths() on win32: - Honor XDG_CONFIG_HOME/XDG_DATA_HOME/XDG_STATE_HOME env vars when set - Auto-detect XDG layout by checking for ~/.config/opencode existence - Fall back to standard Windows AppData paths only if neither applies
Summary of ChangesHello @well0nez, 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 an issue where the sync plugin on Windows failed to correctly locate configuration, session, and state data for applications like opencode that use XDG-style directory structures instead of the traditional AppData paths. By implementing robust XDG path detection, the system can now seamlessly find and utilize these paths, improving compatibility and data synchronization for Windows users employing XDG conventions. Highlights
Changelog
Activity
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 effectively addresses the need for XDG path support on Windows, particularly for opencode compatibility. The changes correctly prioritize explicit XDG environment variables, include a sensible auto-detection mechanism by checking for the ~/.config/opencode directory, and fall back to standard Windows AppData paths when XDG configurations are not present. The addition of fs import is necessary, and the new test cases in src/sync/paths.test.ts provide good coverage for the new logic, ensuring the intended behavior is validated. Overall, the solution is robust and well-tested for the described problem.
| const xdgStateDir = env.XDG_STATE_HOME ?? path.join(homeDir, '.local', 'state'); | ||
|
|
||
| const hasXdgEnv = Boolean(env.XDG_CONFIG_HOME ?? env.XDG_DATA_HOME ?? env.XDG_STATE_HOME); | ||
| const xdgConfigExists = fs.existsSync(path.join(xdgConfigDir, 'opencode')); |
There was a problem hiding this comment.
The use of fs.existsSync is a synchronous file system operation. While it might be acceptable for path resolution during application startup, synchronous I/O operations can block the Node.js event loop, potentially leading to performance bottlenecks or unresponsiveness, especially in larger applications or under heavy load. Consider using an asynchronous alternative like fs.promises.access or fs.promises.stat if the resolveXdgPaths function could be refactored to be asynchronous. If not, ensure this synchronous call's impact is understood and deemed acceptable for the current use case.
🤖 Review Jules RelayI found 1 Gemini suggestion so far. Type |
Summary
resolveXdgPaths()on win32Changes
src/sync/paths.ts- ModifiedresolveXdgPaths()to:XDG_CONFIG_HOME/XDG_DATA_HOME/XDG_STATE_HOMEenv vars on Windows when explicitly set~/.config/opencodedirectory existencesrc/sync/paths.test.ts- Added two test cases:Behavior
Testing