Compact terminal shortcut notification

Shorten the terminal shortcut toast, keep it to two lines, and auto-dismiss it after 20 seconds.
This commit is contained in:
Neil 2026-05-23 23:37:59 -07:00 committed by GitHub
parent 5a130fe077
commit eab824d735
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 7 deletions

View File

@ -41,16 +41,21 @@ describe('showTerminalShortcutCaptureNotification', () => {
vi.clearAllMocks()
})
it('keeps the shortcut capture warning visible until dismissed', () => {
it('keeps the shortcut capture warning visible long enough to act on', () => {
showTerminalShortcutCaptureNotification({
actionId: 'tab.close',
platform: 'darwin'
})
expect(toast.message).toHaveBeenCalledWith(
'Orca handled a terminal shortcut',
'Terminal shortcut handled',
expect.objectContaining({
duration: Infinity,
className: expect.stringContaining('!py-2'),
classNames: expect.objectContaining({
title: expect.stringContaining('truncate'),
description: expect.stringContaining('truncate')
}),
duration: 20_000,
dismissible: true,
action: expect.objectContaining({ label: 'Open Shortcuts' })
})

View File

@ -11,6 +11,7 @@ import {
import { useAppStore } from '../store'
const STORAGE_PREFIX = 'orca.terminalShortcutCapturedNotice.'
const NOTICE_DURATION_MS = 20_000
function hasShownNotice(actionId: KeybindingActionId): boolean {
try {
@ -60,12 +61,21 @@ export function showTerminalShortcutCaptureNotification({
getEffectiveKeybindingsForAction(actionId, platform, keybindings),
platform
)
toast.message('Orca handled a terminal shortcut', {
description: `${definition.title} (${bindingLabel}) can be changed in Keyboard Shortcuts.`,
// Why: this toast stays up longer than normal, so keep it compact while still
// exposing the captured shortcut and the edit path.
toast.message('Terminal shortcut handled', {
description: `${definition.title} (${bindingLabel})`,
// 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,
// needs enough reading time without becoming persistent chrome.
duration: NOTICE_DURATION_MS,
dismissible: true,
className: '!w-[420px] !max-w-[calc(100vw-2rem)] !gap-2 !py-2 !pl-3 !pr-2',
classNames: {
content: 'min-w-0 flex-1 !gap-0.5',
title: 'truncate !leading-5',
description: 'truncate !leading-4',
actionButton: '!h-7 !shrink-0 !rounded-md !px-2.5'
},
icon: <Keyboard className="size-4 text-muted-foreground" />,
action: {
label: 'Open Shortcuts',