fix: clean up ipc edge cases

This commit is contained in:
webadderall
2026-04-17 21:25:13 +10:00
parent 0b3169ffff
commit 528a31b16f
6 changed files with 37 additions and 7 deletions
+2
View File
@@ -97,6 +97,8 @@ export async function startInteractionCapture() {
return;
}
stopInteractionCapture();
try {
const hook = loadUiohookModule();
console.log(
+11 -2
View File
@@ -298,8 +298,17 @@ export async function listProjectLibraryEntries() {
export async function loadProjectFromPath(projectPath: string) {
const normalizedPath = normalizePath(projectPath);
const content = await fs.readFile(normalizedPath, "utf-8");
const project = JSON.parse(content);
let project: unknown;
try {
const content = await fs.readFile(normalizedPath, "utf-8");
project = JSON.parse(content);
} catch (error) {
return {
success: false,
canceled: false,
message: `Failed to read project file: ${error instanceof Error ? error.message : String(error)}`,
};
}
const mediaSources = await resolveProjectMediaSources(project);
if (!mediaSources.success) {
+5 -2
View File
@@ -70,11 +70,14 @@ export async function resolveRecordingSessionManifest(
}
const webcamPath = path.join(path.dirname(normalizedVideoPath), webcamFileName);
await fs.access(webcamPath, fsConstants.F_OK);
const webcamExists = await fs
.access(webcamPath, fsConstants.F_OK)
.then(() => true)
.catch(() => false);
return {
videoPath: normalizedVideoPath,
webcamPath,
webcamPath: webcamExists ? webcamPath : null,
timeOffsetMs: normalizeRecordingTimeOffsetMs(parsed.timeOffsetMs),
};
} catch {
+6 -2
View File
@@ -355,7 +355,8 @@ export function registerProjectHandlers() {
return { success: false, error: 'Only auto-generated recordings can be deleted' };
}
const resolvedPath = await fs.realpath(filePath).catch(() => path.resolve(filePath));
const recordingsDir = await getRecordingsDir();
const recordingsDirRaw = await getRecordingsDir();
const recordingsDir = await fs.realpath(recordingsDirRaw).catch(() => path.resolve(recordingsDirRaw));
if (!isPathInsideDirectory(resolvedPath, recordingsDir) || !isAutoRecordingPath(resolvedPath)) {
return { success: false, error: 'Only auto-generated recordings can be deleted' };
}
@@ -363,7 +364,10 @@ export function registerProjectHandlers() {
// Also delete the cursor telemetry sidecar if it exists
const telemetryPath = getTelemetryPathForVideo(resolvedPath);
await fs.unlink(telemetryPath).catch(() => {});
if (currentVideoPath === resolvedPath) {
const currentResolved = currentVideoPath
? await fs.realpath(currentVideoPath).catch(() => currentVideoPath)
: null;
if (currentResolved === resolvedPath) {
setCurrentVideoPath(null);
setCurrentRecordingSession(null);
}
+5
View File
@@ -994,6 +994,11 @@ export function registerRecordingHandlers(
return await finalizeStoredVideo(finalVideoPath)
} catch (error) {
console.error('Failed to stop FFmpeg recording:', error)
try {
ffmpegCaptureProcess?.kill()
} catch {
// ignore cleanup failures
}
setFfmpegCaptureProcess(null)
setFfmpegCaptureTargetPath(null)
setFfmpegScreenRecordingActive(false)
+8 -1
View File
@@ -432,7 +432,14 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh}
<div class="border-wrap"></div>
</body></html>`
await highlightWin.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`)
try {
await highlightWin.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`)
} catch (loadError) {
if (!highlightWin.isDestroyed()) {
highlightWin.close()
}
throw loadError
}
setTimeout(() => {
if (!highlightWin.isDestroyed()) highlightWin.close()