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
feat(recording): add "capture frequency" floor — guaranteed screenshot at least every N seconds (#4394)
Louis Beaumonte92ccf75b4cc
diff --git a/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx b/apps/screenpipe-app-tauri/components/settings/recording-settings.tsxindex 6e2b3f0f6..1dd28cc7e 100644--- a/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx+++ b/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx@@ -28,6 +28,8 @@ export const searchIndex: SettingsField[] = [{ label: "Screen recording", keywords: ["screen", "video"] },{ label: "Use all monitors", keywords: ["monitor", "display"] },{ label: "Recording quality", keywords: ["fps", "quality"] },+ // conditional: hidden when screen recording is off (same gate as Recording quality).+ { label: "Capture frequency", keywords: ["screenshot", "interval", "idle", "cadence", "every", "minimum"], conditional: true },// conditional: monitor picker only renders when "Use all monitors" is off.{ label: "Monitors", conditional: true },{ label: "HD recording for meetings", keywords: ["hd", "meeting"] },@@ -3718,6 +3720,61 @@ Your screen is a pipe. Everything you see, hear, and type flows through it. Scre</Card>)}+ {/* Capture frequency — guaranteed screenshot cadence. Capture is+ event-driven (clicks, typing, app/window switches, visual change),+ so a screen that sits still can go uncaptured for the power+ profile's idle floor (30s on AC, longer on battery). This pins a+ hard "always capture at least every N seconds" floor for users who+ feel capture is too sparse. Backed by `idleCaptureIntervalMs`+ (null = follow the power profile). Needs a recording restart to+ take effect, hence handleSettingsChange(..., true). */}+ {!settings.disableVision && (() => {+ const idleMs = settings.idleCaptureIntervalMs ?? null;+ const seconds = idleMs == null ? 0 : Math.round(idleMs / 1000);+ return (+ <Card className="border-border bg-card">+ <CardContent className="px-3 py-2.5">+ <div className="flex items-center space-x-2.5 mb-2">+ <Monitor className="h-4 w-4 text-muted-foreground shrink-0" />+ <div className="min-w-0">+ <h3 className="text-sm font-medium text-foreground">Capture frequency</h3>+ <p className="text-xs text-muted-foreground">+ Always take a screenshot at least this often, even when the screen+ isn't changing. Lower = fewer missed moments + more disk used.+ </p>+ </div>+ </div>+ <div className="flex items-center justify-between mb-1.5">+ <span className="text-xs text-muted-foreground">Minimum interval</span>+ <span className="text-xs font-mono text-foreground">+ {seconds === 0 ? "auto (power profile)" : `every ${seconds}s`}+ </span>+ </div>+ <Slider+ value={[seconds]}+ onValueChange={([value]) =>+ handleSettingsChange(+ {+ idleCaptureIntervalMs:+ (value ?? 0) === 0 ? null : (value as number) * 1000,+ },+ true,+ )+ }+ min={0}+ max={10}+ step={1}+ className="w-full"+ />+ <div className="flex justify-between text-[10px] text-muted-foreground mt-0.5">+ <span>auto</span>+ <span>every 10s</span>+ </div>+ </CardContent>+ </Card>+ );+ })()}+{/* HD recording — bound sessions only (meeting or timer; noindefinite mode). The controller lives in the engine and isHTTP-controlled so settings take effect immediately. Primarydiff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rsindex 4c0421e4d..b4a5a7e4f 100644--- a/crates/screenpipe-engine/src/cli/mod.rs+++ b/crates/screenpipe-engine/src/cli/mod.rs@@ -539,10 +539,15 @@ pub struct RecordArgs {#[arg(long, default_value_t = false)]pub keep_computer_awake: bool,- /// Mitsukeru fork: override the active PowerProfile's idle_capture_interval_ms.- /// Forces this idle snapshot interval regardless of power mode. Useful for- /// fixed desktop / long-running recording where AC-power Performance defaults- /// (30s) are too aggressive. Reference: Balanced=60_000, Saver=120_000.+ /// Guaranteed-capture floor (ms): always take a screenshot at least this+ /// often, even when the screen is unchanged. This is the CLI equivalent of+ /// the app's "Capture frequency" setting — use it when the default+ /// event-driven cadence feels too sparse (e.g. long reading / watching with+ /// few clicks). Overrides the active PowerProfile's idle interval (AC 30s …+ /// Saver up to 300s) and, unlike the raw profile value, is PINNED so it+ /// survives power transitions. Idle captures bypass content dedup, so a+ /// frame is written even on a static screen. e.g. 2000 = a frame at least+ /// every 2s. Omitted = follow the PowerProfile.#[arg(long)]pub idle_capture_interval_ms: Option<u64>,diff --git a/crates/screenpipe-engine/src/event_driven_capture.rs b/crates/screenpipe-engine/src/event_driven_capture.rsindex efd2f0259..421403499 100644--- a/crates/screenpipe-engine/src/event_driven_capture.rs+++ b/crates/screenpipe-engine/src/event_driven_capture.rs@@ -317,6 +317,13 @@ pub struct EventDrivenCaptureConfig {pub visual_check_interval_ms: u64,/// Frame difference threshold (0.0–1.0) above which a VisualChange trigger fires.pub visual_change_threshold: f64,+ /// User-pinned guaranteed-capture floor (ms). When `Some`, this is an+ /// explicit "always capture at least every N ms" choice and it must+ /// survive PowerProfile transitions — a battery-saver switch (whose+ /// profile relaxes the idle interval up to 300s) must NOT silently+ /// loosen the floor the user asked for. `None` = follow the active+ /// PowerProfile's `idle_capture_interval_ms` as before.+ pub idle_capture_interval_override_ms: Option<u64>,}impl Default for EventDrivenCaptureConfig {@@ -330,6 +337,7 @@ impl Default for EventDrivenCaptureConfig {capture_on_clipboard: true,visual_check_interval_ms: 3_000, // check every 3 secondsvisual_change_threshold: 0.05, // ~5% difference triggers capture+ idle_capture_interval_override_ms: None, // follow PowerProfile unless pinned}}}@@ -386,6 +394,22 @@ impl EventDrivenCapture {}}+ /// Apply a PowerProfile's idle-capture interval, honoring a user pin.+ ///+ /// Power profiles set the idle floor per power state (30s on AC, up to+ /// 300s on the most aggressive battery-saver). But a user who pinned an+ /// explicit floor via+ /// `idleCaptureIntervalMs` ("always capture at least every N seconds")+ /// must keep that floor regardless of power state — otherwise plugging+ /// out silently relaxes their guaranteed cadence to minutes. The pin+ /// always wins; with no pin we adopt the profile's value as before.+ pub fn apply_power_profile_idle_interval(&mut self, profile_ms: u64) {+ self.config.idle_capture_interval_ms = self+ .config+ .idle_capture_interval_override_ms+ .unwrap_or(profile_ms);+ }+/// Check if enough time has passed since the last capture (debounce).pub fn can_capture(&self) -> bool {self.last_capture.elapsed() >= Duration::from_millis(self.config.min_capture_interval_ms)@@ -1069,7 +1093,10 @@ pub async fn event_driven_capture_loop(// the bookkeeper so the post-override cadence is still correct.state.config.min_capture_interval_ms =high_fps.on_baseline_change(profile.min_capture_interval_ms);- state.config.idle_capture_interval_ms = profile.idle_capture_interval_ms;+ // A user-pinned idle floor (`idleCaptureIntervalMs`) wins over+ // the profile's value so a power transition can't relax the+ // guaranteed "capture at least every N s" cadence.+ state.apply_power_profile_idle_interval(profile.idle_capture_interval_ms);// Power profile can only LOWER quality from the user's baseline,// never raise it — picking "max" in settings shouldn't be silently// bumped above the profile's value, but a user on saver mode also@@ -2895,6 +2922,44 @@ mod tests {assert!(state.needs_idle_capture());}+ #[test]+ fn power_profile_updates_idle_interval_without_a_pin() {+ // No user override: a PowerProfile transition is free to set the idle+ // floor (e.g. battery-saver relaxing it to 5 minutes).+ let config = EventDrivenCaptureConfig {+ idle_capture_interval_ms: 30_000,+ idle_capture_interval_override_ms: None,+ ..Default::default()+ };+ let mut state = EventDrivenCapture::new(config);++ state.apply_power_profile_idle_interval(300_000);+ assert_eq!(state.config.idle_capture_interval_ms, 300_000);+ }++ #[test]+ fn user_idle_pin_survives_power_profile_change() {+ // User pinned "capture at least every 2s". A later PowerProfile update+ // (e.g. unplugging → battery-saver wants 300s) must NOT relax it.+ let config = EventDrivenCaptureConfig {+ idle_capture_interval_ms: 2_000,+ idle_capture_interval_override_ms: Some(2_000),+ ..Default::default()+ };+ let mut state = EventDrivenCapture::new(config);++ state.apply_power_profile_idle_interval(300_000);+ assert_eq!(+ state.config.idle_capture_interval_ms, 2_000,+ "pinned idle floor must win over the power-profile value"+ );++ // Even a tighter profile value (e.g. a meeting/HD-driven 1s) does not+ // override the user's explicit choice — the pin is authoritative.+ state.apply_power_profile_idle_interval(1_000);+ assert_eq!(state.config.idle_capture_interval_ms, 2_000);+ }+#[test]fn test_trigger_channel() {let (tx, mut rx) = trigger_channel();diff --git a/crates/screenpipe-engine/src/vision_manager/manager.rs b/crates/screenpipe-engine/src/vision_manager/manager.rsindex 79e26c417..dcb7cbf28 100644--- a/crates/screenpipe-engine/src/vision_manager/manager.rs+++ b/crates/screenpipe-engine/src/vision_manager/manager.rs@@ -477,6 +477,10 @@ impl VisionManager {};// Mitsukeru fork: apply per-parameter CLI / settings overrides if any.// These force the value regardless of the active PowerProfile.+ // Carry the user's explicit idle override as a *pin* as well as the+ // live value, so a runtime PowerProfile transition can't relax the+ // guaranteed capture floor back to the profile's (much larger) value.+ capture_config.idle_capture_interval_override_ms = self.config.idle_capture_interval_ms;if let Some(v) = self.config.idle_capture_interval_ms {capture_config.idle_capture_interval_ms = v;}