Skip to content

fix: keep change tracking paths workspace-relative - #18

Open
andrewcodehappily wants to merge 1 commit into
Xeift:mainfrom
andrewcodehappily:fix/change-tracking-relative-paths
Open

fix: keep change tracking paths workspace-relative#18
andrewcodehappily wants to merge 1 commit into
Xeift:mainfrom
andrewcodehappily:fix/change-tracking-relative-paths

Conversation

@andrewcodehappily

@andrewcodehappily andrewcodehappily commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix change tracking paths becoming absolute when the workspace root resolves to a different canonical path.

This also fixes the six existing change_tracking test failures on macOS.

Root cause

ChangeSession::begin canonicalizes the workspace root before collecting snapshots, but the paths stored in ChangeTarget previously kept their original form.

On macOS, temporary paths commonly expose this difference:

/var/folders/...

may canonicalize to:

/private/var/folders/...

This caused operations such as path.strip_prefix(workspace_root) to fail because the target path and workspace root no longer shared the same prefix representation.

When that happened, change tracking fell back to the original absolute path instead of producing a workspace-relative path.

Fix

When the workspace root is canonicalized, target paths that are inside the original workspace are now remapped onto the canonical workspace root while preserving their relative suffix.

For example:

  • original workspace: /var/.../project
  • canonical workspace: /private/var/.../project
  • target: /var/.../project/src/main.rs

becomes:

/private/var/.../project/src/main.rs

before snapshot collection.

This keeps the workspace root and target paths in the same path namespace without canonicalizing individual targets or following file symlinks.

Regression coverage

Added a Unix regression test using a symlinked workspace root to reproduce the same class of path mismatch on platforms other than macOS.

The test verifies that change tracking still returns tracked.txt instead of an absolute path.

Validation

Targeted change-tracking tests:

9 passed, 0 failed

Full test suite:

215 passed, 0 failed

Additional validation:

  • cargo build --release
  • rustfmt --check
  • git diff --check

Scope

Only src/change_tracking/mod.rs is changed.

No ignore rules, diff generation, MCP behavior, or configuration formats are modified.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed change tracking when a workspace is opened through a symbolic link.
    • Reported change paths now remain correctly relative to the workspace, matching the snapshot root.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 0c0c6f9d-82a1-43ac-a9de-c327938f15de

📥 Commits

Reviewing files that changed from the base of the PR and between 0e95812 and f056b5e.

📒 Files selected for processing (1)
  • src/change_tracking/mod.rs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

ChangeSession::begin now preserves the original workspace root, canonicalizes the root with fallback, and normalizes scope targets against both roots. A Unix-only test verifies workspace-relative paths when the workspace is opened through a symlink.

Changes

Workspace path normalization

Layer / File(s) Summary
Normalize scope targets and verify relative paths
src/change_tracking/mod.rs
ChangeSession::begin rewrites scope target paths from the original root to the canonical root. A Unix-only test verifies that changes through a workspace symlink report relative paths.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Merge Risk: ⚪ Minimal · up to f056b

The change keeps workspace targets workspace-relative when the workspace root uses a different canonical path. It is localized, validated by the existing test suite and regression coverage, and no actionable merge-blocking risk remains.

Suggested reviewers: xeift

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. 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 concisely describes the main change: preserving workspace-relative paths in change tracking.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution failed


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

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

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.

1 participant