diff --git a/.changeset/error-states-keyboard.md b/.changeset/error-states-keyboard.md new file mode 100644 index 00000000..f6497ce3 --- /dev/null +++ b/.changeset/error-states-keyboard.md @@ -0,0 +1,5 @@ +--- +'lyra': patch +--- + +Problems with a recording (the microphone lost, computer audio not being recorded) now show on Home and People too, not only in the session you left. When a change can't be saved, the session keeps a warning on screen until it's dismissed or the next change is saved, instead of a six-second notice shown once. Errors when starting or finishing a recording, saving a voice or naming a speaker no longer start with "Error invoking remote method". Section headings in the transcript can be focused and opened with Shift+F10 or the menu key, references in your notes can be followed with Ctrl+Enter (⌘↩ on macOS), the shortcut setting tells screen readers what it sets and its current shortcut and lets Tab move on while it listens, and a recording that never started is announced as cancelled rather than stopped. diff --git a/apps/lyra/src/renderer/src/App.tsx b/apps/lyra/src/renderer/src/App.tsx index 3a520742..ee046eac 100644 --- a/apps/lyra/src/renderer/src/App.tsx +++ b/apps/lyra/src/renderer/src/App.tsx @@ -197,7 +197,9 @@ export default function App(): React.JSX.Element { create, remove, restore, - flush + flush, + saveFailed, + dismissSaveFailed } = usePages() const [status, setStatus] = useState({ state: 'idle' }) const [copied, setCopied] = useState(false) @@ -515,6 +517,21 @@ export default function App(): React.JSX.Element { const activity = dockActivity(status, dictation.progress ? behindLabel(dictation.progress) : null) const activityElement = activity ? : null + // A recording keeps going when the session is left, so its problems (the mic lost, computer + // audio not recorded, the disk full) show on Home and People too, not only in the session. + const recorderMessages = ( + <> + + {dictation.systemAudioMessageShown ? ( + + ) : null} + + ) + // Hovering or focusing the toast holds it; F6 reaches its button from anywhere (see onKey). const toastElement = toast ? ( ) : null} - - {dictation.systemAudioMessageShown ? ( - ) : null} + {recorderMessages} {toastElement} @@ -1272,6 +1290,7 @@ export default function App(): React.JSX.Element { )} {activityElement} + {recorderMessages} {toastElement} diff --git a/apps/lyra/src/renderer/src/components/HotkeyInput.tsx b/apps/lyra/src/renderer/src/components/HotkeyInput.tsx index 669ca15b..436c79fd 100644 --- a/apps/lyra/src/renderer/src/components/HotkeyInput.tsx +++ b/apps/lyra/src/renderer/src/components/HotkeyInput.tsx @@ -1,9 +1,12 @@ import { useState, type KeyboardEvent } from 'react' import { isMac } from '../lib/format' +import { shortcutButtonLabel } from '../lib/keys' type Props = { value: string onChange: (accelerator: string) => void + /** What the shortcut does, for its accessible name ("Session shortcut"). */ + label: string } const MODIFIER_KEYS = new Set(['Control', 'Meta', 'Alt', 'Shift', 'AltGraph', 'CapsLock']) @@ -64,11 +67,16 @@ export function displayAccelerator(accelerator: string): string { return parts.join(isMac ? '' : '+') } -export function HotkeyInput({ value, onChange }: Props) { +export function HotkeyInput({ value, onChange, label }: Props) { const [recording, setRecording] = useState(false) const onKeyDown = (event: KeyboardEvent): void => { if (!recording) return + // Tab alone can't be a shortcut: let it move focus on, so the keyboard is never stuck here. + if (event.key === 'Tab' && !event.ctrlKey && !event.metaKey && !event.altKey) { + setRecording(false) + return + } event.preventDefault() event.stopPropagation() if (event.key === 'Escape') { @@ -92,7 +100,7 @@ export function HotkeyInput({ value, onChange }: Props) { setRecording(false) }} onKeyDown={onKeyDown} - aria-label="Change shortcut" + aria-label={shortcutButtonLabel(label, displayAccelerator(value), recording)} > {recording ? 'Press a shortcut…' : displayAccelerator(value)} diff --git a/apps/lyra/src/renderer/src/components/NotesEditor.tsx b/apps/lyra/src/renderer/src/components/NotesEditor.tsx index b23d652f..ac9020b4 100644 --- a/apps/lyra/src/renderer/src/components/NotesEditor.tsx +++ b/apps/lyra/src/renderer/src/components/NotesEditor.tsx @@ -59,6 +59,18 @@ export function NotesEditor({ value, onChange, placeholder, onReference, ref }: if (!href.startsWith(REFERENCE_PREFIX)) return false onReferenceRef.current?.(decodeURIComponent(href.slice(REFERENCE_PREFIX.length))) return true + }, + // Ctrl+Enter (⌘↩ on macOS) with the caret on a reference follows it, as a click does. + // Runs before the editor's own keymap, so elsewhere it still inserts a line break. + handleKeyDown: (view, event) => { + if (event.key !== 'Enter' || !(event.metaKey || event.ctrlKey)) return false + const { $from } = view.state.selection + const marks = [...$from.marks(), ...($from.nodeAfter?.marks ?? []), ...($from.nodeBefore?.marks ?? [])] + const href: unknown = marks.find((mark) => mark.type.name === 'link')?.attrs.href + if (typeof href !== 'string' || !href.startsWith(REFERENCE_PREFIX)) return false + event.preventDefault() + onReferenceRef.current?.(decodeURIComponent(href.slice(REFERENCE_PREFIX.length))) + return true } }, onUpdate: ({ editor: current }) => { diff --git a/apps/lyra/src/renderer/src/components/People.tsx b/apps/lyra/src/renderer/src/components/People.tsx index cd3c9604..19f8a015 100644 --- a/apps/lyra/src/renderer/src/components/People.tsx +++ b/apps/lyra/src/renderer/src/components/People.tsx @@ -3,6 +3,7 @@ import type { Person } from '../../../shared/types' import { openMicrophone, startCapture, type CaptureHandle } from '../audio/capture' import { SAMPLE_RATE } from '../../../shared/audio/vad' import { perform } from '../lib/history' +import { ipcErrorMessage } from '../lib/ipcError' import { log } from '../lib/log' import { notify } from '../lib/toast' import { ConfirmDialog } from './ConfirmDialog' @@ -186,7 +187,7 @@ function Enroll({ micDeviceId, onDone }: EnrollProps) { if (attempt.current === run) attempt.current = null if (stopped()) return log('people', 'enroll failed', errorText(caught)) - setError(caught instanceof Error ? caught.message : 'Could not save the voice') + setError(ipcErrorMessage(caught, 'Couldn’t save the voice.')) setAnnouncement('') setPhase('idle') } diff --git a/apps/lyra/src/renderer/src/components/Settings.tsx b/apps/lyra/src/renderer/src/components/Settings.tsx index 01233c87..93728065 100644 --- a/apps/lyra/src/renderer/src/components/Settings.tsx +++ b/apps/lyra/src/renderer/src/components/Settings.tsx @@ -265,7 +265,11 @@ function StartupSection({ settings, update }: SectionProps) { label="Start or stop a session" hint="Works from any app, even when Lyra is hidden." > - void update({ hotkey })} /> + void update({ hotkey })} + /> {settings.hotkey !== DEFAULT_HOTKEY ? (