Skip to content

Add custom smart feeds with a rule-based criteria builder#2

Open
davidfwatson wants to merge 2 commits into
mainfrom
feature/custom-smart-feeds
Open

Add custom smart feeds with a rule-based criteria builder#2
davidfwatson wants to merge 2 commits into
mainfrom
feature/custom-smart-feeds

Conversation

@davidfwatson

Copy link
Copy Markdown
Owner

What

Adds the ability to create your own smart feeds, instead of only the three built-ins (Today, All Unread, Starred). A custom smart feed is defined by a set of conditions combined with Match All / Match Any.

v1 conditions: read status (unread/read), starred status, and feed is / feed is not.

The motivating example — "all unread except certain feeds" — is just Match All of [unread, feed is not X, feed is not Y].

How it works

  • SmartFeedCriteria (Codable/Sendable/Hashable) lives in the ArticlesDatabase module so both FetchType (Account) and the SQL builder can see it. It builds a bounded WHERE clause. Feed conditions are account-scoped: a feedID from another account reduces to a constant (0/1), so a cross-account smart feed stays correct as each account's database is queried in turn.
  • New FetchType.smartFeedCriteria(_:) reuses AccountManager's cross-account fetch aggregation and SmartFeed's per-account unread counting — no new fan-out plumbing.
  • UserSmartFeed + CustomSmartFeedDelegate, persisted as JSON in AppConfig.dataFolder. SmartFeedsController now loads/adds/updates/removes them and posts .ChildrenDidChange so both sidebars rebuild; find(by:) resolves custom UUIDs for state restoration.
  • A shared SwiftUI editor (SmartFeedEditorView) hosted in a UIHostingController (iOS) and NSHostingController (Mac).
  • iOS: Add Smart Feed in the + menu / action sheet; swipe + context-menu edit/delete for custom feeds only (built-ins stay non-deletable); custom removal path since DeleteCommand rejects pseudo-feeds.
  • Mac: New Smart Feed… in the File menu and the no-selection sidebar menu; Edit/Delete in the smart-feed context menu, gated to custom feeds.

Testing

  • Unit tests (SmartFeedCriteriaTests, 14 cases) cover WHERE-clause building, cross-account scoping, match all/any, negation, the "unread excluding feeds" example, and Codable round-tripping — all passing via swift test.
  • Builds cleanly for both the macOS and iOS schemes.
  • ⚠️ Still needs in-app manual verification (couldn't be exercised headlessly): create a smart feed, confirm it appears on both platforms with correct contents + unread badge, updates live, persists/restores across relaunch, and edit/delete behave.

Out of scope (possible follow-ups)

Text/body-contains (the FTS index is available), date windows, folder conditions, author/URL matching, reordering custom feeds, and syncing definitions across devices.

🤖 Generated with Claude Code

davidfwatson and others added 2 commits July 17, 2026 11:46
Users can now create their own smart feeds — not just the three built-in
ones (Today, All Unread, Starred). A smart feed is defined by a set of
conditions combined with Match All / Match Any. v1 conditions: read status
(unread/read), starred status, and feed is / feed is not. The motivating
example — "all unread except certain feeds" — is expressible as Match All of
[unread, feed is not X, feed is not Y].

Design:
- SmartFeedCriteria (Codable/Sendable/Hashable) lives in the ArticlesDatabase
  module so both FetchType (Account) and the SQL builder can reference it. It
  builds a bounded WHERE clause; feed conditions are account-scoped (a feedID
  from another account reduces to a constant), keeping cross-account feeds
  correct as each account is queried in turn.
- New FetchType.smartFeedCriteria(_:) reuses AccountManager's cross-account
  fetch aggregation and SmartFeed's per-account unread counting for free.
- CustomSmartFeedDelegate + UserSmartFeed, persisted as JSON in
  AppConfig.dataFolder; SmartFeedsController now loads/adds/updates/removes
  them and posts .ChildrenDidChange so both sidebars rebuild. find(by:)
  resolves custom UUIDs for state restoration.
- A shared SwiftUI editor (SmartFeedEditorView) is hosted in a
  UIHostingController on iOS and an NSHostingController on Mac.
- iOS: Add Smart Feed in the + menu / action sheet; swipe + context-menu
  edit/delete for custom feeds only; custom removal path (DeleteCommand
  rejects pseudo-feeds); built-ins stay non-deletable.
- Mac: New Smart Feed… in the File menu and no-selection sidebar menu;
  Edit/Delete in the smart-feed context menu, gated to custom feeds.

Unit tests cover the WHERE-clause building, cross-account scoping, match
all/any, negation, and Codable round-tripping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hyatbnytz2qnLuJsiYQYb4
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hyatbnytz2qnLuJsiYQYb4
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