Skip to content

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Sep 6, 2025

Fixes #7728

Summary

This PR adds the ability to view and edit Qdrant collection names in the codebase indexing popup, allowing users to specify custom collection names instead of relying on auto-generated names from workspace path hashes.

Changes

  • Added a new input field in the CodeIndexPopover component for users to view and edit the Qdrant collection name
  • Updated configuration interfaces and schemas to include the qdrantCollectionName field
  • Modified the QdrantVectorStore class to accept an optional collection name parameter with proper sanitization
  • Updated the config manager and service factory to handle the new collection name field
  • Added translation keys for the new UI field labels in English
  • Fixed TypeScript type definitions to include the new field

Benefits

  • Users can now specify meaningful collection names for their knowledge bases
  • Prevents the need to reindex when switching/reinstalling OS or IDE
  • Makes it easier to manage multiple Qdrant collections
  • Collection names are properly sanitized to ensure Qdrant compatibility

Testing

  • All existing tests pass
  • Type checking passes
  • Linting passes
  • Manual testing shows the field works as expected

Screenshots

The new field appears in the codebase indexing settings popup with proper labels and placeholder text.


Important

Adds support for custom Qdrant collection names in codebase indexing settings, including UI, configuration, and backend updates.

  • Behavior:
    • Adds codebaseIndexQdrantCollectionName field to codebase-index.ts, webviewMessageHandler.ts, and config-manager.ts for custom Qdrant collection names.
    • Updates CodeIndexPopover.tsx to include a new input field for Qdrant collection name.
    • Modifies QdrantVectorStore constructor in qdrant-client.ts to accept and sanitize custom collection names.
  • Configuration:
    • Updates configuration schemas and interfaces to include qdrantCollectionName.
    • Adjusts service-factory.ts to handle optional collection name.
  • Localization:
    • Adds translation keys for new UI elements in multiple language files.
  • Testing:
    • All existing tests pass.
    • Manual testing confirms new field functionality.

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

- Add UI field in CodeIndexPopover for viewing/editing collection name
- Update configuration interfaces to include qdrantCollectionName
- Modify QdrantVectorStore to accept optional collection name parameter
- Update config manager to handle collection name in settings
- Add translation keys for new UI labels
- Update tests to account for new parameter

Fixes #7728
@roomote roomote bot requested review from mrubens, cte and jr as code owners September 6, 2025 02:59
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Sep 6, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 6, 2025
"searchMaxResultsDescription": "查询代码库索引时返回的最大搜索结果数。较高的值提供更多上下文,但可能包含相关性较低的结果。",
"resetToDefault": "恢复默认值"
"resetToDefault": "恢复默认值",
"qdrantCollectionNameLabel": "Qdrant Collection Name",
Copy link

Choose a reason for hiding this comment

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

新添加的 Qdrant collection name 字段(qdrantCollectionNameLabel, qdrantCollectionNamePlaceholder, qdrantCollectionNameDescription)目前保持英文。考虑提供中文翻译以保证本地化一致性,或者在注释中说明暂未翻译的原因。

Suggested change
"qdrantCollectionNameLabel": "Qdrant Collection Name",
"qdrantCollectionNameLabel": "Qdrant 集合名称",

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

"searchMaxResultsDescription": "查詢程式碼庫索引時傳回的最大搜尋結果數。較高的值提供更多上下文,但可能包含相關性較低的結果。",
"resetToDefault": "重設為預設值"
"resetToDefault": "重設為預設值",
"qdrantCollectionNameLabel": "Qdrant Collection Name",
Copy link

Choose a reason for hiding this comment

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

在此文件中,新加入的 Qdrant collection name 字段仍為英文(qdrantCollectionNameLabel、qdrantCollectionNamePlaceholder、qdrantCollectionNameDescription)。建議為繁體中文用戶提供相應翻譯,或在註釋中標明其暫時保留英文。

Suggested change
"qdrantCollectionNameLabel": "Qdrant Collection Name",
"qdrantCollectionNameLabel": "Qdrant 集合名稱",

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

I reviewed my own code and found issues. Classic case of 'it worked on my machine syndrome'.


// Check for model dimension changes (generic for all providers)
if (prevModelDimension !== currentModelDimension) {
return true
Copy link
Author

Choose a reason for hiding this comment

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

Critical Issue: Missing restart detection for collection name changes.

The doesConfigChangeRequireRestart method doesn't check if qdrantCollectionName has changed. When users change the collection name, it requires a restart to take effect (since it affects which Qdrant collection is used), but this won't be detected.

Could we add this check around line 351?

Suggested change
return true
if (
prevQdrantUrl !== currentQdrantUrl ||
prevQdrantCollectionName !== currentQdrantCollectionName ||
prevQdrantApiKey !== currentQdrantApiKey
) {
return true
}

modelDimension: undefined,
qdrantUrl: "http://localhost:6333",
qdrantApiKey: "",
qdrantCollectionName: "",
Copy link
Author

Choose a reason for hiding this comment

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

Important: Missing test coverage for collection name functionality.

While the test file has been updated to include qdrantCollectionName in assertions, there are no specific tests for:

  1. Collection name changes triggering restart detection
  2. Collection name being properly loaded and saved
  3. Edge cases like empty or invalid collection names

Would it make sense to add dedicated test cases for this new feature?

// Generate collection name from workspace path
const hash = createHash("sha256").update(workspacePath).digest("hex")
// Use provided collection name or generate from workspace path
if (collectionName && collectionName.trim()) {
Copy link
Author

Choose a reason for hiding this comment

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

Nice sanitization logic! However, could we add a comment explaining the regex pattern for future maintainers?

Suggested change
if (collectionName && collectionName.trim()) {
// Use provided collection name or generate from workspace path
if (collectionName && collectionName.trim()) {
// Sanitize the collection name to ensure it's valid for Qdrant
// Qdrant collection names must match: ^[a-zA-Z0-9_-]+$
// Invalid characters are replaced with hyphens
this.collectionName = collectionName.trim().replace(/[^a-zA-Z0-9_-]/g, "-")
} else {

onInput={(e: any) =>
updateSetting("codebaseIndexQdrantCollectionName", e.target.value)
}
placeholder={t("settings:codeIndex.qdrantCollectionNamePlaceholder")}
Copy link
Author

Choose a reason for hiding this comment

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

Suggestion: The UI doesn't validate collection names before saving.

While the backend sanitizes invalid characters, it might be better UX to warn users in the UI when they enter invalid characters. Could we add validation feedback similar to other fields?

Also, is the placeholder text informative enough about valid characters? Maybe something like: "Enter collection name (letters, numbers, -, _ only)"?

"http://localhost:6333",
3072,
"test-key",
undefined, // collectionName
Copy link
Author

Choose a reason for hiding this comment

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

The test correctly passes undefined for the new collectionName parameter, but we're missing tests that verify:

  1. Collection name is passed when configured
  2. Sanitization works correctly
  3. Empty/invalid collection names fall back to auto-generation

Should we add test coverage for the new parameter?

@daniel-lxs
Copy link
Collaborator

#7728 (comment)

@daniel-lxs daniel-lxs closed this Sep 8, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 8, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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
Archived in project
Development

Successfully merging this pull request may close these issues.

View qdrant collection name and edit qdrant collection name in codebase indexing
3 participants