From 8057e9f7572c5df65bf5eb9208b7d8b7e4a11557 Mon Sep 17 00:00:00 2001 From: sudacode Date: Fri, 11 Sep 2026 04:01:12 -0700 Subject: [PATCH] fix(overlay): recognize prefixed SubMiner bindings --- src/shared/mpv-input-bindings.test.ts | 15 +++++++++++++++ src/shared/mpv-input-bindings.ts | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/shared/mpv-input-bindings.test.ts b/src/shared/mpv-input-bindings.test.ts index 7f6d112e..e62ccb60 100644 --- a/src/shared/mpv-input-bindings.test.ts +++ b/src/shared/mpv-input-bindings.test.ts @@ -88,3 +88,18 @@ test('SubMiner ownership excludes only its script commands and respects explicit ['a', 'b', 'c', 'd'], ); }); + +test('SubMiner ownership recognizes leading mpv prefixes without matching command arguments', () => { + assert.deepEqual( + parseMpvInputBindingKeys([ + { key: 'a', cmd: 'no-osd script-binding subminer/action', priority: 1 }, + { key: 'b', cmd: ' repeatable\tasync raw script-binding "subminer/action"', priority: 1 }, + { key: 'c', cmd: 'osd-msg-bar sync script-message subminer-toggle', priority: 1 }, + { key: 'd', cmd: 'no-osd show-text "script-binding subminer/action"', priority: 1 }, + { key: 'e', cmd: 'show-text "no-osd script-binding subminer/action"', priority: 1 }, + { key: 'f', cmd: 'no-osd script-binding other/action', priority: 1 }, + { key: 'g', cmd: 'no-osd script-binding subminer/action', owner: 'other', priority: 1 }, + ]), + ['d', 'e', 'f', 'g'], + ); +}); diff --git a/src/shared/mpv-input-bindings.ts b/src/shared/mpv-input-bindings.ts index 8041b275..93f514ef 100644 --- a/src/shared/mpv-input-bindings.ts +++ b/src/shared/mpv-input-bindings.ts @@ -17,6 +17,9 @@ const SPECIAL_KEYS: Record = { ArrowDown: 'DOWN', }; const MPV_SPECIAL_KEYS = new Set(Object.values(SPECIAL_KEYS)); +// Leading command flags accepted by mpv's input/cmd.c, before the command name. +const MPV_COMMAND_PREFIXES = + /^(?:(?:no-osd|osd-bar|osd-msg|osd-msg-bar|osd-auto|expand-properties|raw|repeatable|nonrepeatable|nonscalable|async|sync)\s+)+/; // Only single keyboard strokes are imported. Mouse input and sequences need // their own focus and conflict rules before they can be forwarded safely. @@ -81,7 +84,7 @@ export function parseMpvInputBindingKeys(value: unknown): string[] { owner === 'subminer' || (owner === undefined && /^(?:script-binding\s+["']?subminer\/|script-message\s+["']?subminer-)/.test( - entry.cmd.trimStart(), + entry.cmd.trimStart().replace(MPV_COMMAND_PREFIXES, ''), )); const previous = bindings.get(key); // mpv's reported priority already ranks active non-weak bindings above weak