[codex] Fix Windows workspace data dir paths#1038
Conversation
📝 WalkthroughWalkthroughThe PR refactors platform-aware directory path resolution by introducing a ChangesGlobal Data Path Resolution & E2E Timing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/core/global-config.test.ts (1)
99-135: ⚡ Quick winAdd a test for
XDG_DATA_HOMEwithplatform: 'win32'The
XDG_DATA_HOMEbranch (line 83–86 ofglobal-config.ts) is exercised only withplatform: 'darwin'. Whenplatform: 'win32'is provided alongsideXDG_DATA_HOME,joinGlobalDataPathshould selectpath.win32.join, but that path through the dispatch is currently untested.✅ Proposed additional test case
it('should use Windows separators for native Windows platform overrides', () => { expect( getGlobalDataDir({ env: {}, platform: 'win32', homedir: 'C:\\Users\\Tabish', }) ).toBe('C:\\Users\\Tabish\\AppData\\Local\\openspec'); expect( getGlobalDataDir({ env: { LOCALAPPDATA: 'D:\\Users\\Tabish\\AppData\\Local' }, platform: 'win32', homedir: 'C:\\Users\\Tabish', }) ).toBe('D:\\Users\\Tabish\\AppData\\Local\\openspec'); + + // XDG_DATA_HOME takes precedence even on Windows; path must use Windows separators + expect( + getGlobalDataDir({ + env: { XDG_DATA_HOME: 'D:\\ProgramData\\xdg' }, + platform: 'win32', + homedir: 'C:\\Users\\Tabish', + }) + ).toBe('D:\\ProgramData\\xdg\\openspec'); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/core/global-config.test.ts` around lines 99 - 135, Add a unit test to cover the branch where XDG_DATA_HOME is set but platform is 'win32' so joinGlobalDataPath selects path.win32.join; update the describe 'getGlobalDataDir' tests to include an it case that calls getGlobalDataDir({ env: { XDG_DATA_HOME: 'D:\\xdg' }, platform: 'win32', homedir: 'C:\\Users\\Tabish' }) and assert the result equals 'D:\\xdg\\openspec' (or the appropriate Windows-joined path), referencing getGlobalDataDir/joinGlobalDataPath to ensure the dispatch to path.win32 is exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/core/global-config.test.ts`:
- Around line 99-135: Add a unit test to cover the branch where XDG_DATA_HOME is
set but platform is 'win32' so joinGlobalDataPath selects path.win32.join;
update the describe 'getGlobalDataDir' tests to include an it case that calls
getGlobalDataDir({ env: { XDG_DATA_HOME: 'D:\\xdg' }, platform: 'win32',
homedir: 'C:\\Users\\Tabish' }) and assert the result equals 'D:\\xdg\\openspec'
(or the appropriate Windows-joined path), referencing
getGlobalDataDir/joinGlobalDataPath to ensure the dispatch to path.win32 is
exercised.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 32d5f1b9-aff7-473b-a8f7-82babf52a6dd
📒 Files selected for processing (3)
src/core/global-config.tstest/cli-e2e/basic.test.tstest/core/global-config.test.ts
alfred-openspec
left a comment
There was a problem hiding this comment.
Looks good to me.
Summary
Fixes the Windows CI failure from the workspace foundation merge by making
getGlobalDataDirhonor the requested platform's path conventions whenplatform,env, orhomediroverrides are passed.Root Cause
getGlobalDataDir({ platform: 'linux', homedir: '/home/tabish' })still used nativepath.join. On Windows CI that produced backslash paths like\home\tabish\..., so the workspace foundation test that simulated Linux fallback behavior failed after #1029 merged tomain.Changes
init --tools alle2e test an explicit timeout budget and timeout assertion, matching the slower Windows matrix behavior.Validation
pnpm run buildpnpm lintpnpm exec tsc --noEmitpnpm exec vitest run test/cli-e2e/basic.test.ts test/core/global-config.test.ts test/core/workspace/foundation.test.tspnpm test(71 passed,1435 passed)Summary by CodeRabbit