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(cli): periodic version-check nudge in tip rotation

Louis Beaumont629d1db6b51d
diff --git a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
index 8ee2970e7..3702af205 100644
--- a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
+++ b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
@@ -438,7 +438,7 @@ async fn main() -> anyhow::Result<()> {
// Non-blocking update check — runs in background, prints banner if outdated
tokio::spawn(async {
- check_for_updates().await;
+ screenpipe_engine::cli_reminder::check_for_updates().await;
});
// Periodic terminal nudge to install the desktop app (CLI-only).
@@ -1835,52 +1835,3 @@ async fn main() -> anyhow::Result<()> {
Ok(())
}
-/// Non-blocking update check. Fetches the latest version from npm registry
-/// and prints a one-line banner if the current version is outdated.
-async fn check_for_updates() {
- // Skip if user opted out
- if env::var("SCREENPIPE_NO_UPDATE_CHECK").is_ok() {
- return;
- }
-
- let current = env!("CARGO_PKG_VERSION");
-
- let client = match reqwest::Client::builder()
- .timeout(std::time::Duration::from_secs(3))
- .build()
- {
- Ok(c) => c,
- Err(_) => return,
- };
-
- let resp = match client
- .get("https://registry.npmjs.org/screenpipe/latest")
- .header("Accept", "application/json")
- .send()
- .await
- {
- Ok(r) if r.status().is_success() => r,
- _ => return,
- };
-
- let json: serde_json::Value = match resp.json().await {
- Ok(v) => v,
- Err(_) => return,
- };
-
- let latest = match json.get("version").and_then(|v| v.as_str()) {
- Some(v) => v,
- None => return,
- };
-
- if latest != current {
- eprintln!(
- "\n {} screenpipe {} available (you have {})",
- "update:".yellow().bold(),
- latest.green(),
- current,
- );
- eprintln!(" run: {}", "npx screenpipe@latest record".cyan());
- eprintln!();
- }
-}
diff --git a/crates/screenpipe-engine/src/cli_reminder.rs b/crates/screenpipe-engine/src/cli_reminder.rs
index 170bc6a83..c5e23e20b 100644
--- a/crates/screenpipe-engine/src/cli_reminder.rs
+++ b/crates/screenpipe-engine/src/cli_reminder.rs
@@ -6,7 +6,8 @@
//! binary from a terminal. Fires only from the CLI entrypoint — never from
//! the desktop app, which embeds the engine as a library.
//!
-//! Opt out with `SCREENPIPE_NO_REMINDERS=1`.
+//! Opt out with `SCREENPIPE_NO_REMINDERS=1` (silences all tips).
+//! Opt out of the version-check nudge only with `SCREENPIPE_NO_UPDATE_CHECK=1`.
use colored::Colorize;
use std::env;
@@ -15,6 +16,7 @@ use std::time::Duration;
const REMINDER_INTERVAL: Duration = Duration::from_secs(5 * 60);
const DESKTOP_APP_URL: &str = "https://screenpi.pe";
const SURVEY_URL: &str = "https://screenpi.pe/survey";
+const NPM_LATEST_URL: &str = "https://registry.npmjs.org/screenpipe/latest";
/// Spawn the background reminder loop. Safe to call once at CLI startup.
pub fn spawn() {
@@ -29,21 +31,74 @@ pub fn spawn() {
let mut idx: usize = 0;
loop {
ticker.tick().await;
- print_tip(idx);
+ run_tip(idx).await;
idx = idx.wrapping_add(1);
}
});
}
-fn print_tip(idx: usize) {
- let tips: [fn(); 5] = [
- print_desktop_app_tip,
- print_mcp_tip,
- print_install_bundle_tip,
- print_login_tip,
- print_survey_tip,
- ];
- tips[idx % tips.len()]();
+async fn run_tip(idx: usize) {
+ // Silent slots (update check when up-to-date) still consume a rotation
+ // slot — that's intentional, keeps the cadence predictable.
+ match idx % 6 {
+ 0 => print_desktop_app_tip(),
+ 1 => print_mcp_tip(),
+ 2 => print_install_bundle_tip(),
+ 3 => print_login_tip(),
+ 4 => print_survey_tip(),
+ 5 => check_for_updates().await,
+ _ => unreachable!(),
+ }
+}
+
+/// Non-blocking update check. Fetches the latest version from the npm registry
+/// and prints a banner if the current binary is outdated. Silent on success or
+/// any network/parse error so we never noise up the terminal.
+pub async fn check_for_updates() {
+ if env::var("SCREENPIPE_NO_UPDATE_CHECK").is_ok() {
+ return;
+ }
+
+ let current = env!("CARGO_PKG_VERSION");
+
+ let client = match reqwest::Client::builder()
+ .timeout(Duration::from_secs(3))
+ .build()
+ {
+ Ok(c) => c,
+ Err(_) => return,
+ };
+
+ let resp = match client
+ .get(NPM_LATEST_URL)
+ .header("Accept", "application/json")
+ .send()
+ .await
+ {
+ Ok(r) if r.status().is_success() => r,
+ _ => return,
+ };
+
+ let json: serde_json::Value = match resp.json().await {
+ Ok(v) => v,
+ Err(_) => return,
+ };
+
+ let latest = match json.get("version").and_then(|v| v.as_str()) {
+ Some(v) => v,
+ None => return,
+ };
+
+ if latest != current {
+ eprintln!(
+ "\n {} screenpipe {} available (you have {})",
+ "update:".yellow().bold(),
+ latest.green(),
+ current,
+ );
+ eprintln!(" run: {}", "npx screenpipe@latest record".cyan());
+ eprintln!();
+ }
}
fn print_desktop_app_tip() {