Commit Graph
11 Commits
Author SHA1 Message Date
ksmithandClaude Sonnet 5.5 8d2900424a Use keyset pagination for the stream (C4)
The stream did a COUNT(*) and OFFSET slice on every request, ordered by
a non-unique (published_at, fetched_at) — deep pages got slower and
articles sharing a timestamp could repeat or vanish across pages.

It now orders by (Coalesce(published_at, fetched_at), id) and pages with
before/after cursors, fetching one extra row to know whether another
page exists instead of counting. Pagination links also keep the feed
scope, which the old links silently dropped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-01 08:51:20 -07:00
ksmithandClaude Sonnet 5 abf4cef55b Cache sidebar unread counts for a short TTL (C3)
apps.core.context_processors.sidebar runs on every authenticated page
render and called unread_counts_by_feed, a join/group-by over the
user's whole article corpus, every single time — cost grew with the
archive's size regardless of which page was being viewed.

unread_counts_by_feed now caches its {feed_id: count} result per user
for 30 seconds (apps.core.cache_utils). The reader views that change
the current user's own read state (toggle_read, mark_all_read, viewing
an article) invalidate it immediately so the sidebar never visibly lags
behind the action that just caused it; other paths (rule-driven state
changes during background ingestion) aren't explicitly invalidated and
simply self-heal within the TTL, which is an acceptable tradeoff
already made elsewhere in this app (the stream's own "new articles"
banner polls on the same 30s cadence).

Also adds a global cache.clear() autouse fixture (conftest.py) — the
test CACHES backend (LocMemCache) lives in process memory and survives
Django's per-test DB rollback, so a cached count keyed by a user's pk
could otherwise leak into an unrelated later test reusing that pk.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 16:09:28 -06:00
ksmithandClaude Sonnet 5 03dd37e69d Notify the open stream when new articles arrive
The stream had no way to learn about articles the background poll
ingested while the page was open — only a manual reload or navigation
ever picked them up.

Adds a lightweight "N new articles — click to show" banner: the stream
records the highest article id in its current scope (filter/tag/feed)
when rendered, and an htmx poll every 30s checks reader:check_new for
anything newer in that same scope. It never swaps the list out from
under you mid-read — clicking the banner is what actually reloads it.
id, not published_at, is the cursor, since a feed can backdate an
entry's published date below everything currently on screen while it's
still genuinely new to this stream.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-31 15:04:55 -06:00
ksmithandClaude Sonnet 5 753ae9efc7 Make Starred and Saved-for-later pre-configured system tags
UserArticleState.is_starred/is_saved_for_later/starred_at are gone —
starring and saving now add/remove an ArticleTag against a per-user
"Starred" / "Saved for later" Tag, created lazily on first use and marked
Tag.is_system=True. is_read/is_hidden stay on UserArticleState since
they're genuine reading state, not categorization, which is what made
these two candidates for unifying into the general tag mechanism.

System tags are excluded from the Manage Tags page and from delete_tag
(get_object_or_404 now requires is_system=False, so attempting to delete
one 404s) and from the subscription-tag autocomplete, since they
categorize articles, not feeds. The star/save icons are still exactly
where they were — this only changes what powers them.

apps.rules.engine's star action now does get_system_tag + ArticleTag.
get_or_create instead of setting a boolean field. A data migration
converts every existing is_starred=True/is_saved_for_later=True row into
its ArticleTag equivalent before the fields are dropped — verified by
seeding the pre-removal schema directly (including a row with both flags
set) and confirming the migration produces the right tags.

apps.articles.queries.with_user_state gained one more query (tag lookup
for the current page's articles) to stay in the same "fixed number of
queries regardless of article count" shape it already had.

Verified end to end against a running dev server: toggling star/saved,
the starred/saved filters, the sidebar's Favourites count, and that the
Starred tag doesn't appear on the Manage Tags page.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 21:36:44 -06:00
ksmithandClaude Sonnet 5 0e132e9ab9 Remove folders; feeds are organized by tags now
Folders are gone — organization is tags-only, via the SubscriptionTag
model added last commit. A migration converts every existing Folder into
a same-named Tag applied to its feeds, and every folder-scoped FilterRule
into an equivalent tag-scoped one, before the Folder table is dropped, so
upgrading an existing instance loses nothing (verified by seeding the
pre-removal schema directly and running the migration chain against it).

Unlike folders, a feed can carry more than one tag, so:
- apps.articles.tasks.apply_filter_rules_for_feed and apps.rules.tasks's
  backlog re-apply now scope by "does this feed carry tag X" rather than
  "does this feed belong to folder X".
- apps.feeds.opml: a feed's tags export as a comma-separated "category"
  attribute (the standard OPML way to represent multiple categories)
  instead of nesting under one folder outline. Import reads both that
  attribute and nested category outlines, turning each enclosing level
  into its own tag rather than collapsing to the nearest one.
- The sidebar groups feeds by tag instead of folder, so a feed with two
  tags now appears in both groups; untagged feeds fall into "Untagged".

AddFeedForm gained a comma-separated tag_names field for parity with the
old add-time folder picker. EditSubscriptionForm dropped its folder
field entirely — tagging a subscription happens through the tag editor
already on that page.

Verified end to end: the migration chain from empty, the data migration
against a seeded pre-removal schema (folder/subscription/rule all convert
correctly), and the running app's sidebar grouping, OPML export category
attributes, and tag editor.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 21:30:06 -06:00
ksmithandClaude Sonnet 5 3b58fdcb7e Add subscription editing, feed-level tags, and a remembered stream filter
Subscription editing was a real gap: there was no way to rename a feed's
display title, move it between folders, or create a folder at all outside
OPML import. Added an edit page (apps/feeds/views.py:edit_subscription,
EditSubscriptionForm) reachable from the subscriptions list.

Added feed-level tagging via a new SubscriptionTag model (apps/articles/
models.py), mirroring the existing ArticleTag — tag a whole feed on its
edit page, and every one of its articles surfaces under that tag in the
stream alongside individually-tagged articles (apps.reader.views._apply_
scope now matches either). Renamed AddTagToArticleForm to AddTagForm
since it's shared by both now.

The stream also now remembers the last filter (unread/all/starred/saved)
in the session instead of always defaulting to "unread" when a sidebar
feed/folder/tag link omits ?filter= — sidebar links no longer force
?filter=all, letting the remembered choice apply.

Verified end to end against a running dev server: editing a subscription's
title/folder, creating a folder inline, tagging a feed and seeing its
articles appear under that tag, and the remembered-filter behavior across
requests with no ?filter= param.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 21:20:37 -06:00
ksmithandClaude Sonnet 5 cfa64b5485 Rebuild the reader UI to match FreshRSS's two-column layout
The previous UI was plain unstyled lists. Rebuilt around what FreshRSS
actually looks like (per reference screenshots): a persistent left sidebar
(folders/feeds with unread counts, favourites, tags) and a single main
column with a date-grouped article list, where clicking a title expands
the full article inline in place rather than navigating to a separate page.

- apps/core/context_processors.py: feeds the sidebar's folder/feed tree,
  tags, and starred count to every authenticated page in one shared query
  set, so base.html can render it without each view wiring it up.
- apps/reader/views.py: date-grouped stream (itertools.groupby over the
  already-ordered queryset), ?feed=/?folder= scoping alongside the existing
  ?tag=, a bulk mark-all-read endpoint (bulk_create/update, not one
  UserArticleState per article), and article_inline — the htmx endpoint
  behind the inline expand, sharing its mark-read logic with the full
  article_detail view via _load_article_and_mark_read.
- templates/reader/_article_inline.html returns the article content plus
  an out-of-band swap of _article_actions.html, so the row's read/star
  icons update immediately when an article is expanded and marked read.
- static/js/stream.js: the accordion toggle (one article open at a time),
  calling htmx.ajax() directly rather than hx-* attributes so a second
  click on an already-open row can collapse it without re-fetching.
- static/css/base.css: full FreshRSS-like dark theme (with a light
  variant under prefers-color-scheme) replacing the previous unstyled
  pass — sidebar, topbar search, row/icon states, inline-expand styling.

Verified end to end against a running dev server: folder/feed/tag scoping,
mark-all-read, the inline-expand mark-read side effect and its icon
update, and — against config.settings.prod specifically — that no inline
<script> crept back in anywhere (would silently break under the CSP added
in the previous commit) and the CSP header is still present on every page.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 21:11:17 -06:00
ksmithandClaude Sonnet 5 8653dbeaf9 Add full-text search with per-backend SQLite/Postgres implementations
Implements the backend-agnostic search interface from the plan,
selected at runtime by connection.vendor:

- SQLite: an FTS5 virtual table (external-content, mirroring
  Article.title/content_html) created via a vendor-conditional
  migration, kept in sync by insert/update/delete triggers. Queries
  wrap the whole user input as a single FTS5 phrase so punctuation in
  a search box can't break MATCH syntax. `reindex_search` management
  command rebuilds it after bulk imports.
- Postgres: computes the search vector on the fly per the plan's
  decision (title weighted above content, no stored/indexed column)
  rather than diverging the schema from SQLite.

Both backends scope results to the requesting user's own subscriptions
and share the stream/detail article-row template and read/star/save
actions via a new apps.articles.queries.with_user_state() helper,
extracted from apps.reader.views to avoid duplicating that annotation
logic for search results.

Verified live: the SQLite path end-to-end in-browser against the real
Hacker News subscription (search UI, phrase matching, no-match case),
and the Postgres path against a throwaway Postgres container (search,
feed-scoping, and title-vs-content ranking), torn down afterward — not
part of this project's own infrastructure.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 16:37:22 -06:00
ksmithandClaude Sonnet 5 579696efc0 Add tags and tag-based stream filtering
Implements tag management (create/delete) and per-article tagging with
a freeform "add tag" input that creates the tag on first use instead
of requiring a separate create-then-assign flow. Tags render as pills
in the stream header; clicking one filters the stream to articles
carrying that tag, combinable with the existing read/starred/saved
filters.

The "Saved" filter already added in the reading-UI milestone functions
as the reading list, so this closes out the reading-list/tags
milestone without a separate dedicated view.

Verified live in-browser: creating a tag from an article, the pill
appearing in the stream nav, filtering by it, and deleting it from the
tag-management page, all via htmx without full page reloads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 16:26:30 -06:00
ksmithandClaude Sonnet 5 69e3520e3b Add the reading UI: stream, article detail, htmx actions
Implements the main reader surface: a filterable stream (Unread/All/
Starred/Saved) built on the lazy UserArticleState query pattern, an
article detail view that marks articles read on open, and htmx-backed
read/star/save-for-later toggles that update in place without a full
page reload. Rule-hidden articles are excluded from every filter.

Vendors htmx locally rather than loading it from a CDN, and adds
mobile-first responsive CSS (verified at 375px width in-browser, plus
dark mode via prefers-color-scheme).

Verified live against the real Hacker News feed subscribed in the
previous milestone: ingestion, filter switching, read/star/save
toggles, and article detail all confirmed working in the browser, with
two UI bugs fixed along the way (low-contrast message banners in dark
mode, horizontal overflow from long URLs in article content).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 16:08:44 -06:00
ksmithandClaude Sonnet 5 c635cd9330 Scaffold Django project and add first-run auth flow
Sets up the Evection project structure: split settings supporting both
SQLite and PostgreSQL via DATABASE_URL, Celery+Redis wiring, and the
planned app layout (accounts, feeds, articles, rules, search, reader,
pwa, core). Implements multi-user auth with a FreshRSS-style first-run
setup wizard, login/logout, and admin-only user management, covered by
automated tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 15:56:58 -06:00