Skip to content

feat: implement smart rules engine for notification filtering#5

Merged
samzong merged 1 commit intomainfrom
feat-smart-rules
Jan 9, 2026
Merged

feat: implement smart rules engine for notification filtering#5
samzong merged 1 commit intomainfrom
feat-smart-rules

Conversation

@samzong
Copy link
Copy Markdown
Owner

@samzong samzong commented Jan 9, 2026

No description provided.

@samzong samzong merged commit 22979a8 into main Jan 9, 2026
1 check failed
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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

  • Smart Rules Engine Implementation: Introduced a comprehensive smart rules engine allowing users to define custom rules for filtering and managing GitHub notifications. This includes new data models for rules, conditions, and actions, along with the core logic for evaluating notifications.
  • New Rules Management UI: Added a dedicated 'Rules' tab within the application settings, featuring a user interface for creating, editing, enabling/disabling, reordering, importing, and exporting notification rules. This UI includes detailed editors for rule conditions and actions.
  • Notification Service Integration: Integrated the new rules engine into the NotificationService to automatically evaluate incoming GitHub notifications. Based on matching rules, notifications can now be automatically marked as read or have their system notifications suppressed.
  • Enhanced User Experience: Added a new button to the menu bar's sub-tab picker to quickly access the 'Rules' settings. The settings window size has also been adjusted to accommodate the new rules management interface, and new localization strings were added for English and Chinese.
  • Documentation: A new markdown file (docs/rules_usage.md) has been added, providing detailed guidance on how to use the rules engine, including examples and an explanation of the rule evaluation flow.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

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:

  1. In GitHubNotifierApp.swift, inject ruleStorage into the SettingsView's environment:

    Settings {
        SettingsView(updater: updaterController.updater)
            .environment(notificationService)
            .environment(activityService)
            .environment(ruleStorage) // Add this line
    }
  2. In this file, receive ruleStorage from the environment instead of creating a new instance.

Suggested change
@State private var ruleStorage = RuleStorage()
@Environment(RuleStorage.self) private var ruleStorage

Comment on lines +97 to +98
print("Failed to import rules: \(error)")
// Ideally show an alert here
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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()
}

Comment thread docs/rules_usage.md
Comment on lines +101 to +105
- **Name**: Ignore non-core repos
- **Condition**:
- `Repository` **does not equal** `my-company/*`
- **Action**:
- `Mark as Read`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

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.

1 participant