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
fix(macos): recover capture after updater relaunch
Louis Beaumont1d9b755131bf
diff --git a/apps/screenpipe-app-tauri/e2e/mock-updates/packaged-update-restart.e2e.ts b/apps/screenpipe-app-tauri/e2e/mock-updates/packaged-update-restart.e2e.tsindex f43cd89dd..304a21ddf 100644--- a/apps/screenpipe-app-tauri/e2e/mock-updates/packaged-update-restart.e2e.ts+++ b/apps/screenpipe-app-tauri/e2e/mock-updates/packaged-update-restart.e2e.ts@@ -26,9 +26,12 @@* ("Installing update…") before the process exits.* 3. FAST INSTALL — the exit-path install used the pre-extracted rename* path (log-asserted) and the old→new process blackout stays bounded.- * 4. POST-UPDATE — marker consumed as applied; updater returns None;+ * 4. POST-UPDATE CAPTURE — the replacement starts the real engine and+ * produces a ScreenCaptureKit frame instead of inheriting a stale+ * permission-denied state from the process it replaced.+ * 5. POST-UPDATE — marker consumed as applied; updater returns None;* a click with nothing staged does NOT kill the app.- * 5. FAILED-ATTEMPT DETECTION — a synthetic stale marker (from == running+ * 6. FAILED-ATTEMPT DETECTION — a synthetic stale marker (from == running* version) surfaces "Update didn't apply — click to retry" on boot.** Run (builds two release-local bundles; slow the first time):@@ -65,6 +68,8 @@ const UPDATE_SERVER_PORT = 8765;const STATE_URL = `http://127.0.0.1:${CONTROL_PORT}/e2e/updates/state`;const CLICK_URL = `http://127.0.0.1:${CONTROL_PORT}/e2e/updates/click`;+const START_CAPTURE_URL = `http://127.0.0.1:${CONTROL_PORT}/e2e/updates/start-capture`;+const HEALTH_URL = `http://127.0.0.1:${API_PORT}/health`;const SKIP_BUILD = process.env.SP_PACKAGED_UPDATER_SKIP_BUILD === '1';@@ -107,6 +112,13 @@ interface UpdaterState {app_version: string;}+interface HealthState {+ frame_status?: string;+ pipeline?: {+ capture_attempts?: number;+ };+}+async function fetchState(timeoutMs = 1500): Promise<UpdaterState | null> {try {const res = await fetch(STATE_URL, { signal: AbortSignal.timeout(timeoutMs) });@@ -117,6 +129,16 @@ async function fetchState(timeoutMs = 1500): Promise<UpdaterState | null> {}}+async function fetchHealth(timeoutMs = 1500): Promise<HealthState | null> {+ try {+ const res = await fetch(HEALTH_URL, { signal: AbortSignal.timeout(timeoutMs) });+ const body = await res.json();+ return body && typeof body === 'object' ? (body as HealthState) : null;+ } catch {+ return null;+ }+}+async function waitFor<T>(what: string,timeoutMs: number,@@ -207,11 +229,11 @@ function launchApp(): ReturnType<typeof Bun.spawn> {SCREENPIPE_DATA_DIR: DATA_DIR,SCREENPIPE_PORT: String(API_PORT),SCREENPIPE_FOCUS_PORT: String(CONTROL_PORT),- // Marks the process as isolated (no prod-chat migration) without- // activating any behavior seed — unknown tokens are ignored, so the- // app boots exactly like a fresh signed-out install: entitlement gate+ // The updater token marks the process as isolated (no prod-chat+ // migration). Audio is disabled so the post-update phase isolates SCK;+ // the app still boots like a fresh signed-out install: entitlement gate// → engine never starts → boot phase "idle" (the MacBook Air repro).- SCREENPIPE_E2E_SEED: 'packaged-updater',+ SCREENPIPE_E2E_SEED: 'packaged-updater,no-audio,packaged-updater-sck-race',SCREENPIPE_DISABLE_TELEMETRY: '1',},stdout: 'ignore',@@ -416,7 +438,32 @@ async function main(): Promise<void> {);check('log: no deferred-restart warnings', !logAfter.includes('deferring restart to avoid'));- // ── Scenario 4: post-update state + click-with-nothing-staged safety ─────+ // Scenario 4: a successful app relaunch is not enough. Start the same real+ // capture pipeline users get after entitlement resolves and require an SCK+ // frame from the replacement process. The E2E-only race latch makes the+ // old direct-spawn relaunch deterministically reproduce the field failure.+ log('starting real post-update screen capture…');+ const captureResponse = await fetch(START_CAPTURE_URL, {+ method: 'POST',+ signal: AbortSignal.timeout(60_000),+ });+ must('post-update capture start accepted', captureResponse.ok);+ const captureResult = (await captureResponse.json()) as { started: boolean; error: string | null };+ must('post-update capture session constructed', captureResult.started, captureResult.error ?? undefined);+ const captureHealth = await waitFor('post-update ScreenCaptureKit frame', 45_000, async () => {+ const health = await fetchHealth();+ return health?.frame_status === 'ok' && (health.pipeline?.capture_attempts ?? 0) > 0+ ? health+ : null;+ });+ check('replacement produced a real screen frame', captureHealth.frame_status === 'ok');+ check(+ 'replacement advanced capture attempts',+ (captureHealth.pipeline?.capture_attempts ?? 0) > 0,+ String(captureHealth.pipeline?.capture_attempts ?? 0),+ );++ // ── Scenario 5: post-update state + click-with-nothing-staged safety ─────const settled = await waitFor('post-update updater settled', 60_000, async () => {const s = await fetchState();@@ -433,7 +480,7 @@ async function main(): Promise<void> {check('app survived a no-update click', afterNoopClick !== null && afterNoopClick.app_version === NEW_VERSION);check('no restart was started by the no-update click', afterNoopClick?.restart_started === false);- // ── Scenario 5: failed-install detection on next boot ────────────────────+ // ── Scenario 6: failed-install detection on next boot ────────────────────log('simulating a failed install (marker from == running version)…');killWorkdirApp();diff --git a/apps/screenpipe-app-tauri/e2e/specs/capture-stall-stage-marker.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/capture-stall-stage-marker.spec.tsindex b56c051d6..fdfbeb5cc 100644--- a/apps/screenpipe-app-tauri/e2e/specs/capture-stall-stage-marker.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/capture-stall-stage-marker.spec.ts@@ -75,7 +75,10 @@ const METRICS_RS = resolve(*/function knownStagesFromRust(): string[] {const source = readFileSync(METRICS_RS, "utf8");- const asStr = source.match(+ const implStart = source.indexOf("impl CaptureLoopStage {");+ const captureLoopStageImpl =+ implStart >= 0 ? source.slice(implStart) : "";+ const asStr = captureLoopStageImpl.match(/pub fn as_str\(self\) -> &'static str \{([\s\S]*?)\n {4}\}/,);if (!asStr) {diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 6f9c3a937..aa692a8cb 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -288,7 +288,7 @@ pulseaudio = ["screenpipe-audio/pulseaudio"]directml = ["screenpipe-engine/directml"]vulkan = ["screenpipe-audio/vulkan"]cargo-clippy = []-e2e = ["tauri-plugin-webdriver", "dep:sqlx"]+e2e = ["tauri-plugin-webdriver", "dep:sqlx", "screenpipe-screen/e2e"]# DO NOT REMOVE!!custom-protocol = ["tauri/custom-protocol"]diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex ae29cd8e8..fefdbdae5 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -471,6 +471,10 @@ async fn main() {std::process::exit(exit_code);}+ // The packaged updater E2E latches whether the replacement process began+ // before macOS finished releasing the previous app's SCK/TCC state.+ process_exit::latch_e2e_sck_relaunch_race();+// Point debug builds at their own data dir and ports so `bun tauri dev`// can't hand off to (or kill) an installed production app. Must run before// the DB-recovery-lock check, the /focus single-instance handoff and thediff --git a/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rs b/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rsindex 069d23a11..94396e62b 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rs@@ -26,6 +26,114 @@ use std::time::Duration;use tauri::{AppHandle, Manager};use tracing::{info, warn};+#[cfg(all(feature = "e2e", target_os = "macos"))]+const E2E_SCK_RELAUNCH_RACE_SEED: &str = "packaged-updater-sck-race";+#[cfg(all(feature = "e2e", target_os = "macos"))]+const E2E_SCK_RELAUNCH_DEADLINE_FILE: &str = ".e2e-sck-relaunch-not-before";+const MACOS_UPDATER_RELAUNCH_SETTLE: Duration = Duration::from_secs(3);+#[cfg(any(target_os = "macos", test))]+const MACOS_UPDATER_RELAUNCH_HELPER: &str = r#"+old_pid=$1+settle_seconds=$2+shift 2+checks=0+while kill -0 "$old_pid" 2>/dev/null && [ "$checks" -lt 100 ]; do+ /bin/sleep 0.05+ checks=$((checks + 1))+done+/bin/sleep "$settle_seconds"+exec "$@"+"#;++#[cfg(any(target_os = "macos", test))]+fn macos_updater_relaunch_command<I, S>(+ binary: &Path,+ args: I,+ old_pid: u32,+ settle: Duration,+) -> Command+where+ I: IntoIterator<Item = S>,+ S: AsRef<std::ffi::OsStr>,+{+ let mut command = Command::new("/bin/sh");+ command+ .arg("-c")+ .arg(MACOS_UPDATER_RELAUNCH_HELPER)+ .arg("screenpipe-updater-relaunch-helper")+ .arg(old_pid.to_string())+ .arg(settle.as_secs().to_string())+ .arg(binary)+ .args(args);+ command+}++#[cfg(all(feature = "e2e", target_os = "macos"))]+fn e2e_seed_has_exact_token(token: &str) -> bool {+ std::env::var("SCREENPIPE_E2E_SEED")+ .ok()+ .is_some_and(|seeds| seeds.split(',').any(|seed| seed.trim() == token))+}++#[cfg(all(feature = "e2e", target_os = "macos"))]+fn e2e_sck_relaunch_deadline_path() -> PathBuf {+ screenpipe_core::paths::default_screenpipe_data_dir()+ .join(E2E_SCK_RELAUNCH_DEADLINE_FILE)+}++#[cfg(all(feature = "e2e", target_os = "macos"))]+fn epoch_millis() -> u128 {+ std::time::SystemTime::now()+ .duration_since(std::time::UNIX_EPOCH)+ .unwrap_or_default()+ .as_millis()+}++/// E2E-only model of replayd/TCC still releasing the dying app. The replacement+/// process consumes this marker at the very beginning of `main`, before any+/// ScreenCaptureKit call can happen.+#[cfg(all(feature = "e2e", target_os = "macos"))]+fn arm_e2e_sck_relaunch_race() {+ if !e2e_seed_has_exact_token(E2E_SCK_RELAUNCH_RACE_SEED) {+ return;+ }+ let deadline = epoch_millis() + MACOS_UPDATER_RELAUNCH_SETTLE.as_millis();+ if let Err(error) = std::fs::write(e2e_sck_relaunch_deadline_path(), deadline.to_string()) {+ warn!("e2e: failed to arm SCK updater-relaunch race: {error}");+ } else {+ info!("e2e: armed SCK updater-relaunch settle deadline");+ }+}++#[cfg(not(all(feature = "e2e", target_os = "macos")))]+fn arm_e2e_sck_relaunch_race() {}++/// Latch whether this E2E replacement process started during the simulated+/// replayd/TCC release window. The screen crate turns the latch into the same+/// persistent permission-denied enumeration observed in the field incident.+#[cfg(all(feature = "e2e", target_os = "macos"))]+pub fn latch_e2e_sck_relaunch_race() {+ if !e2e_seed_has_exact_token(E2E_SCK_RELAUNCH_RACE_SEED) {+ return;+ }+ let path = e2e_sck_relaunch_deadline_path();+ let deadline = std::fs::read_to_string(&path)+ .ok()+ .and_then(|value| value.trim().parse::<u128>().ok());+ let _ = std::fs::remove_file(&path);+ match deadline {+ Some(deadline) if epoch_millis() < deadline => {+ std::env::set_var("SCREENPIPE_E2E_SCK_RELAUNCH_POISONED", "1");+ warn!("e2e: replacement launched before SCK settle deadline; latching permission denial");+ }+ Some(_) => info!("e2e: replacement launched after SCK settle deadline"),+ None => {}+ }+}++#[cfg(not(all(feature = "e2e", target_os = "macos")))]+pub fn latch_e2e_sck_relaunch_race() {}+/// Returns true when a panic payload is shutdown-time noise, not a real crash.pub(crate) fn is_orderly_shutdown_panic(payload: &str) -> bool {payload.contains("Tokio 1.x context was found, but it is being shutdown")@@ -180,18 +288,47 @@ pub fn force_app_relaunch(app: AppHandle, status: i32) -> ! {// call. The relaunch binary path below was cached at process start, so// the spawn hits the freshly installed bundle.#[cfg(target_os = "macos")]- crate::staged_update::install_staged_if_any(&app);+ let update_installed = crate::staged_update::install_staged_if_any(&app);+ #[cfg(not(target_os = "macos"))]+ let update_installed = false;++ if update_installed {+ arm_e2e_sck_relaunch_race();+ }let env = app.env();if let Some(binary) = relaunch_binary(&app) {- let mut command = Command::new(&binary);- command.args(env.args_os.iter().skip(1));+ #[cfg(target_os = "macos")]+ let mut command = if update_installed {+ macos_updater_relaunch_command(+ &binary,+ env.args_os.iter().skip(1),+ std::process::id(),+ MACOS_UPDATER_RELAUNCH_SETTLE,+ )+ } else {+ let mut command = Command::new(&binary);+ command.args(env.args_os.iter().skip(1));+ command+ };+ #[cfg(not(target_os = "macos"))]+ let mut command = {+ let mut command = Command::new(&binary);+ command.args(env.args_os.iter().skip(1));+ command+ };#[cfg(unix)]{use std::os::unix::process::CommandExt;command.process_group(0);}match command.spawn() {+ Ok(child) if update_installed => info!(+ "safe relaunch: spawned delayed updater helper for {} (pid {}, settle {}s)",+ binary.display(),+ child.id(),+ MACOS_UPDATER_RELAUNCH_SETTLE.as_secs()+ ),Ok(child) => info!("safe relaunch: spawned replacement {} (pid {})",binary.display(),@@ -592,7 +729,7 @@ pub fn request_app_quit(app: AppHandle) {#[cfg(test)]mod tests {- use super::extract_cf_bundle_executable;+ use super::{extract_cf_bundle_executable, macos_updater_relaunch_command};#[test]fn extracts_bundle_executable_from_xml_plist() {@@ -612,4 +749,24 @@ mod tests {Some("screenpipe-app"));}++ #[cfg(target_os = "macos")]+ #[test]+ fn updater_relaunch_helper_preserves_spaced_arguments_without_shell_interpolation() {+ let args = ["%s|%s", "argument with spaces", "literal;$HOME"];+ let output = macos_updater_relaunch_command(+ std::path::Path::new("/usr/bin/printf"),+ args,+ u32::MAX,+ std::time::Duration::ZERO,+ )+ .output()+ .unwrap();++ assert!(output.status.success());+ assert_eq!(+ String::from_utf8_lossy(&output.stdout),+ "argument with spaces|literal;$HOME"+ );+ }}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/server.rs b/apps/screenpipe-app-tauri/src-tauri/src/server.rsindex 16a8579e0..4866f98bf 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/server.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/server.rs@@ -415,7 +415,11 @@ pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {#[cfg(feature = "e2e")]let app = app.route("/e2e/updates/state", axum::routing::get(e2e_updates_state))- .route("/e2e/updates/click", axum::routing::post(e2e_updates_click));+ .route("/e2e/updates/click", axum::routing::post(e2e_updates_click))+ .route(+ "/e2e/updates/start-capture",+ axum::routing::post(e2e_updates_start_capture),+ );let app = with_control_server_boundary(app).layer(@@ -732,6 +736,52 @@ async fn e2e_updates_click(State(state): State<ServerState>) -> impl IntoResponsJson(serde_json::json!({ "accepted": true }))}+/// Start the real engine and capture pipeline after a packaged updater+/// relaunch. This is intentionally separate from the signed-out boot scenario:+/// the same E2E first proves the idle restart gate, then proves that the updated+/// process can acquire ScreenCaptureKit and produce a frame.+#[cfg(feature = "e2e")]+async fn e2e_updates_start_capture(State(state): State<ServerState>) -> impl IntoResponse {+ use tauri::Manager;++ let mut settings = match crate::store::SettingsStore::get(&state.app_handle) {+ Ok(Some(settings)) => settings,+ Ok(None) => crate::store::SettingsStore::default(),+ Err(error) => {+ return Json(serde_json::json!({+ "started": false,+ "error": format!("failed to load E2E settings: {error}"),+ }));+ }+ };+ settings.user.id = Some("packaged_updater_e2e".to_string());+ settings.user.subscription_plan = Some("none".to_string());+ settings.user.entitlement = Some(serde_json::json!({+ "active": true,+ "plan": "none",+ "source": "free",+ "checked_at": chrono::Utc::now().to_rfc3339(),+ "features": { "app": true, "cloud": false }+ }));+ if let Err(error) = settings.save(&state.app_handle) {+ return Json(serde_json::json!({+ "started": false,+ "error": format!("failed to save E2E recording entitlement: {error}"),+ }));+ }++ let result = crate::recording::spawn_screenpipe(+ state.app_handle.state(),+ state.app_handle.clone(),+ None,+ )+ .await;+ match result {+ Ok(()) => Json(serde_json::json!({ "started": true, "error": null })),+ Err(error) => Json(serde_json::json!({ "started": false, "error": error })),+ }+}+async fn set_window_size(State(state): State<ServerState>,Json(payload): Json<WindowSizePayload>,diff --git a/crates/screenpipe-engine/src/vision_manager/manager.rs b/crates/screenpipe-engine/src/vision_manager/manager.rsindex 5199a2141..e8770646c 100644--- a/crates/screenpipe-engine/src/vision_manager/manager.rs+++ b/crates/screenpipe-engine/src/vision_manager/manager.rs@@ -113,6 +113,12 @@ pub struct VisionManager {status: Arc<RwLock<VisionManagerStatus>>,/// Map of monitor_id -> JoinHandlerecording_tasks: Arc<DashMap<u32, JoinHandle<()>>>,+ /// macOS capture backend used by each active monitor task. A fallback+ /// CoreGraphics handle and a recovered ScreenCaptureKit handle share the+ /// same display ID, so the watcher needs this separate generation signal+ /// to upgrade the running task after SCK recovers.+ #[cfg(target_os = "macos")]+ monitor_sck_backends: Arc<DashMap<u32, bool>>,/// Per-monitor pipeline heartbeat. Aggregate metrics remain in `config` for/// `/health`; these independent clocks are exclusively the recovery source/// so partial multi-display stalls are observable.@@ -221,6 +227,8 @@ impl VisionManager {vision_handle,status: Arc::new(RwLock::new(VisionManagerStatus::Stopped)),recording_tasks: Arc::new(DashMap::new()),+ #[cfg(target_os = "macos")]+ monitor_sck_backends: Arc::new(DashMap::new()),monitor_liveness: Arc::new(DashMap::new()),hd_recording_tasks: Arc::new(DashMap::new()),trigger_tx,@@ -563,12 +571,17 @@ impl VisionManager {monitor.height());+ #[cfg(target_os = "macos")]+ let uses_sck_backend = monitor.uses_sck_backend();let liveness = Arc::new(PipelineMetrics::new());let handle = self.start_event_driven_monitor(monitor_id, monitor, liveness.clone()).await?;self.monitor_liveness.insert(monitor_id, liveness);+ #[cfg(target_os = "macos")]+ self.monitor_sck_backends+ .insert(monitor_id, uses_sck_backend);self.recording_tasks.insert(monitor_id, handle);Ok(())@@ -771,6 +784,8 @@ impl VisionManager {/// Stop recording on a specific monitorpub async fn stop_monitor(&self, monitor_id: u32) -> Result<()> {self.monitor_liveness.remove(&monitor_id);+ #[cfg(target_os = "macos")]+ self.monitor_sck_backends.remove(&monitor_id);// Stop the HD recorder first. Aborting drops its ffmpeg stdin, which// sends EOF so ffmpeg finalizes the .mp4 (moov atom) on its own.if let Some((_, hd_handle)) = self.hd_recording_tasks.remove(&monitor_id) {@@ -820,6 +835,8 @@ impl VisionManager {for id in &dead {self.monitor_liveness.remove(id);+ #[cfg(target_os = "macos")]+ self.monitor_sck_backends.remove(id);if let Some((_, handle)) = self.recording_tasks.remove(id) {// Await to clean up the JoinHandle and capture exit reasonmatch handle.await {@@ -848,6 +865,14 @@ impl VisionManager {.collect()}+ /// Return the capture backend generation held by an active macOS monitor.+ #[cfg(target_os = "macos")]+ pub(crate) fn active_monitor_uses_sck(&self, monitor_id: u32) -> Option<bool> {+ self.monitor_sck_backends+ .get(&monitor_id)+ .map(|entry| *entry.value())+ }+/// Independent liveness for each active capture loop. Never derive this/// from aggregate `vision_metrics`: on a multi-monitor system a healthy/// loop continually refreshes those global timestamps and can otherwisediff --git a/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rs b/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rsindex 1afa1a61c..c1ad8b138 100644--- a/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rs+++ b/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rs@@ -1095,6 +1095,38 @@ pub async fn start_monitor_watcher(}}+ // A bounded SCK failure can start a monitor on the privacy-safe+ // CoreGraphics fallback. Once a fresh enumeration returns an SCK+ // handle, display IDs alone cannot reveal that the active task is+ // still holding the fallback generation. Upgrade it immediately;+ // otherwise excluded-window capture keeps failing closed forever.+ #[cfg(target_os = "macos")]+ for monitor in ¤t_monitors {+ if monitor.uses_sck_backend()+ && vision_manager.active_monitor_uses_sck(monitor.id()) == Some(false)+ {+ info!(+ "ScreenCaptureKit recovered for monitor {}; replacing temporary CoreGraphics fallback",+ monitor.id()+ );+ if let Err(e) = vision_manager.stop_monitor(monitor.id()).await {+ warn!(+ "failed to stop CoreGraphics fallback for monitor {}: {:?}",+ monitor.id(),+ e+ );+ continue;+ }+ if let Err(e) = vision_manager.start_monitor_handle(monitor.clone()).await {+ warn!(+ "failed to upgrade monitor {} back to ScreenCaptureKit: {:?}",+ monitor.id(),+ e+ );+ }+ }+ }+// Get currently recording monitorslet active_ids: HashSet<u32> =vision_manager.active_monitors().await.into_iter().collect();diff --git a/crates/screenpipe-screen/Cargo.toml b/crates/screenpipe-screen/Cargo.tomlindex e7682861b..4c824e94f 100644--- a/crates/screenpipe-screen/Cargo.toml+++ b/crates/screenpipe-screen/Cargo.toml@@ -12,6 +12,7 @@ edition = { workspace = true }[features]default = []+e2e = [][dependencies]screenpipe-a11y = { path = "../screenpipe-a11y" }diff --git a/crates/screenpipe-screen/src/monitor.rs b/crates/screenpipe-screen/src/monitor.rsindex 30b7a6ee0..bb465a3f6 100644--- a/crates/screenpipe-screen/src/monitor.rs+++ b/crates/screenpipe-screen/src/monitor.rs@@ -150,6 +150,17 @@ pub struct MonitorData {}impl SafeMonitor {+ /// Whether this macOS monitor handle came from ScreenCaptureKit rather+ /// than the bounded CoreGraphics recovery path.+ ///+ /// The monitor watcher uses this to replace a temporary fallback handle+ /// once a fresh SCK enumeration succeeds. Comparing display IDs alone is+ /// insufficient because both backends describe the same display.+ #[cfg(target_os = "macos")]+ pub fn uses_sck_backend(&self) -> bool {+ self.use_sck+ }+pub fn id(&self) -> u32 {self.monitor_id}diff --git a/crates/screenpipe-screen/src/monitor/macos.rs b/crates/screenpipe-screen/src/monitor/macos.rsindex 3d4604963..6f5bbd25b 100644--- a/crates/screenpipe-screen/src/monitor/macos.rs+++ b/crates/screenpipe-screen/src/monitor/macos.rs@@ -536,6 +536,18 @@ where}fn enumerate_sck_monitors() -> std::result::Result<Vec<SafeMonitor>, MonitorListError> {+ #[cfg(feature = "e2e")]+ if std::env::var("SCREENPIPE_E2E_SCK_RELAUNCH_POISONED")+ .ok()+ .as_deref()+ == Some("1")+ {+ tracing::warn!(+ "e2e: simulating persistent ScreenCaptureKit permission denial after early updater relaunch"+ );+ return Err(MonitorListError::PermissionDenied);+ }+#[cfg(debug_assertions)]if std::env::var("SCREENPIPE_E2E_SEED").ok()