feat: add background download manager with progress reporting

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-21 11:00:46 -04:00
parent 3e469a931f
commit 088def2ee4
7 changed files with 292 additions and 5 deletions

View File

@@ -1,5 +1,36 @@
<script lang="ts">
import { session } from '$lib/stores/videoSession.svelte';
let progressPercent = $derived(Math.round(session.downloadProgress * 100));
let isDownloading = $derived(
session.status === 'ready' &&
session.downloadStatus === 'downloading' &&
session.downloadProgress > 0 &&
session.downloadProgress < 1
);
let isDownloaded = $derived(
session.localFilePath !== null &&
(session.downloadStatus === 'complete' || session.downloadProgress >= 1)
);
</script>
<div class="status-bar">
<span class="status-text">Ready</span>
{#if isDownloading}
<div class="progress-bar">
<div class="progress-fill" style="width: {progressPercent}%"></div>
</div>
<span class="status-text">Downloading: {progressPercent}%</span>
{:else if isDownloaded}
<span class="status-text success">✓ Downloaded: {session.title}</span>
{:else if session.status === 'resolving'}
<span class="status-text">Resolving URL…</span>
{:else if session.status === 'ready' && session.downloadStatus === 'downloading'}
<span class="status-text">Starting download…</span>
{:else if session.downloadStatus === 'failed'}
<span class="status-text">Download failed</span>
{:else}
<span class="status-text">Ready</span>
{/if}
</div>
<style>
@@ -12,5 +43,25 @@
font-size: 12px;
color: var(--text-secondary);
min-height: 24px;
gap: 8px;
}
.progress-bar {
flex: 1;
height: 4px;
background: var(--bg-primary);
border-radius: 2px;
overflow: hidden;
max-width: 200px;
}
.progress-fill {
height: 100%;
background: var(--accent);
transition: width 0.3s ease;
}
.success {
color: var(--success);
}
</style>

View File

@@ -1,6 +1,12 @@
<script lang="ts">
import { resolveUrl } from '$lib/bindings/video';
import { session, setMetadata, setError, setResolving } from '$lib/stores/videoSession.svelte';
import {
session,
setMetadata,
setError,
setResolving,
beginDownload,
} from '$lib/stores/videoSession.svelte';
let inputValue = $state('');
@@ -12,6 +18,7 @@
try {
const meta = await resolveUrl(trimmed);
setMetadata(meta);
void beginDownload();
} catch (e) {
setError(String(e));
}