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): reduce log spam and show database/logs in disk usage

Louis Beaumont65e9b16542d1
diff --git a/screenpipe-app-tauri/components/settings/disk-usage-section.tsx b/screenpipe-app-tauri/components/settings/disk-usage-section.tsx
index ae6fc452f..40df4198f 100644
--- a/screenpipe-app-tauri/components/settings/disk-usage-section.tsx
+++ b/screenpipe-app-tauri/components/settings/disk-usage-section.tsx
@@ -6,7 +6,7 @@ import { Button } from "../ui/button";
import { Separator } from "../ui/separator";
import { Badge } from "../ui/badge";
import { useDiskUsage } from "@/lib/hooks/use-disk-usage";
-import { RefreshCw, HardDrive, Folder, Video, Mic, Database, Calculator } from "lucide-react";
+import { RefreshCw, HardDrive, Folder, Video, Mic, Database, Calculator, FileText } from "lucide-react";
import { Skeleton } from "../ui/skeleton";
import { Progress } from "../ui/progress";
@@ -47,7 +47,7 @@ export function DiskUsageSection() {
<div>
<h3 className="text-lg font-medium">Disk Usage</h3>
<p className="text-sm text-muted-foreground">
- Monitor storage usage for your Screenpipe data at ~/.screenpipe/data
+ Monitor storage usage for your Screenpipe data at ~/.screenpipe
</p>
</div>
<Button
@@ -209,10 +209,62 @@ export function DiskUsageSection() {
<span>Total Media Size</span>
<Badge className="bg-primary">{diskUsage?.media.total_media_size || "0 KB"}</Badge>
</div>
- {diskUsage && (
- <div className="mt-3 p-3 bg-muted/50 rounded-lg">
- <p className="text-xs text-muted-foreground">
- ✓ Values calculated from recursive directory scan including all subdirectories
+ </>
+ )}
+ </CardContent>
+ </Card>
+
+ {/* Other Files Breakdown */}
+ <Card className={isLoading ? "opacity-75" : ""}>
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <FileText className={`h-5 w-5 ${isLoading ? "animate-pulse" : ""}`} />
+ Other Files
+ </CardTitle>
+ <CardDescription>
+ Database and log files
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="space-y-4">
+ {isLoading ? (
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <Skeleton className="h-4 w-4 rounded" />
+ <Skeleton className="h-4 w-20" />
+ </div>
+ <Skeleton className="h-6 w-16 rounded-full" />
+ </div>
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <Skeleton className="h-4 w-4 rounded" />
+ <Skeleton className="h-4 w-20" />
+ </div>
+ <Skeleton className="h-6 w-16 rounded-full" />
+ </div>
+ </div>
+ ) : (
+ <>
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <Database className="h-4 w-4 text-muted-foreground" />
+ <span className="text-sm font-medium">Database</span>
+ </div>
+ <Badge variant="secondary">{diskUsage?.other?.database_size || "0 KB"}</Badge>
+ </div>
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <FileText className="h-4 w-4 text-muted-foreground" />
+ <span className="text-sm font-medium">Log Files</span>
+ </div>
+ <Badge variant={
+ diskUsage?.other?.logs_size?.includes("GB") ? "destructive" : "secondary"
+ }>{diskUsage?.other?.logs_size || "0 KB"}</Badge>
+ </div>
+ {diskUsage?.other?.logs_size?.includes("GB") && (
+ <div className="mt-3 p-3 bg-destructive/10 rounded-lg border border-destructive/20">
+ <p className="text-xs text-destructive">
+ ⚠️ Log files are unusually large. Consider deleting old logs at ~/.screenpipe/*.log
</p>
</div>
)}
diff --git a/screenpipe-app-tauri/lib/hooks/use-disk-usage.tsx b/screenpipe-app-tauri/lib/hooks/use-disk-usage.tsx
index 03e98c585..57f5281bc 100644
--- a/screenpipe-app-tauri/lib/hooks/use-disk-usage.tsx
+++ b/screenpipe-app-tauri/lib/hooks/use-disk-usage.tsx
@@ -9,8 +9,14 @@ export interface DiskUsedByMedia {
total_media_size: string;
}
+export interface DiskUsedByOther {
+ database_size: string;
+ logs_size: string;
+}
+
export interface DiskUsage {
media: DiskUsedByMedia;
+ other: DiskUsedByOther;
total_data_size: string;
total_cache_size: string;
available_space: string;
diff --git a/screenpipe-app-tauri/src-tauri/src/disk_usage.rs b/screenpipe-app-tauri/src-tauri/src/disk_usage.rs
index 388f32491..ac6a3b7e6 100644
--- a/screenpipe-app-tauri/src-tauri/src/disk_usage.rs
+++ b/screenpipe-app-tauri/src-tauri/src/disk_usage.rs
@@ -10,6 +10,7 @@ use tracing::{info, warn};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DiskUsage {
pub media: DiskUsedByMedia,
+ pub other: DiskUsedByOther,
pub total_data_size: String,
pub total_cache_size: String,
pub available_space: String,
@@ -22,6 +23,12 @@ pub struct DiskUsedByMedia {
pub total_media_size: String,
}
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct DiskUsedByOther {
+ pub database_size: String,
+ pub logs_size: String,
+}
+
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CachedDiskUsage {
pub timestamp: i64,
@@ -216,6 +223,37 @@ pub async fn disk_usage(
let total_media_size_calculated = total_video_size + total_audio_size;
let total_media_size_str = readable(total_media_size_calculated);
+ // Calculate database size (db.sqlite and related files)
+ info!("Calculating database size");
+ let mut database_size: u64 = 0;
+ for file_name in ["db.sqlite", "db.sqlite-wal", "db.sqlite-shm"] {
+ let db_path = screenpipe_dir.join(file_name);
+ if db_path.exists() {
+ if let Ok(metadata) = fs::metadata(&db_path) {
+ database_size += metadata.len();
+ }
+ }
+ }
+ info!("Database size: {} bytes", database_size);
+
+ // Calculate log files size
+ info!("Calculating log files size");
+ let mut logs_size: u64 = 0;
+ if let Ok(entries) = fs::read_dir(screenpipe_dir) {
+ for entry in entries.flatten() {
+ let path = entry.path();
+ if path.is_file() {
+ let file_name = path.file_name().unwrap_or_default().to_string_lossy();
+ if file_name.ends_with(".log") {
+ if let Ok(metadata) = entry.metadata() {
+ logs_size += metadata.len();
+ }
+ }
+ }
+ }
+ }
+ info!("Logs size: {} bytes", logs_size);
+
// Calculate available space
info!("Calculating available disk space");
let available_space = {
@@ -238,6 +276,10 @@ pub async fn disk_usage(
audios_size: audios_size_str,
total_media_size: total_media_size_str,
},
+ other: DiskUsedByOther {
+ database_size: readable(database_size),
+ logs_size: readable(logs_size),
+ },
total_data_size,
total_cache_size,
available_space: readable(available_space),
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index b0d0b9e0f..af10fea5e 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -30,7 +30,7 @@ pub async fn start_continuous_recording(
capture_unfocused_windows: bool,
realtime_vision: bool,
) -> Result<()> {
- info!("Starting video recording for monitors {:?}", monitor_ids);
+ debug!("Starting video recording for monitors {:?}", monitor_ids);
let video_tasks = if !vision_disabled {
monitor_ids
.iter()
@@ -44,11 +44,11 @@ pub async fn start_continuous_recording(
let languages = languages.clone();
- info!("Starting video recording for monitor {}", monitor_id);
+ debug!("Starting video recording for monitor {}", monitor_id);
vision_handle.spawn(async move {
// Wrap in a loop with recovery logic
loop {
- info!("Starting/restarting vision capture for monitor {}", monitor_id);
+ debug!("Starting/restarting vision capture for monitor {}", monitor_id);
match record_video(
db_manager_video.clone(),
output_path_video.clone(),
@@ -129,7 +129,7 @@ pub async fn record_video(
capture_unfocused_windows: bool,
realtime_vision: bool,
) -> Result<()> {
- info!("record_video: Starting for monitor {}", monitor_id);
+ debug!("record_video: Starting for monitor {}", monitor_id);
let device_name = Arc::new(format!("monitor_{}", monitor_id));
// Add heartbeat counter