fix(overlay): keep forwarding mpv keys after a Yomitan popup closes

Decide whether the Yomitan popup is open from the popup host in the DOM
instead of the cached yomitanPopupVisible flag, which can lag a close and
kept input.conf keys from reaching mpv.

Keep the imported mpv key list in place while a refresh is in flight, so a
key pressed right after the overlay regains focus is not dropped. A failed
reload still clears the list.

At --log-level debug, log why the overlay kept an mpv-bound key
(config-loading, modal, lookup-popup, interactive-target or
no-imported-bindings) over a validated IPC channel.

Refs #331
This commit is contained in:
sudacode committed 2026-11-20 15:44:25 -08:00
1 parent 0c1865f4a6
commit 299bc3a2b9
14 files changed
+227 -23

No files matched your search

+26 -1
View File
@@ -14,7 +14,12 @@ import type {
SubsyncManualRunRequest,
} from '../../types/runtime';
import type { RuntimeOptionId, RuntimeOptionValue } from '../../types/runtime-options';
import type { SessionActionId, SessionActionPayload } from '../../types/session-bindings';
import type {
MpvKeyForwardBlock,
SessionActionId,
SessionActionPayload,
UnforwardedMpvKeyReport,
} from '../../types/session-bindings';
import type { SubtitlePosition } from '../../types/subtitle';
import { OVERLAY_HOSTED_MODALS, type OverlayHostedModal } from './contracts';
import { isControllerFaceButtonLabels, parseControllerDiscreteBinding } from '../controller-review';
@@ -365,6 +370,26 @@ export function parseMpvCommand(value: unknown): Array<string | number> | null {
: null;
}
// A Record so a new MpvKeyForwardBlock member fails typecheck until it is listed here.
const MPV_KEY_FORWARD_BLOCKS: Record<MpvKeyForwardBlock, true> = {
'config-loading': true,
modal: true,
'lookup-popup': true,
'interactive-target': true,
'no-imported-bindings': true,
};
function isMpvKeyForwardBlock(value: unknown): value is MpvKeyForwardBlock {
return typeof value === 'string' && Object.hasOwn(MPV_KEY_FORWARD_BLOCKS, value);
}
export function parseUnforwardedMpvKeyReport(value: unknown): UnforwardedMpvKeyReport | null {
if (!isObject(value)) return null;
const { key, reason } = value;
if (typeof key !== 'string' || key.length === 0 || key.length > 64) return null;
return isMpvKeyForwardBlock(reason) ? { key, reason } : null;
}
export function parseOptionalForwardingOptions(value: unknown): {
forward?: boolean;
} {