Create Kaleido Desktop, a cinematic Plex client for Windows

Tauri 2 shell with a React/TypeScript interface and libmpv playback composed
beneath the web view (DirectComposition on Windows). Shared code with per-OS
platform modules and configs so macOS and Linux can follow.

- Plex sign-in (browser, plex.tv/link or manual), server selection, Plex Home
- Home, Movies and TV Shows (Discover, Library, Collections), search, people
- Title pages with logos, ratings, cast, extras, seasons and episodes
- Direct play with Plex conversion fallback, tracks, markers, autoplay
- Metadata editing, artwork, fix match, refresh, analyze and deletion
- Resumable offline downloads
- App settings and Plex server administration with a live dashboard
- Signed updater feed and Forgejo CI

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-30 16:26:37 -07:00
commit 00d72e70f4
121 changed files with 25315 additions and 0 deletions

114
src/plex/plex.test.ts Normal file
View file

@ -0,0 +1,114 @@
import { describe, expect, it } from 'vitest';
import { parseItem, parseScores } from './parse';
import { isLocalAddress } from './account';
import { partAt } from './playback';
import { duration, formatBadges, isWatched, remaining, washGradient } from '../app/format';
import { buildFeatures } from '../screens/discover';
import type { Hub } from './types';
const movie = (over: Record<string, unknown> = {}) =>
parseItem({
ratingKey: '9776',
key: '/library/metadata/9776',
type: 'movie',
title: '2 Fast 2 Furious',
summary: 'An ex-cop…',
art: '/art',
year: 2003,
duration: 6000000,
Image: [{ type: 'clearLogo', url: '/logo' }],
UltraBlurColors: [{ topLeft: '162e4f', topRight: '30618f', bottomRight: '345e96', bottomLeft: '1c2c56' }],
Media: [
{
id: '1',
videoResolution: '4k',
audioChannels: 8,
Part: [
{
id: '10',
key: '/library/parts/10/file.mkv',
duration: 3000000,
Stream: [
{ id: 's1', streamType: 1, codec: 'hevc', DOVIPresent: true, index: 0 },
{ id: 's2', streamType: 2, codec: 'truehd', displayTitle: 'English (TrueHD 7.1 Atmos)', index: 1 },
],
},
{ id: '11', key: '/library/parts/11/file.mkv', duration: 3000000 },
],
},
],
...over,
});
describe('parsing', () => {
it('reads logos, UltraBlur colors and format facts', () => {
const m = movie();
expect(m.logo).toBe('/logo');
expect(m.ultraBlur?.topRight).toBe('30618f');
expect(m.media[0].dynamicRange).toBe('Dolby Vision');
expect(m.media[0].atmos).toBe(true);
expect(formatBadges(m)).toEqual(['4K', 'DOLBY VISION', 'ATMOS']);
});
it('keeps audience scores and never substitutes critic ratings', () => {
const scores = parseScores({
Rating: [
{ image: 'rottentomatoes://image.rating.upright', value: 7.9, type: 'audience' },
{ image: 'rottentomatoes://image.rating.ripe', value: 9.1, type: 'critic' },
{ image: 'imdb://image.rating', value: 7.2, type: 'audience' },
],
});
expect(scores.filter((s) => s.kind === 'audience').map((s) => s.source)).toEqual(['Rotten Tomatoes', 'IMDb']);
expect(scores.find((s) => s.kind === 'critic')?.value).toBe(9.1);
});
});
describe('watched rules', () => {
it('treats a resumed title as watched only past the threshold', () => {
expect(isWatched(movie({ viewCount: 1, viewOffset: 3000000 }), 90)).toBe(false);
expect(isWatched(movie({ viewCount: 1, viewOffset: 5700000 }), 90)).toBe(true);
expect(isWatched(movie({ viewCount: 1 }), 90)).toBe(true);
});
it('uses episode counts for shows', () => {
expect(isWatched(parseItem({ type: 'show', leafCount: 10, viewedLeafCount: 10 }))).toBe(true);
expect(isWatched(parseItem({ type: 'show', leafCount: 10, viewedLeafCount: 3 }))).toBe(false);
});
it('formats durations and time left', () => {
expect(duration(6000000)).toBe('1h 40m');
expect(duration(45 * 60000)).toBe('45m');
expect(remaining(movie({ viewOffset: 3000000 }))).toBe('50m left');
});
});
describe('connections', () => {
it('recognizes local plex.direct and private addresses', () => {
expect(isLocalAddress('https://192-168-50-81.abc.plex.direct:32400')).toBe(true);
expect(isLocalAddress('http://10.0.0.5:32400')).toBe(true);
expect(isLocalAddress('https://38-130-3-235.abc.plex.direct:27015')).toBe(false);
});
});
describe('playback', () => {
it('maps a position to the right part of a multi-part title', () => {
const m = movie().media[0];
expect(partAt(m, 1000).part.id).toBe('10');
expect(partAt(m, 4000000)).toMatchObject({ local: 1000000 });
});
});
describe('features', () => {
it('interleaves sources, skips in-progress titles and needs artwork', () => {
const hub = (id: string, items: Record<string, unknown>[]): Hub => ({ id, key: '', title: id, type: 'movie', context: '', size: items.length, more: false, style: '', items: items.map((i) => movie(i)) });
const features = buildFeatures([
hub('movie.recentlyreleased.1', [{ ratingKey: 'a' }, { ratingKey: 'b', viewOffset: 100 }]),
hub('movie.topunwatched.1', [{ ratingKey: 'c' }, { ratingKey: 'd', art: '' }]),
]);
expect(features.map((f) => f.item.id).sort()).toEqual(['a', 'c']);
});
it('builds an artwork wash from UltraBlur colors', () => {
expect(washGradient(movie().ultraBlur)).toContain('rgba(48, 97, 143');
});
});