fix(feed): keep For You feed populated (no empty-state flash + live recommended endpoint)#14446
Closed
dylanjeffers wants to merge 2 commits into
Closed
fix(feed): keep For You feed populated (no empty-state flash + live recommended endpoint)#14446dylanjeffers wants to merge 2 commits into
dylanjeffers wants to merge 2 commits into
Conversation
…y state The For You feed would render real tracks for a split second and then swap in the "follow artists" empty state, even for users who follow plenty of people. `useForYouFeed` set no `staleTime`, so with the react-query default of 0 the personalized query refetched on the next mount/focus immediately after the first paint. When that refetch settled empty — a transient backend result, or a different validator node in the fleet returning no items — react-query replaced the just-rendered feed with `[]`. The lineup reads an empty list as "no content" and renders the SuggestedFollows / FollowArtists prompt, so the feed appears then blanks. The empty-state has no follow-count check, so a momentary empty response is indistinguishable from "follows nobody." - Set `staleTime: Infinity` (overridable via options) so the loaded feed is stable for the session and isn't re-fetched-and-clobbered. Pagination is unaffected (fetchNextPage ignores staleTime). - Gate `enabled` on `currentUserId != null` (excluding `undefined`) so the query doesn't run while the account is still resolving and cache `[]` under the `[forYouFeed, undefined]` key — a stale empty entry a later render could briefly surface as the empty state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: bacadd1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14446.audius.workers.dev Unique preview for this PR (deployed from this branch). |
The dedicated GET /v1/users/{id}/feed/for-you endpoint is not yet rolled
out across the validator-node fleet and 404s in production, so the For
You tab renders empty. Fall back to GET /v1/tracks/recommended
(sdk.tracks.getRecommendedTracks) — the same personalized recommendation
source the Explore page used before the For You feed existed, which
reliably returns 200 from api.audius.co today.
/tracks/recommended has no offset param, so pagination passes the
already-seen track ids as exclusionList; each page returns fresh
recommendations that don't repeat earlier ones. The pageParam carries
the accumulated exclusion list. The hook keeps its existing return shape
(tracks-only lineup) plus the prior staleTime/enabled hardening, so
feed-page consumers are unchanged.
Swap back to getUserForYouFeed() once the new endpoint is deployed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has two commits, both keeping the For You feed populated:
/tracks/recommendedendpoint (the new for-you endpoint 404s in prod)Commit 1 — stop the empty-state flash
Summary
The For You feed renders real tracks for a split second and then swaps in the "follow artists" empty state — even for users who follow plenty of people. The data lands and renders correctly, then something overwrites it with empty.
Root cause
The empty state is purely lineup-driven (
entries.length === 0on mobile,tiles.length === 0on web) — there is no follow-count check, so a momentarily-empty response is indistinguishable from "follows nobody."useForYouFeedreturnsdata = query.data ?? [], so anything that makesquery.dataempty surfaces the follow prompt.useForYouFeedset nostaleTime. With the react-query default of0, the personalized query refetches on the next mount/focus right after the first paint. When that refetch settles empty — a transient backend result, or a different validator node in the fleet returning no items for this user — react-query replaces the just-rendered pages with[]. The feed appears, then blanks. (The chronological Latest feed shares the same render path but its backend is deterministic, so its refetch returns the same data and it never visibly blanks — which is why only For You is affected.)A secondary trap:
enabledwas gated oncurrentUserId !== null, which is true while the account is still loading (currentUserIdisundefined). The query then runs its!currentUserIdguard and caches[]under the[forYouFeed, undefined]key — a stale empty entry a later render could briefly surface.Fix
packages/common/src/api/tan-query/lineups/useForYouFeed.ts:staleTime: Infinity(overridable viaoptions) — the loaded feed stays stable for the session instead of being re-fetched-and-clobbered. Pagination is unaffected (fetchNextPageignoresstaleTime). This matches the existing pattern inuseLibraryTracks.enabled: ... && currentUserId != null(excludesundefined) — the query no longer runs / seeds an empty cache entry while the account is resolving.isDisabledstill keys off=== null, so during account load the consumer shows skeletons (not the empty state).Commit 2 — back the feed with the live
/tracks/recommendedendpointProblem
The For You tab is empty in production because it calls the new
GET /v1/users/{id}/feed/for-youendpoint (sdk.users.getUserForYouFeed()), which 404s on the current validator-node deployment and won't be fixed for ~a week.Fix
Point
useForYouFeedatGET /v1/tracks/recommended(sdk.tracks.getRecommendedTracks) — the long-standing, personalized recommendation source the Explore page used before the For You feed existed. It reliably returns 200 fromapi.audius.cotoday (verified:for-you→ 404 on the old fleet,/tracks/recommended→ 200).Pagination:
/tracks/recommendedhas nooffsetparameter, but it accepts anexclusionList. Pagination now passes the accumulated already-seen track ids as the exclusion list, so each page returns fresh recommendations without repeats. ThepageParamcarries that list.Compatibility: the hook keeps its existing return shape (a tracks-only
LineupData[]plus derivedtrackIds), so the feed-page consumers (FeedPageContentweb desktop/mobile, mobileFeedScreen) are unchanged.This is a temporary fallback — revert to
getUserForYouFeed()once the dedicated endpoint is deployed (aNOTEcomment in the hook calls this out).Verification status
tsc --noEmitpasses for@audius/commonhttps://api.audius.co/v1/tracks/recommended?limit=3returns200🤖 Generated with Claude Code