feat(feed): cold-start discovery feed for new pets with no follows
A brand-new pet with zero posts of its own and no followees with posts saw a completely empty feed on first visit. Instead of that dead-feeling first impression, getFeed now falls back to recent posts from other pets of the same species, ranked by the existing algoScore (engagement + recency) — same idea as a "For You" feed, scoped by species instead of follows. Only kicks in on the first page (no cursor) of the primary Redis-backed path, so paginating an already-empty follow feed doesn't keep serving discovery pages. Response carries a `source: "following" | "discovery"` flag; FeedList shows a small dismissless banner explaining the posts aren't from follows yet, otherwise the feed renders identically (WelcomeCard, feed-mode toggle, PostCard list all unchanged). Added 2 regression tests covering the discovery-fallback trigger and the "don't discovery-fallback while paginating" edge case.
This commit is contained in:
1 parent
18555341e8
commit
ff607a604d
5 files changed
+142
-25
No files matched your search
@@ -74,6 +74,10 @@ export function FeedList() {
|
||||
const ads = useMemo(() => activeAds ?? [], [activeAds]);
|
||||
|
||||
const allPosts = useMemo(() => data?.pages.flatMap((page) => page.posts) ?? [], [data]);
|
||||
// Cold-start: brand-new pet with no follows yet gets species-matched
|
||||
// discovery posts instead of a dead feed (see feed.ts's getDiscoveryPosts).
|
||||
// Only the first page can carry this flag.
|
||||
const isDiscoveryFeed = data?.pages[0]?.source === "discovery";
|
||||
|
||||
// Build interleaved feed: inject one ad every AD_INTERVAL posts (cycle through ads)
|
||||
type Post = (typeof allPosts)[number];
|
||||
@@ -138,6 +142,15 @@ export function FeedList() {
|
||||
{/* New-user welcome card */}
|
||||
{activePetId && <WelcomeCard petId={activePetId} />}
|
||||
|
||||
{/* Cold-start discovery banner — shown when the feed is filled with
|
||||
species-matched discovery posts because the pet follows no one yet */}
|
||||
{isDiscoveryFeed && (
|
||||
<p className="flex items-center gap-1.5 text-xs text-muted-foreground mb-6 px-1">
|
||||
<Sparkles className="h-3.5 w-3.5 text-orange-500 shrink-0" aria-hidden="true" />
|
||||
{t("discoveryBanner")}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Feed posts + injected ads */}
|
||||
<div className="flex flex-col gap-8">
|
||||
{feedItems.map((item) =>
|
||||
|
||||
Reference in new issue
Block a user