Commit a22bc8cd authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Remix: show 'added to your library' instead of a download link

Matches the backend no longer returning a raw download_url. The
finished remix was already being added to the library automatically -
this just stops offering a way around that (a direct file download)
and instead confirms it's there with a link to view it.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 13ad9396
Pipeline #1128 failed with stage
......@@ -6,7 +6,6 @@ export interface RemixStatus {
stage_detail: string | null
remix_name: string | null
plan?: Record<string, unknown>
download_url?: string
library_song_id?: number
post_id?: number
error?: string
......
......@@ -105,4 +105,27 @@ describe('Remix', () => {
expect(await screen.findByText('Something went wrong')).toBeInTheDocument()
})
it('shows an "added to your library" link once done, never a download link', async () => {
vi.spyOn(remixApi, 'createRemix').mockResolvedValue({ job_id: 7, status: 'queued', status_url: '/remix/7' })
vi.spyOn(remixApi, 'getRemixStatus').mockResolvedValue({
job_id: 7,
status: 'done',
stage_detail: 'Complete',
remix_name: 'Dream Blend',
library_song_id: 42,
post_id: 99,
})
renderRemix()
await pickSong('Invisible')
await userEvent.type(screen.getByPlaceholderText(/Blend the vocals/), 'make it dreamy')
await userEvent.click(screen.getByRole('button', { name: /Create Remix/ }))
// Status is polled on a 2s interval (real timers here, not faked) - the default findBy
// timeout is shorter than that, so give it enough room for the first poll to land.
expect(await screen.findByText(/added to your library/, {}, { timeout: 3000 })).toBeInTheDocument()
expect(screen.getByRole('link', { name: 'view it there' })).toHaveAttribute('href', '/library')
expect(screen.queryByText(/Download/)).not.toBeInTheDocument()
})
})
import { useEffect, useRef, useState } from 'react'
import { AlertCircle, ListMusic, Music2, Sparkles, X } from 'lucide-react'
import { Link } from 'react-router-dom'
import { AlertCircle, Check, ListMusic, Music2, Sparkles, X } from 'lucide-react'
import { Layout } from '../components/Layout'
import { RemixSongPicker } from '../components/RemixSongPicker'
import { Button } from '../components/ui/Button'
......@@ -143,15 +144,14 @@ export function Remix() {
<p className="text-sm text-neutral-300">
{status.status === 'error' ? `Error: ${status.error}` : status.stage_detail ?? status.status}
</p>
{status.status === 'done' && status.download_url && (
<a
href={status.download_url}
target="_blank"
rel="noreferrer"
className="mt-2 inline-block text-sm text-emerald-400 hover:underline"
>
Download {status.remix_name}
</a>
{status.status === 'done' && status.library_song_id && (
<p className="mt-2 flex items-center gap-1.5 text-sm text-emerald-400">
<Check size={14} strokeWidth={2} />
"{status.remix_name}" added to your library -{' '}
<Link to="/library" className="underline hover:no-underline">
view it there
</Link>
</p>
)}
</div>
)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment