Skip to content

[codex] Fix Windows workspace data dir paths#1038

Merged
TabishB merged 1 commit intomainfrom
codex/fix-windows-workspace-data-dir
May 2, 2026
Merged

[codex] Fix Windows workspace data dir paths#1038
TabishB merged 1 commit intomainfrom
codex/fix-windows-workspace-data-dir

Conversation

@TabishB
Copy link
Copy Markdown
Contributor

@TabishB TabishB commented May 1, 2026

Summary

Fixes the Windows CI failure from the workspace foundation merge by making getGlobalDataDir honor the requested platform's path conventions when platform, env, or homedir overrides are passed.

Root Cause

getGlobalDataDir({ platform: 'linux', homedir: '/home/tabish' }) still used native path.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 to main.

Changes

  • Added a small platform-aware join helper for global data paths.
  • Added direct coverage for Linux/macOS-style and native Windows global data directory resolution.
  • Gave the broad init --tools all e2e test an explicit timeout budget and timeout assertion, matching the slower Windows matrix behavior.

Validation

  • pnpm run build
  • pnpm lint
  • pnpm exec tsc --noEmit
  • pnpm exec vitest run test/cli-e2e/basic.test.ts test/core/global-config.test.ts test/core/workspace/foundation.test.ts
  • pnpm test (71 passed, 1435 passed)

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for global directory path resolution across different platforms.
    • Improved timeout handling in CLI end-to-end tests for enhanced stability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

The PR refactors platform-aware directory path resolution by introducing a joinGlobalDataPath helper that consistently applies path.win32.join or path.posix.join based on the provided platform argument, replacing mixed path-joining logic in getGlobalDataDir. Tests validate platform-specific path behavior, and an e2e test timeout is increased to handle initialization timing.

Changes

Global Data Path Resolution & E2E Timing

Layer / File(s) Summary
Path Joining Helper
src/core/global-config.ts
New internal joinGlobalDataPath(platform, ...segments) function selects path.win32.join or path.posix.join based on the provided platform argument.
Core Implementation
src/core/global-config.ts
getGlobalDataDir refactored to use joinGlobalDataPath for all directory path computation (XDG_DATA_HOME, Windows %LOCALAPPDATA%, Unix fallback), ensuring platform-consistent path separators.
Unit Tests
test/core/global-config.test.ts
New test suite for getGlobalDataDir validates POSIX-style paths for Unix-like platform overrides and Windows-style paths (backslash-separated) for Windows overrides.
E2E Test Timing
test/cli-e2e/basic.test.ts
init --tools all test adds explicit timeoutMs: 20000 to runCLI, asserts no timeout occurred, and increases test-level timeout to 25000.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • alfred-openspec

Poem

🐰 Hop along the path, now platform-aware,
Windows, Unix, Mac — we split the fare!
Separators align with precision bright,
Tests and timeouts make the init just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main fix: addressing Windows path handling in the getGlobalDataDir function to respect platform-specific path conventions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-windows-workspace-data-dir

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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@TabishB TabishB marked this pull request as ready for review May 1, 2026 23:37
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/core/global-config.test.ts (1)

99-135: ⚡ Quick win

Add a test for XDG_DATA_HOME with platform: 'win32'

The XDG_DATA_HOME branch (line 83–86 of global-config.ts) is exercised only with platform: 'darwin'. When platform: 'win32' is provided alongside XDG_DATA_HOME, joinGlobalDataPath should select path.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

📥 Commits

Reviewing files that changed from the base of the PR and between e6d81ba and aa75d15.

📒 Files selected for processing (3)
  • src/core/global-config.ts
  • test/cli-e2e/basic.test.ts
  • test/core/global-config.test.ts

Copy link
Copy Markdown
Collaborator

@alfred-openspec alfred-openspec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@TabishB TabishB added this pull request to the merge queue May 1, 2026
Merged via the queue into main with commit 0ca7476 May 2, 2026
12 checks passed
@TabishB TabishB deleted the codex/fix-windows-workspace-data-dir branch May 2, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants