feat: enhance semantic search with multiple paths and pattern filtering#348
Conversation
1. Added support for multiple custom paths in search rules by accepting QVariantList for custom_path field 2. Implemented exclude_patterns to filter search results by file name patterns 3. Added ruleMetadataById method to find rules without knowing their group 4. Improved path expansion logic in ActionExtractor and LocationExtractor 5. Enhanced semantic searcher to apply exclude_patterns when processing results Log: Added support for multiple search paths and result filtering by file patterns Influence: 1. Test search rules with multiple custom paths 2. Verify exclude_patterns filters correct files from results 3. Check backward compatibility with existing single-path rules 4. Validate rule lookups work correctly with new ruleMetadataById 5. Test performance impact with multiple paths and pattern filtering feat: 增强语义搜索支持多路径和模式过滤 1. 在搜索规则中添加对多个自定义路径的支持,支持custom_path字段使用 QVariantList 2. 实现exclude_patterns功能,按文件名模式过滤搜索结果 3. 添加ruleMetadataById方法,无需知道规则组即可查找规则 4. 改进ActionExtractor和LocationExtractor中的路径扩展逻辑 5. 增强语义搜索器在处理结果时应用exclude_patterns Log: 新增支持多个搜索路径及按文件模式过滤结果的功能 Influence: 1. 测试使用多个自定义路径的搜索规则 2. 验证exclude_patterns能正确过滤结果文件 3. 检查与现有单一路径规则的向后兼容性 4. 验证新的ruleMetadataById方法查找规则是否正确 5. 测试多路径和模式过滤对性能的影响
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdds support for multiple custom paths in semantic search rules, introduces exclude_patterns-based filename filtering, factors engine completion/error handling into reusable helpers, and extends rule metadata lookup to work by rule ID across groups while updating extractors to handle QVariantList-based paths without breaking single-path behavior. Sequence diagram for semantic search exclude_patterns filteringsequenceDiagram
actor User
participant SemanticSearcher
participant SemanticSearcherData
participant SemanticRuleEngine
participant SearchEngine
User->>SemanticSearcher: search(naturalLanguage, dirs)
SemanticSearcher->>SemanticSearcherData: doSearch(naturalLanguage, dirs)
SemanticSearcherData->>SemanticSearcherData: intent.consumedSpans()
loop for each MatchSpan
SemanticSearcherData->>SemanticRuleEngine: ruleMetadataById(ruleId)
SemanticRuleEngine-->>SemanticSearcherData: metadata
SemanticSearcherData->>SemanticSearcherData: build excludeNamePatterns
end
SemanticSearcherData->>SearchEngine: createAndLaunchEngine(query, onEngineFinished, onEngineError)
SearchEngine-->>SemanticSearcherData: searchFinished(results)
SemanticSearcherData->>SemanticSearcherData: onEngineFinished(results)
SemanticSearcherData->>SemanticSearcherData: filter by excludeNamePatterns
SemanticSearcherData->>SemanticSearcherData: deduplicate by seenPaths
SemanticSearcherData->>SemanticSearcherData: pendingFinishCount.fetch_sub(1)
alt all engines finished
SemanticSearcherData->>SemanticSearcher: searchFinished(allResults)
end
SearchEngine-->>SemanticSearcherData: errorOccurred(error)
SemanticSearcherData->>SemanticSearcherData: onEngineError(error)
SemanticSearcherData->>SemanticSearcherData: onEngineFinished({})
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:92分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // locationextractor.h - 新增静态工具方法
static QStringList expandCustomPathList(const QVariant &customPathVar);
// locationextractor.cpp - 抽取公共逻辑
QStringList LocationExtractor::expandCustomPathList(const QVariant &customPathVar)
{
QStringList resolved;
if (customPathVar.userType() == QMetaType::QVariantList) {
for (const QVariant &pathVar : customPathVar.toList()) {
const QString relPath = pathVar.toString();
if (relPath.isEmpty()) continue;
const QStringList expanded = expandCustomPath(QDir::homePath(), relPath);
for (const QString &p : expanded) {
if (!resolved.contains(p)) resolved.append(p);
}
}
} else {
const QString customSubdir = customPathVar.toString();
if (!customSubdir.isEmpty()) {
resolved = expandCustomPath(QDir::homePath(), customSubdir);
}
}
return resolved;
}
// actionextractor.cpp - 调用公共方法
QStringList ActionExtractor::resolveImReceivedPaths() const
{
// ... 前置逻辑不变 ...
const QVariant customPathVar = meta.value("custom_path");
QStringList resolved = LocationExtractor::expandCustomPathList(customPathVar);
if (resolved.isEmpty() && !xdgType.isEmpty()) {
const QString path = LocationExtractor::resolveXdgPath(xdgType);
if (!path.isEmpty()) {
resolved = { path };
}
}
// ... 后续逻辑不变 ...
}
// locationextractor.cpp - 同样调用公共方法
void LocationExtractor::extract(const QString &input, ParsedIntent &intent)
{
// ... 前置逻辑不变 ...
const QVariant customPathVar = metadata.value("custom_path");
QStringList resolvedPaths = expandCustomPathList(customPathVar);
if (resolvedPaths.isEmpty()) {
const QString path = resolveXdgPath(xdgType);
if (!path.isEmpty()) {
resolvedPaths = { path };
}
}
// ... 后续逻辑不变 ...
} |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The logic for handling
custom_pathas either a single string orQVariantListis duplicated betweenActionExtractor::resolveImReceivedPathsandLocationExtractor::extract; consider extracting a shared helper to keep behavior aligned and reduce future maintenance overhead. SemanticRuleEngine::ruleMetadataByIdperforms a linear scan over all groups and rules for each lookup; if this method is called frequently (e.g., once per consumed span), consider caching a ruleId→metadata (or ruleId→group) map during initialization to avoid repeated O(n) traversals.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The logic for handling `custom_path` as either a single string or `QVariantList` is duplicated between `ActionExtractor::resolveImReceivedPaths` and `LocationExtractor::extract`; consider extracting a shared helper to keep behavior aligned and reduce future maintenance overhead.
- `SemanticRuleEngine::ruleMetadataById` performs a linear scan over all groups and rules for each lookup; if this method is called frequently (e.g., once per consumed span), consider caching a ruleId→metadata (or ruleId→group) map during initialization to avoid repeated O(n) traversals.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
/forcemerge |
|
This pr force merged! (status: blocked) |
QVariantList for custom_path field
patterns
group
LocationExtractor
results
Log: Added support for multiple search paths and result filtering by
file patterns
Influence:
feat: 增强语义搜索支持多路径和模式过滤
QVariantList
Log: 新增支持多个搜索路径及按文件模式过滤结果的功能
Influence:
Summary by Sourcery
Enhance semantic search to support multiple rule-defined search paths and filtering of results by file name patterns.
New Features:
Enhancements: