From a5eba369b454bb365a9208d2b846736ffb5c3523 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 17 May 2026 03:13:03 -0700 Subject: [PATCH] fix(launcher): suppress Electron menu diagnostics --- .../fix-launcher-electron-menu-diagnostic.md | 4 +++ launcher/main.test.ts | 28 +++++++++++++++++++ launcher/mpv.ts | 25 +++++++++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 changes/fix-launcher-electron-menu-diagnostic.md diff --git a/changes/fix-launcher-electron-menu-diagnostic.md b/changes/fix-launcher-electron-menu-diagnostic.md new file mode 100644 index 00000000..17e4f59b --- /dev/null +++ b/changes/fix-launcher-electron-menu-diagnostic.md @@ -0,0 +1,4 @@ +type: fixed +area: launcher + +- Suppressed Electron macOS menu diagnostics from `subminer config` launcher output. diff --git a/launcher/main.test.ts b/launcher/main.test.ts index 8adc955e..cbb66f38 100644 --- a/launcher/main.test.ts +++ b/launcher/main.test.ts @@ -280,6 +280,34 @@ test('launcher config command forwards app configuration window command', () => }); }); +test('launcher config command suppresses known Electron macOS menu diagnostics', () => { + withTempDir((root) => { + const homeDir = path.join(root, 'home'); + const xdgConfigHome = path.join(root, 'xdg'); + const appPath = path.join(root, 'fake-subminer.sh'); + fs.writeFileSync( + appPath, + [ + '#!/bin/sh', + 'printf "%s\\n" "2026-05-17 02:59:52.141 SubMiner[29060:305323] representedObject is not a WeakPtrToElectronMenuModelAsNSObject" >&2', + 'printf "%s\\n" "real stderr line" >&2', + 'exit 0', + '', + ].join('\n'), + ); + fs.chmodSync(appPath, 0o755); + + const env = { + ...makeTestEnv(homeDir, xdgConfigHome), + SUBMINER_APPIMAGE_PATH: appPath, + }; + const result = runLauncher(['config'], env); + + assert.equal(result.status, 0); + assert.equal(result.stderr, 'real stderr line\n'); + }); +}); + test('launcher forwards --args to mpv as parsed tokens', { timeout: 15000 }, () => { withTempDir((root) => { const homeDir = path.join(root, 'home'); diff --git a/launcher/mpv.ts b/launcher/mpv.ts index 3b366e7b..58b4cd8d 100644 --- a/launcher/mpv.ts +++ b/launcher/mpv.ts @@ -1229,6 +1229,14 @@ function appendCapturedAppOutput(kind: 'STDOUT' | 'STDERR', chunk: string): void } } +const KNOWN_ELECTRON_MENU_DIAGNOSTIC = + 'representedObject is not a WeakPtrToElectronMenuModelAsNSObject'; + +function filterKnownElectronDiagnostics(chunk: string): string { + const lines = chunk.match(/[^\n]*\n|[^\n]+/g) ?? []; + return lines.filter((line) => !line.includes(KNOWN_ELECTRON_MENU_DIAGNOSTIC)).join(''); +} + function attachAppProcessLogging( proc: ReturnType, options?: { @@ -1243,8 +1251,12 @@ function attachAppProcessLogging( if (options?.mirrorStdout) process.stdout.write(chunk); }); proc.stderr?.on('data', (chunk: string) => { - appendCapturedAppOutput('STDERR', chunk); - if (options?.mirrorStderr) process.stderr.write(chunk); + const filteredChunk = filterKnownElectronDiagnostics(chunk); + if (!filteredChunk) { + return; + } + appendCapturedAppOutput('STDERR', filteredChunk); + if (options?.mirrorStderr) process.stderr.write(filteredChunk); }); } @@ -1268,13 +1280,16 @@ function runSyncAppCommand( if (mirrorOutput) process.stdout.write(result.stdout); } if (result.stderr) { - appendCapturedAppOutput('STDERR', result.stderr); - if (mirrorOutput) process.stderr.write(result.stderr); + const filteredStderr = filterKnownElectronDiagnostics(result.stderr); + if (filteredStderr) { + appendCapturedAppOutput('STDERR', filteredStderr); + if (mirrorOutput) process.stderr.write(filteredStderr); + } } return { status: result.status ?? 1, stdout: result.stdout ?? '', - stderr: result.stderr ?? '', + stderr: result.stderr ? filterKnownElectronDiagnostics(result.stderr) : '', error: result.error ?? undefined, }; }