From 0f03547c8342270deb61db3f9f2cc907547a8a7d Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 3 Apr 2026 13:23:15 -0700 Subject: [PATCH] fix latest review feedback --- src/main.ts | 10 +++++-- .../runtime/first-run-setup-window.test.ts | 1 + src/main/runtime/first-run-setup-window.ts | 1 + src/main/runtime/windows-mpv-launch.test.ts | 28 +++++++++++++++++++ src/main/runtime/windows-mpv-launch.ts | 11 +++++--- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/main.ts b/src/main.ts index b5a94301..b0427669 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2244,14 +2244,18 @@ const openFirstRunSetupWindowHandler = createOpenFirstRunSetupWindowHandler({ } if (submission.action === 'configure-mpv-executable-path') { const mpvExecutablePath = submission.mpvExecutablePath?.trim() ?? ''; + const pathStatus = getConfiguredWindowsMpvPathStatus(mpvExecutablePath); configService.patchRawConfig({ mpv: { executablePath: mpvExecutablePath, }, }); - firstRunSetupMessage = mpvExecutablePath - ? `Saved mpv executable path: ${mpvExecutablePath}` - : 'Cleared mpv executable path. SubMiner will auto-discover mpv.exe from PATH.'; + firstRunSetupMessage = + pathStatus === 'invalid' + ? `Saved mpv executable path, but the file was not found: ${mpvExecutablePath}` + : mpvExecutablePath + ? `Saved mpv executable path: ${mpvExecutablePath}` + : 'Cleared mpv executable path. SubMiner will auto-discover mpv.exe from SUBMINER_MPV_PATH or PATH.'; return; } if (submission.action === 'configure-windows-mpv-shortcuts') { diff --git a/src/main/runtime/first-run-setup-window.test.ts b/src/main/runtime/first-run-setup-window.test.ts index 897b66fa..5382e7f7 100644 --- a/src/main/runtime/first-run-setup-window.test.ts +++ b/src/main/runtime/first-run-setup-window.test.ts @@ -61,6 +61,7 @@ test('buildFirstRunSetupHtml switches plugin action to reinstall when already in assert.match(html, /Reinstall mpv plugin/); assert.match(html, /mpv executable path/); assert.match(html, /Leave blank to auto-discover mpv\.exe from PATH\./); + assert.match(html, /aria-label="Path to mpv\.exe"/); assert.match( html, /Finish stays unlocked once the mpv plugin is installed and Yomitan reports at least one installed dictionary\./, diff --git a/src/main/runtime/first-run-setup-window.ts b/src/main/runtime/first-run-setup-window.ts index 08daf671..45c2553c 100644 --- a/src/main/runtime/first-run-setup-window.ts +++ b/src/main/runtime/first-run-setup-window.ts @@ -130,6 +130,7 @@ export function buildFirstRunSetupHtml(model: FirstRunSetupHtmlModel): string { diff --git a/src/main/runtime/windows-mpv-launch.test.ts b/src/main/runtime/windows-mpv-launch.test.ts index f6d18cdf..44f56bf1 100644 --- a/src/main/runtime/windows-mpv-launch.test.ts +++ b/src/main/runtime/windows-mpv-launch.test.ts @@ -134,6 +134,34 @@ test('buildWindowsMpvLaunchArgs mirrors a custom input-ipc-server into script op ); }); +test('buildWindowsMpvLaunchArgs includes socket script opts when plugin entrypoint is present without binary path', () => { + assert.deepEqual( + buildWindowsMpvLaunchArgs( + ['C:\\video.mkv'], + ['--input-ipc-server', '\\\\.\\pipe\\custom-subminer-socket'], + undefined, + 'C:\\Program Files\\SubMiner\\resources\\plugin\\subminer\\main.lua', + ), + [ + '--player-operation-mode=pseudo-gui', + '--force-window=immediate', + '--script=C:\\Program Files\\SubMiner\\resources\\plugin\\subminer\\main.lua', + '--input-ipc-server=\\\\.\\pipe\\custom-subminer-socket', + '--alang=ja,jp,jpn,japanese,en,eng,english,enus,en-us', + '--slang=ja,jp,jpn,japanese,en,eng,english,enus,en-us', + '--sub-auto=fuzzy', + '--sub-file-paths=subs;subtitles', + '--sid=auto', + '--secondary-sid=auto', + '--secondary-sub-visibility=no', + '--script-opts=subminer-socket_path=\\\\.\\pipe\\custom-subminer-socket', + '--input-ipc-server', + '\\\\.\\pipe\\custom-subminer-socket', + 'C:\\video.mkv', + ], + ); +}); + test('launchWindowsMpv reports missing mpv path', async () => { const errors: string[] = []; const result = await launchWindowsMpv( diff --git a/src/main/runtime/windows-mpv-launch.ts b/src/main/runtime/windows-mpv-launch.ts index 8cdca7ca..31b8418b 100644 --- a/src/main/runtime/windows-mpv-launch.ts +++ b/src/main/runtime/windows-mpv-launch.ts @@ -96,14 +96,17 @@ export function buildWindowsMpvLaunchArgs( const launchIdle = targets.length === 0; const inputIpcServer = readExtraArgValue(extraArgs, '--input-ipc-server') ?? DEFAULT_WINDOWS_MPV_SOCKET; - const scriptOpts = - typeof binaryPath === 'string' && binaryPath.trim().length > 0 - ? `--script-opts=subminer-binary_path=${binaryPath.trim().replace(/,/g, '\\,')},subminer-socket_path=${inputIpcServer.replace(/,/g, '\\,')}` - : null; const scriptEntrypoint = typeof pluginEntrypointPath === 'string' && pluginEntrypointPath.trim().length > 0 ? `--script=${pluginEntrypointPath.trim()}` : null; + const scriptOptPairs = scriptEntrypoint + ? [`subminer-socket_path=${inputIpcServer.replace(/,/g, '\\,')}`] + : []; + if (scriptEntrypoint && typeof binaryPath === 'string' && binaryPath.trim().length > 0) { + scriptOptPairs.unshift(`subminer-binary_path=${binaryPath.trim().replace(/,/g, '\\,')}`); + } + const scriptOpts = scriptOptPairs.length > 0 ? `--script-opts=${scriptOptPairs.join(',')}` : null; return [ '--player-operation-mode=pseudo-gui',