Skip to content

Add Rules tab for article automation - #96

Merged
WCY-dt merged 6 commits into
mainfrom
copilot/support-plugin-system
Nov 26, 2025
Merged

WCY-dt merged 6 commits into
mainfrom
copilot/support-plugin-system

Conversation

Copilot AI commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

Description

Implements a rules/plugin system allowing users to create automation rules that apply actions to articles based on filter conditions. Rules follow an "If [conditions] then [actions]" pattern, with conditions reusing the existing filter logic. Rules are automatically applied to new articles when feeds are refreshed and to existing articles when a new rule is created.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style/UI change
  • ♻️ Code refactoring
  • ⚡ Performance improvement
  • ✅ Test addition/update

Related Issues

Fixes #61

Changes Made

Frontend:

  • RulesTab.vue - New settings tab for managing rules with enable/disable toggle and apply-now functionality, styled consistently with other settings tabs
  • RuleEditorModal.vue - Modal for creating/editing rules with condition builder and action selection
  • SettingsModal.vue - Added Rules tab between Feeds and Shortcuts
  • i18n.js - Added English and Chinese translations for all rule-related strings

Backend:

  • rules/engine.go - New rules engine package for reusable rule application logic
  • rules_handlers.go - New /api/rules/apply endpoint that evaluates conditions and applies actions to matching articles
  • article_db.go - Added SetArticleFavorite and SetArticleHidden methods for direct state updates
  • settings_handlers.go - Added rules setting for persistence
  • fetcher.go - Rules are automatically applied to newly fetched articles during feed refresh

Conditions supported: Feed name, category, article title, date range, read/favorite/hidden status. Combinable with AND/OR logic and NOT modifier.

Actions supported: favorite, unfavorite, hide, unhide, mark read, mark unread. Multiple actions per rule.

Automatic rule application:

  • Rules are applied to existing articles when a new rule is created
  • Rules are applied to new articles when feeds are refreshed

Screenshots

After

Rules Tab Rule Editor
With Condition With Action

Testing

Test Configuration

  • OS: Linux
  • Go Version: 1.24
  • Node Version: 20.x

Test Steps

  1. Open Settings → Rules tab
  2. Click "Add Rule" to create a rule
  3. Add conditions (optional - empty means all articles)
  4. Add one or more actions
  5. Save - the rule is automatically applied to existing articles
  6. Refresh feeds to see rules applied to new articles

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Rules are stored as JSON in the rules setting key. The condition evaluation logic mirrors the existing ArticleFilterModal implementation for consistency. Each article is matched against rules in order, and only the first matching rule is applied to prevent conflicting actions.

Breaking Changes

None.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support plugin system</issue_title>
<issue_description>支持用户在应用内编写规则,以执行各类自动化操作。

需要支持以下内容:

  1. 设置页中增加“规则”tab。
  2. 可以添加多条规则,每条规则都类似“如果[条件],则[执行操作]”。
  3. [条件]和[执行操作]都以弹窗形式进行选择,选择后,将选择的内容以合适的文字形式填入。
  4. [条件]部分可以直接照搬之前的过滤器部分。
  5. [执行操作]部分允许顺序组合多条操作,操作可以包括收藏、隐藏等。
  6. [条件]部分也可以设置为空,表明不管什么时候都应当执行操作。

整个功能的其余设计可以参考惯例。</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 26, 2025 03:52
Co-authored-by: WCY-dt <55525165+WCY-dt@users.noreply.github.com>
Co-authored-by: WCY-dt <55525165+WCY-dt@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for plugin system with rules Add Rules tab for article automation Nov 26, 2025
Copilot AI requested a review from WCY-dt November 26, 2025 04:02
@WCY-dt

WCY-dt commented Nov 26, 2025

Copy link
Copy Markdown
Member

@copilot 优化:

  1. rules的提示"If+Condition->Actions"可以删除。
  2. 增加规则后,那个开关样式不好看。可以参考设置页中的其它开关样式修改。
  3. rules和shortcuts页中的文字、图标、按钮等似乎都有点小,其大小需要和其它tab统一。
  4. 规则添加后,首先要对数据库中已有的数据进行应用。之后当更新feed列表或者文章列表时,都需要应用规则。
  5. 分析整个项目,看看是否可以增加更多可用的过滤器或者操作。

Copilot AI and others added 2 commits November 26, 2025 04:13
Co-authored-by: WCY-dt <55525165+WCY-dt@users.noreply.github.com>
Co-authored-by: WCY-dt <55525165+WCY-dt@users.noreply.github.com>

Copilot AI commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor Author

@copilot 优化:

  1. rules的提示"If+Condition->Actions"可以删除。...

Addressed all feedback in commits ca90e92 and d512fb8:

  1. ✅ Removed "If+Condition->Actions" tip
  2. ✅ Updated toggle switch to use the same style as other settings tabs (checkbox toggle class)
  3. ✅ Increased text/icon/button sizes to match other tabs
  4. ✅ Rules now automatically apply to:
    • Existing articles when a new rule is created
    • New articles when feeds are refreshed
  5. ✅ Added "is_hidden" (隐藏状态) as a new filter condition

Updated Rules Tab

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • nonexistent-feed-url-12345.com
    • Triggering command: /tmp/go-build4024589199/b279/discovery.test /tmp/go-build4024589199/b279/discovery.test -test.testlogfile=/tmp/go-build4024589199/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@WCY-dt WCY-dt added the ✨enhancement New feature or request label Nov 26, 2025
@WCY-dt
WCY-dt marked this pull request as ready for review November 26, 2025 04:37
@WCY-dt
WCY-dt merged commit 29cabb5 into main Nov 26, 2025
3 checks passed
@WCY-dt
WCY-dt deleted the copilot/support-plugin-system branch November 26, 2025 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for plugin system with rules

2 participants