Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions electron/ipc/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2651,25 +2651,32 @@ async function finalizeStoredVideo(videoPath: string) {
}

async function recoverNativeMacCaptureOutput() {
const diagnosticsPath =
const macDiagnostics =
lastNativeCaptureDiagnostics?.backend === 'mac-screencapturekit'
? lastNativeCaptureDiagnostics.outputPath ?? null
? lastNativeCaptureDiagnostics
: null
const diagnosticsPath = macDiagnostics?.outputPath ?? null
const candidatePath = nativeCaptureTargetPath ?? diagnosticsPath
const systemAudioPath = nativeCaptureSystemAudioPath ?? macDiagnostics?.systemAudioPath ?? null
const microphonePath = nativeCaptureMicrophonePath ?? macDiagnostics?.microphonePath ?? null

if (!candidatePath) {
return null
}

try {
if (systemAudioPath || microphonePath) {
await muxNativeMacRecordingWithAudio(candidatePath, systemAudioPath, microphonePath)
}

return await finalizeStoredVideo(candidatePath)
Comment on lines +2668 to 2672
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Wrap muxing call in try-catch for consistency with the normal stop path.

The normal stop path (lines 3660-3666) wraps muxNativeMacRecordingWithAudio in a try-catch and continues to finalize even if muxing fails. Here, a muxing error will cause the entire recovery to fail and return null, preventing users from getting even a video-only file.

🐛 Proposed fix to handle muxing errors gracefully
     if (systemAudioPath || microphonePath) {
-      await muxNativeMacRecordingWithAudio(candidatePath, systemAudioPath, microphonePath)
+      try {
+        await muxNativeMacRecordingWithAudio(candidatePath, systemAudioPath, microphonePath)
+      } catch (muxError) {
+        console.warn('Failed to mux recovered native macOS audio into capture:', muxError)
+      }
     }

     return await finalizeStoredVideo(candidatePath)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (systemAudioPath || microphonePath) {
await muxNativeMacRecordingWithAudio(candidatePath, systemAudioPath, microphonePath)
}
return await finalizeStoredVideo(candidatePath)
if (systemAudioPath || microphonePath) {
try {
await muxNativeMacRecordingWithAudio(candidatePath, systemAudioPath, microphonePath)
} catch (muxError) {
console.warn('Failed to mux recovered native macOS audio into capture:', muxError)
}
}
return await finalizeStoredVideo(candidatePath)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@electron/ipc/handlers.ts` around lines 2668 - 2672, Wrap the call to
muxNativeMacRecordingWithAudio(candidatePath, systemAudioPath, microphonePath)
in a try-catch so mux failures do not abort recovery; if an error occurs, log it
(using the same logger used elsewhere) and continue to call
finalizeStoredVideo(candidatePath) so a video-only file is returned; ensure you
reference the same symbols muxNativeMacRecordingWithAudio, candidatePath,
systemAudioPath, microphonePath, and finalizeStoredVideo when making the change.

} catch (error) {
recordNativeCaptureDiagnostics({
backend: 'mac-screencapturekit',
phase: 'stop',
outputPath: candidatePath,
systemAudioPath: nativeCaptureSystemAudioPath,
microphonePath: nativeCaptureMicrophonePath,
systemAudioPath,
microphonePath,
processOutput: nativeCaptureOutputBuffer.trim() || undefined,
fileSizeBytes: await getFileSizeIfPresent(candidatePath),
error: String(error),
Expand Down Expand Up @@ -4899,4 +4906,3 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh}
}
})
}