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
Fix low-storage recovery checks for the active recording volume (#7460)
Ezra Ellette8e51453598d2
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.test.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.test.tsxindex d44279f6d..c33e3b763 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.test.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.test.tsx@@ -7,7 +7,7 @@ import { useRecordingStorage } from "./use-recording-storage";const mocks = vi.hoisted(() => ({settings: { dataDir: "default", stopRecordingOnLowDisk: true },- getDataDir: vi.fn(async () => "/example/data"),+ getActiveDataDir: vi.fn(async () => ({ status: "ok", data: "/example/data" })),getDiskUsage: vi.fn(),getLowDiskGuardConfig: vi.fn(async () => ({ thresholdBytes: 5 * 1024 ** 3 })),}));@@ -19,6 +19,7 @@ beforeEach(() => {vi.clearAllMocks();mocks.settings.dataDir = "default";mocks.settings.stopRecordingOnLowDisk = true;+ mocks.getActiveDataDir.mockResolvedValue({ status: "ok", data: "/example/data" });mocks.getDiskUsage.mockResolvedValue(usage(3));mocks.getLowDiskGuardConfig.mockResolvedValue({ thresholdBytes: 5 * 1024 ** 3 });});@@ -40,6 +41,15 @@ describe("paused recording storage", () => {await waitFor(() => expect(result.current.checking).toBe(false));expect(result.current.warning).toBeNull();expect(mocks.getDiskUsage).toHaveBeenCalledTimes(2);+ expect(mocks.getDiskUsage).toHaveBeenCalledWith(true, "/example/data");+ });++ it("uses the running engine directory instead of the persisted default", async () => {+ mocks.settings.dataDir = "default";+ mocks.getActiveDataDir.mockResolvedValueOnce({ status: "ok", data: "V:\\screenpipe-data" });+ renderHook(() => useRecordingStorage(true));+ await waitFor(() => expect(mocks.getDiskUsage).toHaveBeenCalled());+ expect(mocks.getDiskUsage).toHaveBeenCalledWith(true, "V:\\screenpipe-data");});it("does not report failed probes as zero free bytes", async () => {diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.ts b/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.tsindex 3a7d0cb4f..fb10f44cc 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.ts+++ b/apps/screenpipe-app-tauri/lib/hooks/use-recording-storage.ts@@ -1,7 +1,7 @@// screenpipe — AI that knows everything you've seen, said, or heard// https://screenpipe.com-import { useEffect, useRef, useState } from "react";+import { useEffect, useState } from "react";import { useSettings } from "./use-settings";import { commands } from "@/lib/utils/tauri";@@ -13,9 +13,7 @@ export interface RecordingStorageWarning {/** Inspect storage only while capture is paused. Never poll or scan the data* directory on the active recording path. Native capture owns the safety guard. */export function useRecordingStorage(paused: boolean) {- const { settings, getDataDir } = useSettings();- const getDataDirRef = useRef(getDataDir);- getDataDirRef.current = getDataDir;+ const { settings } = useSettings();const enabled = paused && (settings.stopRecordingOnLowDisk ?? true);const [revision, setRevision] = useState(0);const [state, setState] = useState<{@@ -36,7 +34,11 @@ export function useRecordingStorage(paused: boolean) {}));void (async () => {try {- const directory = await getDataDirRef.current();+ const activeDirectory = await commands.getActiveDataDir();+ if (activeDirectory.status === "error") {+ throw new Error(String(activeDirectory.error));+ }+ const directory = activeDirectory.data;const [usage, config] = await Promise.all([commands.getDiskUsage(true, directory),commands.getLowDiskGuardConfig(),diff --git a/docs/pr-assets/active-recording-volume/after.png b/docs/pr-assets/active-recording-volume/after.pngnew file mode 100644index 000000000..765d5c964Binary files /dev/null and b/docs/pr-assets/active-recording-volume/after.png differdiff --git a/docs/pr-assets/active-recording-volume/before.png b/docs/pr-assets/active-recording-volume/before.pngnew file mode 100644index 000000000..ef149fc1eBinary files /dev/null and b/docs/pr-assets/active-recording-volume/before.png differdiff --git a/docs/pr-assets/active-recording-volume/recovered.png b/docs/pr-assets/active-recording-volume/recovered.pngnew file mode 100644index 000000000..6b659cd77Binary files /dev/null and b/docs/pr-assets/active-recording-volume/recovered.png differ