YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
Preserve absolute media file paths (#3845)
Isaac Sanchez-Hawkins60d896613c64
diff --git a/apps/screenpipe-app-tauri/lib/utils/media-file-path.test.ts b/apps/screenpipe-app-tauri/lib/utils/media-file-path.test.tsindex 16fc5c8f9..fbfb1959a 100644--- a/apps/screenpipe-app-tauri/lib/utils/media-file-path.test.ts+++ b/apps/screenpipe-app-tauri/lib/utils/media-file-path.test.ts@@ -26,6 +26,39 @@ describe("normalizeMediaFilePath", () => {"C:/Users/Hugo Azevedo/.screenpipe/data/audio.wav",);});++ it("preserves the leading slash when decoding Unix file URLs", () => {+ const path = "file:///Users/ansh/.screenpipe/data/audio%20clip.wav";++ expect(normalizeMediaFilePath(path)).toBe(+ "/Users/ansh/.screenpipe/data/audio clip.wav",+ );+ });++ it("normalizes Unix file URLs with non-standard slash counts", () => {+ expect(+ normalizeMediaFilePath("file:/Users/ansh/.screenpipe/data/audio%20clip.wav"),+ ).toBe("/Users/ansh/.screenpipe/data/audio clip.wav");+ expect(+ normalizeMediaFilePath("file:////Users/ansh/.screenpipe/data/audio%20clip.wav"),+ ).toBe("/Users/ansh/.screenpipe/data/audio clip.wav");+ });++ it("preserves the full absolute Unix path", () => {+ const path = "/Users/ansh/.screenpipe/data/audio clip.wav";++ expect(normalizeMediaFilePath(path)).toBe(+ "/Users/ansh/.screenpipe/data/audio clip.wav",+ );+ });++ it("trims outer whitespace before stripping surrounding quotes", () => {+ const path = ' "file:///Users/ansh/.screenpipe/data/audio%20clip.wav" ';++ expect(normalizeMediaFilePath(path)).toBe(+ "/Users/ansh/.screenpipe/data/audio clip.wav",+ );+ });});describe("isAudioMediaPath", () => {diff --git a/apps/screenpipe-app-tauri/lib/utils/media-file-path.ts b/apps/screenpipe-app-tauri/lib/utils/media-file-path.tsindex 230581449..a7ec6e324 100644--- a/apps/screenpipe-app-tauri/lib/utils/media-file-path.ts+++ b/apps/screenpipe-app-tauri/lib/utils/media-file-path.ts@@ -6,7 +6,7 @@ const MEDIA_EXTENSIONS = ["mp4", "mp3", "wav", "webm", "ogg", "m4a"] as const;const MEDIA_EXTENSION_PATTERN = MEDIA_EXTENSIONS.join("|");export function normalizeMediaFilePath(path: string): string {- let cleaned = path.replace(/^["'`]|["'`]$/g, "").trim();+ let cleaned = path.trim().replace(/^["'`]|["'`]$/g, "").trim();try {cleaned = decodeURIComponent(cleaned);@@ -14,7 +14,11 @@ export function normalizeMediaFilePath(path: string): string {// Keep the original string if it contains malformed percent escapes.}- cleaned = cleaned.replace(/^file:\/+/i, "");+ if (/^file:\/\/\/[A-Z]:[\\/]/i.test(cleaned)) {+ cleaned = cleaned.replace(/^file:\/\/\//i, "");+ } else {+ cleaned = cleaned.replace(/^file:\/+/i, "/");+ }// Windows file URLs often become /C:/Users/... after stripping file://.cleaned = cleaned.replace(/^\/([A-Z]:[\\/])/i, "$1");@@ -25,7 +29,7 @@ export function normalizeMediaFilePath(path: string): string {if (windowsMatch) return windowsMatch[0].trim();const unixMatch = cleaned.match(- new RegExp(`/(?:[^\\n\\r\`"<>]+?/)??[^\\n\\r\`"<>]+?\\.(${MEDIA_EXTENSION_PATTERN})`, "i"),+ new RegExp(`/[^\\n\\r\`"<>]+?\\.(${MEDIA_EXTENSION_PATTERN})`, "i"),);if (unixMatch) return unixMatch[0].trim();