feat(keybinding): several shortcuts per action, mouse buttons, searchable picker
Shortcuts were defined in four places that drifted apart: per-action IPC channel pairs, a hand-written VK table in the service, a second one in the renderer, and three copies of the keycap styling. Adding an action meant editing all of them, so two shortcuts stayed hardcoded in bootstrap and one had no settings entry at all. packages/core/src/keybinding.ts is now the single source for the binding type, the selectable key catalog, the action catalog, normalization, validation, conflict detection, display labels, search and deserialization. Main, preload and renderer all read from it; nothing redefines keys or rules locally. - Each action holds a list of bindings instead of one. AppConfig's four *Shortcut fields collapse into a single keyBindings map, migrated on launch. - Mouse buttons can be bound. Left click is refused, right/middle need a modifier, side buttons are free. uiohook cannot swallow events, so the original click still fires and the UI says so. - Keys can be picked from a grouped dropdown with a search box, not only by recording a keypress. - HOTKEY's 14 channels become KEYBINDING's 9, taking the action as a parameter, so actions no longer multiply channels. The history and command popups moved out of bootstrap into ordinary actions. - displayLabel is gone; labels derive from the binding and follow the app language and platform. Fixes found on the way: - Double-press hands-free was unreachable: lookup returned only the first matching action, and dictation shares its default binding. - Reserved-combination checks compared joined key names, so a different modifier order let Ctrl+C through. - Disabling shortcuts released every global registration in the process, including the popup ones, and never restored them. - Enabling shortcuts after starting disabled left nothing registered. - The dashboard stored the caption event payload instead of the state in it.
This commit is contained in:
parent
0ca9e242fa
commit
4ad1ae6ed4
49 changed files with 5901 additions and 1792 deletions
|
|
@ -200,7 +200,7 @@ test.describe.serial('Extreme Red Team - Cycle 3: Modals, Deep Configuration & S
|
|||
expect(uncaughtExceptions).toEqual([]);
|
||||
});
|
||||
|
||||
test('RT-11: HotkeyRecordModal - Interactive Hotkey Recording & Conflict Protection', async () => {
|
||||
test('RT-11: KeyBindingPicker - Key Recording, Reserved-Combo Protection & Cancel Safety', async () => {
|
||||
// 1. Re-open SettingsModal to General Tab
|
||||
const settingsTrigger = window.getByText('설정', { exact: true });
|
||||
await settingsTrigger.click();
|
||||
|
|
@ -211,34 +211,114 @@ test.describe.serial('Extreme Red Team - Cycle 3: Modals, Deep Configuration & S
|
|||
await generalTab.click();
|
||||
await window.waitForTimeout(400);
|
||||
|
||||
// 2. Click pencil icon on Dictation shortcut to open HotkeyRecordModal
|
||||
const editHotkeyBtn = window.locator('button:has(svg.lucide-pencil)').first();
|
||||
await expect(editHotkeyBtn).toBeVisible();
|
||||
await editHotkeyBtn.click();
|
||||
await window.waitForTimeout(500);
|
||||
// 2. The dictation row is rendered by KeyBindingField off KEYBINDING_ACTIONS
|
||||
const dictationField = window.getByTestId('keybinding-field-dictation');
|
||||
await expect(dictationField).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Verify HotkeyRecordModal is open
|
||||
await expect(window.getByText(/단축키 설정|단축키 녹화|키 조합/i).first()).toBeVisible({ timeout: 5000 });
|
||||
// Wait for the binding map to arrive, then snapshot how many bindings this action
|
||||
// has so we can prove afterwards that cancelling did not corrupt them.
|
||||
const bindingChips = dictationField.getByTestId('keybinding-binding');
|
||||
await expect(bindingChips.first()).toBeVisible({ timeout: 5000 });
|
||||
const bindingsBefore = await bindingChips.count();
|
||||
|
||||
// 3. Test pressing a key (F9)
|
||||
// 3. Open the picker with the "+ Add" button (replaces the old pencil icon)
|
||||
await dictationField.getByTestId('keybinding-add-dictation').click();
|
||||
const picker = window.getByTestId('keybinding-picker');
|
||||
await expect(picker).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// 4. Record tab: pressing F9 captures it onto a keycap
|
||||
const recordArea = picker.getByTestId('keybinding-record-area');
|
||||
await expect(recordArea).toBeVisible();
|
||||
await window.keyboard.press('F9');
|
||||
await window.waitForTimeout(400);
|
||||
await expect(recordArea.getByText('F9', { exact: true })).toBeVisible();
|
||||
|
||||
// Verify chip shows F9
|
||||
await expect(window.getByText('F9', { exact: true })).toBeVisible();
|
||||
|
||||
// Take screenshot while modal is open with captured key
|
||||
// Take screenshot while the picker holds the captured key
|
||||
await window.screenshot({
|
||||
path: path.join(SCREENSHOT_DIR, 'rt11_hotkey_modal_verified.png'),
|
||||
path: path.join(SCREENSHOT_DIR, 'rt11_keybinding_picker_recorded.png'),
|
||||
});
|
||||
|
||||
// 4. Click Cancel button to close HotkeyRecordModal without corrupting bindings
|
||||
const cancelBtn = window.getByRole('button', { name: /취소|Cancel/i });
|
||||
await expect(cancelBtn).toBeVisible();
|
||||
await cancelBtn.click();
|
||||
await window.waitForTimeout(500);
|
||||
// 5. Reserved-combo protection: Ctrl+C must be rejected and Save must stay disabled
|
||||
await picker.getByTestId('keybinding-record-again').click();
|
||||
await window.waitForTimeout(300);
|
||||
await window.keyboard.press('Control+c');
|
||||
await window.waitForTimeout(400);
|
||||
await expect(picker.getByTestId('keybinding-rejection').first()).toBeVisible();
|
||||
await expect(picker.getByTestId('keybinding-confirm')).toBeDisabled();
|
||||
|
||||
// 6. Cancel closes the picker without touching the stored bindings
|
||||
await picker.getByTestId('keybinding-cancel').click();
|
||||
await window.waitForTimeout(500);
|
||||
await expect(picker).toBeHidden();
|
||||
await expect(bindingChips).toHaveCount(bindingsBefore);
|
||||
|
||||
// Close SettingsModal (its close button sits in DialogTitle, ahead of any field markup)
|
||||
const closeSettingsBtn = window.locator('div[role="dialog"] button:has(svg.lucide-x)').first();
|
||||
if (await closeSettingsBtn.isVisible()) {
|
||||
await closeSettingsBtn.click();
|
||||
await window.waitForTimeout(500);
|
||||
}
|
||||
|
||||
expect(uncaughtExceptions).toEqual([]);
|
||||
});
|
||||
|
||||
test('RT-11b: KeyBindingPicker - Searchable Key Dropdown & Multi-Binding Add/Remove', async () => {
|
||||
// 1. Re-open SettingsModal to General Tab
|
||||
const settingsTrigger = window.getByText('설정', { exact: true });
|
||||
await settingsTrigger.click();
|
||||
await window.waitForTimeout(600);
|
||||
|
||||
const generalTab = window.getByRole('tab', { name: /일반|General/i });
|
||||
await generalTab.click();
|
||||
await window.waitForTimeout(400);
|
||||
|
||||
const dictationField = window.getByTestId('keybinding-field-dictation');
|
||||
const bindingChips = dictationField.getByTestId('keybinding-binding');
|
||||
await expect(bindingChips.first()).toBeVisible({ timeout: 5000 });
|
||||
const bindingsBefore = await bindingChips.count();
|
||||
|
||||
// 2. Open the picker and switch to the list tab
|
||||
await dictationField.getByTestId('keybinding-add-dictation').click();
|
||||
const picker = window.getByTestId('keybinding-picker');
|
||||
await expect(picker).toBeVisible({ timeout: 5000 });
|
||||
await picker
|
||||
.getByTestId('keybinding-picker-tabs')
|
||||
.getByText(/목록에서 선택|Choose from List/i)
|
||||
.click();
|
||||
await window.waitForTimeout(300);
|
||||
|
||||
// 3. The dropdown carries its own search field and narrows the key catalog as you type.
|
||||
// Its listbox is portalled to <body>, so options are queried from the page root.
|
||||
const searchInput = picker.getByTestId('keybinding-search').locator('input');
|
||||
await expect(searchInput).toBeVisible();
|
||||
|
||||
const keyOptions = window.getByTestId('keybinding-key-option');
|
||||
expect(await keyOptions.count()).toBeGreaterThan(1);
|
||||
|
||||
await searchInput.fill('f8');
|
||||
await window.waitForTimeout(400);
|
||||
await expect(keyOptions).toHaveCount(1);
|
||||
await keyOptions.first().click();
|
||||
await window.waitForTimeout(300);
|
||||
|
||||
// Picked key is reflected back into the picker's selection preview
|
||||
await expect(picker.getByText('F8', { exact: true }).first()).toBeVisible();
|
||||
|
||||
// 4. Saving adds a SECOND binding to the same action (multi-binding)
|
||||
const confirmBtn = picker.getByTestId('keybinding-confirm');
|
||||
await expect(confirmBtn).toBeEnabled({ timeout: 5000 });
|
||||
await confirmBtn.click();
|
||||
await expect(picker).toBeHidden();
|
||||
await expect(bindingChips).toHaveCount(bindingsBefore + 1);
|
||||
|
||||
await window.screenshot({
|
||||
path: path.join(SCREENSHOT_DIR, 'rt11b_keybinding_multi_binding.png'),
|
||||
});
|
||||
|
||||
// 5. Remove it again so the stored config is left exactly as we found it
|
||||
await bindingChips.last().getByTestId('keybinding-remove').click();
|
||||
await expect(bindingChips).toHaveCount(bindingsBefore);
|
||||
|
||||
// Close SettingsModal
|
||||
const closeSettingsBtn = window.locator('div[role="dialog"] button:has(svg.lucide-x)').first();
|
||||
if (await closeSettingsBtn.isVisible()) {
|
||||
await closeSettingsBtn.click();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue