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
Enable keyboard and clipboard capture by default in enterprise builds (#7450)
Louis Beaumonta278a4f32f42
diff --git a/apps/screenpipe-app-tauri/lib/hooks/__tests__/default-settings-input-capture.test.ts b/apps/screenpipe-app-tauri/lib/hooks/__tests__/default-settings-input-capture.test.tsnew file mode 100644index 000000000..b4f65e05f--- /dev/null+++ b/apps/screenpipe-app-tauri/lib/hooks/__tests__/default-settings-input-capture.test.ts@@ -0,0 +1,29 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++import { describe, expect, it } from "vitest";+import { createDefaultSettingsObject } from "@/lib/hooks/use-settings";+import { applyManagedOverrides } from "@/lib/hooks/managed-settings";+import catalog from "../../../src-tauri/src/enterprise/managed-settings.json";++describe("input capture defaults", () => {+ it("enables enterprise capture without changing subsequent consumer defaults", () => {+ const enterprise = createDefaultSettingsObject(true);+ const consumer = createDefaultSettingsObject(false);+ for (const key of ["disableClipboardCapture", "disableKeyboardCapture"] as const) {+ expect(enterprise[key]).toBe(false);+ expect(consumer[key]).toBe(true);+ expect(createDefaultSettingsObject()[key]).toBe(true);+ expect(catalog.find((setting) => setting.deviceKey === key)?.defaultValue).toBe(enterprise[key]);+ }+ });++ it("preserves an admin capture opt-out when resetting enterprise defaults", () => {+ const defaults = applyManagedOverrides(createDefaultSettingsObject(true), {+ disableClipboardCapture: true,+ disableKeyboardCapture: true,+ });+ expect(defaults.disableClipboardCapture).toBe(true);+ expect(defaults.disableKeyboardCapture).toBe(true);+ });+});diff --git a/apps/screenpipe-app-tauri/lib/hooks/__tests__/settings-input-capture.test.tsx b/apps/screenpipe-app-tauri/lib/hooks/__tests__/settings-input-capture.test.tsxnew file mode 100644index 000000000..447124d97--- /dev/null+++ b/apps/screenpipe-app-tauri/lib/hooks/__tests__/settings-input-capture.test.tsx@@ -0,0 +1,91 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++import { act, renderHook, waitFor } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { SettingsProvider, createDefaultSettingsObject, useSettings } from "../use-settings";++const state = vi.hoisted(() => ({+ enterprise: true,+ settings: undefined as Record<string, unknown> | undefined,+}));+vi.mock("../use-is-enterprise-build", () => ({+ resolveEnterpriseBuild: async () => state.enterprise,+ isResolvedConsumerBuild: async () => !state.enterprise,+}));+vi.mock("@tauri-apps/plugin-store", () => ({+ Store: { load: async () => ({+ get: async () => state.settings,+ set: async (_key: string, value: Record<string, unknown>) => { state.settings = value; },+ save: async () => {},+ onKeyChange: async () => () => {},+ }) },+}));+vi.mock("@tauri-apps/api/path", () => ({ homeDir: async () => "/tmp" }));+vi.mock("@tauri-apps/api/event", () => ({ listen: async () => () => {}, emit: async () => {} }));+vi.mock("@tauri-apps/plugin-os", () => ({ platform: () => "macos" }));+vi.mock("@/lib/api", () => ({+ configureApi: () => {}, refreshApiConfig: async () => {}, onUnauthorized: () => () => {},+}));+vi.mock("@/lib/utils/tauri", () => ({+ commands: {+ getScreenpipeBaseDir: async () => ({ status: "ok", data: "/tmp" }),+ getCloudToken: async () => null,+ reencryptStore: async () => {},+ setBrowserCookieAccessState: async () => {},+ },+}));++async function loadSettings() {+ const hook = renderHook(() => useSettings(), { wrapper: SettingsProvider });+ await waitFor(() => expect(hook.result.current.isSettingsLoaded).toBe(true));+ expect(hook.result.current.loadingError).toBeNull();+ return hook;+}++describe("stored input capture defaults", () => {+ beforeEach(() => {+ state.enterprise = true;+ state.settings = { ...createDefaultSettingsObject(), deviceId: "test-device" };+ });++ it("uses enterprise defaults for an empty store", async () => {+ state.settings = undefined;+ const { result } = await loadSettings();+ expect(result.current.settings.disableClipboardCapture).toBe(false);+ expect(result.current.settings.disableKeyboardCapture).toBe(false);+ });++ it.each([true, false])("fills absent capture settings for enterprise=%s", async (enterprise) => {+ state.enterprise = enterprise;+ delete state.settings!.disableClipboardCapture;+ delete state.settings!.disableKeyboardCapture;+ const { result } = await loadSettings();+ expect(result.current.settings.disableClipboardCapture).toBe(!enterprise);+ expect(result.current.settings.disableKeyboardCapture).toBe(!enterprise);+ expect(state.settings!.disableClipboardCapture).toBe(!enterprise);+ expect(state.settings!.disableKeyboardCapture).toBe(!enterprise);+ });++ it("keeps saved off choices and restores enterprise defaults on explicit reset", async () => {+ const { result } = await loadSettings();+ expect(result.current.settings.disableClipboardCapture).toBe(true);+ expect(result.current.settings.disableKeyboardCapture).toBe(true);+ await act(async () => { await result.current.resetSetting("disableKeyboardCapture"); });+ expect(state.settings!.disableKeyboardCapture).toBe(false);+ expect(state.settings!.disableClipboardCapture).toBe(true);+ await act(async () => { await result.current.resetSettings(); });+ expect(state.settings!.disableClipboardCapture).toBe(false);+ expect(state.settings!.disableKeyboardCapture).toBe(false);+ });++ it("keeps admin opt-outs through a full reset", async () => {+ state.settings!.enterpriseManagedSettings = {+ disableClipboardCapture: true, disableKeyboardCapture: true,+ };+ const { result } = await loadSettings();+ await act(async () => { await result.current.resetSettings(); });+ expect(state.settings!.disableClipboardCapture).toBe(true);+ expect(state.settings!.disableKeyboardCapture).toBe(true);+ });+});diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-is-enterprise-build.ts b/apps/screenpipe-app-tauri/lib/hooks/use-is-enterprise-build.tsindex f86c0652d..ba40a597e 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-is-enterprise-build.ts+++ b/apps/screenpipe-app-tauri/lib/hooks/use-is-enterprise-build.ts@@ -53,7 +53,7 @@ function readE2eEnterpriseOverride(): boolean | null {}}-async function resolveEnterpriseBuild(): Promise<boolean> {+export async function resolveEnterpriseBuild(): Promise<boolean> {// E2E binaries are compiled without `enterprise-build`; dedicated managed// deployment specs opt in through the existing local-storage override. Do// not make app startup depend on native IPC that the WebDriver bootstrap candiff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex 367db1f94..8fd3500a7 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -38,7 +38,10 @@ import {applyManagedOverrides,type ManagedSettingValue,} from "./managed-settings";-import { isResolvedConsumerBuild } from "./use-is-enterprise-build";+import {+ isResolvedConsumerBuild,+ resolveEnterpriseBuild,+} from "./use-is-enterprise-build";import {clearLegacyUserGoalCategory,DEFAULT_USER_GOAL_CATEGORY,@@ -416,9 +419,9 @@ export type Settings = SettingsStore & {hideAppInScreenShare?: boolean;/** Pause all screen capture when a DRM-protected streaming app (Netflix, Disney+, etc.) or a remote-desktop client (Omnissa/VMware Horizon) is focused — they blank their windows during screen recording */pauseOnDrmContent?: boolean;- /** Skip clipboard capture in the UI recorder (events + content). Defaults to true (clipboard capture OFF) — passwords / API keys often pass through the clipboard, so it's opt-in. */+ /** Skip clipboard capture in the UI recorder (events + content). Defaults to false in enterprise builds and true in consumer builds. */disableClipboardCapture?: boolean;- /** Skip keyboard / typed-text capture in the UI recorder. Defaults to true (keyboard capture OFF) — the a11y tree + OCR still capture on-screen text, this only drops the raw keystroke stream where secrets get typed. */+ /** Skip keyboard / typed-text capture in the UI recorder. Defaults to false in enterprise builds and true in consumer builds. */disableKeyboardCapture?: boolean;/** Skip mouse-click rows in the UI recorder. Defaults to false (click capture ON) — clicks carry no text payload and drive workflow/task mining. Clicks still wake event-driven capture when disabled. */disableClickCapture?: boolean;@@ -872,7 +875,7 @@ let DEFAULT_SETTINGS: Settings = {fontSize: "16px",};-export function createDefaultSettingsObject(): Settings {+export function createDefaultSettingsObject(isEnterprise = false): Settings {try {const p = platform();DEFAULT_SETTINGS.platform = p;@@ -894,12 +897,13 @@ export function createDefaultSettingsObject(): Settings {if (p === "linux") {DEFAULT_SETTINGS.overlayMode = "window";}-- return DEFAULT_SETTINGS;} catch (e) {- // Fallback if platform detection fails- return DEFAULT_SETTINGS;+ // Keep platform-independent defaults if platform detection fails.}+ return Object.assign({}, DEFAULT_SETTINGS, {+ disableClipboardCapture: !isEnterprise,+ disableKeyboardCapture: !isEnterprise,+ });}export function normalizeSettingsArrays(settings: Settings): boolean {@@ -1104,14 +1108,27 @@ function createSettingsStore() {const get = async (): Promise<Settings> => {const store = await getStore();const settings = await store.get<Settings>("settings");+ // Existing explicit choices do not need a build-identity lookup.+ const needsCaptureDefaults = !settings+ || settings.disableClipboardCapture === undefined+ || settings.disableKeyboardCapture === undefined;+ const defaults = createDefaultSettingsObject(+ needsCaptureDefaults ? await resolveEnterpriseBuild() : false,+ );if (!settings) {- return createDefaultSettingsObject();+ return defaults;}// #3943: re-hydrate the cloud token that no longer persists in store.bin.await hydrateCloudToken(settings);let needsUpdate = normalizeSettingsArrays(settings);+ for (const key of ["disableClipboardCapture", "disableKeyboardCapture"] as const) {+ if (settings[key] === undefined) {+ settings[key] = defaults[key];+ needsUpdate = true;+ }+ }// Migration: Ensure existing users have deviceId for free tier trackingconst existingUserGoal = normalizeUserGoalCategory(@@ -1480,7 +1497,7 @@ function createSettingsStore() {const current = await get();const managedValues = await activeManagedValues(current);const defaults = applyManagedOverrides(- { ...createDefaultSettingsObject(), deviceId: current.deviceId } as Record<string, unknown>,+ { ...createDefaultSettingsObject(await resolveEnterpriseBuild()), deviceId: current.deviceId } as Record<string, unknown>,managedValues) as Settings;if (managedValues) defaults.enterpriseManagedSettings = managedValues;@@ -1491,7 +1508,7 @@ function createSettingsStore() {const resetSetting = async <K extends keyof Settings>(key: K) => {if (key === "deviceId") return;const current = await get();- const defaultValue = createDefaultSettingsObject()[key];+ const defaultValue = createDefaultSettingsObject(await resolveEnterpriseBuild())[key];await set({ [key]: defaultValue } as Partial<Settings>);};@@ -1504,7 +1521,7 @@ function createSettingsStore() {let seq = 0;return store.onKeyChange("settings", async (newValue: Settings | null | undefined) => {const mySeq = ++seq;- const next = await hydrateCloudToken(newValue || createDefaultSettingsObject());+ const next = await hydrateCloudToken(newValue || createDefaultSettingsObject(await resolveEnterpriseBuild()));normalizeSettingsArrays(next);if (mySeq === seq) callback(next);});diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex 55f16341e..ca4c84d7a 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -4079,15 +4079,15 @@ enhancedIncognitoDetection?: boolean;pauseOnDrmContent?: boolean;/*** 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+ * `false` in enterprise builds and `true` in consumer builds.+ * Clipboard operations can still* wake event-driven capture when `captureOnClipboard` is enabled.*/disableClipboardCapture?: boolean;/*** 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+ * Defaults to `false` in enterprise builds and `true` in consumer builds.+ * 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.*/diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex fb19048dc..61581072e 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -312,6 +312,7 @@ enterprise-build = ["dep:thiserror","dep:screenpipe-sync","screenpipe-core/enterprise-build",+ "screenpipe-config/enterprise-build",]qwen3-asr = ["screenpipe-engine/qwen3-asr"]diff --git a/apps/screenpipe-app-tauri/src-tauri/src/enterprise/managed-settings.json b/apps/screenpipe-app-tauri/src-tauri/src/enterprise/managed-settings.jsonindex fd591aba5..a99c8a4b8 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/enterprise/managed-settings.json+++ b/apps/screenpipe-app-tauri/src-tauri/src/enterprise/managed-settings.json@@ -27,8 +27,8 @@{"policyKey": "minCaptureIntervalMs", "deviceKey": "minCaptureIntervalMs", "apply": "engine", "kind": "number", "min": 0, "max": 60000, "integer": true},{"policyKey": "captureOnClipboard", "deviceKey": "captureOnClipboard", "apply": "engine", "kind": "boolean", "defaultValue": false},{"policyKey": "captureScroll", "deviceKey": "captureScroll", "apply": "engine", "kind": "boolean", "defaultValue": false},- {"policyKey": "disableClipboardCapture", "deviceKey": "disableClipboardCapture", "apply": "engine", "kind": "boolean", "defaultValue": true},- {"policyKey": "disableKeyboardCapture", "deviceKey": "disableKeyboardCapture", "apply": "engine", "kind": "boolean", "defaultValue": true},+ {"policyKey": "disableClipboardCapture", "deviceKey": "disableClipboardCapture", "apply": "engine", "kind": "boolean", "defaultValue": false},+ {"policyKey": "disableKeyboardCapture", "deviceKey": "disableKeyboardCapture", "apply": "engine", "kind": "boolean", "defaultValue": false},{"policyKey": "disableClickCapture", "deviceKey": "disableClickCapture", "apply": "engine", "kind": "boolean", "defaultValue": false},{"policyKey": "prioritizeInputLatency", "deviceKey": "prioritizeInputLatency", "apply": "engine", "kind": "boolean", "defaultValue": false},{"policyKey": "extractionThreadPriority", "deviceKey": "extractionThreadPriority", "apply": "engine", "kind": "enum", "values": ["normal", "below_normal", "lowest", "idle"], "defaultValue": "below_normal"},diff --git a/crates/screenpipe-config/Cargo.toml b/crates/screenpipe-config/Cargo.tomlindex a4ba9b999..49b4c1803 100644--- a/crates/screenpipe-config/Cargo.toml+++ b/crates/screenpipe-config/Cargo.toml@@ -21,6 +21,7 @@ specta = { workspace = true, optional = true }[features]default = []+enterprise-build = []specta = ["dep:specta"][dev-dependencies]diff --git a/crates/screenpipe-config/src/recording.rs b/crates/screenpipe-config/src/recording.rsindex 1455e6ed0..0044a8695 100644--- a/crates/screenpipe-config/src/recording.rs+++ b/crates/screenpipe-config/src/recording.rs@@ -616,18 +616,24 @@ pub struct RecordingSettings {pub pause_on_drm_content: bool,/// 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+ /// `false` in enterprise builds and `true` in consumer builds.+ /// Clipboard operations can still/// wake event-driven capture when `captureOnClipboard` is enabled.- #[serde(rename = "disableClipboardCapture", default = "default_true")]+ #[serde(+ rename = "disableClipboardCapture",+ default = "default_disable_input_capture"+ )]pub disable_clipboard_capture: bool,/// 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+ /// Defaults to `false` in enterprise builds and `true` in consumer builds.+ /// 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")]+ #[serde(+ rename = "disableKeyboardCapture",+ default = "default_disable_input_capture"+ )]pub disable_keyboard_capture: bool,/// Skip persisting mouse-click rows in the UI recorder. Defaults to@@ -961,8 +967,8 @@ impl Default for RecordingSettings {ignore_incognito_windows: true,enhanced_incognito_detection: false,pause_on_drm_content: false,- disable_clipboard_capture: true,- disable_keyboard_capture: true,+ disable_clipboard_capture: default_disable_input_capture(),+ disable_keyboard_capture: default_disable_input_capture(),disable_click_capture: false,record_while_locked: false,languages: vec![],@@ -998,6 +1004,10 @@ impl Default for RecordingSettings {}}+fn default_disable_input_capture() -> bool {+ !cfg!(feature = "enterprise-build")+}+fn default_true() -> bool {true}@@ -1081,6 +1091,26 @@ fn default_hd_recording_interval_ms() -> u64 {#[cfg(test)]mod tests {+ #[test]+ fn input_capture_defaults_follow_build_and_preserve_explicit_choices() {+ let disabled = !cfg!(feature = "enterprise-build");+ let defaults = RecordingSettings::default();+ let missing: RecordingSettings = serde_json::from_value(serde_json::json!({})).unwrap();+ for settings in [defaults, missing] {+ assert_eq!(settings.disable_clipboard_capture, disabled);+ assert_eq!(settings.disable_keyboard_capture, disabled);+ }+ for explicit in [true, false] {+ let settings: RecordingSettings = serde_json::from_value(serde_json::json!({+ "disableClipboardCapture": explicit,+ "disableKeyboardCapture": explicit,+ }))+ .unwrap();+ assert_eq!(settings.disable_clipboard_capture, explicit);+ assert_eq!(settings.disable_keyboard_capture, explicit);+ }+ }+#[test]fn screenshot_capture_controls_timeline_cache() {for (timeline, screenshots, vision, expected) in [