Skip to content

Fix permission persistence failure due to Windows path case-sensitivity#69

Open
BingqingLyu wants to merge 7 commits into
mainfrom
fork-pr-2670-main
Open

Fix permission persistence failure due to Windows path case-sensitivity#69
BingqingLyu wants to merge 7 commits into
mainfrom
fork-pr-2670-main

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

TL;DR

This PR fixes a bug on Windows 11 where permission options:

  • "Always allow in this project"
  • "Always allow for this user"

were not persisting between sessions.

Root cause:
Case-sensitive path comparisons on Windows (which is a case-insensitive file system).
process.cwd() and fs.realpathSync() can return paths with different casing (e.g., C:\Users\Aditya\MyProject vs C:\Users\Aditya\myproject), causing workspace settings to fail loading.


Changes

  • packages/cli/src/config/settings.ts
    → Case-insensitive comparison for workspace vs home directory check

  • packages/core/src/utils/fileUtils.ts
    → Case-insensitive isWithinRoot() function for Windows

  • packages/cli/src/config/trustedFolders.ts
    → Case-insensitive isPathTrusted() function for Windows


Fixes

Closes QwenLM#2669


Dive Deeper

Windows file systems are case-insensitive but case-preserving.

Node.js fs.realpathSync() may return paths with different casing than process.cwd(), even if they point to the same directory.

The original code used strict equality (===) for path comparison, which caused:

  1. Workspace settings not loading (incorrectly treated as home directory)
  2. Path trust checks failing
  3. Permissions appearing lost between sessions

Fix:
Normalize paths to lowercase on Windows before comparison to align with OS behavior.


@BingqingLyu BingqingLyu added conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs and removed conflicting-group-1 labels May 7, 2026
@BingqingLyu

BingqingLyu commented May 7, 2026

Copy link
Copy Markdown
Owner Author

Conflict Group 1

This PR shares modified functions with 1 other PR(s): #8.

These PRs should be reviewed as a batch — merging one may affect the others.

Function File Also modified by
loadSettings settings.ts #8
graph LR
    PR69["PR #69"]
    FloadSettings_2596["loadSettings<br>settings.ts"]
    PR69 -->|modifies| FloadSettings_2596
    PR8["PR #8"]
    PR8 -->|modifies| FloadSettings_2596
Loading

Posted by codegraph-ai conflict detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permission options 2 and 3 not persisting in Windows 11 CMD (re-prompts every time)

2 participants