fix: delegate multi-line digit selection to visible overlay (#78)

This commit is contained in:
2026-05-24 00:39:23 -07:00
committed by GitHub
parent c02edc90cc
commit da3c971ee6
62 changed files with 1822 additions and 209 deletions
+15
View File
@@ -670,6 +670,21 @@ test('numeric selection ignores non-digit keys instead of falling through to oth
}
});
test('numeric selection start focuses overlay for follow-up digit keys', async () => {
const { handlers, testGlobals } = createKeyboardHandlerHarness();
try {
await handlers.setupMpvInputForwarding();
handlers.beginSessionNumericSelection('copySubtitleMultiple');
assert.equal(testGlobals.focusMainWindowCalls() > 0, true);
assert.equal(testGlobals.windowFocusCalls() > 0, true);
assert.equal(testGlobals.overlayFocusCalls.length > 0, true);
} finally {
testGlobals.restore();
}
});
test('keyboard mode: left and right move token selection while popup remains open', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
+5 -2
View File
@@ -147,6 +147,7 @@ export function createKeyboardHandlers(
function startPendingNumericSelection(
actionId: 'copySubtitleMultiple' | 'mineSentenceMultiple',
timeoutMs: number = ctx.state.sessionActionTimeoutMs,
): void {
cancelPendingNumericSelection(false);
const timeoutMessage = actionId === 'copySubtitleMultiple' ? 'Copy timeout' : 'Mine timeout';
@@ -159,15 +160,17 @@ export function createKeyboardHandlers(
timeout: setTimeout(() => {
pendingNumericSelection = null;
showSessionSelectionMessage(timeoutMessage);
}, ctx.state.sessionActionTimeoutMs),
}, timeoutMs),
};
showSessionSelectionMessage(promptMessage);
}
function beginSessionNumericSelection(
actionId: 'copySubtitleMultiple' | 'mineSentenceMultiple',
timeoutMs?: number,
): void {
startPendingNumericSelection(actionId);
startPendingNumericSelection(actionId, timeoutMs);
restoreOverlayKeyboardFocus();
}
function handlePendingNumericSelection(e: KeyboardEvent): boolean {
+6
View File
@@ -530,6 +530,12 @@ function registerModalOpenHandlers(): void {
}
function registerKeyboardCommandHandlers(): void {
window.electronAPI.onSessionNumericSelectionStart((payload) => {
runGuarded('session:numeric-selection-start', () => {
keyboardHandlers.beginSessionNumericSelection(payload.actionId, payload.timeoutMs);
});
});
window.electronAPI.onKeyboardModeToggleRequested(() => {
runGuarded('keyboard-mode-toggle:requested', () => {
keyboardHandlers.handleKeyboardModeToggleRequested();