Skip to content

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

fix(storage): keep cleanup warnings out of migration status (#7042)

Ezra Elletteaee619308214
diff --git a/apps/screenpipe-app-tauri/components/settings/storage-migration-card.test.tsx b/apps/screenpipe-app-tauri/components/settings/storage-migration-card.test.tsx
index 65b6fac34..697afc7f5 100644
--- a/apps/screenpipe-app-tauri/components/settings/storage-migration-card.test.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/storage-migration-card.test.tsx
@@ -85,6 +85,20 @@ describe("storage migration", () => {
expect(await screen.findByText("The original database has been deleted.")).toBeTruthy();
});
+ it("keeps completed storage usable when the original cannot be deleted safely", async () => {
+ migrated({ can_delete_source: false });
+ mount();
+ expect(await screen.findByText("Your recordings use the new compressed storage.")).toBeTruthy();
+ expect(screen.getByText("The original database is kept for safety. Your migrated history remains available.")).toBeTruthy();
+ expect(screen.getByRole("button", { name: "delete original database" })).toBeDisabled();
+ expect(screen.queryByRole("alert")).toBeNull();
+ expect(screen.queryByRole("button", { name: "finish switching" })).toBeNull();
+ expect(screen.queryByRole("button", { name: "migrate storage" })).toBeNull();
+ expect(onBusyChange).toHaveBeenLastCalledWith(false);
+ expect(commands.startStorageMigration).not.toHaveBeenCalled();
+ expect(commands.deleteOriginalStorageDatabase).not.toHaveBeenCalled();
+ });
+
it("shows interrupted migration and offers resume and cancellation without deletion", async () => {
Object.assign(status, { pending: true, can_cancel: true, error: "Verification failed; original kept." });
mount();
diff --git a/apps/screenpipe-app-tauri/components/settings/storage-migration-card.tsx b/apps/screenpipe-app-tauri/components/settings/storage-migration-card.tsx
index 3cfef00f4..ca5c2a6fa 100644
--- a/apps/screenpipe-app-tauri/components/settings/storage-migration-card.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/storage-migration-card.tsx
@@ -113,7 +113,7 @@ export function StorageMigrationCard({ dataDirectory, onBusyChange }: {
{status.bytes_saved != null && <p>Space saved: {bytes(status.bytes_saved)}</p>}
<p className="text-muted-foreground">
{status.in_place ? "Your existing database is now the smaller index. Space was recovered during migration." : Number(status.source_bytes) > 0
- ? `Original database kept: ${bytes(status.source_bytes)}. It contains your history up to migration; new recordings go to the new storage.`
+ ? `Original database kept: ${bytes(status.source_bytes)}. New recordings go to the compressed storage.`
: "The original database has been deleted."}
</p>
</div>
@@ -143,6 +143,9 @@ export function StorageMigrationCard({ dataDirectory, onBusyChange }: {
delete original database
</Button>
{!status.using_new_storage && <p className="text-xs text-muted-foreground">Available after Screenpipe is running on the new storage.</p>}
+ {status.using_new_storage && !status.can_delete_source && !busy && !status.pending && !failure && !status.blocked_reason && (
+ <p className="text-xs text-muted-foreground">The original database is kept for safety. Your migrated history remains available.</p>
+ )}
</div>
)}
diff --git a/apps/screenpipe-app-tauri/components/storage-migration-prompt.test.tsx b/apps/screenpipe-app-tauri/components/storage-migration-prompt.test.tsx
index b783112ab..5d90f0057 100644
--- a/apps/screenpipe-app-tauri/components/storage-migration-prompt.test.tsx
+++ b/apps/screenpipe-app-tauri/components/storage-migration-prompt.test.tsx
@@ -127,6 +127,23 @@ describe("automatic storage migration prompt", () => {
expect(commands.startStorageMigration).not.toHaveBeenCalled();
});
+ it("does not interrupt completed migrations when the original is kept for safety", async () => {
+ Object.assign(status, {
+ completed: true, using_new_storage: true, can_migrate: false,
+ can_delete_source: false, generation: "migrated-generation",
+ });
+ for (const session of ["app-launch-1", "app-launch-2"]) {
+ status.app_session_id = session;
+ const app = render(<StorageMigrationPrompt activity={idle} />);
+ await waitFor(() => expect(commands.getStorageMigrationStatus).toHaveBeenCalled());
+ expect(screen.queryByRole("alertdialog")).toBeNull();
+ app.unmount();
+ commands.getStorageMigrationStatus.mockClear();
+ }
+ expect(commands.startStorageMigration).not.toHaveBeenCalled();
+ expect(commands.deleteOriginalStorageDatabase).not.toHaveBeenCalled();
+ });
+
it.each(["failure", "interruption"])("requires an explicit retry after %s across app launches", async (reason) => {
Object.assign(status, {
pending: true, in_place: true,
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/storage_migration.rs b/apps/screenpipe-app-tauri/src-tauri/src/storage_migration.rs
index c21dcefa8..d63c2126b 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/storage_migration.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/storage_migration.rs
@@ -609,7 +609,12 @@ async fn storage_migration_status(
if completed && using_new_storage == Some(true) {
match server.db.retained_migration_source_bytes() {
Ok(bytes) => can_delete_source = bytes.is_some(),
- Err(error) => blocked_reason = Some(error.to_string()),
+ // This guard only decides whether the old copy can be
+ // deleted. It cannot invalidate a completed migration.
+ Err(error) => tracing::debug!(
+ %error,
+ "original database cleanup unavailable; migrated storage remains active"
+ ),
}
}
}