Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(projects): keep unresolved projects loadable

Arham Wania1cd8fc1806c
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index b84b23398..c60cd6d96 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -3547,7 +3547,16 @@ export function registerIpcHandlers(
const content = await fs.readFile(filePath, "utf-8");
const project = await relinkProjectMedia(JSON.parse(content), RECORDINGS_DIR);
currentProjectPath = filePath;
- setCurrentRecordingSessionState(await getApprovedProjectSession(project, filePath));
+ let session: RecordingSession | null = null;
+ try {
+ session = await getApprovedProjectSession(project, filePath);
+ } catch (sessionError) {
+ console.warn(
+ "[loadProjectFile] Could not approve session paths, proceeding without session:",
+ sessionError,
+ );
+ }
+ setCurrentRecordingSessionState(session);
return {
success: true,
@@ -3620,7 +3629,16 @@ export function registerIpcHandlers(
const content = await fs.readFile(currentProjectPath, "utf-8");
const project = await relinkProjectMedia(JSON.parse(content), RECORDINGS_DIR);
- setCurrentRecordingSessionState(await getApprovedProjectSession(project, currentProjectPath));
+ let session: RecordingSession | null = null;
+ try {
+ session = await getApprovedProjectSession(project, currentProjectPath);
+ } catch (sessionError) {
+ console.warn(
+ "[loadCurrentProjectFile] Could not approve session paths, proceeding without session:",
+ sessionError,
+ );
+ }
+ setCurrentRecordingSessionState(session);
return {
success: true,
path: currentProjectPath,
diff --git a/electron/media/mediaLinksRegistry.test.ts b/electron/media/mediaLinksRegistry.test.ts
index 24e21a90c..8d224094b 100644
--- a/electron/media/mediaLinksRegistry.test.ts
+++ b/electron/media/mediaLinksRegistry.test.ts
@@ -124,6 +124,19 @@ describe("mediaLinksRegistry", () => {
).resolves.toBeNull();
});
+ it("rejects a registry candidate whose contents changed after registration", async () => {
+ const screenPath = path.join(tempDir, "recording-changed.mp4");
+ await writeFileOfSize(screenPath, 5_000, "a");
+ await registerMediaLinks(tempDir, screenPath, {
+ webcamVideoPath: `${screenPath}.webcam`,
+ });
+ await writeFileOfSize(screenPath, 5_001, "b");
+
+ await expect(
+ findRelocatedMediaByStoredPath(tempDir, "C:\\Users\\demo\\recording-changed.mp4", 5_000),
+ ).resolves.toBeNull();
+ });
+
it("re-links a copy of the screen video at a brand new path with no sidecars", async () => {
const originalDir = await makeTempDir();
try {
diff --git a/electron/media/mediaLinksRegistry.ts b/electron/media/mediaLinksRegistry.ts
index a2c120644..3e2722cd8 100644
--- a/electron/media/mediaLinksRegistry.ts
+++ b/electron/media/mediaLinksRegistry.ts
@@ -247,7 +247,7 @@ export async function findRelocatedMediaByStoredPath(
stalePath: string,
sizeBytes?: number,
): Promise<RelocatedMediaLookup | null> {
- const basename = portableBasename(stalePath).toLocaleLowerCase();
+ const basename = portableBasename(stalePath).toLowerCase();
if (!basename) return null;
const expectedSize =
@@ -258,7 +258,7 @@ export async function findRelocatedMediaByStoredPath(
const matches: MediaLinkEntry[] = [];
for (const entry of registry.entries) {
- if (portableBasename(entry.lastKnownPath).toLocaleLowerCase() !== basename) continue;
+ if (portableBasename(entry.lastKnownPath).toLowerCase() !== basename) continue;
if (expectedSize !== undefined && entry.fingerprint.sizeBytes !== expectedSize) continue;
try {
const current = await fs.stat(entry.lastKnownPath);
diff --git a/electron/media/projectMediaRelinker.test.ts b/electron/media/projectMediaRelinker.test.ts
index 8ce4f5cdd..d3ee47285 100644
--- a/electron/media/projectMediaRelinker.test.ts
+++ b/electron/media/projectMediaRelinker.test.ts
@@ -50,4 +50,29 @@ describe("relinkProjectMedia", () => {
"C:\\Users\\demo\\recording-42-webcam.mp4",
);
});
+
+ it("preserves unresolved screen and webcam paths without mutating the project", async () => {
+ const project = {
+ assets: [
+ {
+ id: "asset-missing",
+ originalPath: "C:\\Users\\demo\\missing.mp4",
+ sizeBytes: 42,
+ cameraTrack: {
+ sourcePath: "C:\\Users\\demo\\missing-webcam.mp4",
+ visible: true,
+ },
+ },
+ ],
+ };
+ const before = structuredClone(project);
+
+ const relinked = (await relinkProjectMedia(project, tempDir)) as typeof project;
+
+ expect(relinked).toEqual(project);
+ expect(relinked).not.toBe(project);
+ expect(relinked.assets[0].originalPath).toBe("C:\\Users\\demo\\missing.mp4");
+ expect(relinked.assets[0].cameraTrack.sourcePath).toBe("C:\\Users\\demo\\missing-webcam.mp4");
+ expect(project).toEqual(before);
+ });
});