Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(macos): suppress stale microphone warnings
Arham Wani8f5c0f4d7f1f
diff --git a/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx b/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsxindex 8770b4973..040eeee6a 100644--- a/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx+++ b/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx@@ -55,6 +55,7 @@ async function settle(ms = 0) {beforeEach(() => {vi.useFakeTimers();stubElectronAPI();+ vi.mocked(toast.error).mockClear();});afterEach(() => {@@ -87,4 +88,33 @@ describe("useScreenRecorder native macOS start warnings", () => {expect(view.result.current.recording).toBe(true);expect(toast.error).toHaveBeenCalledWith("recording.microphoneDefaulted");});++ it("does not warn after the recording start is cancelled", async () => {+ let resolveStart:+ | ((result: Awaited<ReturnType<ElectronAPI["startNativeMacRecording"]>>) => void)+ | null = null;+ api.startNativeMacRecording.mockImplementation(+ () =>+ new Promise((resolve) => {+ resolveStart = resolve;+ }),+ );+ const view = renderHook(() => useScreenRecorder());+ await settle();++ await act(async () => {+ view.result.current.toggleRecording();+ });+ await settle(3_500);+ expect(api.startNativeMacRecording).toHaveBeenCalledOnce();++ view.unmount();+ await act(async () => {+ resolveStart?.({ success: true, recordingId: 8, microphoneDefaulted: true });+ await Promise.resolve();+ });++ expect(api.stopNativeMacRecording).toHaveBeenCalledWith(true);+ expect(toast.error).not.toHaveBeenCalled();+ });});diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.tsindex 1e741a5e5..8960548b2 100644--- a/src/hooks/useScreenRecorder.ts+++ b/src/hooks/useScreenRecorder.ts@@ -1365,13 +1365,13 @@ export function useScreenRecorder(): UseScreenRecorderReturn {if (!result.success || !result.recordingId) {throw new Error(result.error ?? "Native macOS capture failed.");}- if (result.microphoneDefaulted) {- toast.error(t("recording.microphoneDefaulted"));- }if (!isCountdownRunActive(countdownRunToken)) {await window.electronAPI.stopNativeMacRecording(true);return true;}+ if (result.microphoneDefaulted) {+ toast.error(t("recording.microphoneDefaulted"));+ }// The IPC call above only resolves once the helper's stdout confirms its// screen capture has truly started (see waitForNativeMacCaptureStart in