feat: implement smart rules engine for notification filtering#5
Conversation
Signed-off-by: samzong <[email protected]>
Summary of ChangesHello @samzong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a significant new feature: a smart rules engine for GitHub notifications. It empowers users to automate the handling of their notifications by setting up custom criteria and actions. This enhancement aims to reduce notification fatigue and allow users to focus on the most relevant updates, providing a more personalized and efficient notification experience within the application. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a powerful new rules engine for filtering GitHub notifications. It includes the core logic for the engine, data models for rules, persistence using UserDefaults, and a comprehensive UI in the settings for creating and managing these rules. The integration with the notification service ensures that these rules are applied to new notifications to automatically mark them as read or suppress system notifications.
The implementation is generally solid, but I've found a critical issue where the rules UI is disconnected from the rule engine due to separate RuleStorage instances. I've also noted a couple of medium-severity issues: one regarding user feedback on failed import/export operations, and another concerning a misleading example in the new documentation. Addressing these points will significantly improve the feature's correctness and usability.
| struct RulesTab: View { | ||
| let settingsWidth: CGFloat | ||
|
|
||
| @State private var ruleStorage = RuleStorage() |
There was a problem hiding this comment.
This view creates its own RuleStorage instance, which is separate from the instance created in GitHubNotifierApp and used by NotificationService. This means any rules created or modified in the settings UI will not be applied to incoming notifications, breaking the feature's core functionality.
To fix this, RuleStorage should be treated as a single source of truth. It should be created once in GitHubNotifierApp and passed down to SettingsView and this RulesTab via the SwiftUI environment.
Suggested Fix:
-
In
GitHubNotifierApp.swift, injectruleStorageinto theSettingsView's environment:Settings { SettingsView(updater: updaterController.updater) .environment(notificationService) .environment(activityService) .environment(ruleStorage) // Add this line }
-
In this file, receive
ruleStoragefrom the environment instead of creating a new instance.
| @State private var ruleStorage = RuleStorage() | |
| @Environment(RuleStorage.self) private var ruleStorage |
| print("Failed to import rules: \(error)") | ||
| // Ideally show an alert here |
There was a problem hiding this comment.
The error handling for rule import (and export) currently only prints to the console. For a better user experience, it would be ideal to display an alert to the user if an operation fails. This provides clear feedback when something goes wrong, such as selecting a corrupted or incorrectly formatted file.
You could implement a native alert like this:
} catch {
print("Failed to import rules: \(error)")
// Show an alert to the user
let alert = NSAlert()
alert.messageText = "Import Failed"
alert.informativeText = "Could not import rules from the selected file. The file might be corrupted or in the wrong format."
alert.alertStyle = .critical
alert.runModal()
}| - **Name**: Ignore non-core repos | ||
| - **Condition**: | ||
| - `Repository` **does not equal** `my-company/*` | ||
| - **Action**: | ||
| - `Mark as Read` |
There was a problem hiding this comment.
This example is misleading. The RuleEngine implementation does not support using wildcards (*) with the does not equal operator. Wildcards are only effective with the matches operator.
When a user configures a rule with Repository does not equal my-company/*, the engine will perform a literal string comparison against "my-company/*", not a wildcard match. This will not produce the desired behavior and will cause user confusion.
Please update the documentation to clarify that wildcards are only supported by the matches operator and either correct or remove this example.
No description provided.