From 6a44b54b517578caa4a37b4b4a0bdcdfac912fd3 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 8 Mar 2026 16:02:57 -0700 Subject: [PATCH] fix: reuse background overlay across mpv reconnects --- launcher/commands/playback-command.ts | 9 +++++---- src/main.ts | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/launcher/commands/playback-command.ts b/launcher/commands/playback-command.ts index e0b37ac..565de16 100644 --- a/launcher/commands/playback-command.ts +++ b/launcher/commands/playback-command.ts @@ -5,7 +5,7 @@ import { fail, log } from '../log.js'; import { commandExists, isYoutubeTarget, realpathMaybe, resolvePathMaybe } from '../util.js'; import { collectVideos, showFzfMenu, showRofiMenu } from '../picker.js'; import { - loadSubtitleIntoMpv, + cleanupPlaybackSession, startMpv, startOverlay, state, @@ -264,9 +264,10 @@ export async function runPlaybackCommand(context: LauncherCommandContext): Promi } const finalize = (code: number | null | undefined) => { - stopOverlay(args); - processAdapter.setExitCode(code ?? 0); - resolve(); + void cleanupPlaybackSession(args).finally(() => { + processAdapter.setExitCode(code ?? 0); + resolve(); + }); }; if (mpvProc.exitCode !== null && mpvProc.exitCode !== undefined) { diff --git a/src/main.ts b/src/main.ts index c3d1abc..1b5f038 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2524,6 +2524,7 @@ const { createMpvClientRuntimeService: createMpvClientRuntimeServiceHandler, updateMpvSubtitleRenderMetrics: updateMpvSubtitleRenderMetricsHandler, tokenizeSubtitle, + isTokenizationWarmupReady, createMecabTokenizerAndCheck, prewarmSubtitleDictionaries, startBackgroundWarmups, @@ -2563,6 +2564,12 @@ const { } mediaRuntime.updateCurrentMediaPath(path); }, + signalAutoplayReadyIfWarm: (path) => { + if (!isTokenizationWarmupReady()) { + return; + } + maybeSignalPluginAutoplayReady({ text: path, tokens: null }, { forceWhilePaused: true }); + }, restoreMpvSubVisibility: () => { restoreOverlayMpvSubtitles(); },