Skip to content

feat(homepage): 'What's Happening Now' activity feed widget#12863

Open
mekarpeles wants to merge 3 commits into
masterfrom
12861/homepage-activity-feed
Open

feat(homepage): 'What's Happening Now' activity feed widget#12863
mekarpeles wants to merge 3 commits into
masterfrom
12861/homepage-activity-feed

Conversation

@mekarpeles

Copy link
Copy Markdown
Member

Summary

Adds a mobile-first "What's Happening Now" activity feed to the Open Library homepage, showing recent public reading log activity in a sliding 3-card window.

  • API: GET /api/internal/activity.json — paginated, filters to patrons with public_readlog: yes, Solr-enriched with title/cover/author
  • Lit component: <ol-activity-feed> — 3 stacked cards, auto-advances every 15s, manual right-arrow advance, "More →" link to /trending when exhausted. Uses design system CSS tokens (--primary-blue, --border-radius-*, etc.) for all interactive elements.
  • Template: home/activity_feed.html wired into home/index.html between the welcome section and trending carousel
  • Follow button: optimistic update via POST /people/{key}/follows, redirects anonymous users to login

Closes

Closes #12861

Related

Files changed

File Change
openlibrary/fastapi/internal/api.py New GET /api/internal/activity.json endpoint
openlibrary/components/lit/OLActivityFeed.js New <ol-activity-feed> Lit component
openlibrary/components/lit/index.js Export the new component
openlibrary/templates/home/activity_feed.html New homepage partial
openlibrary/templates/home/index.html Wire in the partial

API response shape

{
  "activity": [
    {
      "type": "shelf_change",
      "shelf_id": 2,
      "shelf_label": "is Currently Reading",
      "username": "jsmith",
      "avatar_url": "https://...",
      "work_key": "/works/OL123W",
      "title": "The Great Gatsby",
      "cover_id": 12345,
      "author": "F. Scott Fitzgerald",
      "updated": "2026-06-04T12:00:00"
    }
  ],
  "page": 1
}

Verification

JS build: webpack compiled with 0 errors (make js)
Linting: ruff ✅, eslint ✅, codespell ✅

⚠️ Docker note: End-to-end browser verification was blocked by a pre-existing Python 3.14 regression in master — except A, B: Python 2 syntax in core/db.py (and other files) causes a SyntaxError on startup. This is unrelated to our 5 changed files. Tracking in #12861 comment.

Checklist

  • API endpoint follows FastAPI patterns in internal/api.py
  • Component uses design system tokens (no hardcoded brand colors)
  • Privacy: only shows public_readlog: yes patrons
  • Follow button redirects anon users to login
  • Fallback images for broken avatars/covers
  • webpack 0 errors
  • pre-commit clean (eslint, ruff, codespell)
  • Browser verification (blocked: see Docker note above)

Copilot AI review requested due to automatic review settings June 5, 2026 15:30
@github-actions github-actions Bot added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “What’s Happening Now” homepage section powered by a Lit web component and a new internal FastAPI endpoint, intended to show recent public reading-log activity in a rotating 3-card feed.

Changes:

  • Added a homepage partial (home/activity_feed.html) and wired it into the homepage template.
  • Introduced GET /api/internal/activity.json to return recent public reading-log activity enriched with Solr work metadata.
  • Added and exported a new Lit component <ol-activity-feed> that fetches/paginates and renders the activity cards, including a Follow action.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
openlibrary/templates/home/index.html Inserts the new activity-feed partial into the homepage layout.
openlibrary/templates/home/activity_feed.html Defines the homepage section wrapper and instantiates <ol-activity-feed>.
openlibrary/fastapi/internal/api.py Adds the new activity feed JSON endpoint and response models.
openlibrary/components/lit/OLActivityFeed.js Implements the Lit activity feed component, auto-advance behavior, and follow button logic.
openlibrary/components/lit/index.js Exports the new Lit component.

Comment thread openlibrary/fastapi/internal/api.py
Comment thread openlibrary/fastapi/internal/api.py Outdated
Comment thread openlibrary/fastapi/internal/api.py
Comment thread openlibrary/components/lit/OLActivityFeed.js
Comment thread openlibrary/components/lit/OLActivityFeed.js
Comment thread openlibrary/templates/home/activity_feed.html Outdated
Comment thread openlibrary/templates/home/activity_feed.html Outdated
@mekarpeles mekarpeles force-pushed the 12861/homepage-activity-feed branch from fdf0bbe to e090359 Compare June 5, 2026 15:55
@mekarpeles mekarpeles self-assigned this Jun 8, 2026
@mekarpeles mekarpeles added Priority: 3 Issues that we can consider at our leisure. [managed] and removed Priority: 1 Do this week, receiving emails, time sensitive, . [managed] labels Jun 15, 2026
Adds a sliding-window activity feed to the Open Library homepage showing
recent public reading log activity. Three vertically-stacked cards are
shown at once, auto-advancing every 15 seconds. Patrons can follow each
other directly from the feed.

- FastAPI endpoint: GET /api/internal/activity.json (paginated, public-only)
- Lit web component: <ol-activity-feed> with auto-advance timer and
  manual navigation; exhausted queue shows "More →" link to /trending
- Homepage partial: home/activity_feed.html wired into home/index.html
- Filters to public reading logs only (public_readlog preference check)
- Solr enrichment for title/cover/author via add_solr_works_async

Closes #12861
…ow DOM

Replace hardcoded hex values with CSS custom properties from the
OL token system (--primary-blue, --link-blue, --white, --dark-grey,
--border-radius-*, --font-size-body-medium) so the component tracks
the design system automatically. Fallback values keep the component
functional in any context that hasn't loaded the token stylesheet.

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
- Use `.isoformat()` for datetime fields so `new Date()` parses reliably
  across all browsers (was: str() → "YYYY-MM-DD HH:MM:SS", non-ISO)
- Add `viewer-username` attribute to <ol-activity-feed>; pass it from
  the homepage partial via ctx.user — document.body.dataset.username
  is only set for librarians/admins on specific pages, not the homepage
- Follow URL: use `/follows.json` to match the delegate route encoding
  (was: `/follows` which does not resolve via web.py delegate)
- Move Bookshelves import to module level; add noqa for `import web`
  which must be deferred (infogami request context not available at load)
@mekarpeles mekarpeles force-pushed the 12861/homepage-activity-feed branch from e090359 to 368b807 Compare June 16, 2026 05:15
@mekarpeles

Copy link
Copy Markdown
Member Author

Hi — I'm Pierre, an AI-assisted PR health agent running on behalf of @mekarpeles.

Resolved a merge conflict in openlibrary/fastapi/internal/api.py:

Master had added:

from openlibrary.core.bestbook import Bestbook
from openlibrary.core.follows import PubSub

This branch added:

from openlibrary.core.bookshelves import Bookshelves

Resolution: kept all three imports in alphabetical order. All three are actively used in the file (verified before resolving). This was a pure import-ordering conflict with no semantic ambiguity.

Safeguards: Confirmed all commits authored by @mekarpeles. Zero unresolved review threads. Used git push --force-with-lease.

To reverse: git reset --hard e090359ef then git push --force-with-lease.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 3 Issues that we can consider at our leisure. [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Mobile-first 'What's Happening Now' activity feed for homepage

2 participants