feat: cross-platform titlebar, video transfers and client cleanup
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

Adds frameless-window controls for Windows/Linux (native traffic lights on macOS), keeps transfers at the current position for video, lets the video player use the same sync/device controls as the media bar, and removes dead code plus assorted UI/perf issues.
This commit is contained in:
1xDed committed 2026-11-28 01:31:16 +03:00
1 parent 4bdd0139bf
commit 6675a55957
26 files changed
+561 -316

No files matched your search

+70 -62
View File
@@ -7,15 +7,13 @@ import React, { useCallback, useState } from "react";
import "./appBar.scss";
import { useShallow } from "zustand/shallow";
// removed search placeholder; library state now managed via zustand
import { useApiInContext } from "@/utils/store/api";
import { useCentralStore } from "@/utils/store/central";
import useHeaderStore from "@/utils/store/header";
import useSearchStore from "@/utils/store/search";
import BackButton from "../buttons/backButton";
import CastButton from "../buttons/castButton";
import { UserAvatarMenu } from "../userAvatarMenu";
import { NavigationDrawer } from "./navigationDrawer";
import WindowControls from "../windowControls";
const MemoizeBackButton = React.memo(BackButton);
@@ -32,7 +30,15 @@ const HIDDEN_PATHS = [
"/home",
];
export const AppBar = () => {
/** Whether the global app header is drawn for this route. */
export const shouldShowAppBar = (pathname: string) =>
!HIDDEN_PATHS.some(
(path) =>
(pathname.startsWith(path) && pathname !== "/player/audio") ||
pathname === "/",
);
const AppBarContent = () => {
const navigate = useNavigate();
const location = useLocation();
@@ -40,13 +46,7 @@ export const AppBar = () => {
useShallow((s) => s.toggleSearchDialog),
);
const display = !HIDDEN_PATHS.some(
(path) =>
(location.pathname.startsWith(path) &&
location.pathname !== "/player/audio") ||
location.pathname === "/",
);
// This hook subscribes to page scroll; keep it out of hidden routes.
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 20,
@@ -54,11 +54,6 @@ export const AppBar = () => {
const [showDrawer, setShowDrawer] = useState(false);
const _handleNavigateToSearch = useCallback(
() => navigate({ to: "/search", search: { query: "" } }),
[navigate],
);
const handleDrawerClose = useCallback(() => {
setShowDrawer(false);
}, []);
@@ -74,53 +69,66 @@ export const AppBar = () => {
useHeaderStore(useShallow((s) => ({ pageTitle: s.pageTitle })));
if (!display) {
return null;
}
if (display) {
return (
<>
<MuiAppBar
return (
<>
<MuiAppBar
data-tauri-drag-region
className={
trigger
? "appBar flex flex-row flex-justify-spaced-between elevated"
: "appBar flex flex-row flex-justify-spaced-between"
}
elevation={0}
color="transparent"
>
<div
className="flex flex-row"
data-tauri-drag-region
className={
trigger
? "appBar flex flex-row flex-justify-spaced-between elevated"
: "appBar flex flex-row flex-justify-spaced-between"
}
elevation={0}
color="transparent"
style={{ gap: "0.6em" }}
>
<div className="flex flex-row" data-tauri-drag-region style={{ gap: "0.6em" }}>
<IconButton onClick={handleDrawerOpen}>
<span className="material-symbols-rounded">menu</span>
</IconButton>
<MemoizeBackButton />
<IconButton onClick={handleNavigateToHome}>
<span
className={
location.pathname === "/home"
? "material-symbols-rounded fill"
: "material-symbols-rounded"
}
>
home
</span>
</IconButton>
</div>
<IconButton onClick={handleDrawerOpen} aria-label="Open navigation">
<span className="material-symbols-rounded">menu</span>
</IconButton>
<MemoizeBackButton />
<IconButton onClick={handleNavigateToHome} aria-label="Home">
<span
className={
location.pathname === "/home"
? "material-symbols-rounded fill"
: "material-symbols-rounded"
}
>
home
</span>
</IconButton>
</div>
<div className="flex flex-row" data-tauri-drag-region style={{ gap: "0.6em" }}>
<CastButton />
<IconButton onClick={toggleSearchDialog}>
<span className="material-symbols-rounded">search</span>
</IconButton>
<IconButton onClick={handleNavigateToFavorite}>
<span className="material-symbols-rounded">favorite</span>
</IconButton>
<UserAvatarMenu />
</div>
</MuiAppBar>
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
</>
);
}
<div
className="flex flex-row"
data-tauri-drag-region
style={{ gap: "0.6em" }}
>
<CastButton />
<IconButton onClick={toggleSearchDialog} aria-label="Search">
<span className="material-symbols-rounded">search</span>
</IconButton>
<IconButton
onClick={handleNavigateToFavorite}
aria-label="Favorites"
>
<span className="material-symbols-rounded">favorite</span>
</IconButton>
<UserAvatarMenu />
<WindowControls />
</div>
</MuiAppBar>
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
</>
);
};
export const AppBar = () => {
const location = useLocation();
if (!shouldShowAppBar(location.pathname)) return null;
return <AppBarContent />;
};
+1 -1
View File
@@ -195,7 +195,7 @@ const PlayButton = ({
},
});
const handleClick = (
e: MouseEvent<HTMLAnchorElement | MouseEvent>,
e: MouseEvent<HTMLElement>,
currentEpisodeId?: string | undefined,
) => {
e.stopPropagation();
@@ -3,8 +3,14 @@ import Typography from "@mui/material/Typography";
import { red } from "@mui/material/colors";
import React from "react";
export const ErrorNotice = ({ error }: { error?: Error }) => {
console.error(error);
export const ErrorNotice = ({ error }: { error?: unknown }) => {
const normalizedError =
error instanceof Error
? error
: error
? new Error(String(error))
: undefined;
console.error(normalizedError ?? error);
return (
<Box
sx={{
@@ -57,8 +63,9 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
fontFamily: "JetBrains Mono Variable",
}}
>
{error
? error.stack || `${error.name}: ${error.message}`
{normalizedError
? normalizedError.stack ||
`${normalizedError.name}: ${normalizedError.message}`
: "Unknown error"}
</Typography>
</Box>
+1
View File
@@ -84,6 +84,7 @@ const PlaybackSync = () => {
const tick = async () => {
if (busy || cancelled) return;
if (document.visibilityState !== "visible") return;
busy = true;
try {
const sessions = (await sessionApi.getSessions()).data;
+10 -4
View File
@@ -98,7 +98,11 @@ const AudioPlayer = () => {
return result.data;
},
enabled: !!api && !!user?.Id,
refetchInterval: 3000,
// Do not keep polling the server while the window is hidden.
refetchInterval: () =>
document.visibilityState === "visible" ? 3000 : false,
refetchIntervalInBackground: false,
staleTime: 1500,
networkMode: "always",
});
@@ -188,11 +192,13 @@ const AudioPlayer = () => {
// Layout hooks (home hero rail) reserve space for the bar. Use explicit
// visibility rather than the DOM: during the exit animation the element is
// still mounted but already off-screen.
const isFullPlayer =
location.pathname === "/player" || location.pathname === "/player/audio";
useEffect(() => {
const visible = barVisible && location.pathname !== "/player/audio";
const visible = barVisible && !isFullPlayer;
document.body.classList.toggle("has-player-bar", visible);
return () => document.body.classList.remove("has-player-bar");
}, [barVisible, location.pathname]);
}, [barVisible, isFullPlayer]);
// Sync local audio element.
useEffect(() => {
@@ -523,7 +529,7 @@ const AudioPlayer = () => {
});
};
if (!barVisible || location.pathname === "/player/audio") {
if (!barVisible || isFullPlayer) {
return null;
}
@@ -1,5 +1,5 @@
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
import { IconButton, Slider, Typography } from "@mui/material";
import { IconButton, Slider, Tooltip, Typography } from "@mui/material";
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
import { AnimatePresence, motion } from "motion/react";
import React, {
@@ -18,6 +18,7 @@ import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
import { secToTicks } from "@/utils/date/time";
import { useApiInContext } from "@/utils/store/api";
import { usePlaybackStore } from "@/utils/store/playback";
import useSyncPlayback from "@/utils/store/syncPlayback";
import CaptionsButton from "./buttons/CaptionsButton";
import ChaptersListButton from "./buttons/ChaptersListButton";
import ForwardButton from "./buttons/ForwardButton";
@@ -54,6 +55,18 @@ const VideoPlayerControls = ({
const playerOSDRef = useRef<HTMLDivElement>(null);
const api = useApiInContext((state) => state.api);
const syncEnabled = useSyncPlayback((state) => state.enabled);
const syncMaster = useSyncPlayback((state) => state.master);
const startSync = useSyncPlayback((state) => state.start);
const stopSync = useSyncPlayback((state) => state.stop);
const syncThisVideo = syncEnabled && syncMaster?.sessionId === null;
const toggleSync = () => {
if (syncThisVideo) {
stopSync();
return;
}
if (itemId) startSync({ itemId, sessionId: null });
};
const {
mediaSourceId,
itemId,
@@ -120,7 +133,9 @@ const VideoPlayerControls = ({
};
}, [increaseVolumeByStep, decreaseVolumeByStep]);
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout | null>(null);
const [clickTimeout, setClickTimeout] = useState<ReturnType<
typeof setTimeout
> | null>(null);
const [showVolumeControl, setShowVolumeControl] = useState(false);
const [settingsMenuRef, setSettingsMenuRef] =
@@ -319,6 +334,21 @@ const VideoPlayerControls = ({
startIndex: useQueue.getState().currentItemIndex,
})}
/>
<Tooltip
title={syncThisVideo ? "Stop device sync" : "Sync playback"}
>
<IconButton
aria-label="Sync playback"
onClick={toggleSync}
sx={
syncThisVideo
? { color: "var(--mui-palette-primary-main)" }
: undefined
}
>
<span className="material-symbols-rounded">sync</span>
</IconButton>
</Tooltip>
<QueueButton />
<ChaptersListButton />
+1
View File
@@ -250,6 +250,7 @@ const RemoteControlDialog = () => {
{nowPlaying.Name}
{nowPlaying.Genres?.length ? (
<Chip
component="span"
size="small"
label={nowPlaying.Genres[0]}
sx={{ ml: 1 }}
-52
View File
@@ -1,52 +0,0 @@
import React, { useCallback, useMemo } from "react";
import { Dialog, Slide } from "@mui/material";
// import { useKonamiEasterEgg } from "../../utils/misc/konami";
export const EasterEgg = () => {
// const [easterEgg, setEasterEgg] = useKonamiEasterEgg();
// // Memoize the onClose function
// const handleClose = useCallback(() => {
// setEasterEgg(false);
// }, [setEasterEgg]);
// // Memoize the sx object
// const dialogSx = useMemo(
// () => ({
// background: "black",
// }),
// [],
// );
// return (
// <>
// <Dialog open={easterEgg} onClose={handleClose} sx={dialogSx}>
// <iframe
// width="560"
// height="315"
// src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&disablekb=1"
// title="EasterEgg"
// allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
// />
// </Dialog>
// <Slide direction="up" in={easterEgg} mountOnEnter unmountOnExit>
// <img
// src="https://i.gifer.com/PYh.gif"
// loading="lazy"
// width={320}
// height={320}
// alt="nyan cat gif"
// style={{
// zIndex: "99999999",
// position: "fixed",
// bottom: 0,
// left: 0,
// objectFit: "cover",
// }}
// />
// </Slide>
// </>
// );
return <></>;
};
+73
View File
@@ -0,0 +1,73 @@
import { getCurrentWindow } from "@tauri-apps/api/window";
import React, { useEffect, useState } from "react";
import "./windowControls.scss";
const isMac = navigator.userAgent.includes("Macintosh");
const WindowsControls = () => {
const [maximized, setMaximized] = useState(false);
useEffect(() => {
const appWindow = getCurrentWindow();
let disposed = false;
let timer: number | undefined;
const sync = () => {
window.clearTimeout(timer);
timer = window.setTimeout(() => {
appWindow.isMaximized().then((value) => {
if (!disposed) setMaximized(value);
});
}, 120);
};
appWindow.isMaximized().then((value) => {
if (!disposed) setMaximized(value);
});
const unlisten = appWindow.onResized(sync);
return () => {
disposed = true;
window.clearTimeout(timer);
unlisten.then((off) => off()).catch(() => undefined);
};
}, []);
return (
<div className="window-controls">
<button
type="button"
aria-label="Minimize"
title="Minimize"
onClick={() => getCurrentWindow().minimize()}
>
<span className="material-symbols-rounded">remove</span>
</button>
<button
type="button"
aria-label={maximized ? "Restore" : "Maximize"}
title={maximized ? "Restore" : "Maximize"}
onClick={() => getCurrentWindow().toggleMaximize()}
>
<span className="material-symbols-rounded">
{maximized ? "filter_none" : "crop_square"}
</span>
</button>
<button
type="button"
className="window-controls-close"
aria-label="Close"
title="Close"
onClick={() => getCurrentWindow().close()}
>
<span className="material-symbols-rounded">close</span>
</button>
</div>
);
};
/**
* Window buttons for frameless windows on Windows/Linux. macOS keeps its
* native traffic lights (overlay titlebar), so this renders nothing there.
*/
const WindowControls = () => (isMac ? null : <WindowsControls />);
export default WindowControls;
@@ -0,0 +1,40 @@
import { useLocation } from "@tanstack/react-router";
import React, { useEffect } from "react";
import { shouldShowAppBar } from "@/components/appBar/appBar";
import WindowControls from ".";
import "./windowControls.scss";
const isMac = navigator.userAgent.includes("Macintosh");
const WindowChromeContent = () => {
useEffect(() => {
document.body.classList.add("has-window-chrome");
return () => document.body.classList.remove("has-window-chrome");
}, []);
return (
<div className="window-chrome">
<div className="window-chrome-drag" data-tauri-drag-region />
<div className="window-chrome-controls">
<WindowControls />
</div>
</div>
);
};
/**
* Frameless-window fallback for pages that do not draw the app header:
* a small drag strip plus the window buttons in the top-right corner.
*/
const WindowChrome = () => {
const { pathname } = useLocation();
if (isMac) return null;
if (pathname === "/home" || shouldShowAppBar(pathname)) return null;
// The video player has its own fullscreen UI.
if (pathname.startsWith("/player")) return null;
return <WindowChromeContent />;
};
export default WindowChrome;
@@ -0,0 +1,72 @@
.window-controls {
display: flex;
align-items: center;
flex: 0 0 auto;
margin-left: 0.35rem;
border-radius: 10px;
overflow: hidden;
background: rgb(255 255 255 / 0.04);
button {
display: flex;
align-items: center;
justify-content: center;
width: 42px;
height: 38px;
padding: 0;
border: 0;
background: transparent;
color: rgb(255 255 255 / 0.82);
cursor: pointer;
transition: background-color 0.12s ease, color 0.12s ease;
.material-symbols-rounded {
font-size: 1.05rem;
}
&:hover {
background: rgb(255 255 255 / 0.12);
color: #fff;
}
}
&-close:hover {
background: #d63b3b;
color: #fff;
}
}
html.is-windows .home-header .window-controls,
html.is-linux .home-header .window-controls {
margin-left: 0.6rem;
}
// Reserve a strip for the custom titlebar on routes without the app header.
html.is-windows body.has-window-chrome #root,
html.is-linux body.has-window-chrome #root {
padding-top: 44px;
}
.window-chrome {
position: fixed;
inset: 0 0 auto;
z-index: 10000;
pointer-events: none;
&-drag {
height: 10px;
width: 100%;
pointer-events: auto;
}
&-controls {
position: absolute;
top: 4px;
right: 8px;
pointer-events: auto;
border-radius: 12px;
background: rgb(10 11 15 / 0.72);
box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
backdrop-filter: blur(14px);
}
}