Skip to content

fix(web): seed contest source track from URL when permalink resolves#14370

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/contest-launch-source-track-sync
May 21, 2026
Merged

fix(web): seed contest source track from URL when permalink resolves#14370
dylanjeffers merged 1 commit into
mainfrom
fix/contest-launch-source-track-sync

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

Clicking Launch on the Host Remix Contest page produced no action, error, or modal when the user entered via the track-scoped route (/:handle/:slug/host-contest) — e.g. via the Host Remix Contest overflow-menu item on a track tile.

Root cause

useTrackByPermalink(...) resolves asynchronously, but the form seeds sourceTrackIds via useState(... primaryTrackId ? [primaryTrackId] : []). useState initializers only run on first mount, and on first mount primaryTrackId === undefined — so sourceTrackIds started empty and there was no useEffect to sync it once the track resolved. The Source Track section then rendered "+ Add Track" instead of the URL's track, and the Launch button stayed disabled (sourceTrackIds.length === 0).

The async race existed since #14151, but the visible breakage was introduced in #14174 when sourceTrackIds.length === 0 was added to the Launch button's disabled check.

Fix

Add a one-shot useEffect that seeds sourceTrackIds from primaryTrackId when it first resolves. Guarded by a ref so it:

  • doesn't overwrite drafts or existing-contest hydration (sourceTrackIds.length > 0 exits early),
  • doesn't re-populate after the user removes the row (the ref locks the effect after the first run).

Test plan

  • As a logged-in artist, open one of your tracks and pick Host Remix Contest from the overflow menu.
  • On the resulting /{handle}/{slug}/host-contest page, the SOURCE TRACK section should show the URL's track instead of the + Add Track button.
  • Fill out date / time / description, click Launch — the contest is created and the page redirects to /{handle}/contest/{slug}.
  • Trackless route (/host-contest from the Contests page) still requires a manual pick and behaves unchanged.
  • Edit mode (existing contest) still hydrates source tracks from event_data.sourceTrackIds and is unaffected.
  • Removing the source-track row no longer auto-re-populates from the URL.

Note: I could not browser-verify locally — the page is gated by useRequiresAccount() and reproducing the bug requires being signed in as the track's owner on a real (prod-data) track. The change typechecks clean.

🤖 Generated with Claude Code

On the track-scoped Host Remix Contest route
(/:handle/:slug/host-contest), the URL identifies the source track, but
useTrackByPermalink resolves asynchronously. The useState initializer
for sourceTrackIds ran before the resolve, captured primaryTrackId as
undefined, and seeded the array to []. The Source Track section then
rendered "+ Add Track" instead of the URL's track, and the Launch
button stayed disabled (sourceTrackIds.length === 0) — so clicking
Launch produced no action, error, or modal.

Regression introduced in #14174, which added the source-track-required
gate to the Launch button's disabled check. Fix by syncing
sourceTrackIds once when primaryTrackId first resolves, guarded against
overwriting drafts, existing-contest hydration, and user removals.

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

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: ea4e1b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylanjeffers dylanjeffers merged commit c5a95ac into main May 21, 2026
13 checks passed
@dylanjeffers dylanjeffers deleted the fix/contest-launch-source-track-sync branch May 21, 2026 01:29
@github-actions
Copy link
Copy Markdown
Contributor

🌐 Web preview ready

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

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

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