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
+8 -8
View File
@@ -1,6 +1,6 @@
<!-- TRACES: UR-004, UR-005, UR-028 | DR-009 -->
<script lang="ts">
import { invoke } from "@tauri-apps/api/core";
import { commands } from "$lib/api/bindings";
import { goto } from "$app/navigation";
import type { MediaItem } from "$lib/api/types";
import { auth } from "$lib/stores/auth";
@@ -74,28 +74,28 @@
async function handleSeekEnd() {
seeking = false;
seekPending = true; // Keep showing target position until backend catches up
await invoke("player_seek", { position: seekValue });
await commands.playerSeek(seekValue);
}
// Control handlers for Controls component
async function handlePlayPause() {
await invoke("player_toggle");
await commands.playerToggle();
}
async function handlePrevious() {
await invoke("player_previous");
await commands.playerPrevious();
}
async function handleNext() {
await invoke("player_next");
await commands.playerNext();
}
async function handleToggleShuffle() {
await invoke("player_toggle_shuffle");
await commands.playerToggleShuffle();
}
async function handleCycleRepeat() {
await invoke("player_cycle_repeat");
await commands.playerCycleRepeat();
}
// Prefer album ID for artwork (all tracks in an album share the same cover)
@@ -128,7 +128,7 @@
async function handleQueueItemClick(index: number) {
try {
queue.skipTo(index);
await invoke("player_skip_to", { index });
await commands.playerSkipTo(index);
} catch (e) {
console.error("Failed to skip to queue item:", e);
}
+7 -7
View File
@@ -14,7 +14,7 @@
* @req: UR-010 - Control playback of Jellyfin remote sessions
*/
import { invoke } from "@tauri-apps/api/core";
import { commands } from "$lib/api/bindings";
import { goto } from "$app/navigation";
import type { MediaItem } from "$lib/api/types";
import { auth } from "$lib/stores/auth";
@@ -105,23 +105,23 @@
// Control handlers for Controls component
async function handlePlayPause() {
await invoke("player_toggle");
await commands.playerToggle();
}
async function handlePrevious() {
await invoke("player_previous");
await commands.playerPrevious();
}
async function handleNext() {
await invoke("player_next");
await commands.playerNext();
}
async function handleToggleShuffle() {
await invoke("player_toggle_shuffle");
await commands.playerToggleShuffle();
}
async function handleCycleRepeat() {
await invoke("player_cycle_repeat");
await commands.playerCycleRepeat();
}
// Scrubbing (seek) handler
@@ -133,7 +133,7 @@
const newPosition = percent * displayDuration;
try {
await invoke("player_seek", { position: newPosition });
await commands.playerSeek(newPosition);
haptics.tap();
} catch (err) {
console.error("Failed to seek:", err);
+3 -6
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { invoke } from "@tauri-apps/api/core";
import { commands } from "$lib/api/bindings";
import { dndzone, SOURCES, TRIGGERS } from "svelte-dnd-action";
import type { MediaItem } from "$lib/api/types";
import { auth } from "$lib/stores/auth";
@@ -79,10 +79,7 @@
queue.moveInQueue(fromIndex, toIndex);
// Sync with backend
await invoke("player_move_in_queue", {
fromIndex,
toIndex,
});
await commands.playerMoveInQueue(fromIndex, toIndex);
} catch (e) {
console.error("Failed to move queue item:", e);
// The store already updated optimistically, refresh if needed
@@ -109,7 +106,7 @@
e.stopPropagation();
try {
queue.removeFromQueue(index);
await invoke("player_remove_from_queue", { index });
await commands.playerRemoveFromQueue(index);
} catch (err) {
console.error("Failed to remove from queue:", err);
}
+33 -41
View File
@@ -1,7 +1,7 @@
<!-- TRACES: UR-003, UR-005, UR-020, UR-021, UR-026 | DR-010, DR-023, DR-024 -->
<script lang="ts">
import { onMount, onDestroy } from "svelte";
import { invoke } from "@tauri-apps/api/core";
import { commands } from "$lib/api/bindings";
import { listen } from "@tauri-apps/api/event";
import Hls from "hls.js";
import type { MediaItem } from "$lib/api/types";
@@ -140,13 +140,7 @@
const userId = auth.getUserId();
if (!userId) return;
const preference = await invoke<{ seriesId: string, audioTrackDisplayTitle?: string | null, audioTrackLanguage?: string | null, audioTrackIndex?: number | null } | null>(
"storage_get_series_audio_preference",
{
userId,
seriesId: media.seriesId
}
);
const preference = await commands.storageGetSeriesAudioPreference(userId, media.seriesId);
if (preference) {
console.log("[VideoPlayer] Loaded series audio preference:", preference);
@@ -403,14 +397,12 @@
// Call Rust backend to start playback
// Rust will choose ExoPlayer (Android), libmpv (Linux), or tell us to use HTML5
// Send minimal video data - no complex serialization to avoid Tauri Android issues
const response: any = await invoke("player_play_item", {
item: {
streamUrl: currentStreamUrl,
title: media.name,
id: media.id,
videoCodec: needsTranscoding ? "hevc" : "h264",
needsTranscoding: needsTranscoding,
},
const response: any = await commands.playerPlayItem({
streamUrl: currentStreamUrl,
title: media.name,
id: media.id,
videoCodec: needsTranscoding ? "hevc" : "h264",
needsTranscoding: needsTranscoding,
});
// Rust tells us which backend it's using
@@ -422,7 +414,7 @@
if (useHtml5Element && !needsTranscoding) {
try {
console.log("[VideoPlayer] Using HTML5 for direct stream - stopping backend player to prevent dual audio");
await invoke("player_stop");
await commands.playerStop();
didStopBackendEarly = true; // Track that we stopped the backend
} catch (err) {
console.warn("[VideoPlayer] Failed to stop backend player:", err);
@@ -460,7 +452,7 @@
// For non-transcoded content, try to stop any backend player that might have started
if (!needsTranscoding) {
try {
await invoke("player_stop");
await commands.playerStop();
didStopBackendEarly = true;
} catch (stopErr) {
// Ignore errors when stopping
@@ -536,7 +528,7 @@
if (didStartNativePlayback && !didStopBackendEarly) {
try {
console.log("[VideoPlayer] Stopping backend player on component unmount");
await invoke("player_stop");
await commands.playerStop();
} catch (err) {
console.error("[VideoPlayer] Failed to stop backend player:", err);
}
@@ -768,7 +760,7 @@
async function togglePlayPause() {
if (!useHtml5Element) {
try {
const response = await invoke<{ state: string }>("player_toggle");
const response = (await commands.playerToggle()) as any;
isPlaying = response.state === "playing";
} catch (err) {
console.error("[VideoPlayer] Failed to toggle native player:", err);
@@ -807,13 +799,13 @@
}
// Backend smart seeking handles both native and HTML5
const response = await invoke<{strategy: string, position?: number, newUrl?: string, seekOffset?: number}>("player_seek_video", {
repositoryHandle: repo.getHandle(),
position: targetTime,
mediaSourceId: mediaSourceId ?? null,
audioStreamIndex: selectedAudioTrackIndex ?? null,
useHtml5: useHtml5Element,
});
const response = (await commands.playerSeekVideo(
repo.getHandle(),
targetTime,
mediaSourceId ?? null,
selectedAudioTrackIndex ?? null,
useHtml5Element
)) as any;
console.log("[VideoPlayer] Backend seek response:", response);
@@ -1095,14 +1087,14 @@
if (!repo) throw new Error("Not authenticated");
// Call unified backend command
const response = await invoke<{strategy: string, success?: boolean, newUrl?: string, position?: number}>("player_switch_audio_track", {
repositoryHandle: repo.getHandle(),
const response = (await commands.playerSwitchAudioTrack(
repo.getHandle(),
streamIndex,
arrayIndex,
useHtml5: useHtml5Element,
currentPosition: useHtml5Element && videoElement ? videoElement.currentTime + seekOffset : null,
mediaSourceId: mediaSourceId ?? null,
});
useHtml5Element,
useHtml5Element && videoElement ? videoElement.currentTime + seekOffset : null,
mediaSourceId ?? null
)) as any;
// Handle response based on strategy
if (response.strategy === "reloadStream" && useHtml5Element && videoElement) {
@@ -1171,14 +1163,14 @@
// Find the selected track info
const selectedTrack = audioTracks().find(t => t.index === streamIndex);
if (selectedTrack) {
await invoke("storage_save_series_audio_preference", {
await commands.storageSaveSeriesAudioPreference(
userId,
seriesId: media.seriesId,
serverId: media.serverId,
audioTrackDisplayTitle: selectedTrack.displayTitle || null,
audioTrackLanguage: selectedTrack.language || null,
audioTrackIndex: streamIndex,
});
media.seriesId,
media.serverId ?? "",
selectedTrack.displayTitle || null,
selectedTrack.language || null,
streamIndex
);
console.log("[VideoPlayer] Saved series audio preference:", selectedTrack.displayTitle || selectedTrack.language);
}
} catch (err) {
@@ -1229,7 +1221,7 @@
// Use array index for ExoPlayer (0-based position in subtitle tracks array)
// If streamIndex is null (disable), pass null; otherwise use arrayIndex
const indexToUse = streamIndex === null ? null : (arrayIndex !== undefined ? arrayIndex : streamIndex);
await invoke("player_set_subtitle_track", { streamIndex: indexToUse });
await commands.playerSetSubtitleTrack(indexToUse);
console.log("[VideoPlayer] Native backend subtitle track changed - arrayIndex:", arrayIndex, "used:", indexToUse);
} catch (error) {
console.error("[VideoPlayer] Failed to set subtitle track:", error);
@@ -1,5 +1,5 @@
<script lang="ts">
import { invoke } from "@tauri-apps/api/core";
import { commands } from "$lib/api/bindings";
import { volume, isMuted, mergedVolume } from "$lib/stores/player";
import { isRemoteMode } from "$lib/stores/playbackMode";
import { selectedSession, sessions } from "$lib/stores/sessions";
@@ -31,7 +31,7 @@
// Remote mode: send volume as 0-100 integer to remote session
await sessions.sendVolume($selectedSession.id, Math.round(newVolume * 100));
} else {
await invoke("player_set_volume", { volume: newVolume });
await commands.playerSetVolume(newVolume);
}
}
@@ -39,7 +39,7 @@
if ($isRemoteMode && $selectedSession) {
await sessions.sendToggleMute($selectedSession.id);
} else {
await invoke("player_toggle_mute");
await commands.playerToggleMute();
}
}