Release Kaleido Desktop 0.1.0-beta.19
All checks were successful
Validate Kaleido Desktop / validate (push) Successful in 1m28s

Up Next fixes:
- Re-arm Up Next when playback leaves the credits, and always open it
  at the end of an episode, so it appears every time the credits start.
- Restore the back arrow (to the miniplayer) and add a full-screen
  button at the top, beside the window buttons.
- The show logo opens the show page, as in the player.
- Draw the countdown fill every frame instead of in 50 ms steps.
- Size the row cards from the space under the header so the rows fill
  it; the related row runs off the bottom of short windows.
- Use the next episode's still as the backdrop with a stronger scrim and
  brighter, shadowed description text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-12 12:53:48 -07:00
parent e2166070d0
commit bb204796ac
10 changed files with 133 additions and 49 deletions

View file

@ -1,4 +1,4 @@
import { useEffect, useLayoutEffect, useRef, type CSSProperties } from 'react';
import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';
import { useQuery } from '@tanstack/react-query';
import { usePlayer } from './store';
import { mpv } from './engine';
@ -73,11 +73,25 @@ export function PostPlay() {
}, []);
const backToVideo = () => usePlayer.getState().dismissPostPlay();
// As in the player: the show page opens with playback moving to the miniplayer.
const openShow = () => {
usePlayer.getState().minimize();
navigate({ name: 'item', id: item.grandparentId });
};
// The next episode's own still, as on Android TV: darker than most show art, so the copy reads.
const scene = upcoming ?? item;
const sceneArt = useMemo(() => ({ ...scene, grandparentArt: scene.thumb || scene.grandparentArt }), [scene]);
return (
<div className="player up-next" ref={root} role="dialog" aria-modal="true" aria-labelledby="up-next-label">
<div className="up-next-scene">{server && <Backdrop item={upcoming ?? item} className="up-next-backdrop" />}</div>
<div className="up-next-top" data-tauri-drag-region={isNative ? true : undefined}>
<div className="up-next-scene">{server && <Backdrop item={sceneArt} className="up-next-backdrop" />}</div>
<div className="player-top up-next-top" data-tauri-drag-region={isNative ? true : undefined}>
<button className="player-back" onClick={() => usePlayer.getState().minimize()} aria-label="Back to browsing" title="Keep playing in the corner">
<Icon name="arrowLeft" size={22} />
</button>
<button className="player-icon up-next-fullscreen" aria-label={fullscreen ? 'Exit full screen' : 'Full screen'} title={fullscreen ? 'Exit full screen' : 'Full screen'} onClick={() => usePlayer.getState().toggleFullscreen()}>
<Icon name={fullscreen ? 'collapse' : 'expand'} size={21} />
</button>
{!fullscreen && <WindowControls />}
</div>
@ -90,7 +104,13 @@ export function PostPlay() {
<span className="micro" id="up-next-label">
{upcoming || !contextReady ? 'Up next' : 'More to watch'}
</span>
<TitleArt item={item} maxWidth={300} maxHeight={64} as="h2" className="up-next-logo" />
{item.grandparentId ? (
<button className="player-title-link up-next-logo" title={`Go to ${item.grandparentTitle}`} onClick={openShow}>
<TitleArt item={item} maxWidth={300} maxHeight={64} as="h2" />
</button>
) : (
<TitleArt item={item} maxWidth={300} maxHeight={64} as="h2" className="up-next-logo" />
)}
{upcoming ? (
<>
<h1>{upcoming.title}</h1>
@ -165,19 +185,36 @@ function NowPlaying({ item }: { item: Item }) {
);
}
/** Play next episode. While autoplay counts down, a lighter fill sweeps across it. */
/**
* Play next episode. While autoplay counts down, a lighter fill sweeps across it.
* The store counts in 50 ms steps; the fill is drawn every frame between them.
*/
function PlayNext({ ref }: { ref: React.Ref<HTMLButtonElement> }) {
const countdown = usePlayer((s) => s.countdown);
const total = usePlayer((s) => s.countdownTotal);
const counting = countdown !== null && total > 0;
const fill = counting ? (1 - countdown / total) * 100 : 0;
const counting = usePlayer((s) => s.countdown !== null && s.countdownTotal > 0);
const fill = useRef<HTMLSpanElement>(null);
useEffect(() => {
if (!counting) return;
let last = { value: usePlayer.getState().countdown ?? 0, at: performance.now() };
const unsubscribe = usePlayer.subscribe((s, prev) => {
if (s.countdown !== prev.countdown && s.countdown !== null) last = { value: s.countdown, at: performance.now() };
});
let raf = 0;
const draw = () => {
const { countdownTotal: total } = usePlayer.getState();
// Run on from the last step, but never more than a couple of steps ahead (a held countdown stays held).
const remaining = Math.max(0, last.value - Math.min(performance.now() - last.at, 120) / 1000);
if (fill.current && total) fill.current.style.transform = `scaleX(${1 - remaining / total})`;
raf = requestAnimationFrame(draw);
};
draw();
return () => {
unsubscribe();
cancelAnimationFrame(raf);
};
}, [counting]);
return (
<button
ref={ref}
className={`btn primary lg up-next-play${counting ? ' counting' : ''}`}
style={{ '--fill': `${fill}%` } as CSSProperties}
onClick={() => usePlayer.getState().playNext()}
>
<button ref={ref} className={`btn primary lg up-next-play${counting ? ' counting' : ''}`} onClick={() => usePlayer.getState().playNext()}>
{counting && <span className="up-next-play-fill" ref={fill} aria-hidden="true" />}
<Icon name="play" size={17} />
<span>Play next episode</span>
</button>

View file

@ -109,13 +109,27 @@ describe('Up Next playback lifecycle', () => {
vi.advanceTimersByTime(10000);
expect(usePlayer.getState()).toMatchObject({ postPlay: true, countdown: null, postPlayDismissed: true });
});
it('returns to credits without reopening on the next time event or EOF', () => {
it('returns to credits without reopening while they play', () => {
time(81);
usePlayer.getState().dismissPostPlay();
time(82);
eof();
expect(usePlayer.getState()).toMatchObject({ postPlay: false, countdown: null });
});
it('reopens at the end after returning to the credits', () => {
time(81);
usePlayer.getState().dismissPostPlay();
eof();
expect(usePlayer.getState()).toMatchObject({ postPlay: true, countdown: 5 });
});
it('reopens when the credits start again after seeking back into the episode', () => {
time(81);
usePlayer.getState().dismissPostPlay();
usePlayer.getState().seek(40);
time(40);
expect(usePlayer.getState().postPlay).toBe(false);
time(80);
expect(usePlayer.getState()).toMatchObject({ postPlay: true, countdown: 5 });
});
it.each(['hidden', 'mini'] as const)('holds the countdown while %s', (reason) => {
time(81);
if (reason === 'hidden') Object.assign(document, { hidden: true });

View file

@ -647,8 +647,12 @@ function fallbackAfterError() {
function maybeCredits(pos: number) {
const st = usePlayer.getState();
if (st.item?.type !== 'episode' || !st.firstFrame || st.postPlayDismissed) return;
if (st.item.markers.some((m) => m.type === 'credits' && pos * 1000 >= m.start && pos * 1000 < m.end)) openPostPlay();
if (st.item?.type !== 'episode' || !st.firstFrame) return;
const inCredits = st.item.markers.some((m) => m.type === 'credits' && pos * 1000 >= m.start && pos * 1000 < m.end);
// Leaving the credits (seeking back into the episode) re-arms Up Next for the next time they start.
if (!inCredits) {
if (st.postPlayDismissed && !st.postPlay && !st.ended) usePlayer.setState({ postPlayDismissed: false });
} else if (!st.postPlayDismissed) openPostPlay();
}
function onEnded() {
@ -657,7 +661,11 @@ function onEnded() {
usePlayer.setState({ ended: true });
report('stopped');
checkScrobble();
if (st.item?.type === 'episode') openPostPlay();
// Reaching the end always offers Up Next, as on Android, even after watching the credits.
if (st.item?.type === 'episode' && !st.postPlay) {
usePlayer.setState({ postPlayDismissed: false });
openPostPlay();
}
}
export const usePlayer = create<PlayerState>((set, get) => ({