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

feat: add lifecycle, tray, windows, DB stress, timeline, and settings tests

Louis Beaumontf13f82ba62dd
diff --git a/.github/scripts/e2e/run-all.ts b/.github/scripts/e2e/run-all.ts
index 6c56ec6ce..44d237d6d 100644
--- a/.github/scripts/e2e/run-all.ts
+++ b/.github/scripts/e2e/run-all.ts
@@ -30,6 +30,10 @@ const SUITES = [
{ name: "permissions", file: "test-permissions.ts" },
{ name: "onboarding", file: "test-onboarding.ts" },
{ name: "chat", file: "test-chat.ts" },
+ { name: "tray", file: "test-tray.ts" },
+ { name: "windows", file: "test-windows.ts" },
+ // lifecycle runs LAST — it kills and restarts the app
+ { name: "lifecycle", file: "test-lifecycle.ts" },
];
// Parse args
diff --git a/.github/scripts/e2e/test-lifecycle.ts b/.github/scripts/e2e/test-lifecycle.ts
new file mode 100644
index 000000000..dec7a9112
--- /dev/null
+++ b/.github/scripts/e2e/test-lifecycle.ts
@@ -0,0 +1,283 @@
+/**
+ * App Lifecycle & Process Tests
+ *
+ * TESTING.md coverage:
+ * - S8: Clean quit, force quit recovery, port conflict, orphaned processes
+ * - S9: DB integrity after crash, concurrent DB access
+ * - S14: COM thread conflict (Windows)
+ *
+ * These tests kill and restart screenpipe, so they run LAST.
+ */
+
+import {
+ suite, test, summary, screenshot, fetchJson, sleep,
+ HEALTH_URL, IS_WINDOWS, IS_MACOS, isScreenpipeRunning,
+} from "./lib";
+
+suite("lifecycle & stability");
+
+// ── Helpers ─────────────────────────────────────────────────────────────────
+
+/** Get list of screenpipe-related PIDs */
+function getScreenpipePids(): number[] {
+ if (IS_WINDOWS) {
+ const proc = Bun.spawnSync([
+ "powershell", "-NoProfile", "-Command",
+ "Get-Process -Name 'screenpipe*' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Id",
+ ]);
+ return proc.stdout.toString().trim().split(/\r?\n/).filter(Boolean).map(Number).filter(n => !isNaN(n));
+ } else {
+ const proc = Bun.spawnSync(["pgrep", "-f", "screenpipe"]);
+ return proc.stdout.toString().trim().split(/\n/).filter(Boolean).map(Number).filter(n => !isNaN(n));
+ }
+}
+
+/** Check if port 3030 is in use */
+function isPortInUse(): boolean {
+ if (IS_WINDOWS) {
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "Get-NetTCPConnection -LocalPort 3030 -ErrorAction SilentlyContinue | Select-Object -First 1"]);
+ return proc.stdout.toString().trim().length > 0;
+ } else {
+ const proc = Bun.spawnSync(["lsof", "-i", ":3030"]);
+ return proc.exitCode === 0;
+ }
+}
+
+/** Find screenpipe executable path */
+function findScreenpipeExe(): string | null {
+ if (IS_WINDOWS) {
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "(Get-Process -Name 'screenpipe*' -ErrorAction SilentlyContinue | Select-Object -First 1).Path"]);
+ const path = proc.stdout.toString().trim();
+ return path || null;
+ } else {
+ const proc = Bun.spawnSync(["bash", "-c", "ps aux | grep -i screenpipe | grep -v grep | head -1 | awk '{print $11}'"]);
+ const path = proc.stdout.toString().trim();
+ return path || null;
+ }
+}
+
+/** Start screenpipe app (best effort) */
+function startScreenpipe(exePath: string) {
+ if (IS_WINDOWS) {
+ Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ `Start-Process '${exePath}'`]);
+ } else {
+ Bun.spawnSync(["open", "-a", exePath]);
+ }
+}
+
+/** Wait for health API with timeout */
+async function waitForHealthUp(timeoutS: number): Promise<boolean> {
+ const start = Date.now();
+ while (Date.now() - start < timeoutS * 1000) {
+ try {
+ const res = await fetch(HEALTH_URL);
+ if (res.ok) return true;
+ } catch {}
+ await sleep(2000);
+ }
+ return false;
+}
+
+// ── Pre-flight: record exe path before we kill anything ─────────────────────
+
+const exePath = findScreenpipeExe();
+console.log(` screenpipe exe: ${exePath ?? "not found"}`);
+
+// ── S9: Concurrent DB access under load ─────────────────────────────────────
+
+await test("concurrent DB access (50 requests)", async () => {
+ const promises = Array.from({ length: 50 }, (_, i) =>
+ fetch(`http://localhost:3030/search?limit=1&q=test${i}`)
+ .then(r => ({ ok: r.ok, status: r.status }))
+ .catch(e => ({ ok: false, status: 0, error: e.message }))
+ );
+ const results = await Promise.all(promises);
+ const failures = results.filter(r => !r.ok);
+ if (failures.length > 5) {
+ throw new Error(`${failures.length}/50 requests failed (>10% failure rate)`);
+ }
+});
+
+await test("mixed read/write concurrent access", async () => {
+ // Interleave search and health requests (simulating real usage)
+ const promises = [];
+ for (let i = 0; i < 20; i++) {
+ promises.push(fetch(`http://localhost:3030/search?limit=1&content_type=ocr`).then(r => r.ok));
+ promises.push(fetch(HEALTH_URL).then(r => r.ok));
+ promises.push(fetch(`http://localhost:3030/search?limit=5&q=e2e`).then(r => r.ok));
+ }
+ const results = await Promise.all(promises);
+ const failures = results.filter(r => !r);
+ if (failures.length > 3) {
+ throw new Error(`${failures.length}/60 mixed requests failed`);
+ }
+});
+
+// ── S14: COM thread conflict (Windows) ──────────────────────────────────────
+
+if (IS_WINDOWS) {
+ await test("audio + vision both active (COM no conflict)", async () => {
+ const health = await fetchJson(HEALTH_URL);
+ // frame_status must be ok (vision thread using COM for screen capture)
+ if (health.frame_status !== "ok") {
+ throw new Error(`frame_status: ${health.frame_status} (vision COM may be broken)`);
+ }
+ // If audio is configured, it should also work (audio thread using COM for WASAPI)
+ if (health.audio_status === "ok") {
+ console.log(" both audio + vision COM threads active");
+ } else {
+ console.log(` vision COM ok, audio: ${health.audio_status} (may not be configured)`);
+ }
+ });
+}
+
+// ── S5: CPU on idle screen ──────────────────────────────────────────────────
+
+await test("CPU not spiking on idle (10s sample)", async () => {
+ if (IS_WINDOWS) {
+ // Measure screenpipe CPU over 10s
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command", `
+ $samples = @()
+ for ($i = 0; $i -lt 5; $i++) {
+ $cpu = (Get-Process -Name 'screenpipe*' -ErrorAction SilentlyContinue | Measure-Object -Property CPU -Sum).Sum
+ $samples += $cpu
+ Start-Sleep -Seconds 2
+ }
+ $delta = $samples[-1] - $samples[0]
+ Write-Output $delta
+ `], { timeout: 30_000 });
+ const cpuDelta = parseFloat(proc.stdout.toString().trim());
+ if (!isNaN(cpuDelta) && cpuDelta > 50) {
+ throw new Error(`high CPU usage on idle: ${cpuDelta.toFixed(1)}s CPU time in 10s`);
+ }
+ console.log(` CPU delta over 10s: ${isNaN(cpuDelta) ? "N/A" : cpuDelta.toFixed(1)}s`);
+ } else {
+ // macOS: use ps to sample CPU %
+ const proc = Bun.spawnSync(["bash", "-c",
+ "ps aux | grep -i screenpipe | grep -v grep | awk '{sum+=$3} END {print sum}'"]);
+ const cpuPct = parseFloat(proc.stdout.toString().trim());
+ if (!isNaN(cpuPct) && cpuPct > 30) {
+ throw new Error(`high CPU on idle: ${cpuPct.toFixed(1)}%`);
+ }
+ console.log(` CPU usage: ${isNaN(cpuPct) ? "N/A" : cpuPct.toFixed(1)}%`);
+ }
+});
+
+// ── S8: No orphaned ffmpeg/bun processes ────────────────────────────────────
+
+await test("no orphaned ffmpeg processes", async () => {
+ if (IS_WINDOWS) {
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "(Get-Process -Name 'ffmpeg' -ErrorAction SilentlyContinue).Count"]);
+ const count = parseInt(proc.stdout.toString().trim()) || 0;
+ // Some ffmpeg processes may be expected during recording, but >10 suggests leak
+ if (count > 10) {
+ throw new Error(`${count} ffmpeg processes running (possible orphan leak)`);
+ }
+ console.log(` ffmpeg processes: ${count}`);
+ } else {
+ const proc = Bun.spawnSync(["bash", "-c", "pgrep -c ffmpeg || echo 0"]);
+ const count = parseInt(proc.stdout.toString().trim()) || 0;
+ if (count > 10) {
+ throw new Error(`${count} ffmpeg processes (possible orphan leak)`);
+ }
+ console.log(` ffmpeg processes: ${count}`);
+ }
+});
+
+// ── S8: Force quit + recovery ───────────────────────────────────────────────
+
+await test("force quit + recovery (DB intact)", async () => {
+ if (!exePath) {
+ console.log(" (skipped: could not find screenpipe exe path)");
+ return;
+ }
+
+ // Record a search result count before kill
+ let preKillCount = 0;
+ try {
+ const pre = await fetchJson("http://localhost:3030/search?limit=1&content_type=ocr");
+ preKillCount = pre?.pagination?.total ?? 0;
+ } catch {}
+
+ // Force kill screenpipe
+ console.log(" force killing screenpipe...");
+ if (IS_WINDOWS) {
+ Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "Get-Process -Name 'screenpipe*' -ErrorAction SilentlyContinue | Stop-Process -Force"]);
+ } else {
+ Bun.spawnSync(["pkill", "-9", "-f", "screenpipe"]);
+ }
+ await sleep(3000);
+
+ // Verify it's dead
+ if (isScreenpipeRunning()) {
+ throw new Error("screenpipe still running after force kill");
+ }
+
+ // Restart
+ console.log(" restarting screenpipe...");
+ startScreenpipe(exePath);
+
+ // Wait for health API
+ const recovered = await waitForHealthUp(60);
+ if (!recovered) {
+ throw new Error("health API did not come back within 60s after force quit");
+ }
+
+ // Verify DB is intact — search should still work
+ await sleep(5000);
+ const post = await fetchJson("http://localhost:3030/search?limit=1&content_type=ocr");
+ const postKillCount = post?.pagination?.total ?? 0;
+
+ // Total should be >= pre-kill (new frames may have been added)
+ if (postKillCount < preKillCount * 0.9) {
+ throw new Error(`DB may be corrupted: pre=${preKillCount}, post=${postKillCount}`);
+ }
+ console.log(` DB intact: pre=${preKillCount}, post=${postKillCount}`);
+});
+
+// ── S8: Port conflict on restart ────────────────────────────────────────────
+
+await test("port 3030 not conflicting", async () => {
+ // After recovery, verify only one process owns port 3030
+ if (IS_WINDOWS) {
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "(Get-NetTCPConnection -LocalPort 3030 -ErrorAction SilentlyContinue | Where-Object State -eq 'Listen').Count"]);
+ const count = parseInt(proc.stdout.toString().trim()) || 0;
+ if (count > 1) {
+ throw new Error(`${count} listeners on port 3030 (port conflict)`);
+ }
+ if (count === 0) {
+ console.log(" (no listeners yet, app may still be starting)");
+ } else {
+ console.log(` port 3030 listeners: ${count}`);
+ }
+ } else {
+ const proc = Bun.spawnSync(["bash", "-c", "lsof -i :3030 -sTCP:LISTEN | tail -n +2 | wc -l"]);
+ const count = parseInt(proc.stdout.toString().trim()) || 0;
+ if (count > 1) {
+ throw new Error(`${count} listeners on port 3030 (port conflict)`);
+ }
+ }
+});
+
+// ── S8: Health stable after restart ─────────────────────────────────────────
+
+await test("health stable after restart (10s)", async () => {
+ for (let i = 0; i < 5; i++) {
+ const health = await fetchJson(HEALTH_URL);
+ if (health.frame_status !== "ok") {
+ throw new Error(`frame_status degraded at check ${i}: ${health.frame_status}`);
+ }
+ await sleep(2000);
+ }
+});
+
+await screenshot("09-lifecycle");
+
+const ok = summary();
+process.exit(ok ? 0 : 1);
diff --git a/.github/scripts/e2e/test-tray.ts b/.github/scripts/e2e/test-tray.ts
new file mode 100644
index 000000000..be65d2413
--- /dev/null
+++ b/.github/scripts/e2e/test-tray.ts
@@ -0,0 +1,180 @@
+/**
+ * Tray Menu Interaction Tests
+ *
+ * TESTING.md coverage:
+ * - S2: Tray icon, tray menu items, tray health indicator
+ * - S8: Quit via tray
+ *
+ * Uses bb CLI to interact with system tray.
+ * Note: On Windows, system tray interaction via UIA is limited.
+ */
+
+import {
+ suite, test, summary, screenshot, bb, fetchJson, sleep,
+ sel, HEALTH_URL, IS_WINDOWS, IS_MACOS, isScreenpipeRunning,
+} from "./lib";
+
+suite("tray & system menu");
+
+if (IS_MACOS) {
+ // ── macOS tray tests ────────────────────────────────────────────────────────
+
+ await test("tray icon visible", async () => {
+ const result = await bb("find", "role:AXMenuBarItem AND name~:status", "--app", "screenpipe-app");
+ const items = result?.data ?? [];
+ if (items.length === 0) throw new Error("tray icon not found");
+ });
+
+ await test("tray shows health indicator", async () => {
+ // Look for the recording indicator (● recording)
+ try {
+ const result = await bb("find", "title~:recording");
+ const items = result?.data ?? [];
+ if (items.length > 0) {
+ console.log(" tray shows: recording active");
+ return;
+ }
+ } catch {}
+ // Might show other status
+ console.log(" (recording indicator not found, checking health)");
+ const health = await fetchJson(HEALTH_URL);
+ console.log(` health status: ${health.status}`);
+ });
+
+ await test("tray menu opens", async () => {
+ // Click the tray icon to open the menu
+ try {
+ await bb("click", "role:AXMenuBarItem AND name~:status", "--app", "screenpipe-app");
+ await sleep(1000);
+ // Verify menu items appeared
+ const items = await bb("find", "role:AXMenuItem", "--app", "screenpipe-app");
+ const count = items?.data?.length ?? 0;
+ if (count === 0) throw new Error("no menu items after clicking tray");
+ console.log(` tray menu has ${count} items`);
+ // Close menu by pressing Escape
+ await bb("press", "escape");
+ } catch (e: any) {
+ throw new Error(`tray menu interaction failed: ${e.message}`);
+ }
+ });
+
+ await test("tray has all expected items", async () => {
+ // Open menu
+ await bb("click", "role:AXMenuBarItem AND name~:status", "--app", "screenpipe-app");
+ await sleep(500);
+
+ const expectedItems = ["show screenpipe", "settings", "quit screenpipe"];
+ for (const item of expectedItems) {
+ try {
+ const result = await bb("find", `role:AXMenuItem AND title~:${item}`);
+ const found = (result?.data?.length ?? 0) > 0;
+ if (!found) console.log(` warning: "${item}" not found in tray menu`);
+ } catch {
+ console.log(` warning: "${item}" check failed`);
+ }
+ }
+
+ // Close menu
+ await bb("press", "escape");
+ });
+
+ await test("tray 'show screenpipe' opens window", async () => {
+ // Open tray menu
+ await bb("click", "role:AXMenuBarItem AND name~:status", "--app", "screenpipe-app");
+ await sleep(500);
+
+ // Click "show screenpipe"
+ try {
+ await bb("click", "role:AXMenuItem AND title~:show screenpipe", "--app", "screenpipe-app");
+ await sleep(2000);
+
+ // Verify window appeared
+ const result = await bb("find", "role:AXWebArea", "--app", "screenpipe-app");
+ const windows = result?.data ?? [];
+ if (windows.length === 0) {
+ console.log(" warning: window may not have appeared");
+ }
+ } catch (e: any) {
+ console.log(` (show screenpipe interaction failed: ${e.message})`);
+ }
+ });
+
+ await test("tray menu does not fire twice (S2)", async () => {
+ // This is hard to test directly — we verify the action count
+ // by checking that "settings" opens exactly one settings window
+ await bb("click", "role:AXMenuBarItem AND name~:status", "--app", "screenpipe-app");
+ await sleep(500);
+ // Just verify menu is responsive without double-firing
+ const result = await bb("find", "role:AXMenuItem AND title:settings", "--app", "screenpipe-app");
+ const settingsCount = result?.data?.length ?? 0;
+ // Should be exactly 1 settings menu item (not duplicated)
+ if (settingsCount > 1) {
+ throw new Error(`${settingsCount} "settings" items in tray (possible double-fire bug)`);
+ }
+ await bb("press", "escape");
+ });
+}
+
+if (IS_WINDOWS) {
+ // ── Windows tray tests ──────────────────────────────────────────────────────
+
+ await test("screenpipe process running", async () => {
+ if (!isScreenpipeRunning()) throw new Error("screenpipe not running");
+ });
+
+ await test("system tray area accessible", async () => {
+ // Windows system tray is tricky — items may be in overflow
+ // Try to find screenpipe in notification area
+ try {
+ const result = await bb("find", "name~:screenpi");
+ const items = result?.data ?? [];
+ if (items.length > 0) {
+ console.log(` found ${items.length} screenpipe element(s) in tray area`);
+ return;
+ }
+ } catch {}
+
+ // Try notification area toolbar
+ try {
+ const result = await bb("find", "role:ToolBar AND name~:notification");
+ const toolbars = result?.data ?? [];
+ console.log(` notification toolbars found: ${toolbars.length}`);
+ } catch {
+ console.log(" (notification area not directly accessible)");
+ }
+ });
+
+ await test("health indicator via API (tray proxy)", async () => {
+ // On Windows we can't easily read tray icon color,
+ // but we verify the health state that drives it
+ const health = await fetchJson(HEALTH_URL);
+ const status = health.status;
+ if (status === "healthy") {
+ console.log(" health: green (healthy)");
+ } else if (status === "degraded") {
+ console.log(" health: yellow (degraded)");
+ } else {
+ console.log(` health: red (${status})`);
+ }
+ });
+
+ await test("screenpipe window focusable via shortcut", async () => {
+ // Alt+S should show/focus the window
+ await bb("shortcut", "s", "--modifiers", "alt");
+ await sleep(2000);
+
+ // Verify window is visible
+ const result = await bb("find", "name~:screenpi");
+ const items = result?.data ?? [];
+ if (items.length === 0) {
+ console.log(" warning: window may not have focused");
+ } else {
+ console.log(` window focused, ${items.length} element(s) visible`);
+ }
+ });
+}
+
+await screenshot("08-tray");
+
+const ok = summary();
+process.exit(ok ? 0 : 1);
diff --git a/.github/scripts/e2e/test-windows.ts b/.github/scripts/e2e/test-windows.ts
new file mode 100644
index 000000000..88002d1f4
--- /dev/null
+++ b/.github/scripts/e2e/test-windows.ts
@@ -0,0 +1,193 @@
+/**
+ * Windows-Specific Tests
+ *
+ * TESTING.md coverage:
+ * - S14: COM thread conflict, High-DPI, multiple monitors, Windows Defender
+ * - S5: OCR at different resolutions
+ *
+ * Only runs on Windows. Skipped entirely on macOS.
+ */
+
+import {
+ suite, test, summary, screenshot, fetchJson, sleep, bb,
+ HEALTH_URL, IS_WINDOWS,
+} from "./lib";
+
+if (!IS_WINDOWS) {
+ console.log("(skipped: windows-only suite)");
+ process.exit(0);
+}
+
+suite("windows-specific");
+
+// ── S14: COM initialization ─────────────────────────────────────────────────
+
+await test("COM: vision thread active", async () => {
+ const health = await fetchJson(HEALTH_URL);
+ if (health.frame_status !== "ok") {
+ throw new Error(`frame_status: ${health.frame_status} — vision COM may have failed`);
+ }
+});
+
+await test("COM: audio thread not crashing", async () => {
+ const health = await fetchJson(HEALTH_URL);
+ // audio can be "ok", "not_started", or "error" — but NOT a COM-related crash
+ // If there's a COM conflict, the whole process usually crashes
+ if (!health.audio_status) {
+ throw new Error("audio_status field missing — possible crash");
+ }
+ console.log(` audio_status: ${health.audio_status}`);
+});
+
+await test("COM: concurrent health checks don't deadlock", async () => {
+ // COM STA threading issues can cause deadlocks on concurrent calls
+ const start = Date.now();
+ const promises = Array.from({ length: 10 }, () =>
+ fetch(HEALTH_URL).then(r => r.json())
+ );
+ const results = await Promise.all(promises);
+ const elapsed = Date.now() - start;
+
+ if (elapsed > 15000) {
+ throw new Error(`concurrent health took ${elapsed}ms (possible COM deadlock)`);
+ }
+ console.log(` 10 concurrent health checks: ${elapsed}ms`);
+});
+
+// ── S14: Multiple monitors ──────────────────────────────────────────────────
+
+await test("multi-monitor detection", async () => {
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "(Get-CimInstance Win32_DesktopMonitor).Count"]);
+ const monitorCount = parseInt(proc.stdout.toString().trim()) || 0;
+
+ // Also check via Win32_VideoController (more reliable on some systems)
+ const proc2 = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens.Count"]);
+ const screenCount = parseInt(proc2.stdout.toString().trim()) || 1;
+
+ console.log(` monitors: ${monitorCount}, screens: ${screenCount}`);
+
+ // Verify health reports frame capture (at least one monitor working)
+ const health = await fetchJson(HEALTH_URL);
+ if (health.frame_status !== "ok") {
+ throw new Error(`frame_status not ok with ${screenCount} screens`);
+ }
+});
+
+// ── S14: High-DPI ───────────────────────────────────────────────────────────
+
+await test("DPI scaling detection", async () => {
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command", `
+ Add-Type -AssemblyName System.Windows.Forms
+ $screen = [System.Windows.Forms.Screen]::PrimaryScreen
+ $bounds = $screen.Bounds
+ Write-Output "$($bounds.Width)x$($bounds.Height)"
+ `]);
+ const resolution = proc.stdout.toString().trim();
+
+ // Check DPI scaling
+ const dpiProc = Bun.spawnSync(["powershell", "-NoProfile", "-Command", `
+ Add-Type @'
+ using System;
+ using System.Runtime.InteropServices;
+ public class DPI {
+ [DllImport("gdi32.dll")] public static extern int GetDeviceCaps(IntPtr hdc, int index);
+ [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hwnd);
+ [DllImport("user32.dll")] public static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
+ }
+'@
+ $hdc = [DPI]::GetDC([IntPtr]::Zero)
+ $dpiX = [DPI]::GetDeviceCaps($hdc, 88)
+ [DPI]::ReleaseDC([IntPtr]::Zero, $hdc) | Out-Null
+ $scale = [math]::Round($dpiX / 96 * 100)
+ Write-Output $scale
+ `]);
+ const scalePct = parseInt(dpiProc.stdout.toString().trim()) || 100;
+
+ console.log(` resolution: ${resolution}, DPI scale: ${scalePct}%`);
+
+ // OCR should still work regardless of DPI
+ const health = await fetchJson(HEALTH_URL);
+ if (health.frame_status !== "ok") {
+ throw new Error(`frame capture failing at ${scalePct}% DPI`);
+ }
+});
+
+await test("OCR works at current DPI", async () => {
+ const data = await fetchJson("http://localhost:3030/search?limit=1&content_type=ocr");
+ const results = data?.data ?? [];
+ if (results.length === 0) {
+ throw new Error("no OCR results — DPI may be affecting capture");
+ }
+ // Check the OCR text has reasonable content (not garbage from scaling)
+ const text = results[0]?.content?.text ?? "";
+ if (text.length < 2) {
+ console.log(" warning: OCR text very short, may indicate DPI issue");
+ } else {
+ console.log(` OCR text sample: "${text.slice(0, 60)}..."`);
+ }
+});
+
+// ── S14: Windows Defender ───────────────────────────────────────────────────
+
+await test("not blocked by Windows Defender", async () => {
+ // Check if screenpipe is in Defender exclusions or if there are recent blocks
+ const proc = Bun.spawnSync(["powershell", "-NoProfile", "-Command", `
+ $threats = Get-MpThreatDetection -ErrorAction SilentlyContinue |
+ Where-Object { $_.ProcessName -like '*screenpipe*' } |
+ Select-Object -First 5
+ if ($threats) {
+ Write-Output "BLOCKED:$($threats.Count)"
+ } else {
+ Write-Output "CLEAR"
+ }
+ `], { timeout: 15_000 });
+ const result = proc.stdout.toString().trim();
+ if (result.startsWith("BLOCKED")) {
+ throw new Error(`Windows Defender blocked screenpipe: ${result}`);
+ }
+ console.log(` Defender status: ${result}`);
+});
+
+// ── S8: No orphaned processes (Windows-specific) ────────────────────────────
+
+await test("no orphaned screenpipe child processes", async () => {
+ // Get screenpipe parent PID
+ const parentProc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ "(Get-Process -Name 'screenpipe*' -ErrorAction SilentlyContinue | Select-Object -First 1).Id"]);
+ const parentPid = parseInt(parentProc.stdout.toString().trim());
+
+ if (!parentPid) {
+ console.log(" (skipped: no screenpipe process found)");
+ return;
+ }
+
+ // Count child processes
+ const childProc = Bun.spawnSync(["powershell", "-NoProfile", "-Command",
+ `(Get-CimInstance Win32_Process | Where-Object { $_.ParentProcessId -eq ${parentPid} }).Count`]);
+ const childCount = parseInt(childProc.stdout.toString().trim()) || 0;
+
+ console.log(` screenpipe PID ${parentPid}, child processes: ${childCount}`);
+
+ // Reasonable child count (ffmpeg, sidecar, etc.) — but >20 suggests leak
+ if (childCount > 20) {
+ throw new Error(`${childCount} child processes (possible orphan leak)`);
+ }
+});
+
+// ── S14: UIA accessibility tree accessible ──────────────────────────────────
+
+await test("UIA tree accessible via bb", async () => {
+ const result = await bb("apps");
+ const apps = result?.data ?? result ?? [];
+ if (!Array.isArray(apps) || apps.length === 0) {
+ throw new Error("bb apps returned empty — UIA may be broken");
+ }
+ console.log(` bb sees ${apps.length} windows`);
+});
+
+await screenshot("10-windows");
+
+const ok = summary();
+process.exit(ok ? 0 : 1);
diff --git a/apps/screenpipe-app-tauri/e2e/tests/db-stress.js b/apps/screenpipe-app-tauri/e2e/tests/db-stress.js
new file mode 100644
index 000000000..a1b1e917a
--- /dev/null
+++ b/apps/screenpipe-app-tauri/e2e/tests/db-stress.js
@@ -0,0 +1,171 @@
+/**
+ * Database Stress & Concurrent Access Test
+ *
+ * Covers TESTING.md sections:
+ * - Section 9: Concurrent DB access, store race condition, UTF-8
+ * - Section 5: OCR pipeline under load
+ * - Section 8: Port conflict detection
+ */
+
+describe('Database & Stability (S9)', () => {
+ const API_BASE = 'http://localhost:3030';
+
+ before(async () => {
+ await browser.waitUntil(
+ async () => (await browser.execute(() => document.readyState)) === 'complete',
+ { timeout: 30000, timeoutMsg: 'app did not load' }
+ );
+
+ // Skip onboarding
+ try {
+ const skipBtn = await $('button*=skip');
+ if (await skipBtn.isDisplayed()) {
+ await skipBtn.click();
+ await browser.pause(500);
+ }
+ } catch {}
+ try {
+ const closeBtn = await $('button svg.lucide-x');
+ if (await closeBtn.isDisplayed()) {
+ await closeBtn.closest('button').click();
+ await browser.pause(500);
+ }
+ } catch {}
+ });
+
+ it('should handle 20 concurrent search requests (S9.2)', async () => {
+ const results = await browser.execute(async (base) => {
+ const promises = Array.from({ length: 20 }, (_, i) =>
+ fetch(`${base}/search?limit=1&q=test${i}`)
+ .then(r => ({ ok: r.ok, status: r.status }))
+ .catch(e => ({ ok: false, status: 0, error: e.message }))
+ );
+ return Promise.all(promises);
+ }, API_BASE);
+
+ const failures = results.filter(r => !r.ok);
+ // Allow up to 10% failure rate under load
+ expect(failures.length).toBeLessThan(3);
+ });
+
+ it('should handle mixed concurrent requests (S9.2)', async () => {
+ const results = await browser.execute(async (base) => {
+ const endpoints = [
+ `${base}/health`,
+ `${base}/search?limit=1&content_type=ocr`,
+ `${base}/search?limit=5&q=test`,
+ `${base}/pipes/list`,
+ `${base}/search?limit=1&content_type=audio`,
+ ];
+ const promises = [];
+ for (let i = 0; i < 4; i++) {
+ for (const url of endpoints) {
+ promises.push(
+ fetch(url)
+ .then(r => ({ ok: r.ok || r.status === 404 || r.status === 403, status: r.status }))
+ .catch(e => ({ ok: false, status: 0 }))
+ );
+ }
+ }
+ return Promise.all(promises);
+ }, API_BASE);
+
+ const failures = results.filter(r => !r.ok);
+ expect(failures.length).toBeLessThan(3);
+ });
+
+ it('should handle UTF-8 in various search queries (S9.5)', async () => {
+ const queries = [
+ '%E4%B8%AD%E6%96%87', // Chinese
+ '%C3%A9%C3%A0%C3%BC', // French accented
+ '%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82', // Russian
+ '%F0%9F%98%80', // Emoji
+ 'caf%C3%A9', // Mixed ASCII + Unicode
+ ];
+
+ for (const q of queries) {
+ const result = await browser.execute(async (base, query) => {
+ try {
+ const res = await fetch(`${base}/search?q=${query}&limit=1`);
+ return { ok: res.ok, status: res.status };
+ } catch (e) {
+ return { ok: false, status: 0, error: e.message };
+ }
+ }, API_BASE, q);
+
+ // Should not crash — 400 or empty results OK, 500 is bad
+ expect(result.status).not.toBe(500);
+ }
+ });
+
+ it('should not return 500 on rapid sequential queries (S9.3)', async () => {
+ const results = await browser.execute(async (base) => {
+ const outcomes = [];
+ for (let i = 0; i < 10; i++) {
+ try {
+ const res = await fetch(`${base}/search?limit=1&offset=${i}`);
+ outcomes.push({ ok: res.ok, status: res.status });
+ } catch (e) {
+ outcomes.push({ ok: false, status: 0 });
+ }
+ }
+ return outcomes;
+ }, API_BASE);
+
+ const serverErrors = results.filter(r => r.status >= 500);
+ expect(serverErrors.length).toBe(0);
+ });
+
+ it('should handle large result set (S9.7)', async () => {
+ const result = await browser.execute(async (base) => {
+ const start = performance.now();
+ const res = await fetch(`${base}/search?limit=100&content_type=ocr`);
+ const elapsed = performance.now() - start;
+ const data = await res.json();
+ return {
+ ok: res.ok,
+ elapsed: Math.round(elapsed),
+ count: data?.data?.length ?? 0,
+ total: data?.pagination?.total ?? 0,
+ };
+ }, API_BASE);
+
+ expect(result.ok).toBe(true);
+ // Should respond within 5 seconds even for 100 results
+ expect(result.elapsed).toBeLessThan(5000);
+ });
+
+ it('should maintain health during stress test', async () => {
+ // After all the stress, health should still be ok
+ const health = await browser.execute(async (base) => {
+ const res = await fetch(`${base}/health`);
+ return res.json();
+ }, API_BASE);
+
+ expect(health).toHaveProperty('status');
+ expect(health.frame_status).toBe('ok');
+ });
+
+ it('should handle search + UI interaction concurrently (S9.4)', async () => {
+ // Simulate what happens when user browses UI while API queries run
+ const apiPromise = browser.execute(async (base) => {
+ const results = [];
+ for (let i = 0; i < 5; i++) {
+ const res = await fetch(`${base}/search?limit=5`);
+ results.push({ ok: res.ok });
+ }
+ return results;
+ }, API_BASE);
+
+ // Meanwhile, interact with UI
+ await browser.execute(() => { window.location.href = '/settings'; });
+ await browser.pause(500);
+ await browser.execute(() => { window.location.href = '/'; });
+ await browser.pause(500);
+
+ // API calls should still succeed
+ const apiResults = await apiPromise;
+ const failures = apiResults.filter(r => !r.ok);
+ expect(failures.length).toBe(0);
+ });
+});
diff --git a/apps/screenpipe-app-tauri/e2e/tests/settings-persistence.js b/apps/screenpipe-app-tauri/e2e/tests/settings-persistence.js
new file mode 100644
index 000000000..ce9417e1a
--- /dev/null
+++ b/apps/screenpipe-app-tauri/e2e/tests/settings-persistence.js
@@ -0,0 +1,156 @@
+/**
+ * Settings Persistence & AI Presets Test
+ *
+ * Covers TESTING.md sections:
+ * - Section 10: Settings survive restart, overlay mode switch, FPS, AI presets
+ * - Section 11: Onboarding doesn't re-show after completion
+ *
+ * Tests that settings persist across navigation and page changes.
+ */
+
+describe('Settings Persistence (S10)', () => {
+ before(async () => {
+ await browser.waitUntil(
+ async () => (await browser.execute(() => document.readyState)) === 'complete',
+ { timeout: 30000, timeoutMsg: 'app did not load' }
+ );
+
+ // Skip onboarding
+ try {
+ const skipBtn = await $('button*=skip');
+ if (await skipBtn.isDisplayed()) {
+ await skipBtn.click();
+ await browser.pause(500);
+ }
+ } catch {}
+ try {
+ const closeBtn = await $('button svg.lucide-x');
+ if (await closeBtn.isDisplayed()) {
+ await closeBtn.closest('button').click();
+ await browser.pause(500);
+ }
+ } catch {}
+ });
+
+ it('should open settings page', async () => {
+ await browser.execute(() => { window.location.href = '/settings'; });
+ await browser.pause(2000);
+ const url = await browser.getUrl();
+ expect(url).toContain('settings');
+ });
+
+ it('should have recording section with FPS setting (S10.5)', async () => {
+ // Navigate to recording section
+ await browser.execute(() => {
+ const els = document.querySelectorAll('a, button');
+ for (const el of els) {
+ if (el.textContent.toLowerCase().includes('recording')) {
+ el.click();
+ break;
+ }
+ }
+ });
+ await browser.pause(1000);
+
+ const pageText = await browser.execute(() => document.body.innerText.toLowerCase());
+ const hasFps = pageText.includes('fps') || pageText.includes('frame');
+ expect(hasFps).toBe(true);
+ });
+
+ it('should persist settings after navigation (S10.3)', async () => {
+ // Read current page state
+ const beforeText = await browser.execute(() => document.body.innerText);
+
+ // Navigate away
+ await browser.execute(() => { window.location.href = '/'; });
+ await browser.pause(2000);
+
+ // Navigate back
+ await browser.execute(() => { window.location.href = '/settings'; });
+ await browser.pause(2000);
+
+ // Page should load without errors
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+
+ const bodyText = await browser.execute(() => document.body.innerText);
+ expect(bodyText).not.toContain('Unhandled Runtime Error');
+ });
+
+ it('should have AI section accessible (S10.1-2)', async () => {
+ await browser.execute(() => {
+ const els = document.querySelectorAll('a, button');
+ for (const el of els) {
+ if (el.textContent.toLowerCase().includes('ai')) {
+ el.click();
+ break;
+ }
+ }
+ });
+ await browser.pause(1000);
+
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+
+ const bodyText = await browser.execute(() => document.body.innerText);
+ expect(bodyText).not.toContain('Unhandled Runtime Error');
+ });
+
+ it('should have shortcuts section (S10.4)', async () => {
+ await browser.execute(() => {
+ const els = document.querySelectorAll('a, button');
+ for (const el of els) {
+ if (el.textContent.toLowerCase().includes('shortcut')) {
+ el.click();
+ break;
+ }
+ }
+ });
+ await browser.pause(1000);
+
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+ });
+
+ it('should not show onboarding after visiting settings (S11.6)', async () => {
+ // Navigate to home — should NOT show onboarding again
+ await browser.execute(() => { window.location.href = '/'; });
+ await browser.pause(3000);
+
+ const bodyText = await browser.execute(() => document.body.innerText.toLowerCase());
+
+ // After settings, onboarding should not reappear
+ // (This checks the "doesn't re-show" requirement loosely)
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+ });
+
+ it('should handle rapid section switching (S9.3)', async () => {
+ // Rapidly toggle between settings sections — tests store race condition
+ await browser.execute(() => { window.location.href = '/settings'; });
+ await browser.pause(1000);
+
+ const sections = ['general', 'recording', 'ai', 'shortcuts', 'account', 'disk'];
+
+ for (const section of sections) {
+ await browser.execute((s) => {
+ const els = document.querySelectorAll('a, button');
+ for (const el of els) {
+ if (el.textContent.toLowerCase().includes(s)) {
+ el.click();
+ break;
+ }
+ }
+ }, section);
+ await browser.pause(200); // Very fast switching
+ }
+
+ await browser.pause(1000);
+
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+
+ const bodyText = await browser.execute(() => document.body.innerText);
+ expect(bodyText).not.toContain('Unhandled Runtime Error');
+ });
+});
diff --git a/apps/screenpipe-app-tauri/e2e/tests/timeline-navigation.js b/apps/screenpipe-app-tauri/e2e/tests/timeline-navigation.js
new file mode 100644
index 000000000..90dae40e7
--- /dev/null
+++ b/apps/screenpipe-app-tauri/e2e/tests/timeline-navigation.js
@@ -0,0 +1,137 @@
+/**
+ * Timeline Navigation & Search Test
+ *
+ * Covers TESTING.md section 12:
+ * - Arrow key navigation
+ * - Search results sorted by time
+ * - No frame clearing during navigation
+ * - URL detection in frames
+ * - Window-focused refresh
+ */
+
+describe('Timeline Navigation (S12)', () => {
+ before(async () => {
+ await browser.waitUntil(
+ async () => (await browser.execute(() => document.readyState)) === 'complete',
+ { timeout: 30000, timeoutMsg: 'app did not load' }
+ );
+
+ // Skip onboarding
+ try {
+ const skipBtn = await $('button*=skip');
+ if (await skipBtn.isDisplayed()) {
+ await skipBtn.click();
+ await browser.pause(500);
+ }
+ } catch {}
+ try {
+ const closeBtn = await $('button svg.lucide-x');
+ if (await closeBtn.isDisplayed()) {
+ await closeBtn.closest('button').click();
+ await browser.pause(500);
+ }
+ } catch {}
+ });
+
+ it('should have timeline visible on main page', async () => {
+ await browser.pause(3000);
+
+ const hasTimeline = await browser.execute(() => {
+ const body = document.body.innerText.toLowerCase();
+ return body.includes('am') || body.includes('pm') ||
+ body.includes('timeline') || body.includes(':');
+ });
+ // Timeline might not be visible in all states, but page should load
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+ });
+
+ it('should navigate with arrow keys without crash (S12.1)', async () => {
+ // Send left/right arrow keys to navigate timeline
+ for (let i = 0; i < 5; i++) {
+ await browser.keys(['ArrowLeft']);
+ await browser.pause(300);
+ }
+ for (let i = 0; i < 5; i++) {
+ await browser.keys(['ArrowRight']);
+ await browser.pause(300);
+ }
+
+ // App should still be responsive
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+
+ const bodyText = await browser.execute(() => document.body.innerText);
+ expect(bodyText).not.toContain('Unhandled Runtime Error');
+ });
+
+ it('should not clear frames during navigation (S12.3)', async () => {
+ // Navigate and check that content doesn't disappear
+ const beforeText = await browser.execute(() => document.body.innerText.length);
+
+ await browser.keys(['ArrowLeft']);
+ await browser.pause(500);
+ await browser.keys(['ArrowRight']);
+ await browser.pause(500);
+
+ const afterText = await browser.execute(() => document.body.innerText.length);
+
+ // Content length shouldn't drop drastically (indicating frame clearing)
+ // Allow 50% reduction as some content may change
+ expect(afterText).toBeGreaterThan(beforeText * 0.5);
+ });
+
+ it('should handle rapid navigation without crash (S12)', async () => {
+ // Rapid-fire arrow keys to stress test
+ for (let i = 0; i < 20; i++) {
+ await browser.keys([i % 2 === 0 ? 'ArrowLeft' : 'ArrowRight']);
+ // No pause — stress test
+ }
+ await browser.pause(2000);
+
+ const ready = await browser.execute(() => document.readyState);
+ expect(ready).toBe('complete');
+ });
+
+ it('should support search via API from UI context (S12.2)', async () => {
+ const data = await browser.execute(async () => {
+ const res = await fetch('http://localhost:3030/search?limit=10&content_type=ocr');
+ return res.json();
+ });
+
+ expect(data).toHaveProperty('data');
+ if (data.data.length > 1) {
+ // Verify results have timestamps and are ordered
+ const timestamps = data.data
+ .map(r => r.content?.timestamp || r.timestamp)
+ .filter(Boolean);
+
+ if (timestamps.length > 1) {
+ // Results should be in some order (desc by default)
+ const dates = timestamps.map(t => new Date(t).getTime());
+ const isSorted = dates.every((d, i) => i === 0 || d <= dates[i - 1]);
+ if (!isSorted) {
+ console.log('Warning: search results may not be sorted by time');
+ }
+ }
+ }
+ });
+
+ it('should detect URLs in search results (S12.4)', async () => {
+ const data = await browser.execute(async () => {
+ const res = await fetch('http://localhost:3030/search?limit=20&content_type=ocr');
+ return res.json();
+ });
+
+ // Check if any OCR results contain URLs
+ let urlCount = 0;
+ for (const item of (data.data || [])) {
+ const text = item?.content?.text || '';
+ if (text.match(/https?:\/\/[^\s]+/)) {
+ urlCount++;
+ }
+ }
+ console.log(`Found ${urlCount} results containing URLs`);
+ // Don't fail — URLs may not be on screen
+ });
+});