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(cursor): read a cursor file again after a failed read
EtienneLescote8389ab8e217
diff --git a/src/components/ai-edition/CursorPane.levels.test.tsx b/src/components/ai-edition/CursorPane.levels.test.tsxindex 6260ba373..9dc86741e 100644--- a/src/components/ai-edition/CursorPane.levels.test.tsx+++ b/src/components/ai-edition/CursorPane.levels.test.tsx@@ -61,14 +61,21 @@ describe("CursorPane cursor types", () => {legacyEditor: Record<string, unknown>,states: Array<NativeCursorType | null>,) {+ mockRecording(states);// A path per test: the pane reads each recording once per session.- const originalPath = `/recordings/${crypto.randomUUID()}.mp4`;- vi.spyOn(nativeBridgeClient.cursor, "getRecordingData").mockResolvedValue({+ renderProject(legacyEditor, `/recordings/${crypto.randomUUID()}.mp4`);+ }++ function mockRecording(states: Array<NativeCursorType | null>) {+ return vi.spyOn(nativeBridgeClient.cursor, "getRecordingData").mockResolvedValue({version: 2,provider: "native",assets: [],samples: states.map((cursorType, i) => ({ timeMs: i * 100, cx: 0.5, cy: 0.5, cursorType })),});+ }++ function renderProject(legacyEditor: Record<string, unknown>, originalPath: string) {vi.spyOn(nativeBridgeClient.aiEdition, "save").mockImplementation(async (document) => ({success: true,document,@@ -150,6 +157,22 @@ describe("CursorPane cursor types", () => {expect(screen.queryByRole("group", { name: "Cursor types" })).toBeNull();});+ // A cursor file still being written right after a take must not hide the row all session.+ it("reads a recording again after a read that failed", async () => {+ const originalPath = `/recordings/${crypto.randomUUID()}.mp4`;+ const read = mockRecording(["arrow", "pointer"]).mockRejectedValueOnce(new Error("busy"));+ renderProject({}, originalPath);+ await waitFor(() => expect(read).toHaveBeenCalledTimes(1));+ // Let the failed read settle before the pane opens again.+ await new Promise((resolve) => setTimeout(resolve, 0));+ expect(screen.queryByRole("group", { name: "Cursor types" })).toBeNull();++ cleanup();+ renderProject({}, originalPath);+ expect(await screen.findByRole("button", { name: "Hand" })).toBeTruthy();+ expect(read).toHaveBeenCalledTimes(2);+ });+// The 3D switch changes how the chosen style looks, so it sits right under the styles.it("puts the 3D switch right under the cursor styles", () => {renderWithCursor({});diff --git a/src/components/ai-edition/recordedCursorTypes.ts b/src/components/ai-edition/recordedCursorTypes.tsindex 032d82b32..b11ecdbcc 100644--- a/src/components/ai-edition/recordedCursorTypes.ts+++ b/src/components/ai-edition/recordedCursorTypes.ts@@ -41,7 +41,8 @@ export function cursorStatesBetween(return states.add(atStart);}-// A recording's cursor file does not change once written: each is read once per session.+// A recording's cursor file does not change once written: each is read once per session. A+// recording without one reads as empty, and that answer is kept.const changesByPath = new Map<string, Promise<CursorStateChange[]>>();function stateChangesOf(videoPath: string): Promise<CursorStateChange[]> {@@ -50,8 +51,12 @@ function stateChangesOf(videoPath: string): Promise<CursorStateChange[]> {changes = Promise.resolve().then(() => nativeBridgeClient.cursor.getRecordingData(videoPath)).then((data) => cursorStateChanges(data.samples))- // No cursor file, or no bridge: nothing but the arrow.- .catch(() => []);+ // A read that failed (no bridge yet, a file still being written) shows nothing but the+ // arrow for now, and is tried again the next time rather than never.+ .catch(() => {+ changesByPath.delete(videoPath);+ return [];+ });changesByPath.set(videoPath, changes);}return changes;