feat(overlay): run session help commands with Enter or double-click (#275)

This commit is contained in:
2026-09-29 18:48:56 -07:00
committed by GitHub
parent 4e43c5c6e1
commit 0bbd8617f4
16 changed files with 701 additions and 49 deletions
@@ -0,0 +1,38 @@
type MpvCommand = (string | number)[];
function isSubtitleSeekCommand(command: MpvCommand): command is [string, number] {
return command[0] === 'sub-seek' && typeof command[1] === 'number';
}
/**
* Sends a configured mpv command. Subtitle seeks re-pause afterwards unless playback
* is known to be running, so stepping lines from a paused video stays paused.
*/
export function dispatchConfiguredMpvCommand(
command: MpvCommand,
deps: {
getPlaybackPaused: () => Promise<boolean | null>;
sendMpvCommand: (command: MpvCommand) => void;
},
): void {
if (!isSubtitleSeekCommand(command)) {
deps.sendMpvCommand(command);
return;
}
// The fallback only covers a failed pause lookup, so a failed re-pause never resends the seek.
void deps
.getPlaybackPaused()
.then(
(paused) => {
deps.sendMpvCommand(command);
if (paused !== false) {
deps.sendMpvCommand(['set_property', 'pause', 'yes']);
}
},
() => {
deps.sendMpvCommand(command);
},
)
.catch((error: unknown) => console.error('Could not send mpv command', error));
}