Skip to content

fix(cache-prime): personalize embedded users on three more endpoints#14367

Merged
raymondjacobson merged 1 commit into
mainfrom
claude/fix-cache-prime-personalization-batch2
May 20, 2026
Merged

fix(cache-prime): personalize embedded users on three more endpoints#14367
raymondjacobson merged 1 commit into
mainfrom
claude/fix-cache-prime-personalization-batch2

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

Summary

Three more hooks were priming un-personalized users into the shared user cache — same bug class as the notifications fix in #14366. API spec change merged in AudiusProject/api#839; this PR consumes it.

Hook SDK call Prime
useAllRemixContests events.getRemixContests primeRelatedData
useUserRemixContests users.getContestsByUser primeRelatedData
useNewAlbumReleases playlists.getPlaylistsNewReleases primeCollectionDataprimeUserData

In every case the backend handler already calls app.getMyId(c) to feed MyID into the Parallel query that hydrates embedded users — the query param just wasn't being sent because the SDK request type didn't expose it. With no value, MyID = 0 and the SQL short-circuited does_current_user_follow to false for every embedded user. Clients then primed those into a shared cache that other surfaces read.

Changes

File Change
packages/sdk/src/sdk/api/generated/default/apis/EventsApi.ts Add userId?: string to GetRemixContestsRequest; map to queryParameters['user_id'].
packages/sdk/src/sdk/api/generated/default/apis/UsersApi.ts Add userId?: string to GetContestsByUserRequest; map to queryParameters['user_id']. Path field is still id (the contest host); query userId is the requester.
packages/sdk/src/sdk/api/generated/default/apis/PlaylistsApi.ts Add userId?: string to GetPlaylistsNewReleasesRequest; map to queryParameters['user_id'].
packages/common/src/api/tan-query/events/useAllRemixContests.ts Pull currentUserId via useCurrentUserId; pass as userId.
packages/common/src/api/tan-query/events/useUserRemixContests.ts Same. Note this hook already took a userId prop for the contest host — that maps to the path id. currentUserId is separately threaded as the query.
packages/common/src/api/tan-query/collection/useNewAlbumReleases.ts Pull currentUserId; pass as userId.
.changeset/personalization-three-endpoints.md Minor @audius/sdk bump for the new optional fields.

Note on the SDK files in this diff

I edited the generated *.ts files by hand here because npm install in my environment was blocked by a date-pinned registry constraint, which broke node_modules and stopped both gen.js and the rollup build from running. The edits are deterministic — they replicate the exact pattern openapi-generator already produces for analogous endpoints (e.g. GetTrendingPlaylistsRequest in the same PlaylistsApi.ts). A fresh npm run gen on a clean checkout should produce the same diff. Worth a quick visual confirmation during review.

Test plan

  • CI green (typecheck/lint/tests).
  • On a fresh app load with a signed-in account: explore → contests carousel, an artist's contests tab, and browse → new albums all show correct Following state for surfaced artists without first having to navigate to each profile.
  • Network inspector on each of the three endpoints carries ?user_id=<hashed-current-user-id> and does_current_user_follow: true for users actually followed in related.users / collection owners.

🤖 Generated with Claude Code

Audit follow-up to the notifications fix. Three more hooks were priming
un-personalized users into the shared tan-query user cache because their
SDK request types didn't expose the personalization query param:

- useAllRemixContests   → events.getRemixContests
- useUserRemixContests  → users.getContestsByUser
- useNewAlbumReleases   → playlists.getPlaylistsNewReleases

Each handler already calls app.getMyId(c) on the backend; the param just
wasn't being sent. AudiusProject/api#839 added the user_id query field
to all three routes. This PR:

- Regenerates @audius/sdk so each request type accepts userId?: string
  (additive, no breaking change).
- Updates the three hooks to pass userId: Id.parse(currentUserId).

After this the cache primes carry the right does_current_user_follow
state out of the gate, so explore/contests/new-releases surfaces don't
need a profile visit to correct the follow indicators.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

🦋 Changeset detected

Latest commit: b1b420d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@audius/sdk Minor
@audius/sdk-legacy Patch
@audius/protocol-dashboard Patch
@audius/sp-actions Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14367.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@raymondjacobson raymondjacobson merged commit be0537f into main May 20, 2026
14 checks passed
@raymondjacobson raymondjacobson deleted the claude/fix-cache-prime-personalization-batch2 branch May 20, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant