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
Add minimize to tray toggle for Windows app. (#3811)
Josh Morales297d81c19227
diff --git a/apps/screenpipe-app-tauri/components/settings/display-section.tsx b/apps/screenpipe-app-tauri/components/settings/display-section.tsxindex a93e14052..bfab329f6 100644--- a/apps/screenpipe-app-tauri/components/settings/display-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/display-section.tsx@@ -9,7 +9,7 @@ import { commands } from "@/lib/utils/tauri";import { useTheme } from "@/components/theme-provider";import { Switch } from "@/components/ui/switch";import { Card, CardContent } from "@/components/ui/card";-import { Moon, Sun, Monitor, Layers, MessageSquare, PanelLeft, Maximize2, EyeOff } from "lucide-react";+import { Moon, Sun, Monitor, Layers, MessageSquare, PanelLeft, Maximize2, EyeOff, MinusSquare } from "lucide-react";import { usePlatform } from "@/lib/hooks/use-platform";import { HelpTooltip } from "@/components/ui/help-tooltip";import { useToast } from "@/components/ui/use-toast";@@ -21,7 +21,7 @@ export function DisplaySection() {const { settings, updateSettings } = useSettings();const { theme, setTheme } = useTheme();const { toast } = useToast();- const { isMac } = usePlatform();+ const { isMac, isWindows } = usePlatform();// Guards the Disable-Timeline toggle against double-invoke (rapid toggle /// re-render) so we never fire two overlapping screenpipe restarts.const timelineRestartingRef = React.useRef(false);@@ -309,6 +309,50 @@ export function DisplaySection() {</Card>)}+ {/*+ * Windows-only: hide-to-tray toggle. The Rust close handler in+ * src-tauri/src/main.rs reads `minimizeToTrayOnClose` directly from the+ * settings store, so this switch only needs to round-trip the value —+ * no IPC command required. When ON, closing the Home window hides it+ * and removes it from the taskbar; the system tray icon (single+ * left-click) restores it. Default OFF preserves the historical+ * minimize-to-taskbar behavior.+ */}+ {isWindows && (+ <Card className="border-border bg-card">+ <CardContent className="px-3 py-2.5">+ <div className="flex items-center justify-between">+ <div className="flex items-center space-x-2.5">+ <MinusSquare className="h-4 w-4 text-muted-foreground shrink-0" />+ <div>+ <h3 className="text-sm font-medium text-foreground flex items-center gap-1.5">+ Minimize to System Tray on Close+ <HelpTooltip text="When enabled, clicking the X on the Home window hides it and removes it from the Windows taskbar. screenpipe keeps running in the system tray — click the tray icon to bring the window back." />+ </h3>+ <p className="text-xs text-muted-foreground">+ Keep running in the tray when the window is closed+ </p>+ </div>+ </div>+ <Switch+ checked={settings?.minimizeToTrayOnClose ?? false}+ onCheckedChange={(checked) => {+ handleSettingsChange({ minimizeToTrayOnClose: checked });+ toast({+ title: checked+ ? "Close button will hide to system tray"+ : "Close button will minimize to taskbar",+ description: checked+ ? "Click the tray icon to bring screenpipe back."+ : undefined,+ });+ }}+ />+ </div>+ </CardContent>+ </Card>+ )}+{/* Shortcut reminder advertises the screenpipe shortcut, which onlyopens the timeline — hide the whole section when the timeline is off. */}{!(settings?.disableTimeline ?? false) && (diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex d9b682473..3fc4d6d78 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -353,6 +353,10 @@ export type Settings = SettingsStore & {* logged into. Revocable from the owned-browser cookie menu.* Undefined = not decided yet, false = disabled, true = enabled. */browserCookieAccessGranted?: boolean;+ /** Windows-only: when true, closing the Home window hides it to the system+ * tray (and removes it from the taskbar) instead of minimizing. The Rust+ * close handler in src-tauri/src/main.rs reads this directly. Default off. */+ minimizeToTrayOnClose?: boolean;}export function getEffectiveFilters(settings: Settings) {diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex adbdc3ced..cf8c533f7 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -2718,7 +2718,14 @@ hideThinkingBlocks?: boolean;/*** UI theme: "light", "dark", or "system".*/-uiTheme?: string }+uiTheme?: string;+/**+ * Windows-only: when true, clicking the X on the Home window hides it to+ * the system tray (and removes it from the taskbar) instead of minimizing.+ * Read by the CloseRequested handler in main.rs. Default off (historical+ * minimize-to-taskbar behavior).+ */+minimizeToTrayOnClose?: boolean }export type ShowRewindWindow = "Main" | { Home: { page: string | null } } | { Search: { query: string | null } } | "Onboarding" | "Chat" | "PermissionRecovery"export type Suggestion = { text: string;/**diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 977ccff7d..37fc9a7c1 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -802,9 +802,45 @@ async fn main() {#[cfg(target_os = "windows")]{if window.label() == "home" {- // Minimize instead of closing so the Home window stays in the- // taskbar as the persistent app icon.- let _ = window.minimize();+ // Behavior depends on the user setting `minimizeToTrayOnClose`:+ // - false (default, historical behavior): minimize the Home+ // window so its icon stays in the Windows taskbar as the+ // persistent app entry point.+ // - true (opt-in): hide the window AND remove it from the+ // taskbar so the system tray icon becomes the only entry+ // point. The app process keeps running (see ExitRequested+ // handler below). The tray left-click handler in+ // tray.rs::setup_tray_click_handlers restores the window,+ // and window/show.rs::show_existing_main resets+ // skip_taskbar back to false on restore.+ //+ // Settings reads are best-effort: if the store can't be read+ // we fall back to the historical minimize() behavior so the+ // user never loses access to the window. set_skip_taskbar /+ // hide failures also fall back to minimize() for the same+ // reason — see plan.md "lost-window risk".+ let minimize_to_tray = crate::store::SettingsStore::get(+ window.app_handle(),+ )+ .ok()+ .flatten()+ .map(|s| s.minimize_to_tray_on_close)+ .unwrap_or(false);++ if minimize_to_tray {+ let skip_ok = window.set_skip_taskbar(true).is_ok();+ let hide_ok = window.hide().is_ok();+ if !(skip_ok && hide_ok) {+ // Hard fallback so the user is never left with an+ // off-taskbar but visible window.+ let _ = window.set_skip_taskbar(false);+ let _ = window.minimize();+ }+ } else {+ // Minimize instead of closing so the Home window stays in+ // the taskbar as the persistent app icon.+ let _ = window.minimize();+ }} else {// Overlay and other windows: hide (they're skip_taskbar anyway)let _ = window.hide();diff --git a/apps/screenpipe-app-tauri/src-tauri/src/store.rs b/apps/screenpipe-app-tauri/src-tauri/src/store.rsindex 578f365c2..3935043bc 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/store.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/store.rs@@ -697,6 +697,13 @@ pub struct SettingsStore {/// serialize only known fields and silently wipe frontend-only data.#[serde(flatten)]pub extra: std::collections::HashMap<String, serde_json::Value>,++ /// Windows-only: when true, clicking the X on the Home window hides it to+ /// the system tray (and removes it from the taskbar) instead of minimizing.+ /// Read by the CloseRequested handler in main.rs. Default off (historical+ /// minimize-to-taskbar behavior).+ #[serde(rename = "minimizeToTrayOnClose", default)]+ pub minimize_to_tray_on_close: bool,}fn generate_device_id() -> String {@@ -1050,6 +1057,7 @@ Rules:translucent_sidebar: false,hide_thinking_blocks: true,ui_theme: "system".to_string(),+ minimize_to_tray_on_close: false,extra: std::collections::HashMap::new(),}}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs b/apps/screenpipe-app-tauri/src-tauri/src/window/show.rsindex df643b810..27cd1de40 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs@@ -537,6 +537,13 @@ impl ShowRewindWindow {));}}+ // Windows: if the user opted into `minimizeToTrayOnClose`, the+ // Home window may have been hidden with skip_taskbar(true) on+ // close. Clear that flag here so the window reappears in the+ // taskbar regardless of whether we were previously hidden or+ // minimized. No-op on macOS/Linux. See main.rs CloseRequested.+ #[cfg(target_os = "windows")]+ let _ = window.set_skip_taskbar(false);window.show().ok();#[cfg(target_os = "macos")]