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

fix(engine): plug frame_linker corr_id leaks at DRM/pause/lag/error gates

Louis Beaumont752d5856b79e
diff --git a/crates/screenpipe-engine/src/event_driven_capture.rs b/crates/screenpipe-engine/src/event_driven_capture.rs
index a13f1cb2f..48930da7f 100644
--- a/crates/screenpipe-engine/src/event_driven_capture.rs
+++ b/crates/screenpipe-engine/src/event_driven_capture.rs
@@ -104,6 +104,52 @@ impl CaptureTriggerMsg {
}
}
+/// Notify the linker that one or more triggers will never produce a
+/// frame. Best-effort: if the linker channel is full or absent, the
+/// pending entries will TTL-evict after 60s. Returns immediately —
+/// `try_send` never blocks the capture loop.
+fn report_triggers_dropped(
+ linker_tx: Option<&crate::frame_linker_actor::LinkerSender>,
+ correlation_ids: Vec<crate::frame_linker::CorrelationId>,
+ reason: crate::frame_linker::DropReason,
+) {
+ let Some(linker) = linker_tx else { return };
+ if correlation_ids.is_empty()
+ && !matches!(reason, crate::frame_linker::DropReason::Lagged)
+ {
+ // Nothing to report unless we're tracking the lag counter.
+ return;
+ }
+ let _ = linker.try_send(crate::frame_linker_actor::LinkerMessage::TriggerDropped {
+ correlation_ids,
+ reason,
+ });
+}
+
+/// Drain whatever's currently in the broadcast receiver into a
+/// `Vec<CorrelationId>`. Used by pause / cold-monitor branches that
+/// must let the linker know these triggers will never produce a frame.
+fn drain_pending_corr_ids(trigger_rx: &mut TriggerReceiver) -> Vec<crate::frame_linker::CorrelationId> {
+ let mut out = Vec::new();
+ loop {
+ match trigger_rx.try_recv() {
+ Ok(msg) => {
+ if let Some(corr) = msg.correlation_id {
+ out.push(corr);
+ }
+ }
+ Err(broadcast::error::TryRecvError::Empty)
+ | Err(broadcast::error::TryRecvError::Closed) => break,
+ Err(broadcast::error::TryRecvError::Lagged(_)) => {
+ // Lagged inside drain — keep trying; the receiver auto-
+ // recovers to the latest available message.
+ continue;
+ }
+ }
+ }
+ out
+}
+
/// Reduce a batch of drained triggers to (kind, correlation_ids).
///
/// - `kind` is the most recent non-skipped trigger (most recent context
@@ -277,9 +323,17 @@ impl EventDrivenCapture {
pub type TriggerSender = broadcast::Sender<CaptureTriggerMsg>;
pub type TriggerReceiver = broadcast::Receiver<CaptureTriggerMsg>;
+/// Broadcast buffer for capture triggers. Sized to absorb a typing
+/// burst (Arc/Claude routinely emit 100+ Text/Click events in <200ms)
+/// while one monitor is mid-screenshot (250-800ms blocking). At 32B per
+/// `CaptureTriggerMsg` this is ~128KB total. Smaller buffers cause
+/// `broadcast::error::RecvError::Lagged`, which drops correlation_ids
+/// permanently — the `ui_events` rows then stay `frame_id = NULL`.
+pub const TRIGGER_CHANNEL_BUFFER: usize = 4096;
+
/// Create a trigger channel pair.
pub fn trigger_channel() -> (TriggerSender, TriggerReceiver) {
- let (tx, rx) = broadcast::channel(64);
+ let (tx, rx) = broadcast::channel(TRIGGER_CHANNEL_BUFFER);
(tx, rx)
}
@@ -562,6 +616,21 @@ pub async fn event_driven_capture_loop(
}
}
CaptureState::Cold => {
+ // Drain any triggers that arrived while we were Cold —
+ // they'll never produce a frame on this monitor, so tell
+ // the linker now instead of letting them TTL-evict. With
+ // multi-monitor setups the linker only needs ONE monitor
+ // to claim a corr_id; if this monitor was Cold but another
+ // captured, the corr_id is already paired and our
+ // TriggerDropped becomes a harmless no-op for it.
+ let drained = drain_pending_corr_ids(&mut trigger_rx);
+ if !drained.is_empty() {
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ drained,
+ crate::frame_linker::DropReason::Other,
+ );
+ }
// Block until focus returns. 5s backstop guards against
// stuck waiters if a focus event is ever missed.
let notify = focus_controller.notify_for(monitor_id);
@@ -605,6 +674,21 @@ pub async fn event_driven_capture_loop(
monitor.release_capture_stream();
}
was_in_pause_state = true;
+ // Drain triggers that piled up while paused so the linker
+ // doesn't hold their corr_ids for the full 60s TTL. The
+ // recorder keeps emitting events through every pause state
+ // (a11y observer is independent of capture), so without this
+ // drain a multi-minute pause overflows the broadcast buffer
+ // and the dropped ids show up as misleading "stale entries"
+ // WARNs later.
+ let drained = drain_pending_corr_ids(&mut trigger_rx);
+ if !drained.is_empty() {
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ drained,
+ crate::frame_linker::DropReason::Paused,
+ );
+ }
tokio::time::sleep(poll_interval).await;
continue;
} else if was_in_pause_state {
@@ -725,8 +809,15 @@ pub async fn event_driven_capture_loop(
);
// Missed broadcast msgs — their correlation_ids are
// gone forever and those ui_events rows will stay
- // frame_id=NULL. Fall back to Manual below if
- // nothing else in this drain wins.
+ // frame_id=NULL. Bump the lagged counter so the
+ // periodic linker WARN shows this slice of loss.
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ Vec::new(),
+ crate::frame_linker::DropReason::Lagged,
+ );
+ let _ = n;
+ // Fall back to Manual below if nothing else wins.
lagged_force_manual = true;
}
Ok(Err(broadcast::error::RecvError::Closed)) => {
@@ -754,6 +845,12 @@ pub async fn event_driven_capture_loop(
"trigger channel lagged by {} more messages on monitor {}",
n, monitor_id
);
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ Vec::new(),
+ crate::frame_linker::DropReason::Lagged,
+ );
+ let _ = n;
lagged_force_manual = true;
}
Err(broadcast::error::TryRecvError::Closed) => {
@@ -861,6 +958,15 @@ pub async fn event_driven_capture_loop(
"pre-capture DRM check blocked capture on monitor {}",
monitor_id
);
+ // Release the corr_ids the linker is waiting on so
+ // the ui_events rows don't sit pending for 60s.
+ if !correlation_ids.is_empty() {
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ std::mem::take(&mut correlation_ids),
+ crate::frame_linker::DropReason::Drm,
+ );
+ }
tokio::time::sleep(poll_interval).await;
continue;
}
@@ -1051,6 +1157,16 @@ pub async fn event_driven_capture_loop(
);
}
+ // Release corr_ids the linker is waiting on —
+ // this capture failed, no frame_id is coming.
+ if !correlation_ids.is_empty() {
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ std::mem::take(&mut correlation_ids),
+ crate::frame_linker::DropReason::CaptureError,
+ );
+ }
+
// Exponential backoff for persistent failures — avoids
// hammering a broken capture path (missing Wayland
// protocol, permission denied, etc.) while still
@@ -1068,6 +1184,13 @@ pub async fn event_driven_capture_loop(
trigger.as_str(),
monitor_id
);
+ if !correlation_ids.is_empty() {
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ std::mem::take(&mut correlation_ids),
+ crate::frame_linker::DropReason::CaptureError,
+ );
+ }
}
}
} else {
@@ -1076,6 +1199,28 @@ pub async fn event_driven_capture_loop(
trigger.as_str(),
monitor_id
);
+ // Debounce within min_capture_interval_ms. The events
+ // belong to the previous frame visually (screen is the
+ // same), so link them to `last_frame_id` if we have one;
+ // otherwise tell the linker to release them.
+ if !correlation_ids.is_empty() {
+ if let (Some(ref linker), Some(fid)) = (&linker_tx, last_frame_id) {
+ let _ = linker.try_send(
+ crate::frame_linker_actor::LinkerMessage::FrameCaptured(
+ crate::frame_linker::FrameCaptured {
+ frame_id: fid,
+ correlation_ids: std::mem::take(&mut correlation_ids),
+ },
+ ),
+ );
+ } else {
+ report_triggers_dropped(
+ linker_tx.as_ref(),
+ std::mem::take(&mut correlation_ids),
+ crate::frame_linker::DropReason::Other,
+ );
+ }
+ }
}
}
diff --git a/crates/screenpipe-engine/src/frame_linker.rs b/crates/screenpipe-engine/src/frame_linker.rs
index 8d56f46a0..97f4f4f82 100644
--- a/crates/screenpipe-engine/src/frame_linker.rs
+++ b/crates/screenpipe-engine/src/frame_linker.rs
@@ -77,6 +77,31 @@ pub struct LinkUpdate {
pub frame_id: i64,
}
+/// Why a triggering event will never get a frame. Reported by the
+/// capture loop at the moment it decides to drop a trigger, so the
+/// linker can release the pending entry immediately instead of waiting
+/// 60s for TTL and emitting a misleading "frame never arrived" WARN.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum DropReason {
+ /// The focused window was DRM-protected at trigger time.
+ Drm,
+ /// The capture loop was in a pause state (locked screen, power
+ /// saver, schedule pause). Triggers received while paused are
+ /// drained and reported with this reason.
+ Paused,
+ /// `broadcast::Receiver::recv` returned `Lagged(n)` — the ring
+ /// buffer overflowed and N messages were dropped before reaching
+ /// us. We don't know which correlation_ids; this reason is reported
+ /// with an empty list, purely for metrics visibility.
+ Lagged,
+ /// `do_capture` returned an error (SCK failure, monitor disconnect,
+ /// etc.). Triggers that drained alongside the failing capture have
+ /// no frame to point at.
+ CaptureError,
+ /// Any other deterministic skip not yet enumerated.
+ Other,
+}
+
/// Configuration. Both knobs derive from existing recorder/capture
/// timeouts; pick values that comfortably exceed the worst-case round
/// trip from "trigger sent" → "frame captured + row flushed."
@@ -194,6 +219,31 @@ impl FrameLinker {
updates
}
+ /// Called by the capture loop when it decides to drop a set of
+ /// triggers (DRM gate, pause state, capture error, etc.). Removes
+ /// the matching pending events without emitting an UPDATE and
+ /// returns how many were actually pending. Idempotent: unknown
+ /// correlation_ids are ignored. Empty input is valid (used by the
+ /// Lagged path which only carries a count, not the ids).
+ pub fn on_trigger_dropped(&mut self, correlation_ids: &[CorrelationId]) -> usize {
+ let mut removed = 0;
+ for corr_id in correlation_ids {
+ if self.pending_events.remove(corr_id).is_some() {
+ removed += 1;
+ }
+ // Also clear from any pending_frame's unmatched list — a
+ // trigger that's been dropped will never get a row, so
+ // future event_persisted calls for this corr_id won't
+ // happen. Without this, a half-paired frame could sit in
+ // pending_frames waiting for a row that's dead.
+ for pf in self.pending_frames.iter_mut() {
+ pf.unmatched.retain(|c| c != corr_id);
+ }
+ }
+ self.compact_pending_frames();
+ removed
+ }
+
/// Drop half-paired entries older than `ttl`. Call periodically
/// from the host actor. Returns the number of entries evicted —
/// useful for metrics ("how many events never got a frame").
@@ -619,6 +669,105 @@ mod tests {
assert_eq!(linker.pending_len(), (1, 1));
}
+ #[test]
+ fn trigger_dropped_removes_pending_event() {
+ let mut linker = FrameLinker::new(cfg());
+ let t0 = Instant::now();
+
+ linker.on_event_persisted(
+ EventPersisted {
+ correlation_id: 1,
+ row_id: 100,
+ },
+ t0,
+ );
+ assert_eq!(linker.pending_len(), (1, 0));
+
+ let removed = linker.on_trigger_dropped(&[1]);
+ assert_eq!(removed, 1);
+ assert_eq!(linker.pending_len(), (0, 0));
+
+ // A late frame for the dropped corr id is a no-op (the row was
+ // never going to be linked anyway).
+ let updates = linker.on_frame_captured(
+ FrameCaptured {
+ frame_id: 999,
+ correlation_ids: vec![1],
+ },
+ t0,
+ );
+ assert!(updates.is_empty());
+ }
+
+ #[test]
+ fn trigger_dropped_unknown_id_is_noop() {
+ let mut linker = FrameLinker::new(cfg());
+ let removed = linker.on_trigger_dropped(&[42]);
+ assert_eq!(removed, 0);
+ assert_eq!(linker.pending_len(), (0, 0));
+ }
+
+ #[test]
+ fn trigger_dropped_clears_unmatched_from_pending_frame() {
+ let mut linker = FrameLinker::new(cfg());
+ let t0 = Instant::now();
+
+ // Frame arrives first with 3 unmatched ids.
+ linker.on_frame_captured(
+ FrameCaptured {
+ frame_id: 999,
+ correlation_ids: vec![1, 2, 3],
+ },
+ t0,
+ );
+ assert_eq!(linker.pending_len(), (0, 1));
+
+ // Drop corr ids 2 and 3 — the frame should now only wait on 1.
+ let removed = linker.on_trigger_dropped(&[2, 3]);
+ assert_eq!(
+ removed, 0,
+ "no events were pending; only frame-side unmatched cleared"
+ );
+ // Pending frame still alive (unmatched=[1]).
+ assert_eq!(linker.pending_len(), (0, 1));
+
+ // Event 1 lands → pair, frame entry compacts away.
+ let u = linker.on_event_persisted(
+ EventPersisted {
+ correlation_id: 1,
+ row_id: 100,
+ },
+ t0,
+ );
+ assert_eq!(
+ u,
+ Some(LinkUpdate {
+ row_id: 100,
+ frame_id: 999
+ })
+ );
+ assert_eq!(linker.pending_len(), (0, 0));
+ }
+
+ #[test]
+ fn trigger_dropped_compacts_fully_cleared_frame() {
+ let mut linker = FrameLinker::new(cfg());
+ let t0 = Instant::now();
+
+ linker.on_frame_captured(
+ FrameCaptured {
+ frame_id: 999,
+ correlation_ids: vec![1, 2],
+ },
+ t0,
+ );
+ assert_eq!(linker.pending_len(), (0, 1));
+
+ // Both unmatched ids dropped → frame entry should be compacted away.
+ linker.on_trigger_dropped(&[1, 2]);
+ assert_eq!(linker.pending_len(), (0, 0));
+ }
+
#[test]
fn pending_frame_with_mixed_matched_and_unmatched_corr_ids() {
let mut linker = FrameLinker::new(cfg());
diff --git a/crates/screenpipe-engine/src/frame_linker_actor.rs b/crates/screenpipe-engine/src/frame_linker_actor.rs
index 30947ae2d..0b1ea4a9b 100644
--- a/crates/screenpipe-engine/src/frame_linker_actor.rs
+++ b/crates/screenpipe-engine/src/frame_linker_actor.rs
@@ -22,7 +22,7 @@ use tokio::task::JoinHandle;
use tracing::{debug, info, warn};
use crate::frame_linker::{
- CorrelationId, EventPersisted, FrameCaptured, FrameLinker, FrameLinkerConfig,
+ CorrelationId, DropReason, EventPersisted, FrameCaptured, FrameLinker, FrameLinkerConfig,
};
/// Cumulative counters published by the linker actor. Read via
@@ -36,11 +36,25 @@ pub struct LinkerMetrics {
pub updates_failed: u64,
/// Half-paired entries dropped because their TTL expired without a match.
pub evicted_ttl: u64,
+ /// Triggers explicitly dropped by the capture loop, broken down by
+ /// reason. Reported via [`LinkerMessage::TriggerDropped`]; these
+ /// numbers should account for the bulk of NULL `frame_id` rows
+ /// once instrumentation is in place across every drop site.
+ pub dropped_drm: u64,
+ pub dropped_paused: u64,
+ pub dropped_lagged: u64,
+ pub dropped_capture_error: u64,
+ pub dropped_other: u64,
}
static PAIRS_EMITTED: AtomicU64 = AtomicU64::new(0);
static UPDATES_FAILED: AtomicU64 = AtomicU64::new(0);
static EVICTED_TTL: AtomicU64 = AtomicU64::new(0);
+static DROPPED_DRM: AtomicU64 = AtomicU64::new(0);
+static DROPPED_PAUSED: AtomicU64 = AtomicU64::new(0);
+static DROPPED_LAGGED: AtomicU64 = AtomicU64::new(0);
+static DROPPED_CAPTURE_ERROR: AtomicU64 = AtomicU64::new(0);
+static DROPPED_OTHER: AtomicU64 = AtomicU64::new(0);
/// Read a point-in-time snapshot of the linker counters. Process-wide
/// (the actor itself is a singleton inside `VisionManager`).
@@ -49,16 +63,36 @@ pub fn linker_metrics_snapshot() -> LinkerMetrics {
pairs_emitted: PAIRS_EMITTED.load(Ordering::Relaxed),
updates_failed: UPDATES_FAILED.load(Ordering::Relaxed),
evicted_ttl: EVICTED_TTL.load(Ordering::Relaxed),
+ dropped_drm: DROPPED_DRM.load(Ordering::Relaxed),
+ dropped_paused: DROPPED_PAUSED.load(Ordering::Relaxed),
+ dropped_lagged: DROPPED_LAGGED.load(Ordering::Relaxed),
+ dropped_capture_error: DROPPED_CAPTURE_ERROR.load(Ordering::Relaxed),
+ dropped_other: DROPPED_OTHER.load(Ordering::Relaxed),
+ }
+}
+
+fn drop_reason_counter(reason: DropReason) -> &'static AtomicU64 {
+ match reason {
+ DropReason::Drm => &DROPPED_DRM,
+ DropReason::Paused => &DROPPED_PAUSED,
+ DropReason::Lagged => &DROPPED_LAGGED,
+ DropReason::CaptureError => &DROPPED_CAPTURE_ERROR,
+ DropReason::Other => &DROPPED_OTHER,
}
}
/// Messages flowing into the linker actor. The recorder side sends
/// `EventPersisted` after each batch flush; each capture loop sends
-/// `FrameCaptured` after each successful capture.
+/// `FrameCaptured` after each successful capture, or `TriggerDropped`
+/// when it decides not to capture (DRM, pause, capture error, etc.).
#[derive(Debug)]
pub enum LinkerMessage {
EventPersisted(EventPersisted),
FrameCaptured(FrameCaptured),
+ TriggerDropped {
+ correlation_ids: Vec<CorrelationId>,
+ reason: DropReason,
+ },
}
pub type LinkerSender = mpsc::Sender<LinkerMessage>;
@@ -162,6 +196,22 @@ pub fn spawn_frame_linker(
apply_update(&db, update.row_id, update.frame_id).await;
}
}
+ Some(LinkerMessage::TriggerDropped { correlation_ids, reason }) => {
+ let n_corr = correlation_ids.len();
+ // Bump the per-reason counter regardless of whether
+ // the corr_ids were pending — for `Lagged` the
+ // capture side can't recover the ids, only the
+ // count, and we still want visibility.
+ let bump = if n_corr == 0 { 1 } else { n_corr as u64 };
+ drop_reason_counter(reason).fetch_add(bump, Ordering::Relaxed);
+ let removed = linker.on_trigger_dropped(&correlation_ids);
+ debug!(
+ ?reason,
+ n_corr,
+ removed,
+ "frame_linker: trigger(s) dropped by capture loop"
+ );
+ }
}
}
_ = tick.tick() => {
@@ -170,6 +220,11 @@ pub fn spawn_frame_linker(
let total_pairs = PAIRS_EMITTED.load(Ordering::Relaxed);
let total_evicted = EVICTED_TTL.load(Ordering::Relaxed) + evicted as u64;
let total_failed = UPDATES_FAILED.load(Ordering::Relaxed);
+ let dropped_drm = DROPPED_DRM.load(Ordering::Relaxed);
+ let dropped_paused = DROPPED_PAUSED.load(Ordering::Relaxed);
+ let dropped_lagged = DROPPED_LAGGED.load(Ordering::Relaxed);
+ let dropped_capture_error = DROPPED_CAPTURE_ERROR.load(Ordering::Relaxed);
+ let dropped_other = DROPPED_OTHER.load(Ordering::Relaxed);
if evicted > 0 {
EVICTED_TTL.fetch_add(evicted as u64, Ordering::Relaxed);
warn!(
@@ -179,7 +234,12 @@ pub fn spawn_frame_linker(
total_pairs,
total_evicted,
total_failed,
- "frame_linker: stale entries expired without pairing (frame or event never arrived)"
+ dropped_drm,
+ dropped_paused,
+ dropped_lagged,
+ dropped_capture_error,
+ dropped_other,
+ "frame_linker: stale entries expired without pairing — these slipped past every instrumented drop site (DRM/paused/lagged/capture_error); investigate the residual"
);
} else {
debug!(
@@ -188,6 +248,11 @@ pub fn spawn_frame_linker(
total_pairs,
total_evicted,
total_failed,
+ dropped_drm,
+ dropped_paused,
+ dropped_lagged,
+ dropped_capture_error,
+ dropped_other,
"frame_linker: tick"
);
}
diff --git a/crates/screenpipe-engine/src/ui_recorder.rs b/crates/screenpipe-engine/src/ui_recorder.rs
index da8422ad4..28a84dbd2 100644
--- a/crates/screenpipe-engine/src/ui_recorder.rs
+++ b/crates/screenpipe-engine/src/ui_recorder.rs
@@ -577,9 +577,23 @@ pub async fn start_ui_recording(
matches!(db_event.event_type, screenpipe_db::UiEventType::Scroll);
let trigger_kind =
capture_trigger_kind(&db_event, &ignored_patterns, trigger_gates);
+ // A correlation id is only useful if there's somewhere
+ // for both halves to land: a live capture-loop receiver
+ // to produce the frame AND a linker to pair them. If
+ // either side is missing (no monitors / linker stopped),
+ // minting an id just parks an entry in the linker for
+ // 60s before TTL-evicting it. Check `receiver_count`
+ // explicitly so the recorder doesn't bother — there's
+ // an inherent send/recv race but it shrinks the window
+ // from "always" to "near miss."
+ let has_trigger_receivers = capture_trigger_tx
+ .as_ref()
+ .map(|tx| tx.receiver_count() > 0)
+ .unwrap_or(false);
let want_corr_id = (trigger_kind.is_some() || is_scroll)
- && (capture_trigger_tx.is_some() || linker_tx.is_some());
- let correlation_id = if want_corr_id {
+ && has_trigger_receivers
+ && linker_tx.is_some();
+ let mut correlation_id = if want_corr_id {
Some(next_correlation_id())
} else {
None
@@ -593,8 +607,16 @@ pub async fn start_ui_recording(
(&capture_trigger_tx, trigger_kind, correlation_id)
{
use crate::event_driven_capture::CaptureTriggerMsg;
- let _ =
- trigger_tx.send(CaptureTriggerMsg::with_correlation(trigger, corr_id));
+ // 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()
+ {
+ correlation_id = None;
+ }
}
if record_input_events {
@@ -686,14 +708,26 @@ pub async fn start_ui_recording(
// Did a scroll burst just settle? Emit ScrollStop with the
// tail corr id so the linker can populate frame_id on the
- // last Scroll row in the burst.
+ // last Scroll row in the burst. If the broadcast has no
+ // receivers the trigger evaporates, so notify the linker to
+ // drop that corr_id immediately rather than waiting on TTL.
if let Some(corr_id) = scroll_burst.poll_burst_end() {
if let Some(ref trigger_tx) = capture_trigger_tx {
use crate::event_driven_capture::{CaptureTrigger, CaptureTriggerMsg};
- let _ = trigger_tx.send(CaptureTriggerMsg::with_correlation(
- CaptureTrigger::ScrollStop,
- corr_id,
- ));
+ let send_failed = trigger_tx
+ .send(CaptureTriggerMsg::with_correlation(
+ CaptureTrigger::ScrollStop,
+ corr_id,
+ ))
+ .is_err();
+ if send_failed {
+ if let Some(ref linker) = linker_tx {
+ let _ = linker.try_send(LinkerMessage::TriggerDropped {
+ correlation_ids: vec![corr_id],
+ reason: crate::frame_linker::DropReason::Other,
+ });
+ }
+ }
}
}
}
diff --git a/crates/screenpipe-engine/src/vision_manager/manager.rs b/crates/screenpipe-engine/src/vision_manager/manager.rs
index 6d87a4c7a..3c063d25f 100644
--- a/crates/screenpipe-engine/src/vision_manager/manager.rs
+++ b/crates/screenpipe-engine/src/vision_manager/manager.rs
@@ -107,7 +107,9 @@ impl VisionManager {
vision_handle: Handle,
) -> Self {
// Single broadcast channel shared across all monitors + UI recorder.
- let (trigger_tx, _rx) = tokio::sync::broadcast::channel::<CaptureTriggerMsg>(64);
+ let (trigger_tx, _rx) = tokio::sync::broadcast::channel::<CaptureTriggerMsg>(
+ crate::event_driven_capture::TRIGGER_CHANNEL_BUFFER,
+ );
// Frame-linker actor: pairs UI events with the frames they
// caused us to capture. Single shared instance across all