Skip to content

fix(skills): fall back to junctions for Windows skill links#2749

Open
TheLonelyDevil9 wants to merge 1 commit into
farion1231:mainfrom
TheLonelyDevil9:fix/windows-skill-junction-fallback
Open

fix(skills): fall back to junctions for Windows skill links#2749
TheLonelyDevil9 wants to merge 1 commit into
farion1231:mainfrom
TheLonelyDevil9:fix/windows-skill-junction-fallback

Conversation

@TheLonelyDevil9
Copy link
Copy Markdown

What?

Adds a Windows fallback for skill sync when directory symlink creation fails. CC Switch now treats skill sync links as managed links: Unix symlinks, Windows directory symlinks, or Windows junctions.

Why?

Non-admin Windows sessions without Developer Mode can fail directory symlink creation with an administrator-privilege error. That breaks live skill sync across CLI harnesses and can remove an existing link during toggle/re-sync flows.

How?

  • Keeps Unix symlink behavior unchanged.
  • Tries std::os::windows::fs::symlink_dir first on Windows.
  • Falls back to an NTFS junction using CreateFileW and DeviceIoControl(FSCTL_SET_REPARSE_POINT), avoiding cmd.exe/mklink shell parsing.
  • Detects Windows directory reparse points as managed skill links.
  • Removes managed links without recursively deleting the target directory.
  • Normalizes Windows link targets with \??\ / \\?\ prefixes before SSOT comparisons.
  • Updates skill sync tests to validate live managed-link behavior and orphan cleanup through the public sync path.

Testing?

  • git diff --check
  • Manual Windows validation: junctions work in the affected non-admin session where symlink creation fails.
  • Not run locally: cargo fmt, cargo test, or Rust build checks because Rust tooling is not available in this shell.

Screenshots (optional)

Not applicable.

Anything Else?

No matching open upstream PR was found for Windows skill symlink-to-junction fallback.

@farion1231
Copy link
Copy Markdown
Owner

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79e2e09ba7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1762 to +1763
attributes & FILE_ATTRIBUTE_DIRECTORY != 0
&& attributes & FILE_ATTRIBUTE_REPARSE_POINT != 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict managed-link detection to symlink/junction tags

The Windows managed-link check currently treats any directory with FILE_ATTRIBUTE_REPARSE_POINT as a CC Switch link, but many non-link directory types (for example cloud placeholders or other reparse-tagged directories) also match this predicate. Those paths are then routed through remove_path() as managed links, which uses remove_dir instead of recursive removal; this can fail on non-empty directories and break sync/remove flows when a normal skill directory carries a non-symlink reparse tag. The check should validate the reparse tag (e.g., only symlink/mount-point junction tags) before classifying a path as managed.

Useful? React with 👍 / 👎.

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