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(macos): preserve TCC grants across updates (#6553)

Ezra Elletteead27f067bb8
diff --git a/TESTING.md b/TESTING.md
index b6933132c..c0b05b6b5 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -985,8 +985,8 @@ commits: 2026-08-11 tray-update-ux
- [ ] **Tray restart while signed out** — On a signed-out / entitlement-gated install (engine never starts, boot phase `idle`), stage an update and click the tray "Restart to update". It MUST proceed and relaunch — before this fix the click silently no-oped forever (MacBook Air report).
- [ ] **Tray click feedback** — Clicking "Restart to update" immediately changes the menu item to "Installing update…"; a deferred/failed restart shows a native notification instead of doing nothing.
-- [ ] **Fast install (no blackout)** — The exit-path install uses the pre-extracted rename path (log: `installed via pre-extracted fast path`). Old→new blackout is a few seconds, not 10–40s.
+- [ ] **TCC-safe install** — Start with healthy capture, apply an update, and verify the replacement records a new frame without toggling Screen Recording or reopening the app. The updater must not create `staged-update/replaced/previous.app`.
- [ ] **Failed-install detection** — If an update quits but doesn't apply, the next boot shows "Update didn't apply — click to retry" (marker in `~/.screenpipe/update-attempt.json`, consumed once).
- [ ] **No-update click safety** — Clicking the menu item with nothing staged runs a check and must NOT restart the app.
-Automated: `bun run test:e2e:packaged-updater:macos` drives all of the above against two real signed release-local builds (macOS only). Rust unit coverage: `cargo test --features e2e staged_update:: updates::tests` (pre-extract fast path, rollback, fallback, idle gate, marker classification).
+Automated: `bun run test:e2e:packaged-updater:macos` drives all of the above against two real signed release-local builds (macOS only). Rust unit coverage: `cargo test --features e2e staged_update:: updates::tests` (verified deferred install, no `previous.app`, idle gate, marker classification).
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.ts
index 304a21ddf..87bf513cd 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
@@ -11,10 +11,10 @@
* drives two REAL release-profile builds through the full production path:
*
* real updater check (signed manifest, local server)
- * → real download → signature verify → stage + PRE-EXTRACT
+ * → real download → signature verify → stage
* → tray click (exact production handler, via the e2e driver route)
* → restart gate (boot phase = idle: the signed-out MacBook Air repro)
- * → teardown → rename fast-path install → relaunch
+ * → teardown → verified updater install → relaunch
* → new version boots, update-attempt marker classified as applied
*
* Scenarios asserted, in order:
@@ -24,8 +24,8 @@
* silently does nothing").
* 2. FEEDBACK — the menu item visibly acknowledges the click
* ("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.
+ * 3. TCC-SAFE INSTALL — the exit-path install does not park the authorized
+ * bundle at `staged-update/replaced/previous.app`.
* 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.
@@ -352,20 +352,17 @@ async function main(): Promise<void> {
});
check('engine idle (signed-out install repro)', idleState.boot_phase === 'idle');
- // Real check → download → verify → stage → PRE-EXTRACT.
- const staged = await waitFor('update staged + pre-extracted', 300_000, async () => {
+ // Real check → download → verify → stage.
+ const staged = await waitFor('update staged', 300_000, async () => {
const s = await fetchState();
- return s && s.update_installed && s.staged_pre_extracted ? s : null;
+ return s && s.update_installed && s.staged_version === NEW_VERSION ? s : null;
});
check('staged version is the served update', staged.staged_version === NEW_VERSION, String(staged.staged_version));
- check('archive was pre-extracted at stage time', staged.staged_pre_extracted);
+ check('custom pre-extraction is disabled', !staged.staged_pre_extracted);
check('menu offers restart', staged.menu_text === 'Restart to update', staged.menu_text);
check('menu item enabled', staged.menu_enabled);
check('still idle while staged', staged.boot_phase === 'idle', staged.boot_phase);
- const logBefore = await todayLog();
- check('log: pre-extraction recorded', logBefore.includes('pre-extracted to'));
-
// THE CLICK — exact production tray handler.
log('clicking "Restart to update" (production path via driver)…');
const clickAt = Date.now();
@@ -404,29 +401,18 @@ async function main(): Promise<void> {
const blackoutSecs = (upAt - exitAt) / 1000;
const clickToUpSecs = (upAt - clickAt) / 1000;
check('relaunched as updated version', relaunched.app_version === NEW_VERSION, relaunched.app_version);
- // The pre-fix exit path did a 400 MB extract in the dying process; the
- // rename fast path plus boot must comfortably beat 30s wall-clock even on
- // slow hardware (measured ~3–6s on M4 Max, release-local profile).
- check('blackout bounded (< 30s exit→driver-up)', blackoutSecs < 30, `${blackoutSecs.toFixed(1)}s`);
+ check('blackout bounded (< 60s exit→driver-up)', blackoutSecs < 60, `${blackoutSecs.toFixed(1)}s`);
log(`click→up total ${clickToUpSecs.toFixed(1)}s, exit→up blackout ${blackoutSecs.toFixed(1)}s`);
// The swap really happened on disk, not just in process state.
check('installed bundle Info.plist is new version', installedBundleVersion() === NEW_VERSION, installedBundleVersion());
- // Scenario 3 log assertions: fast path used; marker written + consumed.
- const logAfter = await waitFor('log contains fast-path install', 30_000, async () => {
+ // Scenario 3 log assertions: verified installer used; marker written + consumed.
+ const logAfter = await waitFor('log contains verified install', 30_000, async () => {
const l = await todayLog();
- return l.includes('installed via pre-extracted fast path') ? l : null;
+ return /staged update v[^\n]+ installed in /.test(l) ? l : null;
});
- check('log: install used the rename fast path', true);
- // Rust Duration debug formatting: "123.456µs" | "12.345ms" | "1.234s".
- const fastMs = logAfter.match(/installed via pre-extracted fast path in ([\d.]+)(µs|ms|s)/);
- check('fast-path duration parseable from log', fastMs !== null);
- if (fastMs) {
- const unit = fastMs[2];
- const ms = parseFloat(fastMs[1]) * (unit === 's' ? 1000 : unit === 'ms' ? 1 : 0.001);
- check('fast-path swap under 2s', ms < 2000, `${ms.toFixed(1)}ms`);
- }
+ check('log: custom rename fast path was not used', !logAfter.includes('pre-extracted fast path'));
check('log: idle gate proceeded (not deferred)', /engine idle \(never started\)[^\n]*proceeding/.test(logAfter));
check(
'log: update attempt recorded',
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 973bf84fc..dda393462 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -11165,7 +11165,6 @@ dependencies = [
"dispatch2",
"eventkit-rs",
"fix-path-env",
- "flate2",
"freedesktop-desktop-entry",
"freedesktop-icon-lookup",
"futures",
@@ -11225,7 +11224,6 @@ dependencies = [
"specta-typescript",
"sqlx",
"sysinfo",
- "tar",
"tauri",
"tauri-build",
"tauri-helper",
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index a2655b768..c0a0cef85 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -50,11 +50,6 @@ tauri-plugin-updater = "=2.10.1"
semver = "1"
# staged-update signature re-verification (same crate/version the updater plugin uses)
minisign-verify = "0.2"
-# staged-update pre-extraction at download time — the exit path must be two
-# renames, not a 400 MB gunzip in the dying process (same crates/versions the
-# updater plugin already pulls in)
-flate2 = "1"
-tar = "0.4"
tauri-plugin-dialog = "=2.6.0"
tauri-plugin-os = "=2.3.2"
tauri-plugin-process = "=2.3.1"
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/staged_update.rs b/apps/screenpipe-app-tauri/src-tauri/src/staged_update.rs
index b7dac31fd..d87132068 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/staged_update.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/staged_update.rs
@@ -19,49 +19,22 @@
//! (relaunch or quit), when orphaning the bundle no longer matters.
//! Windows and Linux keep `download_and_install` unchanged.
//!
-//! ## Pre-extraction (2026-08-11)
-//!
-//! Originally the exit path did ALL the install work in the dying process:
-//! read the ~160 MB archive back, re-verify the minisign signature, and
-//! gunzip+untar ~420 MB — a 10–40 s window (M4 Max → old Air) in which the
-//! app has already torn down its UI but nothing new has launched. Users read
-//! that blackout as "restart to update did nothing" and clicked again.
-//! Claude Desktop (Squirrel/ShipIt) and the ChatGPT/Codex desktop (Sparkle)
-//! both avoid this by never extracting at exit: the expensive work happens
-//! while the app is still alive, and quit only swaps directories.
-//!
-//! We now do the same: `stage()` extracts the verified archive into the
-//! stage dir immediately after download, and the exit path degrades to two
-//! `rename(2)` calls (bundle → scratch, extracted → bundle). If anything
-//! about the pre-extracted tree is off — wrong shape, cross-volume rename,
-//! permission error — the exit path falls back to the original
-//! read + re-verify + `Update::install()` route, so the fast path can only
-//! make things faster, never less correct.
-//!
-//! Trust note: between stage and exit the extracted tree sits in a 0700 dir
-//! under the user's app-data directory. An attacker who can tamper with it
-//! can equally tamper with the destination bundle in the user-writable
-//! /Applications, so the fast path does not weaken the existing threat
-//! model; the slow path keeps its at-exit signature re-verification.
+//! Do not replace the bundle with a custom rename. The 2026-08-11 fast swap
+//! parked the authorized app at `staged-update/replaced/previous.app`; macOS
+//! TCC then kept resolving Screenpipe through that moved path and rejected
+//! the replacement process. Use the updater's verified installer path even
+//! though extraction at exit is slower: recording must survive the update.
use log::{info, warn};
use std::io::Write;
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
use std::sync::Mutex;
use tauri::Manager;
use tauri_plugin_updater::Update;
struct Staged {
update: Update,
- /// Verified archive bytes on disk (fallback install source).
path: PathBuf,
- /// Pre-extracted `.app` root, ready to be renamed into place. `None`
- /// when extraction failed or the archive had an unexpected shape — the
- /// exit path then uses the plugin's own extractor.
- extracted_app: Option<PathBuf>,
- /// The bundle directory this update will replace, captured at stage
- /// time (while the process is healthy) rather than at exit.
- bundle_root: Option<PathBuf>,
}
/// In-memory handle to the staged update. The `Update` object carries the
@@ -77,10 +50,8 @@ fn stage_dir<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> Option<PathBuf> {
.map(|d| d.join("staged-update"))
}
-/// Remove leftovers from a previous process. Called once at boot. The stage
-/// dir can now hold a full ~420 MB extracted bundle plus the previous app
-/// bundle parked by the rename fast path, so deletion runs off-thread — boot
-/// must not wait multiple seconds on `remove_dir_all`.
+/// Remove leftovers from a previous process. Called once at boot. Deletion
+/// runs off-thread so old fast-swap leftovers do not delay startup.
pub fn clear_stage_dir<R: tauri::Runtime>(app: &tauri::AppHandle<R>) {
let Some(dir) = stage_dir(app) else { return };
@@ -126,114 +97,14 @@ pub fn clear_stage_dir<R: tauri::Runtime>(app: &tauri::AppHandle<R>) {
});
}
-/// The bundle directory the running executable lives in:
-/// `…/screenpipe.app/Contents/MacOS/screenpipe-app` → `…/screenpipe.app`.
-/// Pure so the shape logic is unit-testable; returns `None` for non-bundled
-/// (dev) executables, which simply disables the rename fast path.
-fn bundle_root_from_exe(exe: &Path) -> Option<PathBuf> {
- let macos_dir = exe.parent()?; // MacOS/
- let contents_dir = macos_dir.parent()?; // Contents/
- let bundle = contents_dir.parent()?; // Foo.app
- if macos_dir.file_name()? != "MacOS" || contents_dir.file_name()? != "Contents" {
- return None;
- }
- if bundle.extension()? != "app" {
- return None;
- }
- Some(bundle.to_path_buf())
-}
-
-fn current_bundle_root() -> Option<PathBuf> {
- std::env::current_exe()
- .ok()
- .and_then(|exe| bundle_root_from_exe(&exe))
-}
-
-/// Extract the verified archive into `dir` and return the path of the single
-/// top-level `.app` inside it. Anything unexpected (multiple roots, no
-/// `.app`, extraction error) is an `Err` — callers treat that as "no fast
-/// path" rather than a failure.
-fn pre_extract(dir: &Path, version: &str, bytes: &[u8]) -> std::io::Result<PathBuf> {
- use flate2::read::GzDecoder;
-
- let tmp = dir.join("extracted.tmp");
- let _ = std::fs::remove_dir_all(&tmp);
- std::fs::create_dir_all(&tmp)?;
-
- let decoder = GzDecoder::new(std::io::Cursor::new(bytes));
- let mut archive = tar::Archive::new(decoder);
- // `unpack` refuses entries that escape the destination; symlinks and
- // permissions inside the bundle (Frameworks/Versions/Current etc.) are
- // preserved, matching what the plugin's own extractor produces.
- archive.unpack(&tmp)?;
-
- // Expected artifact shape (same contract as the plugin's installer):
- // exactly one top-level entry, the .app bundle itself.
- let mut roots = std::fs::read_dir(&tmp)?
- .filter_map(|e| e.ok())
- .map(|e| e.path())
- .collect::<Vec<_>>();
- if roots.len() != 1 {
- let _ = std::fs::remove_dir_all(&tmp);
- return Err(std::io::Error::other(format!(
- "expected exactly one top-level archive entry, found {}",
- roots.len()
- )));
- }
- let app_root = roots.remove(0);
- if app_root.extension().and_then(|e| e.to_str()) != Some("app") || !app_root.is_dir() {
- let _ = std::fs::remove_dir_all(&tmp);
- return Err(std::io::Error::other(
- "top-level archive entry is not a .app directory",
- ));
- }
-
- let final_dir = dir.join(format!("extracted-{version}"));
- let _ = std::fs::remove_dir_all(&final_dir);
- std::fs::rename(&tmp, &final_dir)?;
- Ok(final_dir.join(app_root.file_name().expect("app root has a name")))
-}
-
-/// Swap the pre-extracted bundle into place with two renames. `scratch`
-/// receives the previous bundle (deleted at next boot by `clear_stage_dir`,
-/// so the exit path never pays for a 400 MB `remove_dir_all`). On failure
-/// the original bundle is rolled back into place so the user always keeps a
-/// launchable app.
-fn fast_swap(extracted_app: &Path, bundle_root: &Path, scratch: &Path) -> std::io::Result<()> {
- std::fs::create_dir_all(scratch)?;
- let backup = scratch.join("previous.app");
- let _ = std::fs::remove_dir_all(&backup);
- std::fs::rename(bundle_root, &backup)?;
- if let Err(e) = std::fs::rename(extracted_app, bundle_root) {
- let _ = std::fs::rename(&backup, bundle_root);
- return Err(e);
- }
- // LaunchServices cache nudge, same as the plugin's installer.
- let _ = std::process::Command::new("touch")
- .arg(bundle_root)
- .status();
- Ok(())
-}
-
-/// Write downloaded (already plugin-verified) update bytes to disk, extract
-/// them so the exit path is two renames, and keep the `Update` handle for
-/// install-at-exit. Replaces any previously staged version — with the
-/// current release cadence a newer update can arrive before the user ever
-/// restarts. Blocking (gunzip of a ~160 MB archive): call from
-/// `spawn_blocking`, not directly on an async runtime thread.
+/// Write downloaded (already plugin-verified) update bytes to disk and keep
+/// the `Update` handle for install-at-exit. Replaces any previously staged
+/// version — with the current release cadence a newer update can arrive before
+/// the user ever restarts.
pub fn stage<R: tauri::Runtime>(
app: &tauri::AppHandle<R>,
update: Update,
bytes: &[u8],
-) -> std::io::Result<()> {
- stage_impl(app, update, bytes, current_bundle_root())
-}
-
-fn stage_impl<R: tauri::Runtime>(
- app: &tauri::AppHandle<R>,
- update: Update,
- bytes: &[u8],
- bundle_root: Option<PathBuf>,
) -> std::io::Result<()> {
let dir = stage_dir(app).ok_or_else(|| std::io::Error::other("no app data dir"))?;
std::fs::create_dir_all(&dir)?;
@@ -257,49 +128,11 @@ fn stage_impl<R: tauri::Runtime>(
}
std::fs::rename(&tmp, &path)?;
- // Pre-extract now, while the app is alive and can afford the CPU/IO —
- // this is what turns the exit path into two renames. Failure is
- // non-fatal: the exit path falls back to the plugin's extractor.
- let started = std::time::Instant::now();
- let extracted_app = match pre_extract(&dir, &update.version, bytes) {
- Ok(app_path) => {
- info!(
- "staged update v{}: pre-extracted to {} in {:?}",
- update.version,
- app_path.display(),
- started.elapsed()
- );
- Some(app_path)
- }
- Err(e) => {
- warn!(
- "staged update v{}: pre-extraction unavailable ({}); exit path will extract",
- update.version, e
- );
- None
- }
- };
- if bundle_root.is_none() {
- info!(
- "staged update v{}: running executable is not inside a .app bundle; \
- rename fast path disabled",
- update.version
- );
- }
-
let mut staged = STAGED.lock().unwrap();
if let Some(old) = staged.take() {
if old.path != path {
let _ = std::fs::remove_file(&old.path);
}
- if let Some(old_extracted) = old.extracted_app {
- // extracted-<version> dir is the parent of the .app inside it
- if let Some(old_dir) = old_extracted.parent() {
- if old_dir != dir && old_dir.starts_with(&dir) {
- let _ = std::fs::remove_dir_all(old_dir);
- }
- }
- }
}
info!(
"staged update v{} at {} ({} bytes); install deferred to quit/restart",
@@ -307,22 +140,16 @@ fn stage_impl<R: tauri::Runtime>(
path.display(),
bytes.len()
);
- *staged = Some(Staged {
- update,
- path,
- extracted_app,
- bundle_root,
- });
+ *staged = Some(Staged { update, path });
Ok(())
}
/// Content-free snapshot of the staged state for diagnostics and the e2e
-/// driver: (version, pre-extracted?).
+/// driver. The Boolean remains for wire compatibility and is always false now
+/// that the TCC-breaking pre-extracted swap has been removed.
pub fn staged_snapshot() -> Option<(String, bool)> {
let staged = STAGED.lock().unwrap();
- staged
- .as_ref()
- .map(|s| (s.update.version.clone(), s.extracted_app.is_some()))
+ staged.as_ref().map(|s| (s.update.version.clone(), false))
}
/// Version of the currently staged update, if any.
@@ -337,45 +164,12 @@ pub fn staged_version() -> Option<String> {
/// version and the checker re-stages later.
pub fn install_staged_if_any<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> bool {
let staged = STAGED.lock().unwrap().take();
- let Some(Staged {
- update,
- path,
- extracted_app,
- bundle_root,
- }) = staged
- else {
+ let Some(Staged { update, path }) = staged else {
return false;
};
let started = std::time::Instant::now();
- // Fast path: everything expensive already happened at stage time; the
- // remaining work is two renames. Failure of any kind falls through to
- // the plugin's own extract-and-swap below.
- if let (Some(extracted), Some(bundle)) = (extracted_app.as_deref(), bundle_root.as_deref()) {
- let scratch = path
- .parent()
- .map(|d| d.join("replaced"))
- .unwrap_or_else(|| std::env::temp_dir().join("screenpipe-replaced"));
- match fast_swap(extracted, bundle, &scratch) {
- Ok(()) => {
- let _ = std::fs::remove_file(&path);
- info!(
- "staged update v{} installed via pre-extracted fast path in {:?}",
- update.version,
- started.elapsed()
- );
- return true;
- }
- Err(e) => {
- warn!(
- "staged update v{}: fast swap failed ({}); falling back to full install",
- update.version, e
- );
- }
- }
- }
-
let bytes = match std::fs::read(&path) {
Ok(b) => b,
Err(e) => {
@@ -463,6 +257,7 @@ mod tests {
use super::*;
use base64::Engine;
use std::io::Read;
+ use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering};
use tauri_plugin_updater::UpdaterExt;
@@ -519,7 +314,7 @@ mod tests {
std::fs::write(newapp.join("Contents/MacOS/app"), b"new-binary").unwrap();
std::fs::write(newapp.join("marker.txt"), marker).unwrap();
// A symlink, because real bundles contain them (Frameworks/Versions)
- // and the fast path must preserve them through extract + rename.
+ // and the updater installer must preserve them.
#[cfg(unix)]
std::os::unix::fs::symlink("marker.txt", newapp.join("marker-link")).unwrap();
let archive_path = tmp.join("update.tar.gz");
@@ -631,7 +426,7 @@ mod tests {
}
#[tokio::test(flavor = "multi_thread")]
- async fn staged_update_full_cycle_installs_via_pre_extracted_fast_path() {
+ async fn staged_update_full_cycle_uses_verified_installer() {
let _guard = STAGED_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
init_test_logger();
let tmp = tempfile::tempdir().unwrap();
@@ -647,46 +442,21 @@ mod tests {
let (update, bytes) = check_and_download(&handle, &fake_exe, &pubkey_b64, port).await;
- // Stage with an explicit bundle root (tests don't run from a .app):
- // bytes hit disk AND the bundle is pre-extracted; current bundle is
- // NOT touched.
- stage_impl(&handle, update.clone(), &bytes, Some(current.clone())).expect("stage");
+ // Staging stores the verified archive but leaves the current bundle
+ // untouched until the exit path installs it.
+ stage(&handle, update.clone(), &bytes).expect("stage");
let staged_file = stage_dir(&handle).unwrap().join("update-99.0.0.bin");
assert!(staged_file.exists(), "staged file should exist");
let (version, pre_extracted) = staged_snapshot().expect("staged snapshot");
assert_eq!(version, "99.0.0");
- assert!(
- pre_extracted,
- "archive should have been pre-extracted at stage time"
- );
- let extracted_app = stage_dir(&handle)
- .unwrap()
- .join("extracted-99.0.0")
- .join("FakeApp.app");
- assert!(
- extracted_app.join("marker.txt").exists(),
- "pre-extracted bundle should be complete"
- );
- #[cfg(unix)]
- assert!(
- extracted_app
- .join("marker-link")
- .symlink_metadata()
- .unwrap()
- .file_type()
- .is_symlink(),
- "extraction must preserve symlinks (Frameworks/Versions layout)"
- );
+ assert!(!pre_extracted, "custom pre-extraction must stay disabled");
assert_eq!(
std::fs::read(current.join("marker.txt")).unwrap(),
b"OLD",
"bundle must be untouched while staged (the -3801 regression)"
);
- // Install at "exit": swap happens via renames — prove it by deleting
- // the archive file first. The old slow path would need it; the fast
- // path must not.
- std::fs::remove_file(&staged_file).unwrap();
+ // Install at "exit" through tauri-plugin-updater's verified path.
assert!(install_staged_if_any(&handle), "install should succeed");
assert_eq!(
std::fs::read(current.join("marker.txt")).unwrap(),
@@ -703,16 +473,9 @@ mod tests {
.is_symlink(),
"installed bundle must keep its symlinks"
);
- // Previous bundle parked in scratch for next-boot cleanup, not deleted
- // on the exit path.
- let parked = stage_dir(&handle)
- .unwrap()
- .join("replaced")
- .join("previous.app");
- assert_eq!(
- std::fs::read(parked.join("marker.txt")).unwrap(),
- b"OLD",
- "previous bundle should be parked in the stage dir scratch"
+ assert!(
+ !stage_dir(&handle).unwrap().join("replaced/previous.app").exists(),
+ "the TCC-breaking previous.app path must never be created"
);
assert!(
!install_staged_if_any(&handle),
@@ -724,87 +487,6 @@ mod tests {
clear_stage_dir(&handle);
}
- /// The fast path is an optimization, not a new failure mode: when
- /// pre-extraction was unavailable the exit path must still install via
- /// the plugin's own extractor (the pre-2026-08-11 behavior).
- #[tokio::test(flavor = "multi_thread")]
- async fn staged_update_without_pre_extraction_falls_back_to_full_install() {
- let _guard = STAGED_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
- init_test_logger();
- let tmp = tempfile::tempdir().unwrap();
-
- let current = make_current_bundle(tmp.path());
- let fake_exe = current.join("Contents/MacOS/app");
- let (archive, sig_b64, pubkey_b64, _kp) = build_signed_fake_bundle(tmp.path(), b"NEW");
- let (port, stop) = serve_update(archive, &sig_b64);
-
- let app = mock_app_with_updater(&pubkey_b64);
- let handle = app.handle().clone();
- clear_stage_dir(&handle);
-
- let (update, bytes) = check_and_download(&handle, &fake_exe, &pubkey_b64, port).await;
-
- // No bundle root (dev-style executable) → fast path disabled even
- // though extraction succeeds.
- stage_impl(&handle, update.clone(), &bytes, None).expect("stage");
-
- assert!(
- install_staged_if_any(&handle),
- "fallback install should succeed"
- );
- assert_eq!(
- std::fs::read(current.join("marker.txt")).unwrap(),
- b"NEW",
- "plugin fallback should still install the update"
- );
-
- stop.store(true, Ordering::SeqCst);
- let _ = std::net::TcpStream::connect(("127.0.0.1", port));
- clear_stage_dir(&handle);
- }
-
- /// A broken pre-extracted tree (deleted/tampered-away) must roll back the
- /// bundle rename and fall through to the verified full install — never
- /// leave the user without a launchable app.
- #[tokio::test(flavor = "multi_thread")]
- async fn broken_pre_extraction_rolls_back_and_falls_back() {
- let _guard = STAGED_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
- init_test_logger();
- let tmp = tempfile::tempdir().unwrap();
-
- let current = make_current_bundle(tmp.path());
- let fake_exe = current.join("Contents/MacOS/app");
- let (archive, sig_b64, pubkey_b64, _kp) = build_signed_fake_bundle(tmp.path(), b"NEW");
- let (port, stop) = serve_update(archive, &sig_b64);
-
- let app = mock_app_with_updater(&pubkey_b64);
- let handle = app.handle().clone();
- clear_stage_dir(&handle);
-
- let (update, bytes) = check_and_download(&handle, &fake_exe, &pubkey_b64, port).await;
- stage_impl(&handle, update.clone(), &bytes, Some(current.clone())).expect("stage");
-
- // Sabotage the extracted tree AFTER staging: the fast path's second
- // rename fails, the first rename must be rolled back, and the slow
- // path must complete the install from the (re-verified) archive.
- let extracted_dir = stage_dir(&handle).unwrap().join("extracted-99.0.0");
- std::fs::remove_dir_all(&extracted_dir).unwrap();
-
- assert!(
- install_staged_if_any(&handle),
- "install should still succeed"
- );
- assert_eq!(
- std::fs::read(current.join("marker.txt")).unwrap(),
- b"NEW",
- "slow path should have installed after fast-path rollback"
- );
-
- stop.store(true, Ordering::SeqCst);
- let _ = std::net::TcpStream::connect(("127.0.0.1", port));
- clear_stage_dir(&handle);
- }
-
#[tokio::test(flavor = "multi_thread")]
async fn tampered_staged_file_is_rejected_and_discarded() {
let keypair = minisign::KeyPair::generate_unencrypted_keypair().unwrap();
@@ -835,67 +517,4 @@ mod tests {
);
}
- #[test]
- fn bundle_root_requires_macos_bundle_shape() {
- assert_eq!(
- bundle_root_from_exe(Path::new(
- "/Applications/screenpipe.app/Contents/MacOS/screenpipe-app"
- )),
- Some(PathBuf::from("/Applications/screenpipe.app"))
- );
- // dev binary → no bundle → fast path disabled
- assert_eq!(
- bundle_root_from_exe(Path::new("/tmp/target/debug/screenpipe-app")),
- None
- );
- // right depth, wrong directory names
- assert_eq!(
- bundle_root_from_exe(Path::new("/foo/bar.app/Wrong/MacOS/app")),
- None
- );
- }
-
- #[test]
- fn fast_swap_rolls_back_when_extracted_bundle_is_missing() {
- let tmp = tempfile::tempdir().unwrap();
- let bundle = tmp.path().join("Cur.app");
- std::fs::create_dir_all(&bundle).unwrap();
- std::fs::write(bundle.join("marker.txt"), b"OLD").unwrap();
-
- let missing = tmp.path().join("nope.app");
- let scratch = tmp.path().join("scratch");
- assert!(fast_swap(&missing, &bundle, &scratch).is_err());
- assert_eq!(
- std::fs::read(bundle.join("marker.txt")).unwrap(),
- b"OLD",
- "failed swap must leave the original bundle in place"
- );
- }
-
- #[test]
- fn pre_extract_rejects_multi_root_archives() {
- let tmp = tempfile::tempdir().unwrap();
- // two top-level entries → not the expected updater artifact shape
- let src = tmp.path().join("src");
- std::fs::create_dir_all(src.join("A.app")).unwrap();
- std::fs::create_dir_all(src.join("B.app")).unwrap();
- std::fs::write(src.join("A.app/x"), b"x").unwrap();
- std::fs::write(src.join("B.app/x"), b"x").unwrap();
- let archive_path = tmp.path().join("multi.tar.gz");
- let status = std::process::Command::new("tar")
- .env("COPYFILE_DISABLE", "1")
- .arg("-czf")
- .arg(&archive_path)
- .arg("-C")
- .arg(&src)
- .arg("A.app")
- .arg("B.app")
- .status()
- .unwrap();
- assert!(status.success());
- let bytes = std::fs::read(&archive_path).unwrap();
- let out = tmp.path().join("out");
- std::fs::create_dir_all(&out).unwrap();
- assert!(pre_extract(&out, "1.2.3", &bytes).is_err());
- }
}
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs
index 9ab4f5df6..db8275bf4 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs
@@ -537,7 +537,7 @@ pub async fn trigger_update_now(app: tauri::AppHandle) {
let manager = app.state::<Arc<UpdatesManager>>().inner().clone();
if manager.has_update_installed().await {
// Immediate feedback in the menu itself: the install + relaunch can
- // take a few seconds even on the rename fast path.
+ // take several seconds while the verified installer extracts the update.
manager.set_menu_installing();
match restart_for_update(app.clone(), None).await {
Ok(outcome) if outcome == "proceed" => {
@@ -1152,8 +1152,8 @@ impl UpdatesManager {
// the running bundle into a temp dir, which breaks TCC
// attribution for the live process (ScreenCaptureKit -3801)
// until relaunch. Download + stage only; the install runs
- // on the exit path (see staged_update.rs). stage() now also
- // pre-extracts the ~160 MB archive (seconds of gunzip), so
+ // on the exit path (see staged_update.rs). Persisting the
+ // ~160 MB archive includes blocking file I/O and fsync, so
// it runs on the blocking pool, not an async worker.
#[cfg(target_os = "macos")]
let result = match update.download(on_chunk, || {}).await {