fix: restore subtitle playback keybindings

This commit is contained in:
2026-05-03 23:52:07 -07:00
parent 5396b08972
commit 8f43f8825d
14 changed files with 183 additions and 22 deletions
+6 -3
View File
@@ -489,7 +489,7 @@ test('MpvIpcClient updates current audio stream index from track list', async ()
assert.equal(client.currentAudioStreamIndex, 11);
});
test('MpvIpcClient playNextSubtitle preserves a manual paused state', async () => {
test('MpvIpcClient playNextSubtitle starts playback from paused state and auto-pauses at end', async () => {
const commands: unknown[] = [];
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
(client as any).send = (payload: unknown) => {
@@ -507,9 +507,12 @@ test('MpvIpcClient playNextSubtitle preserves a manual paused state', async () =
client.playNextSubtitle();
assert.equal((client as any).pendingPauseAtSubEnd, false);
assert.equal((client as any).pendingPauseAtSubEnd, true);
assert.equal((client as any).pauseAtTime, null);
assert.deepEqual(commands, [{ command: ['sub-seek', 1] }]);
assert.deepEqual(commands, [
{ command: ['sub-seek', 1] },
{ command: ['set_property', 'pause', false] },
]);
});
test('MpvIpcClient playNextSubtitle still auto-pauses at end while already playing', async () => {
+4 -6
View File
@@ -522,14 +522,12 @@ export class MpvIpcClient implements MpvClient {
}
playNextSubtitle(): void {
if (this.playbackPaused === true) {
this.pendingPauseAtSubEnd = false;
this.pauseAtTime = null;
this.send({ command: ['sub-seek', 1] });
return;
}
this.pendingPauseAtSubEnd = true;
this.pauseAtTime = null;
this.send({ command: ['sub-seek', 1] });
if (this.playbackPaused === true) {
this.send({ command: ['set_property', 'pause', false] });
}
}
restorePreviousSecondarySubVisibility(): void {
+31 -1
View File
@@ -2,7 +2,8 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import type { Keybinding } from '../../types';
import type { ConfiguredShortcuts } from '../utils/shortcut-config';
import { SPECIAL_COMMANDS } from '../../config/definitions';
import { DEFAULT_CONFIG, DEFAULT_KEYBINDINGS, SPECIAL_COMMANDS } from '../../config/definitions';
import { resolveConfiguredShortcuts } from '../utils/shortcut-config';
import { compileSessionBindings } from './session-bindings';
function createShortcuts(overrides: Partial<ConfiguredShortcuts> = {}): ConfiguredShortcuts {
@@ -179,6 +180,35 @@ test('compileSessionBindings drops conflicting bindings that canonicalize to the
]);
});
test('compileSessionBindings keeps default replay and next subtitle session actions on Linux', () => {
const result = compileSessionBindings({
shortcuts: resolveConfiguredShortcuts(DEFAULT_CONFIG, DEFAULT_CONFIG),
keybindings: DEFAULT_KEYBINDINGS,
statsToggleKey: DEFAULT_CONFIG.stats.toggleKey,
platform: 'linux',
rawConfig: DEFAULT_CONFIG,
});
assert.deepEqual(
result.warnings.filter((warning) => warning.kind === 'conflict'),
[],
);
const bySignature = new Map(
result.bindings.map((binding) => [
`${binding.key.modifiers.join('+')}+${binding.key.code}`,
binding,
]),
);
const replay = bySignature.get('ctrl+shift+KeyH');
assert.equal(replay?.actionType, 'session-action');
assert.equal(replay?.actionId, 'replayCurrentSubtitle');
const next = bySignature.get('ctrl+shift+KeyL');
assert.equal(next?.actionType, 'session-action');
assert.equal(next?.actionId, 'playNextSubtitle');
});
test('compileSessionBindings omits disabled bindings', () => {
const result = compileSessionBindings({
shortcuts: createShortcuts({