Skip to content

fix: clean up stale vectors on directory deletion and add Qdrant collection alias#12116

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/stale-vectors-deleted-files-12115
Draft

fix: clean up stale vectors on directory deletion and add Qdrant collection alias#12116
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/stale-vectors-deleted-files-12115

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 14, 2026

Related GitHub Issue

Closes: #12115

Description

This PR attempts to address Issue #12115. Feedback and guidance are welcome.

Two changes:

  1. Directory deletion handling in FileWatcher: When a directory is deleted, VSCode's FileSystemWatcher with extension-specific glob patterns does not fire individual onDidDelete events for each file inside it. The handleFileDeleted method now detects directory deletions by checking the cache manager for any files whose paths start with the deleted path prefix, and queues them all for vector deletion. This ensures stale vectors are cleaned up promptly rather than persisting until a full re-index.

  2. Qdrant collection alias: After collection initialization, a human-readable alias is created using the sanitized workspace folder name (e.g., my-project -> alias for ws-fc1843e42d391b4f). This allows external tools to discover and query the collection without reverse-engineering the hashed naming scheme. Alias creation is non-fatal -- failures are logged but do not block initialization.

Test Procedure

  • Added 3 new tests to file-watcher.spec.ts covering directory deletion (child paths queued), single file deletion, and deletion of paths not in cache
  • Added 3 new tests to qdrant-client.spec.ts covering alias creation during init, graceful failure handling, and alias name sanitization
  • All existing tests continue to pass (8 file-watcher tests, 69 qdrant-client tests)
  • Run: cd src && pnpm vitest run services/code-index/processors/__tests__/file-watcher.spec.ts
  • Run: cd src && pnpm vitest run services/code-index/vector-store/__tests__/qdrant-client.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates needed -- changes are internal behavior fixes.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A -- backend-only changes, no UI impact.

Documentation Updates

No documentation updates required.

Interactively review PR in Roo Code Cloud

…ection alias

- Detect directory deletions in FileWatcher by checking cache for child
  paths, queuing all children for vector deletion
- Add human-readable Qdrant collection alias based on workspace folder name
- Add tests for both features

Addresses #12115
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.

[BUG] Deleted files leave stale vectors in Qdrant — not cleaned up until full re-index

1 participant