The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 13:30 UTC
fix(desktop): preserve recordings saved in the same millisecond (#34314)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Romil committed
Nov 15, 2026 at 07:37 UTC
34db335ed56417943db7e1b19ac3e15f6633ac2f
2 files changed
+29
-2
apps/desktop/src/preview/Manager.test.ts
+26
@@ -617,6 +617,32 @@ describe("PreviewManager", () => {
617
webviewSend.mockClear();
618
});
619
620
+ effectIt.effect("preserves recording artifacts saved in the same millisecond", () =>
621
+ withManager((manager) =>
622
+ Effect.gen(function* () {
623
+ const stored = new Map<string, Uint8Array>();
624
+ const save = (path: string, bytes: Uint8Array) => {
625
+ stored.set(path, Uint8Array.from(bytes));
626
+ return undefined;
627
+ };
628
+ writeFile.mockImplementationOnce(save).mockImplementationOnce(save);
629
+ const firstBytes = new Uint8Array([1, 2, 3]);
630
+ const secondBytes = new Uint8Array([4, 5, 6]);
631
+ const [first, second] = yield* Effect.all(
632
+ [
633
+ manager.saveRecording("tab_first", "video/webm", firstBytes),
634
+ manager.saveRecording("tab_second", "video/webm", secondBytes),
635
+ ],
636
+ { concurrency: "unbounded" },
637
+ );
638
+
639
+ expect(first.path).not.toBe(second.path);
640
+ expect(stored.get(first.path)).toEqual(firstBytes);
641
+ expect(stored.get(second.path)).toEqual(secondBytes);
642
+ }),
643
+ ),
644
+ );
645
+
646
effectIt.effect.each([false, true])(
647
"preserves simultaneous same-name downloads with an existing destination: %s",
648
(existing) =>
apps/desktop/src/preview/Manager.ts
+3
-2
@@ -3503,7 +3503,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
3503
data: Uint8Array,
3504
) {
3505
const [createdAt, millis] = yield* Effect.all([currentIso, currentMillis]);
3506
- const id = `browser-recording-${millis.toString(36)}`;
3506
+ const uuid = yield* random.uuidV4();
3507
+ const id = `browser-recording-${millis.toString(36)}-${uuid.slice(0, 8)}`;
3508
const extension = recordingFileExtension(mimeType);
3509
const artifactPath = path.join(resolvedArtifactDirectory, `${id}.${extension}`);
3510
yield* fileSystem.makeDirectory(resolvedArtifactDirectory, { recursive: true }).pipe(
@@ -3517,7 +3518,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
3518
}),
3519
),
3520
);
3520
- yield* fileSystem.writeFile(artifactPath, data).pipe(
3521
+ yield* fileSystem.writeFile(artifactPath, data, { flag: "wx" }).pipe(
3522
Effect.mapError(
3523
(cause) =>
3524
new PreviewOperationError({