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(enterprise): policy-managed click + keyboard capture (#4093)

Louis Beaumont4e3a22dbe497
diff --git a/.github/assets/input-capture-policy-mockup.png b/.github/assets/input-capture-policy-mockup.png
new file mode 100644
index 000000000..0c29ad278
Binary files /dev/null and b/.github/assets/input-capture-policy-mockup.png differ
diff --git a/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx b/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx
index 8a823468d..838db3732 100644
--- a/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx
@@ -29,6 +29,7 @@ import {
Copy,
ClipboardX,
Keyboard,
+ MousePointerClick,
FolderTree,
} from "lucide-react";
import { cn } from "@/lib/utils";
@@ -287,6 +288,12 @@ export function PrivacySection() {
// useEnterprisePolicy.applyPiiPolicy on every policy poll).
const { getManagedValue } = useEnterprisePolicy();
const managedPiiBackend = getManagedValue("piiBackend");
+ // Same idea for input capture: the admin can force keyboard/click rows on
+ // or off org-wide (applied by useEnterprisePolicy.applyInputCapturePolicy).
+ // These settings are inverted ("disable…"), so ManagedSwitch — which assumes
+ // checked == managed value — doesn't fit; lock the switches manually.
+ const managedKeyboardCapture = getManagedValue("disableKeyboardCapture");
+ const managedClickCapture = getManagedValue("disableClickCapture");
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
const [isUpdating, setIsUpdating] = useState(false);
@@ -573,6 +580,12 @@ export function PrivacySection() {
handleSettingsChange({ disableKeyboardCapture: !checked }, true);
};
+ const handleClickCaptureToggle = (checked: boolean) => {
+ // UI is "Capture clicks" on/off. Settings store inverts to match
+ // the CLI flag name (--disable-click-capture).
+ handleSettingsChange({ disableClickCapture: !checked }, true);
+ };
+
const handleRecordWhileLockedToggle = (checked: boolean) => {
handleSettingsChange({ recordWhileLocked: checked }, true);
};
@@ -1013,20 +1026,58 @@ export function PrivacySection() {
<HelpTooltip text="when on, screenpipe records what you type (your keystrokes). off by default. the accessibility tree and OCR still capture on-screen text either way, so Rewind and Ask keep working — this only controls the raw keystroke stream, where passwords, API keys, and secrets you type would otherwise be logged." />
</h3>
<p className="text-xs text-muted-foreground">
- Off by default. Records the raw keystroke stream (secrets
- often get typed). On-screen text is still captured.
+ {managedKeyboardCapture !== undefined
+ ? "Managed by your organization."
+ : "Off by default. Records the raw keystroke stream (secrets often get typed). On-screen text is still captured."}
</p>
</div>
</div>
<Switch
id="captureKeyboard"
- checked={!(settings.disableKeyboardCapture ?? true)}
+ checked={
+ managedKeyboardCapture !== undefined
+ ? managedKeyboardCapture === "false"
+ : !(settings.disableKeyboardCapture ?? true)
+ }
+ disabled={managedKeyboardCapture !== undefined}
onCheckedChange={handleKeyboardCaptureToggle}
/>
</div>
</CardContent>
</Card>
+ {/* Click capture toggle */}
+ <Card>
+ <CardContent className="px-3 py-2.5">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-2.5">
+ <MousePointerClick className="h-4 w-4 text-muted-foreground shrink-0" />
+ <div>
+ <h3 className="text-sm font-medium text-foreground flex items-center gap-1.5">
+ Capture clicks
+ <HelpTooltip text="when on, screenpipe records mouse click events (where and what you clicked). on by default — clicks carry no text payload and power workflow analysis and task mining. turning this off only skips the click rows; clicks still trigger screen captures." />
+ </h3>
+ <p className="text-xs text-muted-foreground">
+ {managedClickCapture !== undefined
+ ? "Managed by your organization."
+ : "On by default. Click events power workflow analysis; no text is recorded."}
+ </p>
+ </div>
+ </div>
+ <Switch
+ id="captureClicks"
+ checked={
+ managedClickCapture !== undefined
+ ? managedClickCapture === "false"
+ : !(settings.disableClickCapture ?? false)
+ }
+ disabled={managedClickCapture !== undefined}
+ onCheckedChange={handleClickCaptureToggle}
+ />
+ </div>
+ </CardContent>
+ </Card>
+
{/* Record While Locked */}
<Card>
<CardContent className="px-3 py-2.5">
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-enterprise-policy.ts b/apps/screenpipe-app-tauri/lib/hooks/use-enterprise-policy.ts
index c4f472ace..4731d68a4 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-enterprise-policy.ts
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-enterprise-policy.ts
@@ -203,6 +203,68 @@ async function applyPiiPolicy(lockedSettings: Record<string, unknown>): Promise<
await store.save();
}
+/**
+ * Apply enterprise-forced input-capture settings (keyboard / click rows) to
+ * the local settings store so the recording engine honors them. The admin
+ * sets these in the workspace policy's Managed settings
+ * (lockedSettings.disableKeyboardCapture / disableClickCapture — "true" |
+ * "false" strings like every managed value). Unlike the PII policy, the
+ * engine only reads these at spawn, so when a forced value actually changes
+ * the device's effective setting we restart the engine once. The matching
+ * privacy-section toggles are disabled separately so the employee can't
+ * override a forced value.
+ */
+let inputCaptureRestartInFlight = false;
+
+async function applyInputCapturePolicy(lockedSettings: Record<string, unknown>): Promise<void> {
+ const updates: Record<string, boolean> = {};
+
+ const keyboard = lockedSettings.disableKeyboardCapture;
+ if (keyboard === "true" || keyboard === "false") {
+ updates.disableKeyboardCapture = keyboard === "true";
+ }
+
+ const clicks = lockedSettings.disableClickCapture;
+ if (clicks === "true" || clicks === "false") {
+ updates.disableClickCapture = clicks === "true";
+ }
+
+ if (Object.keys(updates).length === 0) return;
+
+ const store = await getStore();
+ const settings = (await store.get<Record<string, unknown>>("settings")) || {};
+ // Defaults when the key was never persisted mirror the app defaults:
+ // keyboard rows off, click rows on.
+ const current: Record<string, boolean> = {
+ disableKeyboardCapture: (settings.disableKeyboardCapture as boolean | undefined) ?? true,
+ disableClickCapture: (settings.disableClickCapture as boolean | undefined) ?? false,
+ };
+ const changed = Object.entries(updates).some(([key, value]) => current[key] !== value);
+ if (!changed) return;
+
+ await store.set("settings", { ...settings, ...updates });
+ await store.save();
+ console.log(
+ `[enterprise] input capture policy changed settings: ${Object.entries(updates)
+ .map(([k, v]) => `${k}=${v}`)
+ .join(", ")} — restarting engine`
+ );
+
+ // Restart so the forced values take effect without waiting for the
+ // employee to restart manually. Guarded so overlapping policy polls in
+ // this window don't stack restarts; steady-state polls are no-ops because
+ // the store already matches the policy.
+ if (inputCaptureRestartInFlight) return;
+ inputCaptureRestartInFlight = true;
+ try {
+ await commands.stopScreenpipe();
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ await commands.spawnScreenpipe(null);
+ } finally {
+ inputCaptureRestartInFlight = false;
+ }
+}
+
/**
* Fire-and-forget heartbeat to report device status to the enterprise API.
* Called after a successful policy fetch. Never throws, never blocks.
@@ -428,6 +490,14 @@ export function useEnterprisePolicy() {
console.warn("[enterprise] failed to apply PII policy:", e);
}
+ // Apply enterprise-forced input capture (keyboard / click rows).
+ // Restarts the engine when a forced value actually changed.
+ try {
+ await applyInputCapturePolicy(result.lockedSettings);
+ } catch (e) {
+ console.warn("[enterprise] failed to apply input capture policy:", e);
+ }
+
// Fire-and-forget heartbeat
sendHeartbeat(licenseKey);
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 716c1800d..cbfed5def 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -281,6 +281,8 @@ export type Settings = SettingsStore & {
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. */
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;
/** Experimental: capture System Audio via CoreAudio Process Tap (macOS 14.4+) instead of ScreenCaptureKit.
* Off by default. Ignored on macOS <14.4 and non-macOS — falls back to SCK. */
experimentalCoreaudioSystemAudio?: boolean;
@@ -600,6 +602,7 @@ let DEFAULT_SETTINGS: Settings = {
pauseOnDrmContent: false,
disableClipboardCapture: true,
disableKeyboardCapture: true,
+ disableClickCapture: false,
keepComputerAwake: false,
experimentalCoreaudioSystemAudio: false,
windowsInputAecEnabled: false,
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index 2e60278bc..9b389746b 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -2642,6 +2642,13 @@ disableClipboardCapture?: boolean;
* Opt in to keyboard DB rows via the "Capture keyboard" toggle.
*/
disableKeyboardCapture?: boolean;
+/**
+ * Skip persisting mouse-click rows in the UI recorder. Defaults to
+ * `false` (click DB capture ON — clicks carry no text payload and are
+ * the backbone of workflow/task mining). Clicks still wake event-driven
+ * capture when disabled; only the `ui_events` click rows are skipped.
+ */
+disableClickCapture?: boolean;
/**
* Continue recording audio when the screen is locked.
* Default: false (audio pauses when screen is locked to save resources).
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index a3be846e8..43f0f69f4 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -10939,7 +10939,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.5.35"
+version = "2.5.36"
dependencies = [
"aes 0.8.4",
"aes-gcm 0.10.3",
diff --git a/crates/screenpipe-config/src/recording.rs b/crates/screenpipe-config/src/recording.rs
index 58b164ff9..b0b6af853 100644
--- a/crates/screenpipe-config/src/recording.rs
+++ b/crates/screenpipe-config/src/recording.rs
@@ -326,6 +326,13 @@ pub struct RecordingSettings {
#[serde(rename = "disableKeyboardCapture", default = "default_true")]
pub disable_keyboard_capture: bool,
+ /// Skip persisting mouse-click rows in the UI recorder. Defaults to
+ /// `false` (click DB capture ON — clicks carry no text payload and are
+ /// the backbone of workflow/task mining). Clicks still wake event-driven
+ /// capture when disabled; only the `ui_events` click rows are skipped.
+ #[serde(rename = "disableClickCapture", default)]
+ pub disable_click_capture: bool,
+
/// Continue recording audio when the screen is locked.
/// Default: false (audio pauses when screen is locked to save resources).
#[serde(rename = "recordWhileLocked", default)]
@@ -582,6 +589,7 @@ impl Default for RecordingSettings {
pause_on_drm_content: false,
disable_clipboard_capture: true,
disable_keyboard_capture: true,
+ disable_click_capture: false,
record_while_locked: false,
languages: vec![],
use_pii_removal: false,
diff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rs
index 15db6c759..f62763c57 100644
--- a/crates/screenpipe-engine/src/cli/mod.rs
+++ b/crates/screenpipe-engine/src/cli/mod.rs
@@ -614,6 +614,12 @@ pub struct RecordArgs {
#[arg(long, default_value_t = false)]
pub disable_keyboard_capture: bool,
+ /// Disable persisting mouse-click rows. Clicks still wake event-driven
+ /// capture; only the `ui_events` click rows are skipped. On by default —
+ /// click rows carry no text payload and drive workflow/task mining.
+ #[arg(long, default_value_t = false)]
+ pub disable_click_capture: bool,
+
/// Require authentication for remote API access. When enabled, non-localhost
/// requests must include Authorization: Bearer <SCREENPIPE_API_KEY>.
/// Localhost requests are always allowed.
@@ -708,6 +714,7 @@ pub struct RecordArgSources {
pub pause_on_drm_content: bool,
pub disable_clipboard_capture: bool,
pub disable_keyboard_capture: bool,
+ pub disable_click_capture: bool,
pub api_auth: bool,
pub listen_on_lan: bool,
pub encrypt_secrets: bool,
@@ -758,6 +765,7 @@ impl RecordArgSources {
pause_on_drm_content: from_command_line(record, "pause_on_drm_content"),
disable_clipboard_capture: from_command_line(record, "disable_clipboard_capture"),
disable_keyboard_capture: from_command_line(record, "disable_keyboard_capture"),
+ disable_click_capture: from_command_line(record, "disable_click_capture"),
api_auth: from_command_line(record, "api_auth"),
listen_on_lan: from_command_line(record, "listen_on_lan"),
encrypt_secrets: from_command_line(record, "encrypt_secrets"),
@@ -800,6 +808,7 @@ impl RecordArgSources {
|| self.pause_on_drm_content
|| self.disable_clipboard_capture
|| self.disable_keyboard_capture
+ || self.disable_click_capture
|| self.api_auth
|| self.listen_on_lan
|| self.encrypt_secrets
@@ -895,6 +904,9 @@ impl RecordArgs {
capture_keystrokes: true,
record_keyboard_events: !self.disable_keyboard_capture,
record_clipboard_events: !self.disable_clipboard_capture,
+ // Clicks stay captured at the hook level so they keep waking
+ // event-driven capture; only row persistence is gated.
+ record_click_events: !self.disable_click_capture,
// Same-app title changes must reach the event-driven trigger
// mapper so focus changes can produce linked captures.
capture_window_focus: true,
@@ -969,6 +981,7 @@ impl RecordArgs {
pause_on_drm_content: self.pause_on_drm_content,
disable_clipboard_capture: self.disable_clipboard_capture,
disable_keyboard_capture: self.disable_keyboard_capture,
+ disable_click_capture: self.disable_click_capture,
listen_on_lan: self.listen_on_lan,
// Passing any `--schedule-rule` implies the schedule is on.
schedule_enabled: self.schedule_enabled || !self.schedule_rules.is_empty(),
@@ -1247,6 +1260,9 @@ impl RecordArgs {
if sources.disable_keyboard_capture {
settings.disable_keyboard_capture = self.disable_keyboard_capture;
}
+ if sources.disable_click_capture {
+ settings.disable_click_capture = self.disable_click_capture;
+ }
if sources.api_auth {
settings.api_auth = self.api_auth;
}
diff --git a/crates/screenpipe-engine/src/recording_config.rs b/crates/screenpipe-engine/src/recording_config.rs
index c60641553..906e6cdac 100644
--- a/crates/screenpipe-engine/src/recording_config.rs
+++ b/crates/screenpipe-engine/src/recording_config.rs
@@ -93,6 +93,10 @@ pub struct RecordingConfig {
/// wake event-driven capture, and the a11y tree + OCR still capture on-screen text. See
/// `RecordingSettings.disable_keyboard_capture`.
pub disable_keyboard_capture: bool,
+ /// Skip persisting mouse-click rows in the UI recorder
+ /// (`UiRecorderConfig::record_click_events`). Clicks still wake
+ /// event-driven capture. See `RecordingSettings.disable_click_capture`.
+ pub disable_click_capture: bool,
pub languages: Vec<Language>,
// Cloud/auth
@@ -285,6 +289,7 @@ impl RecordingConfig {
pause_on_drm_content: settings.pause_on_drm_content,
disable_clipboard_capture: settings.disable_clipboard_capture,
disable_keyboard_capture: settings.disable_keyboard_capture,
+ disable_click_capture: settings.disable_click_capture,
languages: settings
.languages
.iter()
@@ -396,6 +401,9 @@ impl RecordingConfig {
capture_keystrokes: true,
record_keyboard_events: !self.disable_keyboard_capture,
record_clipboard_events: !self.disable_clipboard_capture,
+ // Clicks stay captured at the hook level so they keep waking
+ // event-driven capture; only row persistence is gated.
+ record_click_events: !self.disable_click_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.
@@ -546,6 +554,7 @@ mod tests {
let settings = screenpipe_config::RecordingSettings {
disable_clipboard_capture: true,
disable_keyboard_capture: true,
+ disable_click_capture: true,
ignored_windows: vec!["Secret Notes".to_string(), "Password Manager".to_string()],
included_windows: vec!["Work Browser".to_string()],
capture_on_keystroke: Some(true),
@@ -565,6 +574,10 @@ mod tests {
assert!(ui.capture_keystrokes);
assert!(!ui.record_keyboard_events);
assert!(!ui.record_clipboard_events);
+ assert!(!ui.record_click_events);
+ // The click hook itself stays alive so clicks keep waking
+ // event-driven capture even when click rows are disabled.
+ assert!(ui.capture_clicks);
assert!(ui.capture_window_focus);
assert_eq!(ui.ignored_windows, settings.ignored_windows);
assert_eq!(ui.excluded_windows, settings.ignored_windows);
@@ -612,6 +625,23 @@ mod tests {
assert!(ui.capture_on_keystroke);
}
+ #[test]
+ fn click_capture_defaults_on_and_rows_follow_setting() {
+ // Default: click rows recorded (workflow mining backbone).
+ let ui = build(&screenpipe_config::RecordingSettings::default()).to_ui_recorder_config();
+ assert!(ui.capture_clicks);
+ assert!(ui.record_click_events);
+
+ // Opt-out (user or enterprise policy): rows off, hook stays alive.
+ let settings = screenpipe_config::RecordingSettings {
+ disable_click_capture: true,
+ ..Default::default()
+ };
+ let ui = build(&settings).to_ui_recorder_config();
+ assert!(ui.capture_clicks);
+ assert!(!ui.record_click_events);
+ }
+
#[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.rs
index 09e563c71..6d59d9f27 100644
--- a/crates/screenpipe-engine/src/ui_recorder.rs
+++ b/crates/screenpipe-engine/src/ui_recorder.rs
@@ -125,6 +125,9 @@ pub struct UiRecorderConfig {
/// still wake event-driven capture, but clipboard payloads/operation rows
/// are not written.
pub record_clipboard_events: bool,
+ /// Persist mouse-click rows to DB. When false, clicks can still wake
+ /// event-driven capture, but `ui_events` click rows are not written.
+ pub record_click_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,
@@ -163,6 +166,7 @@ impl Default for UiRecorderConfig {
record_input_events: true,
record_keyboard_events: true,
record_clipboard_events: true,
+ record_click_events: true,
prioritize_input_latency: false,
extraction_thread_priority: ExtractionThreadPriority::BelowNormal,
pause_extraction_on_input_ms: 150,
@@ -530,6 +534,7 @@ pub async fn start_ui_recording(
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 record_click_events = config.record_click_events;
let trigger_gates = TriggerGates;
// Start the recording
@@ -603,6 +608,7 @@ pub async fn start_ui_recording(
&db_event,
record_keyboard_events,
record_clipboard_events,
+ record_click_events,
);
// Decide whether this event warrants a capture and, if so,
@@ -790,12 +796,14 @@ fn should_record_input_event(
db_event: &InsertUiEvent,
record_keyboard_events: bool,
record_clipboard_events: bool,
+ record_click_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,
+ screenpipe_db::UiEventType::Click => record_click_events,
_ => true,
}
}
@@ -1227,42 +1235,56 @@ mod capture_trigger_kind_tests {
assert!(!should_record_input_event(
&evt(UiEventType::Key),
false,
+ true,
true
));
assert!(!should_record_input_event(
&evt(UiEventType::Text),
false,
+ true,
true
));
assert!(!should_record_input_event(
&evt(UiEventType::Clipboard),
true,
+ false,
+ true
+ ));
+ assert!(!should_record_input_event(
+ &evt(UiEventType::Click),
+ true,
+ true,
false
));
assert!(should_record_input_event(
&evt(UiEventType::Key),
true,
+ false,
false
));
assert!(should_record_input_event(
&evt(UiEventType::Text),
true,
+ false,
false
));
assert!(should_record_input_event(
&evt(UiEventType::Clipboard),
false,
- true
+ true,
+ false
));
assert!(should_record_input_event(
&evt(UiEventType::WindowFocus),
false,
+ false,
false
));
assert!(should_record_input_event(
&evt(UiEventType::Click),
false,
- false
+ false,
+ true
));
}
@@ -1270,7 +1292,7 @@ mod capture_trigger_kind_tests {
fn key_event_can_trigger_without_being_stored() {
let event = evt(UiEventType::Key);
- assert!(!should_record_input_event(&event, false, true));
+ assert!(!should_record_input_event(&event, false, true, true));
assert!(matches!(
capture_trigger_kind(&event, &[], gates(true, true)),
Some(CaptureTrigger::KeyPress)
@@ -1311,13 +1333,28 @@ mod capture_trigger_kind_tests {
fn clipboard_event_can_trigger_without_being_stored() {
let event = evt(UiEventType::Clipboard);
- assert!(!should_record_input_event(&event, true, false));
+ assert!(!should_record_input_event(&event, true, false, true));
assert!(matches!(
capture_trigger_kind(&event, &[], gates(true, true)),
Some(CaptureTrigger::Clipboard)
));
}
+ #[test]
+ fn click_event_can_trigger_without_being_stored() {
+ // Policy/setting may disable click rows; the click must still reach
+ // the event-driven capture trigger mapper so frames keep flowing.
+ let mut event = evt(UiEventType::Click);
+ event.x = Some(10);
+ event.y = Some(20);
+
+ assert!(!should_record_input_event(&event, true, true, false));
+ assert!(matches!(
+ capture_trigger_kind(&event, &[], gates(true, true)),
+ Some(CaptureTrigger::Click { x: 10, y: 20 })
+ ));
+ }
+
#[test]
fn text_event_unaffected_by_gates() {
// TypingPause / ScrollStop don't have a capture-loop gate, so