Skip to content

fix: use stable cache key for SSH remote workspaces #6067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Jul 22, 2025

Summary

This PR fixes the issue where codebase indexing starts from scratch after closing VS Code when using SSH remote connections.

Problem

When using VS Code Remote SSH, the workspace path might be different between sessions (e.g., due to different temporary mount points or path variations). Since the cache file name was generated using a hash of the workspace path, a different path would result in a different cache file, causing the indexing to start from scratch.

Solution

Instead of using just the workspace path for the cache key, we now use a composite key that includes:

  1. The workspace folder name
  2. The relative path from the home directory (when the workspace is under the home directory)

This creates a more stable cache key that persists across SSH sessions where the absolute path might change but the relative structure remains the same.

Changes

  • Modified CacheManager to generate a stable cache key using workspace name and relative path
  • Added comprehensive tests for the new cache key generation logic
  • All existing tests pass without regression

Testing

  • Added new tests to verify cache key generation for workspaces under and outside the home directory
  • All code-index tests pass successfully (129 tests)
  • Linting and type checking pass

Fixes #6066


Important

CacheManager now generates stable cache keys for SSH remote workspaces, preventing unnecessary re-indexing.

  • Behavior:
    • CacheManager now generates a stable cache key using workspace name and relative path in cache-manager.ts.
    • Fixes issue where codebase indexing restarted due to different cache keys across SSH sessions.
  • Testing:
    • Added tests in cache-manager.spec.ts for cache key generation under home and outside home directory.
    • All existing tests pass without regression.
  • Misc:
    • Mocked os.homedir() in cache-manager.spec.ts to return a consistent home directory for testing.

This description was created by Ellipsis for 743dc97. You can customize this summary. It will automatically update as commits are pushed.

- Generate cache key using workspace name and relative path from home
- This ensures cache persistence across SSH sessions where absolute paths may change
- Add comprehensive tests for the new cache key generation logic

Fixes #6066
@roomote roomote bot requested review from mrubens, cte and jr as code owners July 22, 2025 16:37
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jul 22, 2025
- Ensure consistent cache keys across Windows and Unix systems
- Replace backslashes with forward slashes in relative paths
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

Codebase indexing starting from scratch after closing VS Code
2 participants