feat(rules): add "Title Contains" condition to Rule Engine (#1670)#2354
Conversation
WalkthroughAdds two title-based condition types ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
Greptile SummaryAdds two new condition types to the Rule Engine: "Title Contains" and "Title Does Not Contain", enabling users to create automation rules based on bookmark titles. Key Changes
The implementation follows existing patterns from Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UI as RuleEngineConditionBuilder
participant Types as rules.ts (Zod)
participant Engine as RuleEngine
participant DB as Database
User->>UI: Select "Title Contains" condition
UI->>UI: handleTypeChange("titleContains")
UI->>UI: onChange({type: "titleContains", str: ""})
User->>UI: Enter search string
UI->>UI: Update condition.str value
User->>UI: Save rule
UI->>Types: Validate rule schema
Types->>Types: Check str.length > 0
Types-->>UI: Validation success
UI->>DB: Save rule with condition
Note over Engine: When bookmark event occurs
Engine->>DB: Fetch bookmark with title
DB-->>Engine: Bookmark data
Engine->>Engine: doesBookmarkMatchConditions(condition)
Engine->>Engine: Check (bookmark.title ?? "").includes(condition.str)
Engine-->>Engine: Return true/false
alt Condition matches
Engine->>Engine: Execute rule actions
Engine->>DB: Apply actions (add tag, etc)
end
|
Greptile found no issues!From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
|
Hey, thanks for opening the PR! Although the logic itself is correct, |
packages/trpc/lib/ruleEngine.ts
Outdated
| ); | ||
| } | ||
| case "titleContains": { | ||
| return (this.bookmark.title ?? "").includes(condition.str); |
There was a problem hiding this comment.
crawled bookmarks has their links in this.bookmark.content.title (if they're links) with no user overrides. So this might need to be something like:
this.bookmark.title ?? (this bookmark.type == BookmarkTypes.LINK ? this.bookmark.content.title : "")
Thanks for the clarification. I’ve updated the PR to hide this action under the “bookmark created” condition to avoid confusion |
|
Thank you! |
Adds two new conditions to the Rule Engine:
This allows users to create automation rules based on bookmark titles. Solved #1670