feat(config): show default keybindings in generated example config

- Expand `keybindings` array in `config.example.jsonc` to list all built-in defaults instead of `[]`
- Inject `DEFAULT_KEYBINDINGS` into template when resolved config has an empty keybindings array
- Add regression tests for template parity, default binding compile/action mapping, overlay keyboard dispatch, and mpv plugin registration/dispatch
- Add fullscreen binding to docs shortcut tables and clarify keybindings can target mpv commands or session actions
This commit is contained in:
2026-05-12 22:58:58 -07:00
parent 430373f010
commit c1ee0dfd2e
12 changed files with 665 additions and 40 deletions
@@ -209,6 +209,41 @@ test('compileSessionBindings keeps default replay and next subtitle session acti
assert.equal(next?.actionId, 'playNextSubtitle');
});
test('compileSessionBindings wires every default keybinding to an overlay or mpv action', () => {
const expectedSpecialActions: Record<string, string> = {
[SPECIAL_COMMANDS.SHIFT_SUB_DELAY_TO_PREVIOUS_SUBTITLE_START]: 'shiftSubDelayPrevLine',
[SPECIAL_COMMANDS.SHIFT_SUB_DELAY_TO_NEXT_SUBTITLE_START]: 'shiftSubDelayNextLine',
[SPECIAL_COMMANDS.YOUTUBE_PICKER_OPEN]: 'openYoutubePicker',
[SPECIAL_COMMANDS.PLAYLIST_BROWSER_OPEN]: 'openPlaylistBrowser',
[SPECIAL_COMMANDS.REPLAY_SUBTITLE]: 'replayCurrentSubtitle',
[SPECIAL_COMMANDS.PLAY_NEXT_SUBTITLE]: 'playNextSubtitle',
};
const result = compileSessionBindings({
shortcuts: createShortcuts(),
keybindings: DEFAULT_KEYBINDINGS,
platform: 'linux',
});
assert.deepEqual(result.warnings, []);
const byOriginalKey = new Map(result.bindings.map((binding) => [binding.originalKey, binding]));
assert.equal(byOriginalKey.size, DEFAULT_KEYBINDINGS.length);
for (const defaultBinding of DEFAULT_KEYBINDINGS) {
const compiled = byOriginalKey.get(defaultBinding.key);
assert.ok(compiled, `${defaultBinding.key} should compile`);
const specialAction = expectedSpecialActions[String(defaultBinding.command?.[0])];
if (specialAction) {
assert.equal(compiled.actionType, 'session-action');
assert.equal(compiled.actionId, specialAction);
continue;
}
assert.equal(compiled.actionType, 'mpv-command');
assert.deepEqual(compiled.command, defaultBinding.command);
}
});
test('compileSessionBindings omits disabled bindings', () => {
const result = compileSessionBindings({
shortcuts: createShortcuts({