From b8a7adf8edcfdb9926a6da92ac105dc40296df7e Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 23 May 2026 19:07:07 -0700 Subject: [PATCH] Keep terminal shortcut notice visible Keep the terminal shortcut capture warning on screen until the user dismisses it or opens shortcut settings. --- ...nal-shortcut-capture-notification.test.tsx | 59 +++++++++++++++++++ ...terminal-shortcut-capture-notification.tsx | 4 ++ 2 files changed, 63 insertions(+) create mode 100644 src/renderer/src/lib/terminal-shortcut-capture-notification.test.tsx diff --git a/src/renderer/src/lib/terminal-shortcut-capture-notification.test.tsx b/src/renderer/src/lib/terminal-shortcut-capture-notification.test.tsx new file mode 100644 index 000000000..1a49f6634 --- /dev/null +++ b/src/renderer/src/lib/terminal-shortcut-capture-notification.test.tsx @@ -0,0 +1,59 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { toast } from 'sonner' +import { showTerminalShortcutCaptureNotification } from './terminal-shortcut-capture-notification' + +const { toastMessage } = vi.hoisted(() => ({ + toastMessage: vi.fn() +})) + +vi.mock('sonner', () => ({ + toast: { + message: toastMessage + } +})) + +function createLocalStorage(): Storage { + const values = new Map() + + return { + get length() { + return values.size + }, + clear: () => values.clear(), + getItem: (key: string) => values.get(key) ?? null, + key: (index: number) => Array.from(values.keys())[index] ?? null, + removeItem: (key: string) => { + values.delete(key) + }, + setItem: (key: string, value: string) => { + values.set(key, value) + } + } +} + +describe('showTerminalShortcutCaptureNotification', () => { + beforeEach(() => { + vi.stubGlobal('localStorage', createLocalStorage()) + }) + + afterEach(() => { + vi.unstubAllGlobals() + vi.clearAllMocks() + }) + + it('keeps the shortcut capture warning visible until dismissed', () => { + showTerminalShortcutCaptureNotification({ + actionId: 'tab.close', + platform: 'darwin' + }) + + expect(toast.message).toHaveBeenCalledWith( + 'Orca handled a terminal shortcut', + expect.objectContaining({ + duration: Infinity, + dismissible: true, + action: expect.objectContaining({ label: 'Open Shortcuts' }) + }) + ) + }) +}) diff --git a/src/renderer/src/lib/terminal-shortcut-capture-notification.tsx b/src/renderer/src/lib/terminal-shortcut-capture-notification.tsx index 541fb4a33..0e814fcc3 100644 --- a/src/renderer/src/lib/terminal-shortcut-capture-notification.tsx +++ b/src/renderer/src/lib/terminal-shortcut-capture-notification.tsx @@ -62,6 +62,10 @@ export function showTerminalShortcutCaptureNotification({ ) toast.message('Orca handled a terminal shortcut', { description: `${definition.title} (${bindingLabel}) can be changed in Keyboard Shortcuts.`, + // Why: this is the user's one-time rebind path for a captured shortcut; it + // should stay visible until they act on or dismiss it. + duration: Infinity, + dismissible: true, icon: , action: { label: 'Open Shortcuts',