From e72fb8252ccbfb07e3c4c48f7ed8c0cfafc882b7 Mon Sep 17 00:00:00 2001 From: Etienne Lescot Date: Sat, 14 Mar 2026 11:22:45 +0100 Subject: [PATCH] Fix Windows cursor telemetry path resolution --- src/components/video-editor/VideoEditor.tsx | 8 +++++--- .../video-editor/projectPersistence.ts | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx index ac9a9f4..67e81d7 100644 --- a/src/components/video-editor/VideoEditor.tsx +++ b/src/components/video-editor/VideoEditor.tsx @@ -419,7 +419,9 @@ export default function VideoEditor() { let mounted = true; async function loadCursorTelemetry() { - if (!videoPath) { + const sourcePath = videoSourcePath ?? (videoPath ? fromFileUrl(videoPath) : null); + + if (!sourcePath) { if (mounted) { setCursorTelemetry([]); } @@ -427,7 +429,7 @@ export default function VideoEditor() { } try { - const result = await window.electronAPI.getCursorTelemetry(fromFileUrl(videoPath)); + const result = await window.electronAPI.getCursorTelemetry(sourcePath); if (mounted) { setCursorTelemetry(result.success ? result.samples : []); } @@ -444,7 +446,7 @@ export default function VideoEditor() { return () => { mounted = false; }; - }, [videoPath]); + }, [videoPath, videoSourcePath]); function togglePlayPause() { const playback = videoPlaybackRef.current; diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.ts index 9339770..b1aa346 100644 --- a/src/components/video-editor/projectPersistence.ts +++ b/src/components/video-editor/projectPersistence.ts @@ -61,9 +61,9 @@ function clamp(value: number, min: number, max: number) { export function toFileUrl(filePath: string): string { const normalized = filePath.replace(/\\/g, "/"); if (normalized.match(/^[a-zA-Z]:/)) { - return `file:///${normalized}`; + return `file:///${encodeURI(normalized)}`; } - return `file://${normalized}`; + return `file://${encodeURI(normalized)}`; } export function fromFileUrl(fileUrl: string): string { @@ -73,9 +73,20 @@ export function fromFileUrl(fileUrl: string): string { try { const url = new URL(fileUrl); - return decodeURIComponent(url.pathname); + const pathname = decodeURIComponent(url.pathname); + + if (url.host && url.host !== "localhost") { + return `//${url.host}${pathname}`; + } + + if (/^\/[a-zA-Z]:/.test(pathname)) { + return pathname.slice(1); + } + + return pathname; } catch { - return fileUrl.replace(/^file:\/\//, ""); + const fallbackPath = decodeURIComponent(fileUrl.replace(/^file:\/\//, "")); + return fallbackPath.replace(/^\/([a-zA-Z]:)/, "$1"); } }