Migrate all IPC call sites to typed tauri-specta commands.*
🏗️ Build and Test JellyTau / Run Tests (pull_request) Successful in 4m39s
Traceability Validation / Check Requirement Traces (pull_request) Failing after 36s
🏗️ Build and Test JellyTau / Build Android APK (pull_request) Failing after 1m57s

Replace the remaining ~155 untyped invoke() calls across stores, services,
components, and routes with the generated commands.* wrappers from
$lib/api/bindings, so every IPC call is compile-time-checked against the
command signatures.

- Register repository_get_subtitle_url and repository_get_video_download_url
  in specta_builder() and the invoke_handler; regenerate bindings.ts.
- Source duplicated wire types (AutoplaySettings, CacheConfig, Session,
  ConnectivityStatus, audio/video settings, etc.) from bindings.
- Fix two bugs surfaced by the typed wrappers:
  - VideoDownloadButton passed an un-awaited Promise as the stream URL.
  - setAutoplaySettings omitted the required userId argument.
- Update unit tests asserting the old invoke(name, args) shape.
- Remove the five param-naming guard tests; the compiler and codegen now
  enforce what they checked.

svelte-check: 0 errors. vitest: green. cargo test --lib: green.
This commit is contained in:
2026-06-21 08:47:04 +02:00
parent 14e9d7e03a
commit d01c2aab9f
47 changed files with 456 additions and 2119 deletions
+27 -35
View File
@@ -1,7 +1,6 @@
// Download manager state store
// TRACES: UR-011, UR-013, UR-018 | DR-015, DR-017
import { writable, derived, get } from 'svelte/store';
import { invoke } from '@tauri-apps/api/core';
import { commands } from '$lib/api/bindings';
import { listen, type UnlistenFn } from '@tauri-apps/api/event';
@@ -95,13 +94,10 @@ function createDownloadsStore() {
try {
console.log('🔄 Refreshing downloads for user:', userId);
const response = await invoke<{ downloads: DownloadInfo[]; stats: DownloadStats }>(
'get_downloads',
{
userId,
statusFilter
}
);
const response = (await commands.getDownloads(
userId,
statusFilter ?? null
)) as unknown as { downloads: DownloadInfo[]; stats: DownloadStats };
console.log(' Got', response.downloads.length, 'downloads from backend');
console.log(' Stats:', response.stats);
@@ -182,11 +178,7 @@ function createDownloadsStore() {
async downloadAlbum(albumId: string, userId: string, basePath: string): Promise<number[]> {
try {
console.log('📥 downloadAlbum called:', { albumId, userId, basePath });
const downloadIds = await invoke<number[]>('download_album', {
albumId,
userId,
basePath
});
const downloadIds = await commands.downloadAlbum(albumId, userId, basePath);
console.log(' Got download IDs from backend:', downloadIds);
// Refresh downloads
@@ -267,13 +259,13 @@ function createDownloadsStore() {
basePath,
qualityPreset
});
const downloadIds = await invoke<number[]>('download_series', {
const downloadIds = await commands.downloadSeries(
seriesId,
seriesName,
userId,
basePath,
qualityPreset
});
qualityPreset ?? null
);
console.log(' Queued', downloadIds.length, 'episodes for download');
// Refresh downloads
@@ -306,15 +298,15 @@ function createDownloadsStore() {
seasonNumber,
qualityPreset
});
const downloadIds = await invoke<number[]>('download_season', {
const downloadIds = await commands.downloadSeason(
seasonId,
seriesName,
seasonName,
seasonNumber,
userId,
basePath,
qualityPreset
});
qualityPreset ?? null
);
console.log(' Queued', downloadIds.length, 'episodes for download');
// Refresh downloads
@@ -332,7 +324,7 @@ function createDownloadsStore() {
*/
async pinItem(itemId: string): Promise<void> {
try {
await invoke('pin_item', { itemId });
await commands.pinItem(itemId);
} catch (error) {
console.error('Failed to pin item:', error);
throw error;
@@ -344,7 +336,7 @@ function createDownloadsStore() {
*/
async unpinItem(itemId: string): Promise<void> {
try {
await invoke('unpin_item', { itemId });
await commands.unpinItem(itemId);
} catch (error) {
console.error('Failed to unpin item:', error);
throw error;
@@ -356,7 +348,7 @@ function createDownloadsStore() {
*/
async isItemPinned(itemId: string): Promise<boolean> {
try {
return await invoke<boolean>('is_item_pinned', { itemId });
return await commands.isItemPinned(itemId);
} catch (error) {
console.error('Failed to check pin status:', error);
return false;
@@ -368,7 +360,7 @@ function createDownloadsStore() {
*/
async pause(downloadId: number): Promise<void> {
try {
await invoke('pause_download', { downloadId });
await commands.pauseDownload(downloadId);
} catch (error) {
console.error('Failed to pause download:', error);
throw error;
@@ -380,7 +372,7 @@ function createDownloadsStore() {
*/
async resume(downloadId: number): Promise<void> {
try {
await invoke('resume_download', { downloadId });
await commands.resumeDownload(downloadId);
} catch (error) {
console.error('Failed to resume download:', error);
throw error;
@@ -392,7 +384,7 @@ function createDownloadsStore() {
*/
async cancel(downloadId: number): Promise<void> {
try {
await invoke('cancel_download', { downloadId });
await commands.cancelDownload(downloadId);
} catch (error) {
console.error('Failed to cancel download:', error);
throw error;
@@ -404,7 +396,7 @@ function createDownloadsStore() {
*/
async delete(downloadId: number): Promise<void> {
try {
await invoke('delete_download', { downloadId });
await commands.deleteDownload(downloadId);
update((state) => {
const { [downloadId]: removed, ...remaining } = state.downloads;
return { ...state, downloads: remaining };
@@ -574,11 +566,11 @@ function handleDownloadEvent(payload: DownloadEvent): void {
case 'completed':
if (download) {
// Persist to database
invoke('mark_download_completed', {
downloadId: payload.downloadId,
bytesDownloaded: payload.totalBytes || download.fileSize || download.bytesDownloaded,
filePath: payload.filePath || download.filePath
}).catch((err) => console.error('Failed to persist download completion:', err));
commands.markDownloadCompleted(
payload.downloadId,
payload.totalBytes || download.fileSize || download.bytesDownloaded,
payload.filePath || download.filePath
).catch((err) => console.error('Failed to persist download completion:', err));
updateDownloadInStore(payload.downloadId, {
status: 'completed',
@@ -592,10 +584,10 @@ function handleDownloadEvent(payload: DownloadEvent): void {
case 'failed':
if (download) {
// Persist to database
invoke('mark_download_failed', {
downloadId: payload.downloadId,
errorMessage: payload.error || 'Unknown error'
}).catch((err) => console.error('Failed to persist download failure:', err));
commands.markDownloadFailed(
payload.downloadId,
payload.error || 'Unknown error'
).catch((err) => console.error('Failed to persist download failure:', err));
updateDownloadInStore(payload.downloadId, {
status: 'failed',