From e539eb5caaa58fdd588020c2473d134a93601ba2 Mon Sep 17 00:00:00 2001 From: dillonstreator Date: Sat, 28 Nov 2026 13:18:07 -0600 Subject: [PATCH 1/6] Show recorder problems on Home and People, and keep a refused edit's warning on screen. - A recording keeps going when its session is left; the lost-mic, computer-audio and recorder errors now show in Home and People's toast stack too. - An edit main refused used to raise one 6-second polite toast per session, then nothing. The session now keeps a role="alert" line until it's dismissed or an edit lands. --- apps/lyra/src/renderer/src/App.tsx | 33 +++++++++++++++----- apps/lyra/src/renderer/src/hooks/usePages.ts | 25 ++++++++++----- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/apps/lyra/src/renderer/src/App.tsx b/apps/lyra/src/renderer/src/App.tsx index 3a52074..ee046ea 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/hooks/usePages.ts b/apps/lyra/src/renderer/src/hooks/usePages.ts index b44f912..a854ef6 100644 --- a/apps/lyra/src/renderer/src/hooks/usePages.ts +++ b/apps/lyra/src/renderer/src/hooks/usePages.ts @@ -9,7 +9,6 @@ import { import type { Span, TranscriptEdit } from '../../../shared/transcriptOverlay' import { log } from '../lib/log' import { SessionReplica } from '../lib/sessionReplica' -import { notify } from '../lib/toast' import { latest } from './latest' /** What the editor shows of the open session. */ @@ -34,7 +33,7 @@ type Open = { replica: SessionReplica /** Draws the session's current state. */ render: () => void - /** An edit main refused: it's gone from the view; the user is told once. */ + /** An edit main refused: it's gone from the view, and the session shows it until dismissed. */ failed: (error: unknown) => void dispose: () => void } @@ -54,6 +53,11 @@ export function usePages() { const [opens] = useState(latest) /** The session the newest `attach` is opening. */ const wanted = useRef(null) + /** + * The session an edit was refused for, until one lands or the person dismisses it: a lasting + * `role="alert"`, never only a toast (docs/STATES.md). + */ + const [refusedIn, setRefusedIn] = useState(null) const show = (page: OpenPage | null): void => { currentRef.current = page @@ -140,7 +144,6 @@ export function usePages() { return sent } const replica = new SessionReplica(id, state, send) - let warnedUnsaved = false const opened: Open = { replica, render: () => { @@ -160,9 +163,7 @@ export function usePages() { failed: (error) => { log('pages', 'could not save change', String(error)) opened.render() - if (warnedUnsaved) return - warnedUnsaved = true - notify('Lyra couldn’t save your latest changes to this session. Copy anything important, then reopen it.') + if (session.current === opened) setRefusedIn(id) }, dispose: stop } @@ -178,9 +179,16 @@ export function usePages() { const apply = useCallback((ops: SessionOp[], undoable: 'step' | 'typing' | 'none') => { const open = session.current if (!open) return - open.replica.edit(ops, undoable).catch(open.failed) + open.replica.edit(ops, undoable).then( + () => { + // Edits are taken again: the warning about the refused one has done its job. + setRefusedIn((refused) => (refused === open.replica.id ? null : refused)) + }, + open.failed + ) open.render() }, []) + const dismissSaveFailed = useCallback(() => setRefusedIn(null), []) const edit = useCallback( (changes: Edit) => { @@ -351,6 +359,9 @@ export function usePages() { pages, current, currentRef, + /** An edit to the open session was refused, and nothing has landed since. */ + saveFailed: refusedIn !== null && refusedIn === current?.id, + dismissSaveFailed, edit, editSummary, editSegment, From 630b84bc1c0db1bad6695bcbb25062c3fae5cc94 Mon Sep 17 00:00:00 2001 From: dillonstreator Date: Sat, 28 Nov 2026 13:18:30 -0600 Subject: [PATCH 2/6] Drop Electron's "Error invoking remote method" wrapper from recording, voice and speaker errors. - Starting or finishing a recording, saving a voice and naming a speaker showed main's error with the IPC wrapper; they now go through ipcErrorMessage, as About and Settings do, with a plain fallback. --- apps/lyra/src/renderer/src/components/People.tsx | 3 ++- apps/lyra/src/renderer/src/components/Transcript.tsx | 3 ++- apps/lyra/src/renderer/src/hooks/useDictation.ts | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/lyra/src/renderer/src/components/People.tsx b/apps/lyra/src/renderer/src/components/People.tsx index cd3c960..19f8a01 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/Transcript.tsx b/apps/lyra/src/renderer/src/components/Transcript.tsx index 91fe80d..88d7e77 100644 --- a/apps/lyra/src/renderer/src/components/Transcript.tsx +++ b/apps/lyra/src/renderer/src/components/Transcript.tsx @@ -23,6 +23,7 @@ import { useAnchoredPosition } from '../hooks/useAnchoredPosition' import { useDialogFocus } from '../hooks/useDialogFocus' import { rovingIndex } from '../lib/focus' import { clockLabel as clock } from '../lib/format' +import { ipcErrorMessage } from '../lib/ipcError' import { log } from '../lib/log' import { unusedSpeakerName } from '../lib/status' import { notify } from '../lib/toast' @@ -326,7 +327,7 @@ function SpeakerPicker({ onClose() } catch (caught) { log('transcript', 'could not name speaker', String(caught)) - setError(caught instanceof Error ? caught.message : 'Could not name this speaker') + setError(ipcErrorMessage(caught, 'Couldn’t name this speaker.')) } } diff --git a/apps/lyra/src/renderer/src/hooks/useDictation.ts b/apps/lyra/src/renderer/src/hooks/useDictation.ts index 8484eff..a2ae0c4 100644 --- a/apps/lyra/src/renderer/src/hooks/useDictation.ts +++ b/apps/lyra/src/renderer/src/hooks/useDictation.ts @@ -16,6 +16,7 @@ import { import { SessionRecorder } from '../audio/sessionRecorder' import { rms } from '../../../shared/audio/vad' import type { TranscriptProgress } from '../../../shared/types' +import { ipcErrorMessage } from '../lib/ipcError' import { log } from '../lib/log' export type DictationPhase = 'idle' | 'starting' | 'listening' | 'finishing' @@ -354,7 +355,8 @@ export function useDictation({ getDeviceId }: Options) { if (cancelled()) return 'cancelled' log('dictation', 'failed to start', errorText(caught)) if (owner.current === attempt) { - setError(caught instanceof Error ? caught.message : 'Recording failed') + // Main's errors come wrapped ("Error invoking remote method …"); the wrapper goes to the log. + setError(ipcErrorMessage(caught, 'Couldn’t start recording.')) setSystemAudio('off') setPageId(null) setPhase('idle') @@ -391,7 +393,7 @@ export function useDictation({ getDeviceId }: Options) { await current.stop() } catch (caught) { log('dictation', 'stop failed', errorText(caught)) - setError(`The recording stopped, but finishing its transcript failed: ${errorText(caught)}`) + setError(`The recording stopped, but finishing its transcript failed: ${ipcErrorMessage(caught, 'something went wrong.')}`) } finally { // A newer session (started once this one settled) owns the state from here. if (owner.current === current.owner) { From eed4e5176b5a19ab04a7926e5c4e04058bcb03de Mon Sep 17 00:00:00 2001 From: dillonstreator Date: Sat, 28 Nov 2026 13:18:30 -0600 Subject: [PATCH 3/6] Announce a recording that never started as cancelled, not stopped. --- apps/lyra/src/renderer/src/lib/status.test.ts | 7 ++++++- apps/lyra/src/renderer/src/lib/status.ts | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/lyra/src/renderer/src/lib/status.test.ts b/apps/lyra/src/renderer/src/lib/status.test.ts index dc52244..94fd210 100644 --- a/apps/lyra/src/renderer/src/lib/status.test.ts +++ b/apps/lyra/src/renderer/src/lib/status.test.ts @@ -108,7 +108,12 @@ describe('phaseAnnouncement', () => { 'Recording stopped. Finishing the transcript' ) expect(phaseAnnouncement('finishing', 'idle')).toBe('Transcript finished') - expect(phaseAnnouncement('starting', 'idle')).toBe('Recording stopped') + expect(phaseAnnouncement('listening', 'idle')).toBe('Recording stopped') + }) + + it('never says a recording that never started has stopped', () => { + // Mic access denied, or Stop pressed while the model warmed up: the alert says why. + expect(phaseAnnouncement('starting', 'idle')).toBe('Recording cancelled') }) }) diff --git a/apps/lyra/src/renderer/src/lib/status.ts b/apps/lyra/src/renderer/src/lib/status.ts index a351a01..4e27ecb 100644 --- a/apps/lyra/src/renderer/src/lib/status.ts +++ b/apps/lyra/src/renderer/src/lib/status.ts @@ -176,6 +176,8 @@ export function phaseAnnouncement(previous: Phase, phase: Phase): string | null case 'finishing': return 'Recording stopped. Finishing the transcript' case 'idle': - return previous === 'finishing' ? 'Transcript finished' : 'Recording stopped' + if (previous === 'finishing') return 'Transcript finished' + // It never got going (mic access denied, or stopped while warming up): nothing to stop. + return previous === 'starting' ? 'Recording cancelled' : 'Recording stopped' } } From 4f6a999934c973180d50d08c0d097f92e1b696db Mon Sep 17 00:00:00 2001 From: dillonstreator Date: Sat, 28 Nov 2026 13:18:30 -0600 Subject: [PATCH 4/6] Name the shortcut button by its setting and shortcut, and let Tab leave it while it listens. - Its accessible name was "Change shortcut", hiding the value it shows; it is now "Session shortcut: . Change", and "press a shortcut, or Esc to cancel" while listening. - Tab used to be swallowed while listening, trapping the keyboard until Esc. --- .../src/renderer/src/components/HotkeyInput.tsx | 12 ++++++++++-- .../src/renderer/src/components/Settings.tsx | 6 +++++- apps/lyra/src/renderer/src/lib/keys.test.ts | 17 ++++++++++++++++- apps/lyra/src/renderer/src/lib/keys.ts | 8 ++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/apps/lyra/src/renderer/src/components/HotkeyInput.tsx b/apps/lyra/src/renderer/src/components/HotkeyInput.tsx index 669ca15..436c79f 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/Settings.tsx b/apps/lyra/src/renderer/src/components/Settings.tsx index 01233c8..9372806 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 ? (