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
[codex] fix event trigger capture wiring (#3831)
Louis Beaumont1b955cc98d47
diff --git a/apps/screenpipe-app-tauri/e2e/COVERAGE.md b/apps/screenpipe-app-tauri/e2e/COVERAGE.mdindex babf23e79..d1f2bd33f 100644--- a/apps/screenpipe-app-tauri/e2e/COVERAGE.md+++ b/apps/screenpipe-app-tauri/e2e/COVERAGE.md@@ -7,8 +7,8 @@ and layer declared in the manifest, weighted by confidence and criticality.- Manifest: `e2e/coverage-map.json`- Specs directory: `e2e/specs`- Mapped specs: 41-- Declared test blocks: 143-- Weighted coverage points: 113.7+- Declared test blocks: 147+- Weighted coverage points: 115.3Confidence weights: strong=1.0, partial=0.7, conditional=0.4, smoke=0.3.Criticality weights: high=1.0, medium=0.7, low=0.4.@@ -19,7 +19,7 @@ can execute more runtime cases than this number shows.| Platform | Specs | Declared tests | Weighted points | Layers | Features | Critical score || --- | --- | --- | --- | --- | --- | --- |-| windows | 34 | 132 | 110.3 | 14 | 39 | 92% |+| windows | 34 | 136 | 111.9 | 14 | 39 | 92% || macos | 38 | 113 | 87.9 | 14 | 40 | 89% || linux | 29 | 101 | 84.3 | 12 | 36 | 86% |@@ -33,16 +33,16 @@ pass/fail/skip counts.| Layer | windows | macos | linux || --- | --- | --- | --- |-| audio-device | 2 specs / 22 tests / 17.8 pts | 1 specs / 1 tests / 0.3 pts | - |-| capture-ocr | 2 specs / 9 tests / 3.6 pts | 2 specs / 3 tests / 1.2 pts | 1 specs / 2 tests / 0.8 pts |+| audio-device | 2 specs / 26 tests / 19.4 pts | 1 specs / 1 tests / 0.3 pts | - |+| capture-ocr | 2 specs / 13 tests / 5.2 pts | 2 specs / 3 tests / 1.2 pts | 1 specs / 2 tests / 0.8 pts || chat-ai | 7 specs / 7 tests / 3.9 pts | 9 specs / 10 tests / 4.8 pts | 7 specs / 7 tests / 3.9 pts |-| local-api | 10 specs / 72 tests / 62.5 pts | 9 specs / 51 tests / 45.1 pts | 8 specs / 50 tests / 44.7 pts |+| local-api | 10 specs / 76 tests / 64.1 pts | 9 specs / 51 tests / 45.1 pts | 8 specs / 50 tests / 44.7 pts || notifications | 2 specs / 11 tests / 10.1 pts | 2 specs / 4 tests / 2.4 pts | 1 specs / 3 tests / 2.1 pts || onboarding | 1 specs / 3 tests / 1.2 pts | 1 specs / 3 tests / 1.2 pts | 1 specs / 3 tests / 1.2 pts || os-integration | 3 specs / 16 tests / 15.1 pts | 3 specs / 3 tests / 0.9 pts | - || performance | 2 specs / 43 tests / 43.0 pts | 4 specs / 33 tests / 29.5 pts | 1 specs / 28 tests / 28.0 pts || pipes | 1 specs / 7 tests / 7.0 pts | 1 specs / 7 tests / 7.0 pts | 1 specs / 7 tests / 7.0 pts |-| real-ui-e2e | 16 specs / 63 tests / 53.5 pts | 17 specs / 54 tests / 44.6 pts | 14 specs / 48 tests / 42.7 pts |+| real-ui-e2e | 16 specs / 67 tests / 55.1 pts | 17 specs / 54 tests / 44.6 pts | 14 specs / 48 tests / 42.7 pts || settings | 4 specs / 19 tests / 18.4 pts | 4 specs / 12 tests / 10.7 pts | 3 specs / 11 tests / 10.4 pts || storage-privacy | 4 specs / 19 tests / 18.4 pts | 3 specs / 11 tests / 10.4 pts | 3 specs / 11 tests / 10.4 pts || tauri-command | 8 specs / 17 tests / 10.3 pts | 9 specs / 19 tests / 10.8 pts | 8 specs / 17 tests / 10.3 pts |@@ -126,7 +126,7 @@ pass/fail/skip counts.| viewer-deeplink.spec.ts | windows, macos, linux | window-lifecycle, tauri-command | viewer-deeplink, window-lifecycle | medium | partial | command | 3 | Viewer window creation and per-path dedupe. || window-activation.spec.ts | macos | window-lifecycle, tauri-command, real-ui-e2e | window-lifecycle, chat | medium | conditional | real-user-flow | 2 | macOS-only show_window_activated focus coverage. || window-lifecycle.spec.ts | windows, macos, linux | window-lifecycle, tauri-command, real-ui-e2e | window-lifecycle, onboarding, tray-search | high | strong | mixed | 3 | Home, Search, and onboarding window routing. |-| windows-core-recording.spec.ts | windows | capture-ocr, local-api, audio-device, real-ui-e2e | capture-ocr, local-api-auth, local-api-search, audio-device-health, timeline | high | conditional | mixed | 7 | Windows recording-enabled lane; hosted runners can skip frame-dependent OCR assertions. |+| windows-core-recording.spec.ts | windows | capture-ocr, local-api, audio-device, real-ui-e2e | capture-ocr, local-api-auth, local-api-search, audio-device-health, timeline | high | conditional | mixed | 11 | Windows recording-enabled lane; hosted runners can skip frame-dependent OCR assertions. || windows-system-integration.spec.ts | windows | os-integration, local-api, audio-device, window-lifecycle, performance | app-launch, local-api-auth, audio-device-health, window-lifecycle, os-process-health, webview-stability | high | strong | mixed | 15 | Windows display, WebView2, loopback, process, Defender, audio, focus, and crash-report checks. || windows-user-journey.spec.ts | windows | real-ui-e2e, settings, notifications, storage-privacy, window-lifecycle | home-search, timeline, settings-recording, meeting-notes, shortcut-reminder, notifications, storage-retention, settings-privacy-api-auth | high | strong | real-user-flow | 8 | Windows-first real UX journey across search, timeline, settings, meetings, notifications, storage, and privacy. || zz-owned-browser-background-nav.spec.ts | windows, macos | os-integration, window-lifecycle | owned-browser, window-lifecycle | low | smoke | command | 0 | Owned browser background navigation visibility. |diff --git a/apps/screenpipe-app-tauri/e2e/README.md b/apps/screenpipe-app-tauri/e2e/README.mdindex 82dafae32..d17f97b24 100644--- a/apps/screenpipe-app-tauri/e2e/README.md+++ b/apps/screenpipe-app-tauri/e2e/README.md@@ -91,6 +91,14 @@ $env:RECORD_VIDEO="1"; bun run test:e2e# with OCR/Timeline assertions when the runner exposes usable frames; no-audio# keeps hosted runners out of Whisper startup while vision capture stays on)$env:SCREENPIPE_E2E_SEED="onboarding,no-audio"; bun run wdio run e2e/wdio.conf.ts --spec e2e/specs/windows-core-recording.spec.ts++# 6. Run the Windows event-trigger capture checks (keystroke/clipboard/window-focus+# triggers on; raw key and clipboard rows stay disabled and focus rows get linked)+$env:SCREENPIPE_E2E_SEED="onboarding,no-audio,event-trigger-capture"; bun run wdio run e2e/wdio.conf.ts --spec e2e/specs/windows-core-recording.spec.ts++# 7. Run the same trigger lane with raw key DB rows opted in; verifies key rows+# get linked frame_id too.+$env:SCREENPIPE_E2E_SEED="onboarding,no-audio,event-trigger-capture,keyboard-db-capture"; bun run wdio run e2e/wdio.conf.ts --spec e2e/specs/windows-core-recording.spec.ts```### Run a single specdiff --git a/apps/screenpipe-app-tauri/e2e/helpers/app-launcher.ts b/apps/screenpipe-app-tauri/e2e/helpers/app-launcher.tsindex 5e7a0eaba..89372eecf 100644--- a/apps/screenpipe-app-tauri/e2e/helpers/app-launcher.ts+++ b/apps/screenpipe-app-tauri/e2e/helpers/app-launcher.ts@@ -63,7 +63,9 @@ const APP_PID_FILE = resolve(E2E_DATA_DIR, 'app.pid');// Override with `SCREENPIPE_E2E_SEED=onboarding` (or any custom value) when// running on a host that DOES have TCC granted and you want to exercise the// real capture pipeline. Add `no-audio` when a lane only needs vision/OCR and-// should not boot Whisper. `cloud-audio-fallback` is an opt-in macOS seed that+// should not boot Whisper. Add `event-trigger-capture` for the Windows+// key/clipboard/window-focus trigger lane; raw key and clipboard rows stay+// disabled unless an explicit DB-capture seed opts them in. `cloud-audio-fallback` is an opt-in macOS seed that// leaves audio UI enabled, disables vision, and saves Screenpipe Cloud while// logged out so the fallback UX can be asserted. The same env var is read by// specs (e.g. timeline) to skip when recording is off.diff --git a/apps/screenpipe-app-tauri/e2e/specs/windows-core-recording.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/windows-core-recording.spec.tsindex 3374bd46b..d60a9d293 100644--- a/apps/screenpipe-app-tauri/e2e/specs/windows-core-recording.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/windows-core-recording.spec.ts@@ -34,11 +34,18 @@ import {const seedFlags = E2E_SEED_FLAGS.split(",").map((s) => s.trim().toLowerCase());const recordingDisabled = seedFlags.includes("no-recording");const canRun = process.platform === "win32" && !recordingDisabled;+const eventTriggerCaptureEnabled = seedFlags.includes("event-trigger-capture");+const canRunEventTriggerCapture = canRun && eventTriggerCaptureEnabled;+const keyboardDbCaptureEnabled = seedFlags.includes("keyboard-db-capture");type HealthBody = {status?: string;frame_status?: string;audio_status?: string;+ pipeline?: {+ frames_captured?: number;+ frames_db_written?: number;+ } | null;};type MarkerProbe = {@@ -47,6 +54,17 @@ type MarkerProbe = {rows: unknown[];};+type InputEventContent = {+ id?: number;+ timestamp?: string;+ event_type?: string;+ app_name?: string | null;+ window_title?: string | null;+ text_content?: string | null;+ key_code?: number | null;+ frame_id?: number | null;+};+function apiUrl(cfg: LocalApiConfig, path: string): string {return `http://127.0.0.1:${cfg.port}${path}`;}@@ -61,8 +79,31 @@ function collectText(value: unknown): string {return String(value);}+function psString(value: string): string {+ return `'${value.replace(/'/g, "''")}'`;+}++function spawnDetachedPowerShell(script: string): () => void {+ const child = spawn(+ "powershell.exe",+ ["-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-Command", script],+ { detached: true, stdio: "ignore", windowsHide: false },+ );+ child.unref();++ return () => {+ if (!child.pid) return;+ try {+ execFileSync("taskkill.exe", ["/PID", String(child.pid), "/T", "/F"], {+ stdio: "ignore",+ });+ } catch {+ // already closed+ }+ };+}+function spawnWindowsMarkerWindow(marker: string): () => void {- const safeMarker = marker.replace(/'/g, "''");const script = `Add-Type -AssemblyName System.Windows.FormsAdd-Type -AssemblyName System.Drawing@@ -76,28 +117,207 @@ $label = New-Object System.Windows.Forms.Label$label.Dock = 'Fill'$label.Font = New-Object System.Drawing.Font('Arial', 34, [System.Drawing.FontStyle]::Bold)$label.TextAlign = 'MiddleCenter'-$label.Text = '${safeMarker}'+$label.Text = ${psString(marker)}$form.Controls.Add($label)[void]$form.ShowDialog()`;- const child = spawn(- "powershell.exe",- ["-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-Command", script],- { detached: true, stdio: "ignore", windowsHide: false },- );- child.unref();+ return spawnDetachedPowerShell(script);+}- return () => {- if (!child.pid) return;- try {- execFileSync("taskkill.exe", ["/PID", String(child.pid), "/T", "/F"], {- stdio: "ignore",- });- } catch {- // already closed- }- };+function spawnWindowsFocusProbe(marker: string): () => void {+ const titleA = `${marker} focus alpha`;+ const titleB = `${marker} focus beta`;+ const script = `+Add-Type -AssemblyName System.Windows.Forms+Add-Type -AssemblyName System.Drawing+Add-Type @"+using System;+using System.Runtime.InteropServices;+public static class ScreenpipeE2EForeground {+ [DllImport("user32.dll")]+ public static extern bool SetForegroundWindow(IntPtr hWnd);+}+"@+$formA = New-Object System.Windows.Forms.Form+$formA.Text = ${psString(titleA)}+$formA.StartPosition = 'CenterScreen'+$formA.Width = 720+$formA.Height = 240+$formA.TopMost = $true+$labelA = New-Object System.Windows.Forms.Label+$labelA.Dock = 'Fill'+$labelA.Font = New-Object System.Drawing.Font('Arial', 24, [System.Drawing.FontStyle]::Bold)+$labelA.TextAlign = 'MiddleCenter'+$labelA.Text = ${psString(titleA)}+$formA.Controls.Add($labelA)++$formB = New-Object System.Windows.Forms.Form+$formB.Text = ${psString(titleB)}+$formB.StartPosition = 'CenterScreen'+$formB.Width = 720+$formB.Height = 240+$formB.Left = $formA.Left + 60+$formB.Top = $formA.Top + 60+$formB.TopMost = $true+$labelB = New-Object System.Windows.Forms.Label+$labelB.Dock = 'Fill'+$labelB.Font = New-Object System.Drawing.Font('Arial', 24, [System.Drawing.FontStyle]::Bold)+$labelB.TextAlign = 'MiddleCenter'+$labelB.Text = ${psString(titleB)}+$formB.Controls.Add($labelB)++$script:step = 0+$timer = New-Object System.Windows.Forms.Timer+$timer.Interval = 700+$timer.Add_Tick({+ if ($script:step -eq 0) {+ [void][ScreenpipeE2EForeground]::SetForegroundWindow($formA.Handle)+ $formA.Activate()+ } elseif ($script:step -eq 1) {+ [void][ScreenpipeE2EForeground]::SetForegroundWindow($formB.Handle)+ $formB.Activate()+ } elseif ($script:step -eq 2) {+ [void][ScreenpipeE2EForeground]::SetForegroundWindow($formA.Handle)+ $formA.Activate()+ } elseif ($script:step -eq 3) {+ [void][ScreenpipeE2EForeground]::SetForegroundWindow($formB.Handle)+ $formB.Activate()+ } else {+ $timer.Stop()+ }+ $script:step += 1+})+$formA.Show()+$formB.Show()+$timer.Start()+[System.Windows.Forms.Application]::Run()+`;++ return spawnDetachedPowerShell(script);+}++function spawnWindowsKeyProbe(marker: string): () => void {+ const title = `${marker} key window`;+ const script = `+Add-Type -AssemblyName System.Windows.Forms+Add-Type -AssemblyName System.Drawing+Add-Type @"+using System;+using System.Runtime.InteropServices;+public static class ScreenpipeE2EForeground {+ [DllImport("user32.dll")]+ public static extern bool SetForegroundWindow(IntPtr hWnd);+}+"@+$form = New-Object System.Windows.Forms.Form+$form.Text = ${psString(title)}+$form.StartPosition = 'CenterScreen'+$form.Width = 820+$form.Height = 320+$form.TopMost = $true+$label = New-Object System.Windows.Forms.Label+$label.Dock = 'Top'+$label.Height = 110+$label.Font = New-Object System.Drawing.Font('Arial', 22, [System.Drawing.FontStyle]::Bold)+$label.TextAlign = 'MiddleCenter'+$label.Text = ${psString(`${marker} waiting`)}+$textbox = New-Object System.Windows.Forms.TextBox+$textbox.Dock = 'Fill'+$textbox.Multiline = $true+$textbox.Font = New-Object System.Drawing.Font('Consolas', 18)+$textbox.Text = ${psString(`${marker} textbox`)}+$form.Controls.Add($textbox)+$form.Controls.Add($label)++$script:step = -3+$timer = New-Object System.Windows.Forms.Timer+$timer.Interval = 750+$timer.Add_Tick({+ [void][ScreenpipeE2EForeground]::SetForegroundWindow($form.Handle)+ $form.Activate()+ $textbox.Focus()+ if ($script:step -lt 0) {+ $label.Text = ${psString(`${marker} ready`)}+ } elseif ($script:step -eq 0) {+ $label.Text = ${psString(`${marker} first key`)}+ [System.Windows.Forms.SendKeys]::SendWait('{F5}')+ } elseif ($script:step -eq 1) {+ $label.Text = ${psString(`${marker} second key`)}+ [System.Windows.Forms.SendKeys]::SendWait('{TAB}')+ } elseif ($script:step -eq 2) {+ $label.Text = ${psString(`${marker} modifier key`)}+ [System.Windows.Forms.SendKeys]::SendWait('^s')+ } else {+ $timer.Stop()+ }+ $script:step += 1+})+$form.Show()+$timer.Start()+[System.Windows.Forms.Application]::Run($form)+`;++ return spawnDetachedPowerShell(script);+}++function spawnWindowsClipboardProbe(marker: string): () => void {+ const title = `${marker} clipboard window`;+ const script = `+Add-Type -AssemblyName System.Windows.Forms+Add-Type -AssemblyName System.Drawing+Add-Type @"+using System;+using System.Runtime.InteropServices;+public static class ScreenpipeE2EForeground {+ [DllImport("user32.dll")]+ public static extern bool SetForegroundWindow(IntPtr hWnd);+}+"@+$form = New-Object System.Windows.Forms.Form+$form.Text = ${psString(title)}+$form.StartPosition = 'CenterScreen'+$form.Width = 820+$form.Height = 320+$form.TopMost = $true+$label = New-Object System.Windows.Forms.Label+$label.Dock = 'Top'+$label.Height = 110+$label.Font = New-Object System.Drawing.Font('Arial', 22, [System.Drawing.FontStyle]::Bold)+$label.TextAlign = 'MiddleCenter'+$label.Text = ${psString(`${marker} waiting`)}+$textbox = New-Object System.Windows.Forms.TextBox+$textbox.Dock = 'Fill'+$textbox.Multiline = $true+$textbox.Font = New-Object System.Drawing.Font('Consolas', 18)+$textbox.Text = ${psString(`${marker} clipboard payload`)}+$form.Controls.Add($textbox)+$form.Controls.Add($label)++$script:step = -4+$timer = New-Object System.Windows.Forms.Timer+$timer.Interval = 750+$timer.Add_Tick({+ [void][ScreenpipeE2EForeground]::SetForegroundWindow($form.Handle)+ $form.Activate()+ $textbox.Focus()+ if ($script:step -lt 0) {+ $label.Text = ${psString(`${marker} ready`)}+ } elseif ($script:step -eq 0) {+ $label.Text = ${psString(`${marker} copy`)}+ $textbox.SelectAll()+ [System.Windows.Forms.SendKeys]::SendWait('^c')+ } else {+ $timer.Stop()+ }+ $script:step += 1+})+$form.Show()+$timer.Start()+[System.Windows.Forms.Application]::Run($form)+`;++ return spawnDetachedPowerShell(script);}async function getHealth(port: number): Promise<HealthBody> {@@ -110,6 +330,115 @@ async function getHealth(port: number): Promise<HealthBody> {return res.body as HealthBody;}+function asInputEventContent(row: unknown): InputEventContent | null {+ if (typeof row !== "object" || row == null) return null;+ const record = row as Record<string, unknown>;+ const content = record.content;+ if (record.type === "Input" && typeof content === "object" && content != null) {+ return content as InputEventContent;+ }+ if (typeof record.event_type === "string") {+ return record as InputEventContent;+ }+ return null;+}++async function inputRowsSince(+ cfg: LocalApiConfig,+ sinceIso: string,+ q: string,+): Promise<InputEventContent[]> {+ const res = await fetchJson(+ apiUrl(+ cfg,+ `/search?content_type=input&limit=50&q=${encodeURIComponent(q)}&start_time=${encodeURIComponent(sinceIso)}`,+ ),+ authHeaders(cfg.key),+ );+ if (!res.ok) return [];+ const data = (res.body as { data?: unknown[] } | null)?.data;+ if (!Array.isArray(data)) return [];+ return data.map(asInputEventContent).filter((row): row is InputEventContent => row !== null);+}++async function frameTimestampMs(cfg: LocalApiConfig, frameId: number): Promise<number | null> {+ const res = await fetchJson(+ apiUrl(cfg, `/frames/${frameId}/metadata`),+ authHeaders(cfg.key),+ );+ if (!res.ok || typeof res.body !== "object" || res.body == null) return null;+ const timestamp = (res.body as { timestamp?: unknown }).timestamp;+ if (typeof timestamp !== "string") return null;+ const parsed = Date.parse(timestamp);+ return Number.isFinite(parsed) ? parsed : null;+}++async function waitForLinkedFreshInputEvent(+ cfg: LocalApiConfig,+ sinceIso: string,+ query: string,+ predicate: (row: InputEventContent) => boolean,+ label: string,+ timeoutMs = t(75_000),+): Promise<InputEventContent[]> {+ const sinceMs = Date.parse(sinceIso);+ let latestRows: InputEventContent[] = [];+ let freshLinkedRows: InputEventContent[] = [];++ await browser.waitUntil(+ async () => {+ latestRows = await inputRowsSince(cfg, sinceIso, query);+ const candidates = latestRows.filter(+ (row) => predicate(row) && typeof row.frame_id === "number" && row.frame_id > 0,+ );+ freshLinkedRows = [];+ for (const row of candidates) {+ const frameMs = await frameTimestampMs(cfg, row.frame_id!);+ if (frameMs != null && frameMs >= sinceMs) {+ freshLinkedRows.push(row);+ }+ }+ return freshLinkedRows.length > 0;+ },+ {+ timeout: timeoutMs,+ interval: 2_000,+ timeoutMsg: `${label} input event never received a fresh linked frame_id`,+ },+ );++ return freshLinkedRows.length > 0 ? freshLinkedRows : latestRows;+}++function framesDbWritten(health: HealthBody): number {+ return typeof health.pipeline?.frames_db_written === "number"+ ? health.pipeline.frames_db_written+ : 0;+}++async function waitForFrameWriteAfter(+ cfg: LocalApiConfig,+ beforeFrames: number,+ label = "event trigger",+ timeoutMs = t(75_000),+): Promise<HealthBody> {+ let latestHealth = await getHealth(cfg.port);++ await browser.waitUntil(+ async () => {+ latestHealth = await getHealth(cfg.port);+ return framesDbWritten(latestHealth) > beforeFrames;+ },+ {+ timeout: timeoutMs,+ interval: 1_500,+ timeoutMsg: `${label} did not produce a newly written frame`,+ },+ );++ return latestHealth;+}+async function tryWaitForFrameCapture(cfg: LocalApiConfig,timeoutMs = t(60_000),@@ -325,6 +654,106 @@ describe("Windows core recording pipeline", function () {expect(probe.rows.length).toBeGreaterThan(0);});+ it("links window focus events to captured frames", async function () {+ if (!canRunEventTriggerCapture || !cfg) this.skip();++ const health = await tryWaitForFrameCapture(cfg, t(45_000));+ if (health.frame_status !== "ok") this.skip();++ const marker = `SCREENPIPE FOCUS TRIGGER ${Date.now()}`;+ const sinceIso = new Date(Date.now() - 1_000).toISOString();+ cleanupMarkerWindow = spawnWindowsFocusProbe(marker);++ const rows = await waitForLinkedFreshInputEvent(+ cfg,+ sinceIso,+ marker,+ (row) =>+ row.event_type === "window_focus" &&+ (row.window_title ?? "").toLowerCase().includes(marker.toLowerCase()),+ "window_focus",+ );++ const linked = rows.find((row) => row.event_type === "window_focus");+ expect(linked?.frame_id).toBeGreaterThan(0);+ });++ it("uses keystrokes as capture triggers without storing raw key rows by default", async function () {+ if (!canRunEventTriggerCapture || !cfg) this.skip();+ if (keyboardDbCaptureEnabled) this.skip();++ const health = await tryWaitForFrameCapture(cfg, t(45_000));+ if (health.frame_status !== "ok") this.skip();++ const marker = `SCREENPIPE KEY TRIGGER ${Date.now()}`;+ const sinceIso = new Date(Date.now() - 1_000).toISOString();+ cleanupMarkerWindow = spawnWindowsKeyProbe(marker);+ await browser.pause(t(1_500));+ const beforeFrames = framesDbWritten(await getHealth(cfg.port));++ const afterHealth = await waitForFrameWriteAfter(cfg, beforeFrames);+ expect(framesDbWritten(afterHealth)).toBeGreaterThan(beforeFrames);++ await browser.pause(t(2_500));+ const keyRows = (await inputRowsSince(cfg, sinceIso, marker)).filter(+ (row) =>+ row.event_type === "key" &&+ (row.window_title ?? "").toLowerCase().includes(marker.toLowerCase()),+ );++ expect(keyRows.length).toBe(0);+ });++ it("uses clipboard operations as capture triggers without storing clipboard rows by default", async function () {+ if (!canRunEventTriggerCapture || !cfg) this.skip();++ const health = await tryWaitForFrameCapture(cfg, t(45_000));+ if (health.frame_status !== "ok") this.skip();++ const marker = `SCREENPIPE CLIPBOARD TRIGGER ${Date.now()}`;+ const sinceIso = new Date(Date.now() - 1_000).toISOString();+ cleanupMarkerWindow = spawnWindowsClipboardProbe(marker);+ await browser.pause(t(1_500));+ const beforeFrames = framesDbWritten(await getHealth(cfg.port));++ const afterHealth = await waitForFrameWriteAfter(cfg, beforeFrames, "clipboard trigger");+ expect(framesDbWritten(afterHealth)).toBeGreaterThan(beforeFrames);++ await browser.pause(t(2_500));+ const clipboardRows = (await inputRowsSince(cfg, sinceIso, marker)).filter(+ (row) =>+ row.event_type === "clipboard" &&+ ((row.window_title ?? "").toLowerCase().includes(marker.toLowerCase()) ||+ (row.text_content ?? "").toLowerCase().includes(marker.toLowerCase())),+ );++ expect(clipboardRows.length).toBe(0);+ });++ it("links opt-in raw key rows to captured frames", async function () {+ if (!canRunEventTriggerCapture || !keyboardDbCaptureEnabled || !cfg) this.skip();++ const health = await tryWaitForFrameCapture(cfg, t(45_000));+ if (health.frame_status !== "ok") this.skip();++ const marker = `SCREENPIPE KEY DB TRIGGER ${Date.now()}`;+ const sinceIso = new Date(Date.now() - 1_000).toISOString();+ cleanupMarkerWindow = spawnWindowsKeyProbe(marker);++ const rows = await waitForLinkedFreshInputEvent(+ cfg,+ sinceIso,+ marker,+ (row) =>+ row.event_type === "key" &&+ (row.window_title ?? "").toLowerCase().includes(marker.toLowerCase()),+ "key",+ );++ const linked = rows.find((row) => row.event_type === "key");+ expect(linked?.frame_id).toBeGreaterThan(0);+ });+it("finds captured OCR through query search and recent-time filtering", async function () {if (!canRun || !cfg) this.skip();diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex 539e19bab..0f8f5449e 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -2410,21 +2410,16 @@ hdRecordingDefault?: string;*/hdRecordingIntervalMs?: number;/**- * Override `EventDrivenCaptureConfig::capture_on_keystroke`.- * None = engine default (false). When true, non-printable key events- * (Arrow / Enter / Tab / Esc, modifier combos like Ctrl+S) fire a paired- * capture so `ui_events.frame_id` is populated for the originating row.- * Off by default — fast typing can generate a storm of captures even- * with the 200ms `min_capture_interval_ms` debounce.+ * Legacy key-trigger override retained for settings compatibility.+ * Recording sessions keep keyboard-triggered capture on; raw key/text DB+ * rows are controlled separately by `disableKeyboardCapture`.*/captureOnKeystroke?: boolean | null;/*** Override `EventDrivenCaptureConfig::capture_on_clipboard`.* None = engine default (false). When true, clipboard changes fire a- * paired capture so `ui_events.frame_id` is populated for the- * clipboard row. Off by default — adds 50-150ms of blocking work per- * Ctrl+C/X/V (more with OCR fallback) which can cause visible HID lag- * on some USB devices.+ * paired capture. Clipboard DB rows are still controlled separately by+ * `disableClipboardCapture`.*/captureOnClipboard?: boolean | null;/**@@ -2477,19 +2472,18 @@ ignoreIncognitoWindows: boolean;*/pauseOnDrmContent?: boolean;/**- * Skip clipboard capture in the UI recorder. Defaults to `true`- * (clipboard capture OFF) — passwords / API keys / private keys- * frequently pass through the clipboard, so it's opt-in via the- * "Capture clipboard" toggle.+ * Skip persisting clipboard rows/content in the UI recorder. Defaults to+ * `true` (clipboard DB capture OFF) — passwords / API keys / private keys+ * frequently pass through the clipboard. Clipboard operations can still+ * wake event-driven capture when `captureOnClipboard` is enabled.*/disableClipboardCapture?: boolean;/**- * Skip keyboard / typed-text capture in the UI recorder- * (`UiCaptureConfig::capture_text`). Defaults to `true` (keyboard- * capture OFF) — the raw keystroke stream is the highest-risk,- * most-redundant signal (secrets get typed), and the accessibility- * tree + OCR still capture on-screen text so Rewind/Ask keep working.- * Opt-in via the "Capture keyboard" toggle.+ * Skip persisting keyboard / typed-text rows in the UI recorder.+ * Defaults to `true` (keyboard DB capture OFF). Keyboard events still+ * wake event-driven capture, and the accessibility tree + OCR still+ * capture on-screen text so Rewind/Ask keep working.+ * Opt in to keyboard DB rows via the "Capture keyboard" toggle.*/disableKeyboardCapture?: boolean;/**diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 3ef499100..8557db360 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -1079,6 +1079,18 @@ async fn main() {store.recording.disable_audio = true;info!("E2E seed: audio disabled");}+ if e2e_flags.iter().any(|f| f == "event-trigger-capture") {+ store.recording.capture_on_keystroke = Some(true);+ store.recording.capture_on_clipboard = Some(true);+ store.recording.min_capture_interval_ms = Some(50);+ store.recording.disable_keyboard_capture = true;+ store.recording.disable_clipboard_capture = true;+ info!("E2E seed: event-trigger capture enabled with keyboard/clipboard DB rows disabled");+ }+ if e2e_flags.iter().any(|f| f == "keyboard-db-capture") {+ store.recording.disable_keyboard_capture = false;+ info!("E2E seed: keyboard DB capture enabled");+ }if e2e_flags.iter().any(|f| f == "cloud-audio-fallback") {store.recording.disable_audio = false;store.recording.disable_vision = true;diff --git a/crates/screenpipe-a11y/src/config.rs b/crates/screenpipe-a11y/src/config.rsindex 686a4e6ac..6bef4b545 100644--- a/crates/screenpipe-a11y/src/config.rs+++ b/crates/screenpipe-a11y/src/config.rs@@ -24,7 +24,8 @@ pub struct UiCaptureConfig {/// Capture aggregated text inputpub capture_text: bool,- /// Capture individual keystrokes (privacy risk - disabled by default)+ /// Emit individual key events. The engine decides whether those events+ /// are persisted or used only as capture triggers.pub capture_keystrokes: bool,/// Capture app switchesdiff --git a/crates/screenpipe-a11y/src/platform/linux.rs b/crates/screenpipe-a11y/src/platform/linux.rsindex d72631290..5963b0c0b 100644--- a/crates/screenpipe-a11y/src/platform/linux.rs+++ b/crates/screenpipe-a11y/src/platform/linux.rs@@ -678,21 +678,23 @@ fn monitor_keyboards(// Modifier + key → record as Key eventif ctrl_held || super_held {- let event = UiEvent {- id: None,- timestamp: Utc::now(),- relative_ms: t,- data: EventData::Key {- key_code: code,- modifiers: mods.0,- },- app_name,- window_title,- browser_url: None,- element: None,- frame_id: None,- };- let _ = tx.try_send(event);+ if config.capture_keystrokes {+ let event = UiEvent {+ id: None,+ timestamp: Utc::now(),+ relative_ms: t,+ data: EventData::Key {+ key_code: code,+ modifiers: mods.0,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = tx.try_send(event);+ }} else if config.capture_text {// Normal key → aggregate into text bufferif let Some(c) = evdev_key_to_char(key, shift_held) {@@ -714,6 +716,22 @@ fn monitor_keyboards(};let _ = tx.try_send(event);}+ } else if config.capture_keystrokes {+ let event = UiEvent {+ id: None,+ timestamp: Utc::now(),+ relative_ms: t,+ data: EventData::Key {+ key_code: code,+ modifiers: mods.0,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = tx.try_send(event);}}}diff --git a/crates/screenpipe-a11y/src/platform/macos.rs b/crates/screenpipe-a11y/src/platform/macos.rsindex 5c0cfb3f3..0581008d8 100644--- a/crates/screenpipe-a11y/src/platform/macos.rs+++ b/crates/screenpipe-a11y/src/platform/macos.rs@@ -903,21 +903,23 @@ extern "C" fn tap_callback(// Record key events for shortcutsif mods.any_modifier() {- let event = UiEvent {- id: None,- timestamp,- relative_ms: t,- data: EventData::Key {- key_code: keycode,- modifiers: mods.0,- },- app_name,- window_title,- browser_url: None,- element: None,- frame_id: None,- };- let _ = state.tx.try_send(event);+ if state.config.capture_keystrokes {+ let event = UiEvent {+ id: None,+ timestamp,+ relative_ms: t,+ data: EventData::Key {+ key_code: keycode,+ modifiers: mods.0,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = state.tx.try_send(event);+ }} else if state.config.capture_text {// Aggregate into text bufferif let Some(c) = keycode_to_char(keycode, mods) {@@ -940,6 +942,22 @@ extern "C" fn tap_callback(};let _ = state.tx.try_send(event);}+ } else if state.config.capture_keystrokes {+ let event = UiEvent {+ id: None,+ timestamp,+ relative_ms: t,+ data: EventData::Key {+ key_code: keycode,+ modifiers: mods.0,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = state.tx.try_send(event);}}diff --git a/crates/screenpipe-a11y/src/platform/windows.rs b/crates/screenpipe-a11y/src/platform/windows.rsindex 30afb2524..0ae86a15b 100644--- a/crates/screenpipe-a11y/src/platform/windows.rs+++ b/crates/screenpipe-a11y/src/platform/windows.rs@@ -675,21 +675,23 @@ unsafe extern "system" fn keyboard_hook_proc(code: i32, wparam: WPARAM, lparam:// Record key events for shortcuts (with modifiers)if mods & 0x0A != 0 {// Ctrl or Win pressed- let event = UiEvent {- id: None,- timestamp,- relative_ms: t,- data: EventData::Key {- key_code: vk_code,- modifiers: mods,- },- app_name,- window_title,- browser_url: None,- element: None,- frame_id: None,- };- let _ = s.tx.try_send(event);+ if s.config.capture_keystrokes {+ let event = UiEvent {+ id: None,+ timestamp,+ relative_ms: t,+ data: EventData::Key {+ key_code: vk_code,+ modifiers: mods,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = s.tx.try_send(event);+ }} else if s.config.capture_text {// Aggregate text inputif let Some(c) = vk_to_char(vk_code, mods) {@@ -718,6 +720,22 @@ unsafe extern "system" fn keyboard_hook_proc(code: i32, wparam: WPARAM, lparam:};let _ = s.tx.try_send(event);}+ } else if s.config.capture_keystrokes {+ let event = UiEvent {+ id: None,+ timestamp,+ relative_ms: t,+ data: EventData::Key {+ key_code: vk_code,+ modifiers: mods,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = s.tx.try_send(event);}}});diff --git a/crates/screenpipe-config/src/recording.rs b/crates/screenpipe-config/src/recording.rsindex e232550e3..298fadb1a 100644--- a/crates/screenpipe-config/src/recording.rs+++ b/crates/screenpipe-config/src/recording.rs@@ -229,21 +229,16 @@ pub struct RecordingSettings {)]pub hd_recording_interval_ms: u64,- /// Override `EventDrivenCaptureConfig::capture_on_keystroke`.- /// None = engine default (false). When true, non-printable key events- /// (Arrow / Enter / Tab / Esc, modifier combos like Ctrl+S) fire a paired- /// capture so `ui_events.frame_id` is populated for the originating row.- /// Off by default — fast typing can generate a storm of captures even- /// with the 200ms `min_capture_interval_ms` debounce.+ /// Legacy key-trigger override retained for settings compatibility.+ /// Recording sessions keep keyboard-triggered capture on; raw key/text DB+ /// rows are controlled separately by `disableKeyboardCapture`.#[serde(rename = "captureOnKeystroke", default)]pub capture_on_keystroke: Option<bool>,/// Override `EventDrivenCaptureConfig::capture_on_clipboard`./// None = engine default (false). When true, clipboard changes fire a- /// paired capture so `ui_events.frame_id` is populated for the- /// clipboard row. Off by default — adds 50-150ms of blocking work per- /// Ctrl+C/X/V (more with OCR fallback) which can cause visible HID lag- /// on some USB devices.+ /// paired capture. Clipboard DB rows are still controlled separately by+ /// `disableClipboardCapture`.#[serde(rename = "captureOnClipboard", default)]pub capture_on_clipboard: Option<bool>,@@ -303,19 +298,18 @@ pub struct RecordingSettings {#[serde(rename = "pauseOnDrmContent", default)]pub pause_on_drm_content: bool,- /// Skip clipboard capture in the UI recorder. Defaults to `true`- /// (clipboard capture OFF) — passwords / API keys / private keys- /// frequently pass through the clipboard, so it's opt-in via the- /// "Capture clipboard" toggle.+ /// Skip persisting clipboard rows/content in the UI recorder. Defaults to+ /// `true` (clipboard DB capture OFF) — passwords / API keys / private keys+ /// frequently pass through the clipboard. Clipboard operations can still+ /// wake event-driven capture when `captureOnClipboard` is enabled.#[serde(rename = "disableClipboardCapture", default = "default_true")]pub disable_clipboard_capture: bool,- /// Skip keyboard / typed-text capture in the UI recorder- /// (`UiCaptureConfig::capture_text`). Defaults to `true` (keyboard- /// capture OFF) — the raw keystroke stream is the highest-risk,- /// most-redundant signal (secrets get typed), and the accessibility- /// tree + OCR still capture on-screen text so Rewind/Ask keep working.- /// Opt-in via the "Capture keyboard" toggle.+ /// Skip persisting keyboard / typed-text rows in the UI recorder.+ /// Defaults to `true` (keyboard DB capture OFF). Keyboard events still+ /// wake event-driven capture, and the accessibility tree + OCR still+ /// capture on-screen text so Rewind/Ask keep working.+ /// Opt in to keyboard DB rows via the "Capture keyboard" toggle.#[serde(rename = "disableKeyboardCapture", default = "default_true")]pub disable_keyboard_capture: bool,diff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rsindex 0e546aa22..a74d4cee9 100644--- a/crates/screenpipe-engine/src/cli/mod.rs+++ b/crates/screenpipe-engine/src/cli/mod.rs@@ -507,19 +507,15 @@ pub struct RecordArgs {#[arg(long)]pub min_capture_interval_ms: Option<u64>,- /// Mitsukeru fork: override `EventDrivenCaptureConfig::capture_on_keystroke`.- /// When true, non-printable key events (Arrow/Enter/Tab/Esc, modifier- /// combos like Ctrl+S) fire a paired capture so `ui_events.frame_id`- /// is populated for the originating row. Off by default — fast typing- /// can flood the pipeline even with the min-capture-interval debounce.+ /// Legacy key-trigger override. Recording sessions keep keyboard-triggered+ /// capture on; raw key/text DB rows are controlled separately by+ /// `--disable-keyboard-capture`.#[arg(long)]pub capture_on_keystroke: Option<bool>,/// Mitsukeru fork: override `EventDrivenCaptureConfig::capture_on_clipboard`.- /// When true, clipboard changes fire a paired capture so the clipboard- /// row's `frame_id` is linked. Off by default — adds 50-150ms of- /// blocking work per Ctrl+C/X/V (more with OCR fallback) which can- /// cause visible HID input lag on some USB devices.+ /// When true, clipboard changes fire a paired capture. Clipboard DB row+ /// persistence is controlled separately by `--disable-clipboard-capture`.#[arg(long)]pub capture_on_clipboard: Option<bool>,@@ -589,10 +585,10 @@ pub struct RecordArgs {#[arg(long, default_value_t = false)]pub disable_clipboard_capture: bool,- /// Disable keyboard / typed-text capture entirely. The UI recorder will- /// not record what you type (`capture_text`) — the accessibility tree +- /// OCR still capture on-screen text. Useful when piping ~/.screenpipe- /// data into a remote LLM (secrets get typed).+ /// Disable persisting keyboard / typed-text rows. Keyboard events still+ /// wake event-driven capture, and the accessibility tree + OCR still+ /// capture on-screen text. Useful when piping ~/.screenpipe data into a+ /// remote LLM (secrets get typed).#[arg(long, default_value_t = false)]pub disable_keyboard_capture: bool,@@ -783,11 +779,10 @@ impl RecordArgs {/// Create UI recorder configuration from record argumentspub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {- // Mirror `--capture-on-keystroke` / `--capture-on-clipboard` into- // the recorder so it doesn't mint corr_ids for triggers the- // capture loop will drop. None = engine default (false), same as- // in `RecordingConfig::to_ui_recorder_config`.let defaults = crate::ui_recorder::UiRecorderConfig::default();+ let capture_on_clipboard = self+ .capture_on_clipboard+ .unwrap_or(defaults.capture_on_clipboard);crate::ui_recorder::UiRecorderConfig {enabled: true,enable_tree_walker: true,@@ -795,19 +790,22 @@ impl RecordArgs {excluded_windows: self.ignored_windows.clone(),ignored_windows: self.ignored_windows.clone(),included_windows: self.included_windows.clone(),- // --disable-clipboard-capture flips both flags off. Defaults are- // `true` for both, so opting out has to be explicit.- capture_clipboard: !self.disable_clipboard_capture,+ // Keep operation detection alive when clipboard-triggered capture+ // is enabled, but do not store rows/content when the user opted out.+ capture_clipboard: !self.disable_clipboard_capture || capture_on_clipboard,capture_clipboard_content: !self.disable_clipboard_capture,- // --disable-keyboard-capture drops the typed-text stream; the- // a11y tree + OCR still capture on-screen text.+ // Keyboard events always reach the recorder so they can wake+ // event-driven capture. --disable-keyboard-capture only stops+ // text/key rows from being persisted.capture_text: !self.disable_keyboard_capture,- capture_on_keystroke: self- .capture_on_keystroke- .unwrap_or(defaults.capture_on_keystroke),- capture_on_clipboard: self- .capture_on_clipboard- .unwrap_or(defaults.capture_on_clipboard),+ capture_keystrokes: true,+ record_keyboard_events: !self.disable_keyboard_capture,+ record_clipboard_events: !self.disable_clipboard_capture,+ // Same-app title changes must reach the event-driven trigger+ // mapper so focus changes can produce linked captures.+ capture_window_focus: true,+ capture_on_keystroke: true,+ capture_on_clipboard,capture_scroll: self.capture_scroll.unwrap_or(defaults.capture_scroll),..defaults}@@ -1907,6 +1905,35 @@ mod tests {}}+ #[test]+ fn test_cli_trigger_sources_survive_sensitive_storage_opt_out() {+ let cli = Cli::try_parse_from([+ "screenpipe",+ "record",+ "--capture-on-clipboard",+ "true",+ "--disable-keyboard-capture",+ "--disable-clipboard-capture",+ ])+ .unwrap();++ match cli.command {+ Command::Record(args) => {+ let ui = args.to_ui_recorder_config();+ assert!(ui.capture_window_focus);+ assert!(ui.capture_keystrokes);+ assert!(ui.capture_on_keystroke);+ assert!(ui.capture_clipboard);+ assert!(ui.capture_on_clipboard);+ assert!(!ui.capture_clipboard_content);+ assert!(!ui.capture_text);+ assert!(!ui.record_keyboard_events);+ assert!(!ui.record_clipboard_events);+ }+ _ => panic!("expected Record command"),+ }+ }+#[test]fn test_survey_command_parses() {let cli = Cli::try_parse_from(["screenpipe", "survey"]).unwrap();diff --git a/crates/screenpipe-engine/src/event_driven_capture.rs b/crates/screenpipe-engine/src/event_driven_capture.rsindex d30f2f1b3..dc31b107c 100644--- a/crates/screenpipe-engine/src/event_driven_capture.rs+++ b/crates/screenpipe-engine/src/event_driven_capture.rs@@ -58,11 +58,9 @@ pub enum CaptureTrigger {TypingPause,/// User stopped scrollingScrollStop,- /// A non-printable key was pressed (Arrow / Enter / Tab / Esc, or- /// modifier combo like Ctrl+S) while `capture_keystrokes=true`.- /// Only fires when `capture_on_keystroke=true` — off by default- /// to avoid the capture-per-keystroke storm that would otherwise- /// happen during heavy keyboard use.+ /// A keyboard event was observed while key-event listening is enabled.+ /// Raw key/text DB persistence is controlled separately by the recorder.+ /// Only fires when `capture_on_keystroke=true`.KeyPress,/// Clipboard content changedClipboard,@@ -219,18 +217,15 @@ pub struct EventDrivenCaptureConfig {pub jpeg_quality: u8,/// Whether to capture on clicks.pub capture_on_click: bool,- /// Whether to capture on non-printable keypresses when the a11y- /// layer has `capture_keystrokes=true`. Off by default — turning- /// this on can fire dozens of captures during a fast typing burst.+ /// Whether to capture on key events when the a11y layer has+ /// `capture_keystrokes=true`. Recording sessions force this on; the+ /// lower-level default stays conservative for library callers.pub capture_on_keystroke: bool,/// Whether to capture on clipboard changes. **Off by default**:/// taking a full paired capture (screenshot + tree walk + OCR) on- /// every Ctrl+C/X/V costs 250–800ms of blocking work and tends to- /// saturate the thread pool, causing visible input lag on USB HID- /// devices. The clipboard text is already stored in `ui_events`- /// via the input event batch — only the frame would be missing.- /// When this is false, Clipboard rows leave `frame_id` as NULL.- /// Flip to true to opt into linkage and accept the latency.+ /// every Ctrl+C/X/V costs 250-800ms of blocking work and can cause+ /// visible input lag on USB HID devices. Clipboard row persistence+ /// is controlled separately by the UI recorder.pub capture_on_clipboard: bool,/// Interval (ms) between visual-change checks (screenshot + frame diff)./// Set to 0 to disable visual change detection.diff --git a/crates/screenpipe-engine/src/recording_config.rs b/crates/screenpipe-engine/src/recording_config.rsindex 3b12a3443..5d1b6740d 100644--- a/crates/screenpipe-engine/src/recording_config.rs+++ b/crates/screenpipe-engine/src/recording_config.rs@@ -84,14 +84,14 @@ pub struct RecordingConfig {pub ignore_incognito_windows: bool,/// Pause all screen capture when a DRM streaming app (Netflix, etc.) is focused.pub pause_on_drm_content: bool,- /// Skip clipboard capture in the UI recorder (events + content). Useful- /// when piping ~/.screenpipe data into a remote LLM or shipping it off- /// the box — passwords / api keys / private keys frequently flow- /// through the clipboard.+ /// Skip persisting clipboard rows/content in the UI recorder. Clipboard+ /// operations can still wake event-driven capture when clipboard-triggered+ /// capture is enabled.pub disable_clipboard_capture: bool,- /// Skip keyboard / typed-text capture in the UI recorder- /// (`UiCaptureConfig::capture_text`). The a11y tree + OCR still capture- /// on-screen text. See `RecordingSettings.disable_keyboard_capture`.+ /// Skip persisting keyboard / typed-text rows in the UI recorder+ /// (`UiRecorderConfig::record_keyboard_events`). Keyboard events still+ /// wake event-driven capture, and the a11y tree + OCR still capture on-screen text. See+ /// `RecordingSettings.disable_keyboard_capture`.pub disable_keyboard_capture: bool,pub languages: Vec<Language>,@@ -174,8 +174,9 @@ pub struct RecordingConfig {/// Capture debounce (ms) installed while an HD session is active./// Clamped to >= 33 ms by the controller.pub hd_recording_interval_ms: u64,- /// Override `EventDrivenCaptureConfig::capture_on_keystroke`.- /// None = engine default (false). See `RecordingSettings.capture_on_keystroke`.+ /// Legacy key-trigger override. Recording sessions keep keyboard-triggered+ /// capture on; raw key/text DB rows are controlled separately by+ /// `disable_keyboard_capture`.pub capture_on_keystroke: Option<bool>,/// Override `EventDrivenCaptureConfig::capture_on_clipboard`./// None = engine default (false). See `RecordingSettings.capture_on_clipboard`.@@ -366,12 +367,10 @@ impl RecordingConfig {/// Build a `UiRecorderConfig` from this recording config.pub fn to_ui_recorder_config(&self) -> crate::ui_recorder::UiRecorderConfig {- // `capture_on_keystroke` / `capture_on_clipboard` are mirrored- // from the corresponding `EventDrivenCaptureConfig` overrides so- // the recorder doesn't mint correlation_ids for triggers the- // capture loop will drop. `None` means "engine default" — same- // semantics as in `to_vision_manager_config`.let defaults = crate::ui_recorder::UiRecorderConfig::default();+ let capture_on_clipboard = self+ .capture_on_clipboard+ .unwrap_or(defaults.capture_on_clipboard);crate::ui_recorder::UiRecorderConfig {enabled: true,enable_tree_walker: true,@@ -379,23 +378,26 @@ impl RecordingConfig {excluded_windows: self.ignored_windows.clone(),ignored_windows: self.ignored_windows.clone(),included_windows: self.included_windows.clone(),- capture_clipboard: !self.disable_clipboard_capture,+ capture_clipboard: !self.disable_clipboard_capture || capture_on_clipboard,capture_clipboard_content: !self.disable_clipboard_capture,- // Keyboard / typed-text capture. Off when disabled — the a11y- // tree + OCR still capture on-screen text, this only drops the- // raw keystroke stream.+ // Keyboard events always reach the recorder so they can wake+ // event-driven capture. Persisting text/key rows remains the+ // privacy-sensitive opt-in controlled by disable_keyboard_capture.capture_text: !self.disable_keyboard_capture,+ capture_keystrokes: true,+ record_keyboard_events: !self.disable_keyboard_capture,+ record_clipboard_events: !self.disable_clipboard_capture,+ // Event-driven capture relies on same-app title changes reaching+ // the trigger mapper. The lower-level a11y default keeps this off+ // for libraries, but recording sessions need it on.+ capture_window_focus: true,// Input-latency tuning. `extraction_thread_priority` is parsed from its// string form; an unrecognized value falls back to the enum default.prioritize_input_latency: self.prioritize_input_latency,extraction_thread_priority: self.extraction_thread_priority.parse().unwrap_or_default(),pause_extraction_on_input_ms: self.pause_extraction_on_input_ms,- capture_on_keystroke: self- .capture_on_keystroke- .unwrap_or(defaults.capture_on_keystroke),- capture_on_clipboard: self- .capture_on_clipboard- .unwrap_or(defaults.capture_on_clipboard),+ capture_on_keystroke: true,+ capture_on_clipboard,capture_scroll: self.capture_scroll.unwrap_or(defaults.capture_scroll),..defaults}@@ -453,7 +455,7 @@ impl RecordingConfig {visual_check_interval_ms: self.visual_check_interval_ms,visual_change_threshold: self.visual_change_threshold,min_capture_interval_ms: self.min_capture_interval_ms,- capture_on_keystroke: self.capture_on_keystroke,+ capture_on_keystroke: Some(true),capture_on_clipboard: self.capture_on_clipboard,}}@@ -550,6 +552,10 @@ mod tests {assert!(!ui.capture_clipboard);assert!(!ui.capture_clipboard_content);assert!(!ui.capture_text);+ assert!(ui.capture_keystrokes);+ assert!(!ui.record_keyboard_events);+ assert!(!ui.record_clipboard_events);+ assert!(ui.capture_window_focus);assert_eq!(ui.ignored_windows, settings.ignored_windows);assert_eq!(ui.excluded_windows, settings.ignored_windows);assert_eq!(ui.included_windows, settings.included_windows);@@ -564,6 +570,38 @@ mod tests {assert_eq!(ui.pause_extraction_on_input_ms, 400);}+ #[test]+ fn clipboard_trigger_can_run_without_clipboard_db_rows() {+ let settings = screenpipe_config::RecordingSettings {+ disable_clipboard_capture: true,+ capture_on_clipboard: Some(true),+ ..Default::default()+ };++ let ui = build(&settings).to_ui_recorder_config();++ assert!(ui.capture_clipboard);+ assert!(ui.capture_on_clipboard);+ assert!(!ui.capture_clipboard_content);+ assert!(!ui.record_clipboard_events);+ }++ #[test]+ fn keyboard_capture_opt_in_enables_text_and_key_rows() {+ let settings = screenpipe_config::RecordingSettings {+ disable_keyboard_capture: false,+ capture_on_keystroke: Some(true),+ ..Default::default()+ };++ let ui = build(&settings).to_ui_recorder_config();++ assert!(ui.capture_text);+ assert!(ui.capture_keystrokes);+ assert!(ui.record_keyboard_events);+ assert!(ui.capture_on_keystroke);+ }+#[test]fn vision_filters_and_capture_triggers_flow_to_vision_manager_config() {let settings = screenpipe_config::RecordingSettings {diff --git a/crates/screenpipe-engine/src/ui_recorder.rs b/crates/screenpipe-engine/src/ui_recorder.rsindex 28a84dbd2..bc151ca46 100644--- a/crates/screenpipe-engine/src/ui_recorder.rs+++ b/crates/screenpipe-engine/src/ui_recorder.rs@@ -88,18 +88,13 @@ pub struct UiRecorderConfig {pub capture_scroll: bool,/// Capture element context via accessibilitypub capture_context: bool,- /// Mirror of `EventDrivenCaptureConfig::capture_on_keystroke`. The- /// recorder reads this to skip minting a correlation_id for `Key`- /// events when the gate is off — otherwise every keystroke would- /// stash a `pending_event` in the frame linker that can only ever- /// TTL-evict (the capture loop drops the trigger at the same gate).- /// Default false to match the capture-loop default.+ /// Mirror of `EventDrivenCaptureConfig::capture_on_keystroke`. When on,+ /// keyboard activity may send trigger-only capture messages even if+ /// keyboard rows are not persisted.pub capture_on_keystroke: bool,- /// Mirror of `EventDrivenCaptureConfig::capture_on_clipboard`. Same- /// rationale as `capture_on_keystroke` — when the capture loop is- /// configured to skip Clipboard triggers, the recorder must also- /// skip minting the corr_id so the linker doesn't accumulate- /// pending_events that never pair.+ /// Mirror of `EventDrivenCaptureConfig::capture_on_clipboard`. When on,+ /// clipboard activity may send trigger-only capture messages even if+ /// clipboard rows are not persisted.pub capture_on_clipboard: bool,/// Additional apps to excludepub excluded_apps: Vec<String>,@@ -119,6 +114,14 @@ pub struct UiRecorderConfig {pub tree_walk_interval_ms: u64,/// Record input events to DB (false = still capture for wake signal but don't write)pub record_input_events: bool,+ /// Persist keyboard-derived rows (`text` / `key`) to DB. When false,+ /// keyboard events can still wake event-driven capture, but private input+ /// payloads are not written.+ pub record_keyboard_events: bool,+ /// Persist clipboard rows to DB. When false, clipboard operations can+ /// still wake event-driven capture, but clipboard payloads/operation rows+ /// are not written.+ pub record_clipboard_events: bool,/// Prioritize input latency over event metadata completeness./// Maps to `UiCaptureConfig.prioritize_input_latency`. See that field for details.pub prioritize_input_latency: bool,@@ -155,6 +158,8 @@ impl Default for UiRecorderConfig {enable_tree_walker: true,tree_walk_interval_ms: 3000,record_input_events: true,+ record_keyboard_events: true,+ record_clipboard_events: true,prioritize_input_latency: false,extraction_thread_priority: ExtractionThreadPriority::BelowNormal,pause_extraction_on_input_ms: 150,@@ -506,6 +511,8 @@ pub async fn start_ui_recording(let batch_size = config.batch_size;let batch_timeout = Duration::from_millis(config.batch_timeout_ms);let record_input_events = config.record_input_events;+ let record_keyboard_events = config.record_keyboard_events;+ let record_clipboard_events = config.record_clipboard_events;let trigger_gates = TriggerGates {capture_on_keystroke: config.capture_on_keystroke,capture_on_clipboard: config.capture_on_clipboard,@@ -562,6 +569,25 @@ pub async fn start_ui_recording(match handle.recv_timeout(Duration::from_millis(100)) {Some(event) => {let db_event = event.to_db_insert(Some(session_id.clone()));+ let app_lower = db_event+ .app_name+ .as_deref()+ .unwrap_or_default()+ .to_lowercase();+ let title_lower = db_event+ .window_title+ .as_deref()+ .unwrap_or_default()+ .to_lowercase();+ let is_ignored =+ window_pattern::matches_any(&ignored_patterns, &app_lower, &title_lower);+ let should_record_event = record_input_events+ && !is_ignored+ && should_record_input_event(+ &db_event,+ record_keyboard_events,+ record_clipboard_events,+ );// Decide whether this event warrants a capture and, if so,// mint a correlation id that travels with the trigger AND@@ -590,7 +616,8 @@ pub async fn start_ui_recording(.as_ref().map(|tx| tx.receiver_count() > 0).unwrap_or(false);- let want_corr_id = (trigger_kind.is_some() || is_scroll)+ let want_corr_id = should_record_event+ && (trigger_kind.is_some() || is_scroll)&& has_trigger_receivers&& linker_tx.is_some();let mut correlation_id = if want_corr_id {@@ -603,43 +630,25 @@ pub async fn start_ui_recording(if let Some(corr_id) = correlation_id {scroll_burst.record(corr_id);}- } else if let (Some(ref trigger_tx), Some(trigger), Some(corr_id)) =- (&capture_trigger_tx, trigger_kind, correlation_id)+ } else if let (Some(ref trigger_tx), Some(trigger)) =+ (&capture_trigger_tx, trigger_kind){use crate::event_driven_capture::CaptureTriggerMsg;// If `send` returns Err the broadcast lost its// receivers between the count check above and now —// blank the corr_id so the batch flush doesn't// notify the linker about a doomed event.- if trigger_tx- .send(CaptureTriggerMsg::with_correlation(trigger, corr_id))- .is_err()- {+ let msg = match correlation_id {+ Some(corr_id) => CaptureTriggerMsg::with_correlation(trigger, corr_id),+ None => CaptureTriggerMsg::new(trigger),+ };+ if trigger_tx.send(msg).is_err() {correlation_id = None;}}- if record_input_events {- // Don't store input events from ignored windows/apps.- // Supports both legacy and scoped `App::Title` patterns.- let app_lower = db_event- .app_name- .as_deref()- .unwrap_or_default()- .to_lowercase();- let title_lower = db_event- .window_title- .as_deref()- .unwrap_or_default()- .to_lowercase();- let is_ignored = window_pattern::matches_any(- &ignored_patterns,- &app_lower,- &title_lower,- );- if !is_ignored {- batch.push(db_event, correlation_id);- }+ if should_record_event {+ batch.push(db_event, correlation_id);}// Flush if batch is full@@ -761,6 +770,20 @@ pub async fn start_ui_recording(// Tree walker is disabled — paired_capture.rs handles accessibility capture.// Keeping this comment as a tombstone for git blame.+fn should_record_input_event(+ db_event: &InsertUiEvent,+ record_keyboard_events: bool,+ record_clipboard_events: bool,+) -> bool {+ match db_event.event_type {+ screenpipe_db::UiEventType::Key | screenpipe_db::UiEventType::Text => {+ record_keyboard_events+ }+ screenpipe_db::UiEventType::Clipboard => record_clipboard_events,+ _ => true,+ }+}+async fn flush_batch(db: &Arc<DatabaseManager>,batch: &mut EventBatch,@@ -873,10 +896,9 @@ fn capture_trigger_kind(}}screenpipe_db::UiEventType::Click => Some(CaptureTrigger::Click),- // Clipboard rows are always written to the DB when clipboard- // capture is enabled. The frame linkage is gated separately:- // when `capture_on_clipboard` is off the capture loop drops the- // trigger, so we skip minting a corr_id here too.+ // Clipboard operations can be trigger-only when DB persistence is+ // disabled. The capture-loop gate is still separate: when+ // `capture_on_clipboard` is off we skip the trigger entirely.screenpipe_db::UiEventType::Clipboard if gates.capture_on_clipboard => {Some(CaptureTrigger::Clipboard)}@@ -1077,6 +1099,50 @@ mod capture_trigger_kind_tests {assert!(matches!(result, Some(CaptureTrigger::KeyPress)));}+ #[test]+ fn sensitive_rows_follow_recording_gates() {+ assert!(!should_record_input_event(+ &evt(UiEventType::Key),+ false,+ true+ ));+ assert!(!should_record_input_event(+ &evt(UiEventType::Text),+ false,+ true+ ));+ assert!(!should_record_input_event(+ &evt(UiEventType::Clipboard),+ true,+ false+ ));+ assert!(should_record_input_event(+ &evt(UiEventType::Key),+ true,+ false+ ));+ assert!(should_record_input_event(+ &evt(UiEventType::Text),+ true,+ false+ ));+ assert!(should_record_input_event(+ &evt(UiEventType::Clipboard),+ false,+ true+ ));+ assert!(should_record_input_event(+ &evt(UiEventType::WindowFocus),+ false,+ false+ ));+ assert!(should_record_input_event(+ &evt(UiEventType::Click),+ false,+ false+ ));+ }+#[test]fn clipboard_event_suppressed_when_clipboard_gate_off() {let result = capture_trigger_kind(&evt(UiEventType::Clipboard), &[], gates(false, false));