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

chore: cargo fmt + remove unused deps (killport, zip, url, sentry, http-cache-reqwest, reqwest-middleware)

Louis Beaumontfe639c3538f6
diff --git a/Cargo.lock b/Cargo.lock
index d02647e05..252e1d848 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -255,7 +255,7 @@ dependencies = [
"base64ct",
"blake2",
"cpufeatures",
- "password-hash 0.5.0",
+ "password-hash",
]
[[package]]
@@ -801,50 +801,6 @@ dependencies = [
"piper",
]
-[[package]]
-name = "bollard"
-version = "0.16.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0aed08d3adb6ebe0eff737115056652670ae290f177759aac19c30456135f94c"
-dependencies = [
- "base64 0.22.1",
- "bollard-stubs",
- "bytes",
- "futures-core",
- "futures-util",
- "hex",
- "http 1.3.1",
- "http-body-util",
- "hyper 1.6.0",
- "hyper-named-pipe",
- "hyper-util",
- "hyperlocal-next",
- "log",
- "pin-project-lite",
- "serde",
- "serde_derive",
- "serde_json",
- "serde_repr",
- "serde_urlencoded",
- "thiserror 1.0.69",
- "tokio",
- "tokio-util",
- "tower-service",
- "url",
- "winapi",
-]
-
-[[package]]
-name = "bollard-stubs"
-version = "1.44.0-rc.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "709d9aa1c37abb89d40f19f5d0ad6f0d88cb1581264e571c9350fc5bb89cf1c5"
-dependencies = [
- "serde",
- "serde_repr",
- "serde_with",
-]
-
[[package]]
name = "built"
version = "0.7.7"
@@ -898,16 +854,6 @@ dependencies = [
"serde",
]
-[[package]]
-name = "bzip2"
-version = "0.4.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8"
-dependencies = [
- "bzip2-sys",
- "libc",
-]
-
[[package]]
name = "bzip2"
version = "0.5.2"
@@ -927,33 +873,6 @@ dependencies = [
"pkg-config",
]
-[[package]]
-name = "cacache"
-version = "13.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c5063741c7b2e260bbede781cf4679632dd90e2718e99f7715e46824b65670b"
-dependencies = [
- "digest",
- "either",
- "futures",
- "hex",
- "libc",
- "memmap2 0.5.10",
- "miette",
- "reflink-copy",
- "serde",
- "serde_derive",
- "serde_json",
- "sha1",
- "sha2",
- "ssri",
- "tempfile",
- "thiserror 1.0.69",
- "tokio",
- "tokio-stream",
- "walkdir",
-]
-
[[package]]
name = "candle-core"
version = "0.8.3"
@@ -967,7 +886,7 @@ dependencies = [
"half",
"intel-mkl-src",
"libc",
- "memmap2 0.9.5",
+ "memmap2",
"metal 0.27.0",
"num-traits",
"num_cpus",
@@ -1097,12 +1016,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-[[package]]
-name = "cfg_aliases"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
-
[[package]]
name = "cfg_aliases"
version = "0.2.1"
@@ -1242,16 +1155,6 @@ dependencies = [
"clap_derive",
]
-[[package]]
-name = "clap-verbosity-flag"
-version = "2.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34c77f67047557f62582784fd7482884697731b2932c7d37ced54bce2312e1e2"
-dependencies = [
- "clap",
- "log",
-]
-
[[package]]
name = "clap_builder"
version = "4.5.32"
@@ -1435,12 +1338,6 @@ version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
-[[package]]
-name = "constant_time_eq"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
-
[[package]]
name = "constant_time_eq"
version = "0.3.1"
@@ -1882,7 +1779,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
dependencies = [
"powerfmt",
- "serde",
]
[[package]]
@@ -2135,16 +2031,6 @@ dependencies = [
"syn 2.0.100",
]
-[[package]]
-name = "env_filter"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
-dependencies = [
- "log",
- "regex",
-]
-
[[package]]
name = "env_home"
version = "0.1.0"
@@ -2164,19 +2050,6 @@ dependencies = [
"termcolor",
]
-[[package]]
-name = "env_logger"
-version = "0.11.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3716d7a920fb4fac5d84e9d4bce8ceb321e9414b4409da61b07b75c1e3d0697"
-dependencies = [
- "anstream",
- "anstyle",
- "env_filter",
- "jiff",
- "log",
-]
-
[[package]]
name = "equivalent"
version = "1.0.2"
@@ -3180,61 +3053,6 @@ dependencies = [
"pin-project-lite",
]
-[[package]]
-name = "http-cache"
-version = "0.20.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e883defacf53960c7717d9e928dc8667be9501d9f54e6a8b7703d7a30320e9c"
-dependencies = [
- "async-trait",
- "bincode",
- "cacache",
- "http 1.3.1",
- "http-cache-semantics",
- "httpdate",
- "serde",
- "url",
-]
-
-[[package]]
-name = "http-cache-reqwest"
-version = "0.15.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e076afd9d376f09073b515ce95071b29393687d98ed521948edb899195595ddf"
-dependencies = [
- "anyhow",
- "async-trait",
- "http 1.3.1",
- "http-cache",
- "http-cache-semantics",
- "reqwest 0.12.12",
- "reqwest-middleware",
- "serde",
- "url",
-]
-
-[[package]]
-name = "http-cache-semantics"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92baf25cf0b8c9246baecf3a444546360a97b569168fdf92563ee6a47829920c"
-dependencies = [
- "http 1.3.1",
- "http-serde",
- "serde",
- "time",
-]
-
-[[package]]
-name = "http-serde"
-version = "2.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f056c8559e3757392c8d091e796416e4649d8e49e88b8d76df6c002f05027fd"
-dependencies = [
- "http 1.3.1",
- "serde",
-]
-
[[package]]
name = "httparse"
version = "1.10.1"
@@ -3298,21 +3116,6 @@ dependencies = [
"want",
]
-[[package]]
-name = "hyper-named-pipe"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278"
-dependencies = [
- "hex",
- "hyper 1.6.0",
- "hyper-util",
- "pin-project-lite",
- "tokio",
- "tower-service",
- "winapi",
-]
-
[[package]]
name = "hyper-rustls"
version = "0.24.2"
@@ -3392,21 +3195,6 @@ dependencies = [
"tracing",
]
-[[package]]
-name = "hyperlocal-next"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "acf569d43fa9848e510358c07b80f4adf34084ddc28c6a4a651ee8474c070dcc"
-dependencies = [
- "hex",
- "http-body-util",
- "hyper 1.6.0",
- "hyper-util",
- "pin-project-lite",
- "tokio",
- "tower-service",
-]
-
[[package]]
name = "iana-time-zone"
version = "0.1.61"
@@ -3658,7 +3446,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
- "serde",
]
[[package]]
@@ -3819,30 +3606,6 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
-[[package]]
-name = "jiff"
-version = "0.2.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c102670231191d07d37a35af3eb77f1f0dbf7a71be51a962dcd57ea607be7260"
-dependencies = [
- "jiff-static",
- "log",
- "portable-atomic",
- "portable-atomic-util",
- "serde",
-]
-
-[[package]]
-name = "jiff-static"
-version = "0.2.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cdde31a9d349f1b1f51a0b3714a5940ac022976f4b49485fc04be052b183b4c"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.100",
-]
-
[[package]]
name = "jni"
version = "0.21.1"
@@ -3906,24 +3669,6 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
-[[package]]
-name = "killport"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "317ecd5bf5ef33cfba26c3bdd8df22cc77978754bc2111c9bc7fbd8ac8084235"
-dependencies = [
- "bollard",
- "clap",
- "clap-verbosity-flag",
- "env_logger 0.11.7",
- "libproc",
- "log",
- "nix 0.28.0",
- "procfs",
- "tokio",
- "windows-sys 0.52.0",
-]
-
[[package]]
name = "knf-rs"
version = "0.2.4"
@@ -4007,17 +3752,6 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
-[[package]]
-name = "libproc"
-version = "0.14.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e78a09b56be5adbcad5aa1197371688dc6bb249a26da3bca2011ee2fb987ebfb"
-dependencies = [
- "bindgen 0.70.1",
- "errno",
- "libc",
-]
-
[[package]]
name = "libpulse-binding"
version = "2.30.1"
@@ -4136,7 +3870,7 @@ dependencies = [
"gl",
"image",
"khronos-egl",
- "memmap2 0.9.5",
+ "memmap2",
"rustix 1.1.3",
"thiserror 2.0.12",
"tracing",
@@ -4335,15 +4069,6 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
-[[package]]
-name = "memmap2"
-version = "0.5.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327"
-dependencies = [
- "libc",
-]
-
[[package]]
name = "memmap2"
version = "0.9.5"
@@ -4403,29 +4128,6 @@ dependencies = [
"paste",
]
-[[package]]
-name = "miette"
-version = "5.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
-dependencies = [
- "miette-derive",
- "once_cell",
- "thiserror 1.0.69",
- "unicode-width 0.1.14",
-]
-
-[[package]]
-name = "miette-derive"
-version = "5.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.100",
-]
-
[[package]]
name = "mime"
version = "0.3.17"
@@ -4618,18 +4320,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "nix"
-version = "0.28.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
-dependencies = [
- "bitflags 2.9.0",
- "cfg-if",
- "cfg_aliases 0.1.1",
- "libc",
-]
-
[[package]]
name = "nix"
version = "0.29.0"
@@ -4638,7 +4328,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.9.0",
"cfg-if",
- "cfg_aliases 0.2.1",
+ "cfg_aliases",
"libc",
]
@@ -4650,7 +4340,7 @@ checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags 2.9.0",
"cfg-if",
- "cfg_aliases 0.2.1",
+ "cfg_aliases",
"libc",
"memoffset",
]
@@ -5505,17 +5195,6 @@ dependencies = [
"windows-targets 0.52.6",
]
-[[package]]
-name = "password-hash"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
-dependencies = [
- "base64ct",
- "rand_core 0.6.4",
- "subtle",
-]
-
[[package]]
name = "password-hash"
version = "0.5.0"
@@ -5533,18 +5212,6 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
-[[package]]
-name = "pbkdf2"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
-dependencies = [
- "digest",
- "hmac",
- "password-hash 0.4.2",
- "sha2",
-]
-
[[package]]
name = "pbkdf2"
version = "0.12.2"
@@ -5830,32 +5497,6 @@ dependencies = [
"unicode-ident",
]
-[[package]]
-name = "procfs"
-version = "0.16.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "731e0d9356b0c25f16f33b5be79b1c57b562f141ebfcdb0ad8ac2c13a24293b4"
-dependencies = [
- "bitflags 2.9.0",
- "chrono",
- "flate2",
- "hex",
- "lazy_static",
- "procfs-core",
- "rustix 0.38.44",
-]
-
-[[package]]
-name = "procfs-core"
-version = "0.16.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29"
-dependencies = [
- "bitflags 2.9.0",
- "chrono",
- "hex",
-]
-
[[package]]
name = "profiling"
version = "1.0.16"
@@ -6211,17 +5852,6 @@ dependencies = [
"thiserror 1.0.69",
]
-[[package]]
-name = "reflink-copy"
-version = "0.1.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a7aea22fc8204e0f291719120cbcdae4f25f0807d7b00f5b6b27d95a8f1a2ad"
-dependencies = [
- "cfg-if",
- "rustix 0.38.44",
- "windows 0.59.0",
-]
-
[[package]]
name = "regex"
version = "1.11.1"
@@ -6361,21 +5991,6 @@ dependencies = [
"windows-registry",
]
-[[package]]
-name = "reqwest-middleware"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "64e8975513bd9a7a43aad01030e79b3498e05db14e9d945df6483e8cf9b8c4c4"
-dependencies = [
- "anyhow",
- "async-trait",
- "http 1.3.1",
- "reqwest 0.12.12",
- "serde",
- "thiserror 1.0.69",
- "tower-service",
-]
-
[[package]]
name = "rgb"
version = "0.8.50"
@@ -6753,7 +6368,7 @@ dependencies = [
"dashmap",
"deepgram",
"dirs",
- "env_logger 0.10.2",
+ "env_logger",
"esaxx-rs",
"futures",
"hf-hub",
@@ -6817,7 +6432,6 @@ dependencies = [
"hex",
"hf-hub",
"hmac",
- "http-cache-reqwest",
"lazy_static",
"log",
"objc",
@@ -6826,8 +6440,6 @@ dependencies = [
"rand 0.8.5",
"regex",
"reqwest 0.12.12",
- "reqwest-middleware",
- "sentry",
"serde",
"serde_json",
"sha2",
@@ -6838,10 +6450,8 @@ dependencies = [
"tracing",
"tracing-subscriber",
"uiautomation",
- "url",
"which 6.0.3",
"zeroize",
- "zip 0.6.6",
]
[[package]]
@@ -6929,14 +6539,13 @@ dependencies = [
"crossbeam",
"dashmap",
"dirs",
- "env_logger 0.10.2",
+ "env_logger",
"fastrand",
"futures",
"hf-hub",
"hostname",
"image",
"imageproc",
- "killport",
"lru",
"md5",
"moka",
@@ -7288,23 +6897,6 @@ dependencies = [
"serde",
]
-[[package]]
-name = "serde_with"
-version = "3.12.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa"
-dependencies = [
- "base64 0.22.1",
- "chrono",
- "hex",
- "indexmap 1.9.3",
- "indexmap 2.8.0",
- "serde",
- "serde_derive",
- "serde_json",
- "time",
-]
-
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
@@ -7343,17 +6935,6 @@ dependencies = [
"syn 2.0.100",
]
-[[package]]
-name = "sha-1"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c"
-dependencies = [
- "cfg-if",
- "cpufeatures",
- "digest",
-]
-
[[package]]
name = "sha1"
version = "0.10.6"
@@ -7737,23 +7318,6 @@ dependencies = [
"url",
]
-[[package]]
-name = "ssri"
-version = "9.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da7a2b3c2bc9693bcb40870c4e9b5bf0d79f9cb46273321bf855ec513e919082"
-dependencies = [
- "base64 0.21.7",
- "digest",
- "hex",
- "miette",
- "serde",
- "sha-1",
- "sha2",
- "thiserror 1.0.69",
- "xxhash-rust",
-]
-
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
@@ -8788,7 +8352,7 @@ dependencies = [
"gemm 0.18.2",
"half",
"libloading",
- "memmap2 0.9.5",
+ "memmap2",
"num",
"num-traits",
"num_cpus",
@@ -10112,12 +9676,6 @@ version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f"
-[[package]]
-name = "xxhash-rust"
-version = "0.8.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3"
-
[[package]]
name = "xz2"
version = "0.1.7"
@@ -10363,26 +9921,6 @@ dependencies = [
"syn 2.0.100",
]
-[[package]]
-name = "zip"
-version = "0.6.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
-dependencies = [
- "aes",
- "byteorder",
- "bzip2 0.4.4",
- "constant_time_eq 0.1.5",
- "crc32fast",
- "crossbeam-utils",
- "flate2",
- "hmac",
- "pbkdf2 0.11.0",
- "sha1",
- "time",
- "zstd 0.11.2+zstd.1.5.2",
-]
-
[[package]]
name = "zip"
version = "1.1.4"
@@ -10406,8 +9944,8 @@ checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50"
dependencies = [
"aes",
"arbitrary",
- "bzip2 0.5.2",
- "constant_time_eq 0.3.1",
+ "bzip2",
+ "constant_time_eq",
"crc32fast",
"crossbeam-utils",
"deflate64",
@@ -10418,14 +9956,14 @@ dependencies = [
"indexmap 2.8.0",
"lzma-rs",
"memchr",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"sha1",
"thiserror 2.0.12",
"time",
"xz2",
"zeroize",
"zopfli",
- "zstd 0.13.3",
+ "zstd",
]
[[package]]
@@ -10442,32 +9980,13 @@ dependencies = [
"simd-adler32",
]
-[[package]]
-name = "zstd"
-version = "0.11.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
-dependencies = [
- "zstd-safe 5.0.2+zstd.1.5.2",
-]
-
[[package]]
name = "zstd"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a"
dependencies = [
- "zstd-safe 7.2.4",
-]
-
-[[package]]
-name = "zstd-safe"
-version = "5.0.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
-dependencies = [
- "libc",
- "zstd-sys",
+ "zstd-safe",
]
[[package]]
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index c16910349..08b07f299 100755
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -9096,7 +9096,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.0.378"
+version = "2.0.379"
dependencies = [
"anyhow",
"async-stream",
diff --git a/crates/screenpipe-accessibility/src/platform/windows.rs b/crates/screenpipe-accessibility/src/platform/windows.rs
index 7c6ebf77a..3ed95a5a6 100644
--- a/crates/screenpipe-accessibility/src/platform/windows.rs
+++ b/crates/screenpipe-accessibility/src/platform/windows.rs
@@ -26,8 +26,8 @@ use windows::Win32::UI::WindowsAndMessaging::{
CallNextHookEx, DispatchMessageW, GetForegroundWindow, GetMessageW, GetWindowTextW,
GetWindowThreadProcessId, SetWindowsHookExW, TranslateMessage, UnhookWindowsHookEx, HC_ACTION,
HHOOK, KBDLLHOOKSTRUCT, MSG, MSLLHOOKSTRUCT, WH_KEYBOARD_LL, WH_MOUSE_LL, WM_KEYDOWN, WM_KEYUP,
- WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_MOUSEMOVE, WM_MOUSEWHEEL,
- WM_RBUTTONDOWN, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_XBUTTONDOWN,
+ WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN, WM_SYSKEYDOWN,
+ WM_SYSKEYUP, WM_XBUTTONDOWN,
};
/// Permission status for UI capture
diff --git a/crates/screenpipe-apple-intelligence/src/engine.rs b/crates/screenpipe-apple-intelligence/src/engine.rs
index bb09babff..2d4d67389 100644
--- a/crates/screenpipe-apple-intelligence/src/engine.rs
+++ b/crates/screenpipe-apple-intelligence/src/engine.rs
@@ -328,20 +328,13 @@ pub async fn query_screenpipe_with_ai(
.get("window_name")
.and_then(|v| v.as_str())
.unwrap_or("");
- let text = content
- .get("text")
- .and_then(|v| v.as_str())
- .unwrap_or("");
+ let text = content.get("text").and_then(|v| v.as_str()).unwrap_or("");
let ts = content
.get("timestamp")
.and_then(|v| v.as_str())
.unwrap_or("");
- let text_truncated = if text.len() > 500 {
- &text[..500]
- } else {
- text
- };
+ let text_truncated = if text.len() > 500 { &text[..500] } else { text };
context.push_str(&format!(
"[{}] {} - {}: {}\n",
ts, app, window, text_truncated
@@ -387,10 +380,8 @@ pub async fn query_screenpipe_with_ai(
let instructions_owned = instructions.to_string();
let prompt_owned = full_prompt;
- tokio::task::spawn_blocking(move || {
- generate_text(Some(&instructions_owned), &prompt_owned)
- })
- .await?
+ tokio::task::spawn_blocking(move || generate_text(Some(&instructions_owned), &prompt_owned))
+ .await?
}
#[cfg(test)]
@@ -448,8 +439,7 @@ mod tests {
return;
}
- let result =
- generate_text(None, "What is 2 + 2? Reply with just the number.").unwrap();
+ let result = generate_text(None, "What is 2 + 2? Reply with just the number.").unwrap();
println!("Response: {}", result.text);
println!("Total time: {:.0}ms", result.metrics.total_time_ms);
@@ -631,8 +621,7 @@ mod tests {
// 5. Back-to-back latency (model should be warm)
let mut times = Vec::new();
for i in 0..3 {
- let r = generate_text(None, &format!("Count to {}. Just the numbers.", i + 3))
- .unwrap();
+ let r = generate_text(None, &format!("Count to {}. Just the numbers.", i + 3)).unwrap();
times.push(r.metrics.total_time_ms);
}
println!("\nBack-to-back latency (3 requests):");
@@ -701,10 +690,7 @@ mod tests {
// Check if screenpipe is running
let client = reqwest::Client::new();
- let health = client
- .get("http://localhost:3030/health")
- .send()
- .await;
+ let health = client.get("http://localhost:3030/health").send().await;
if health.is_err() || !health.unwrap().status().is_success() {
println!("Skipping: screenpipe server not running on localhost:3030");
return;
@@ -736,8 +722,13 @@ mod tests {
let ocr_total = ocr_resp["pagination"]["total"].as_i64().unwrap_or(0);
let audio_total = audio_resp["pagination"]["total"].as_i64().unwrap_or(0);
- println!("Data fetched: {} OCR frames (of {}), {} audio chunks (of {})",
- ocr_items.len(), ocr_total, audio_items.len(), audio_total);
+ println!(
+ "Data fetched: {} OCR frames (of {}), {} audio chunks (of {})",
+ ocr_items.len(),
+ ocr_total,
+ audio_items.len(),
+ audio_total
+ );
// Build context from real data
let mut context = String::new();
@@ -749,7 +740,13 @@ mod tests {
let text = c["text"].as_str().unwrap_or("");
let ts = c["timestamp"].as_str().unwrap_or("?");
let truncated = if text.len() > 300 { &text[..300] } else { text };
- context.push_str(&format!("[{}] {} - {}: {}\n", &ts[..16], app, &window[..window.len().min(40)], truncated));
+ context.push_str(&format!(
+ "[{}] {} - {}: {}\n",
+ &ts[..16],
+ app,
+ &window[..window.len().min(40)],
+ truncated
+ ));
}
context.push_str("\n=== Recent Audio ===\n");
@@ -762,7 +759,11 @@ mod tests {
}
}
- println!("Context size: {} chars (~{} tokens)\n", context.len(), context.len() / 4);
+ println!(
+ "Context size: {} chars (~{} tokens)\n",
+ context.len(),
+ context.len() / 4
+ );
// Test 1: Daily summary
let wall_start = std::time::Instant::now();
@@ -775,7 +776,10 @@ mod tests {
println!("Response:\n{}\n", r1.text);
println!("Foundation Models time: {:.0}ms", r1.metrics.total_time_ms);
println!("Wall clock time: {:?}", wall_time_1);
- println!("Mem delta: {:.1}MB\n", r1.metrics.mem_delta_bytes as f64 / 1_048_576.0);
+ println!(
+ "Mem delta: {:.1}MB\n",
+ r1.metrics.mem_delta_bytes as f64 / 1_048_576.0
+ );
// Test 2: Action item extraction
let wall_start = std::time::Instant::now();
@@ -788,7 +792,10 @@ mod tests {
println!("Response:\n{}\n", r2.text);
println!("Foundation Models time: {:.0}ms", r2.metrics.total_time_ms);
println!("Wall clock time: {:?}", wall_time_2);
- println!("Mem delta: {:.1}MB\n", r2.metrics.mem_delta_bytes as f64 / 1_048_576.0);
+ println!(
+ "Mem delta: {:.1}MB\n",
+ r2.metrics.mem_delta_bytes as f64 / 1_048_576.0
+ );
// Test 3: Question answering
let wall_start = std::time::Instant::now();
@@ -801,20 +808,38 @@ mod tests {
println!("Response:\n{}\n", r3.text);
println!("Foundation Models time: {:.0}ms", r3.metrics.total_time_ms);
println!("Wall clock time: {:?}", wall_time_3);
- println!("Mem delta: {:.1}MB\n", r3.metrics.mem_delta_bytes as f64 / 1_048_576.0);
+ println!(
+ "Mem delta: {:.1}MB\n",
+ r3.metrics.mem_delta_bytes as f64 / 1_048_576.0
+ );
// Summary
println!("=== BENCHMARK SUMMARY ===");
println!("Total OCR in DB: {}", ocr_total);
println!("Total audio in DB: {}", audio_total);
- println!("Context fed to model: {} chars ({} tokens est.)", context.len(), context.len() / 4);
- println!("Summary generation: {:.0}ms (wall: {:?})", r1.metrics.total_time_ms, wall_time_1);
- println!("Action items: {:.0}ms (wall: {:?})", r2.metrics.total_time_ms, wall_time_2);
- println!("Q&A: {:.0}ms (wall: {:?})", r3.metrics.total_time_ms, wall_time_3);
- println!("Memory: before={:.1}MB, after={:.1}MB, delta={:.1}MB",
+ println!(
+ "Context fed to model: {} chars ({} tokens est.)",
+ context.len(),
+ context.len() / 4
+ );
+ println!(
+ "Summary generation: {:.0}ms (wall: {:?})",
+ r1.metrics.total_time_ms, wall_time_1
+ );
+ println!(
+ "Action items: {:.0}ms (wall: {:?})",
+ r2.metrics.total_time_ms, wall_time_2
+ );
+ println!(
+ "Q&A: {:.0}ms (wall: {:?})",
+ r3.metrics.total_time_ms, wall_time_3
+ );
+ println!(
+ "Memory: before={:.1}MB, after={:.1}MB, delta={:.1}MB",
r1.metrics.mem_before_bytes as f64 / 1_048_576.0,
r3.metrics.mem_after_bytes as f64 / 1_048_576.0,
- (r3.metrics.mem_after_bytes as i64 - r1.metrics.mem_before_bytes as i64) as f64 / 1_048_576.0,
+ (r3.metrics.mem_after_bytes as i64 - r1.metrics.mem_before_bytes as i64) as f64
+ / 1_048_576.0,
);
println!("=========================");
}
diff --git a/crates/screenpipe-apple-intelligence/src/server_bin.rs b/crates/screenpipe-apple-intelligence/src/server_bin.rs
index 1c6a69759..23b82d591 100644
--- a/crates/screenpipe-apple-intelligence/src/server_bin.rs
+++ b/crates/screenpipe-apple-intelligence/src/server_bin.rs
@@ -8,13 +8,14 @@
use axum::{
extract::Json,
http::StatusCode,
- response::{sse::{Event, Sse}, IntoResponse},
+ response::{
+ sse::{Event, Sse},
+ IntoResponse,
+ },
routing::{get, post},
Router,
};
-use screenpipe_apple_intelligence::{
- check_availability, generate_text, prewarm, Availability,
-};
+use screenpipe_apple_intelligence::{check_availability, generate_text, prewarm, Availability};
use serde::{Deserialize, Serialize};
use std::convert::Infallible;
use tokio_stream::StreamExt as _;
@@ -26,18 +27,79 @@ const MODEL_NAME: &str = "Apple Intelligence (on-device)";
// Keeps only sentences likely to contain action items before sending to model.
// This reduces volume 10-50x, critical for a ~3B model with ~2000 token context.
const ACTION_KEYWORDS: &[&str] = &[
- "todo", "to-do", "to do", "need to", "should", "must", "have to", "gotta",
- "follow up", "follow-up", "followup", "deadline", "reminder", "remember",
- "don't forget", "dont forget", "buy", "call", "email", "schedule",
- "fix", "update", "review", "send", "submit", "complete", "finish",
- "prepare", "book", "remind", "set up", "setup", "arrange", "organize",
- "plan", "assign", "check", "respond", "reply", "confirm", "cancel",
- "reschedule", "meeting", "appointment", "task", "action item",
- "important", "urgent", "asap", "priority", "due", "by tomorrow",
- "by friday", "by monday", "next week", "eod", "end of day",
- "action", "blocked", "blocker", "waiting on", "pending",
- "implement", "deploy", "ship", "release", "merge", "pr",
- "bug", "issue", "ticket", "jira", "linear",
+ "todo",
+ "to-do",
+ "to do",
+ "need to",
+ "should",
+ "must",
+ "have to",
+ "gotta",
+ "follow up",
+ "follow-up",
+ "followup",
+ "deadline",
+ "reminder",
+ "remember",
+ "don't forget",
+ "dont forget",
+ "buy",
+ "call",
+ "email",
+ "schedule",
+ "fix",
+ "update",
+ "review",
+ "send",
+ "submit",
+ "complete",
+ "finish",
+ "prepare",
+ "book",
+ "remind",
+ "set up",
+ "setup",
+ "arrange",
+ "organize",
+ "plan",
+ "assign",
+ "check",
+ "respond",
+ "reply",
+ "confirm",
+ "cancel",
+ "reschedule",
+ "meeting",
+ "appointment",
+ "task",
+ "action item",
+ "important",
+ "urgent",
+ "asap",
+ "priority",
+ "due",
+ "by tomorrow",
+ "by friday",
+ "by monday",
+ "next week",
+ "eod",
+ "end of day",
+ "action",
+ "blocked",
+ "blocker",
+ "waiting on",
+ "pending",
+ "implement",
+ "deploy",
+ "ship",
+ "release",
+ "merge",
+ "pr",
+ "bug",
+ "issue",
+ "ticket",
+ "jira",
+ "linear",
];
const TODO_INSTRUCTIONS: &str = "\
@@ -533,22 +595,21 @@ async fn chat_completions(
prompt_len, has_tools, req.stream
);
- let result = tokio::task::spawn_blocking(move || {
- generate_text(instructions.as_deref(), &prompt)
- })
- .await
- .map_err(|e| {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(serde_json::json!({"error": {"message": e.to_string()}})),
- )
- })?
- .map_err(|e| {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(serde_json::json!({"error": {"message": e.to_string()}})),
- )
- })?;
+ let result =
+ tokio::task::spawn_blocking(move || generate_text(instructions.as_deref(), &prompt))
+ .await
+ .map_err(|e| {
+ (
+ StatusCode::INTERNAL_SERVER_ERROR,
+ Json(serde_json::json!({"error": {"message": e.to_string()}})),
+ )
+ })?
+ .map_err(|e| {
+ (
+ StatusCode::INTERNAL_SERVER_ERROR,
+ Json(serde_json::json!({"error": {"message": e.to_string()}})),
+ )
+ })?;
eprintln!(
"[fm-server] response: {} chars, {:.0}ms",
@@ -726,10 +787,7 @@ async fn extract_todos(
let chunks = chunk_text(&all_filtered_text, chunk_size);
let num_chunks = chunks.len();
- eprintln!(
- "[fm-server] extract: processing {} chunks",
- num_chunks
- );
+ eprintln!("[fm-server] extract: processing {} chunks", num_chunks);
// Step 3: Process each chunk with generate_json (schema-constrained)
let mut all_items: Vec<TodoItem> = Vec::new();
@@ -740,7 +798,10 @@ async fn extract_todos(
let result = tokio::task::spawn_blocking(move || {
generate_text(
Some(TODO_INSTRUCTIONS),
- &format!("Extract action items from this screen/audio activity:\n\n{}", chunk_clone),
+ &format!(
+ "Extract action items from this screen/audio activity:\n\n{}",
+ chunk_clone
+ ),
)
})
.await
@@ -775,9 +836,8 @@ async fn extract_todos(
};
// Try parsing as array directly, or as object with "items" key
- let items_result: Option<Vec<TodoItem>> = serde_json::from_str(&json_text)
- .ok()
- .or_else(|| {
+ let items_result: Option<Vec<TodoItem>> =
+ serde_json::from_str(&json_text).ok().or_else(|| {
// Try as {"items": [...]}
serde_json::from_str::<serde_json::Value>(&json_text)
.ok()
@@ -872,7 +932,10 @@ async fn main() {
.route("/health", get(health));
let port = std::env::var("FM_PORT").unwrap_or_else(|_| "5273".to_string());
- eprintln!("\n🧠 Apple Intelligence API at http://localhost:{}/v1", port);
+ eprintln!(
+ "\n🧠 Apple Intelligence API at http://localhost:{}/v1",
+ port
+ );
eprintln!(" Model: {}", MODEL_NAME);
eprintln!(" Endpoints:");
eprintln!(" POST /v1/chat/completions (OpenAI-compatible)");
diff --git a/crates/screenpipe-audio/src/audio_manager/builder.rs b/crates/screenpipe-audio/src/audio_manager/builder.rs
index 8342cae7a..a36865b4e 100644
--- a/crates/screenpipe-audio/src/audio_manager/builder.rs
+++ b/crates/screenpipe-audio/src/audio_manager/builder.rs
@@ -169,7 +169,9 @@ impl AudioManagerBuilder {
devices.push(output.to_string());
}
if devices.is_empty() {
- tracing::warn!("No audio devices found — audio manager will start but won't record");
+ tracing::warn!(
+ "No audio devices found — audio manager will start but won't record"
+ );
}
options.enabled_devices = HashSet::from_iter(devices);
}
diff --git a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
index 4f000626d..d294ee741 100644
--- a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
+++ b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
@@ -91,8 +91,14 @@ pub async fn start_device_monitor(
// Start the new default input device
if let Ok(new_device) = parse_audio_device(&new_default_input) {
match audio_manager.start_device(&new_device).await {
- Ok(()) => info!("switched to new system default input: {}", new_default_input),
- Err(e) => error!("failed to start new default input {}: {}", new_default_input, e),
+ Ok(()) => info!(
+ "switched to new system default input: {}",
+ new_default_input
+ ),
+ Err(e) => error!(
+ "failed to start new default input {}: {}",
+ new_default_input, e
+ ),
}
}
}
@@ -113,8 +119,14 @@ pub async fn start_device_monitor(
// Start the new default output device
if let Ok(new_device) = parse_audio_device(&new_default_output) {
match audio_manager.start_device(&new_device).await {
- Ok(()) => info!("switched to new system default output: {}", new_default_output),
- Err(e) => error!("failed to start new default output {}: {}", new_default_output, e),
+ Ok(()) => info!(
+ "switched to new system default output: {}",
+ new_default_output
+ ),
+ Err(e) => error!(
+ "failed to start new default output {}: {}",
+ new_default_output, e
+ ),
}
}
}
diff --git a/crates/screenpipe-audio/src/core/device.rs b/crates/screenpipe-audio/src/core/device.rs
index d96b739f4..be57242b3 100644
--- a/crates/screenpipe-audio/src/core/device.rs
+++ b/crates/screenpipe-audio/src/core/device.rs
@@ -300,9 +300,7 @@ pub async fn list_audio_devices() -> Result<Vec<AudioDevice>> {
Ok(n) => n,
Err(_) => continue,
};
- if !devices.iter().any(|d| d.name == name)
- && should_include_output_device(&name)
- {
+ if !devices.iter().any(|d| d.name == name) && should_include_output_device(&name) {
// TODO: not sure if it can be input, usually aggregate or multi output
devices.push(AudioDevice::new(name, DeviceType::Output));
}
diff --git a/crates/screenpipe-audio/src/core/pulse.rs b/crates/screenpipe-audio/src/core/pulse.rs
index 312513e4c..ee1a9aca9 100644
--- a/crates/screenpipe-audio/src/core/pulse.rs
+++ b/crates/screenpipe-audio/src/core/pulse.rs
@@ -27,7 +27,8 @@ fn with_pulse_context<F, T>(f: F) -> Result<T>
where
F: FnOnce(&pulse::context::introspect::Introspector, &mut Mainloop) -> Result<T>,
{
- let mut mainloop = Mainloop::new().ok_or_else(|| anyhow!("failed to create PulseAudio mainloop"))?;
+ let mut mainloop =
+ Mainloop::new().ok_or_else(|| anyhow!("failed to create PulseAudio mainloop"))?;
let mut context = pulse::context::Context::new(&mainloop, "screenpipe")
.ok_or_else(|| anyhow!("failed to create PulseAudio context"))?;
@@ -39,7 +40,8 @@ where
// Wait for the context to be ready
loop {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => {
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => {
return Err(anyhow!("PulseAudio mainloop error while connecting"));
}
pulse::mainloop::standard::IterateResult::Success(_) => {}
@@ -96,7 +98,8 @@ pub fn list_pulse_devices() -> Result<Vec<AudioDevice>> {
// Iterate until the operation completes
while !done.load(Ordering::Relaxed) {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => break,
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => break,
pulse::mainloop::standard::IterateResult::Success(_) => {}
}
match op.get_state() {
@@ -115,25 +118,24 @@ pub fn list_pulse_devices() -> Result<Vec<AudioDevice>> {
let done = Arc::new(AtomicBool::new(false));
let done_clone = done.clone();
- let op = introspector.get_sink_info_list(move |result| {
- match result {
- pulse::callbacks::ListResult::Item(info) => {
- if let Some(name) = &info.name {
- devs_clone
- .lock()
- .unwrap()
- .push(AudioDevice::new(name.to_string(), DeviceType::Output));
- }
- }
- pulse::callbacks::ListResult::End | pulse::callbacks::ListResult::Error => {
- done_clone.store(true, Ordering::Relaxed);
+ let op = introspector.get_sink_info_list(move |result| match result {
+ pulse::callbacks::ListResult::Item(info) => {
+ if let Some(name) = &info.name {
+ devs_clone
+ .lock()
+ .unwrap()
+ .push(AudioDevice::new(name.to_string(), DeviceType::Output));
}
}
+ pulse::callbacks::ListResult::End | pulse::callbacks::ListResult::Error => {
+ done_clone.store(true, Ordering::Relaxed);
+ }
});
while !done.load(Ordering::Relaxed) {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => break,
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => break,
pulse::mainloop::standard::IterateResult::Success(_) => {}
}
match op.get_state() {
@@ -167,7 +169,8 @@ pub fn default_pulse_source() -> Result<AudioDevice> {
while !done.load(Ordering::Relaxed) {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => break,
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => break,
pulse::mainloop::standard::IterateResult::Success(_) => {}
}
match op.get_state() {
@@ -203,7 +206,8 @@ pub fn default_pulse_sink() -> Result<AudioDevice> {
while !done.load(Ordering::Relaxed) {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => break,
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => break,
pulse::mainloop::standard::IterateResult::Success(_) => {}
}
match op.get_state() {
@@ -237,22 +241,26 @@ pub fn get_pulse_device_config(device: &AudioDevice) -> Result<AudioStreamConfig
match device.device_type {
DeviceType::Input => {
- let op = introspector.get_source_info_by_name(&device_name, move |result| {
- match result {
- pulse::callbacks::ListResult::Item(info) => {
- let rate = info.sample_spec.rate;
- let channels = info.sample_spec.channels as u16;
- *config_clone.lock().unwrap() = Some((rate, channels));
- }
- pulse::callbacks::ListResult::End | pulse::callbacks::ListResult::Error => {
- done_clone.store(true, Ordering::Relaxed);
- }
- }
- });
+ let op =
+ introspector.get_source_info_by_name(
+ &device_name,
+ move |result| match result {
+ pulse::callbacks::ListResult::Item(info) => {
+ let rate = info.sample_spec.rate;
+ let channels = info.sample_spec.channels as u16;
+ *config_clone.lock().unwrap() = Some((rate, channels));
+ }
+ pulse::callbacks::ListResult::End
+ | pulse::callbacks::ListResult::Error => {
+ done_clone.store(true, Ordering::Relaxed);
+ }
+ },
+ );
while !done.load(Ordering::Relaxed) {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => break,
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => break,
pulse::mainloop::standard::IterateResult::Success(_) => {}
}
match op.get_state() {
@@ -262,8 +270,8 @@ pub fn get_pulse_device_config(device: &AudioDevice) -> Result<AudioStreamConfig
}
}
DeviceType::Output => {
- let op = introspector.get_sink_info_by_name(&device_name, move |result| {
- match result {
+ let op =
+ introspector.get_sink_info_by_name(&device_name, move |result| match result {
pulse::callbacks::ListResult::Item(info) => {
let rate = info.sample_spec.rate;
let channels = info.sample_spec.channels as u16;
@@ -272,12 +280,12 @@ pub fn get_pulse_device_config(device: &AudioDevice) -> Result<AudioStreamConfig
pulse::callbacks::ListResult::End | pulse::callbacks::ListResult::Error => {
done_clone.store(true, Ordering::Relaxed);
}
- }
- });
+ });
while !done.load(Ordering::Relaxed) {
match mainloop.iterate(true) {
- pulse::mainloop::standard::IterateResult::Quit(_) | pulse::mainloop::standard::IterateResult::Err(_) => break,
+ pulse::mainloop::standard::IterateResult::Quit(_)
+ | pulse::mainloop::standard::IterateResult::Err(_) => break,
pulse::mainloop::standard::IterateResult::Success(_) => {}
}
match op.get_state() {
@@ -288,10 +296,12 @@ pub fn get_pulse_device_config(device: &AudioDevice) -> Result<AudioStreamConfig
}
}
- let (rate, channels) = config
- .lock()
- .unwrap()
- .ok_or_else(|| anyhow!("failed to get PulseAudio config for device: {}", device.name))?;
+ let (rate, channels) = config.lock().unwrap().ok_or_else(|| {
+ anyhow!(
+ "failed to get PulseAudio config for device: {}",
+ device.name
+ )
+ })?;
Ok(AudioStreamConfig::new(rate, channels))
})
@@ -326,16 +336,22 @@ fn create_pulse_record_stream(
}
let simple = Simple::new(
- None, // default server
- "screenpipe", // app name
- pulse::stream::Direction::Record, // direction
- Some(&source_name), // source device
- "audio-capture", // stream description
- &spec, // sample format
- None, // default channel map
- None, // default buffering
+ None, // default server
+ "screenpipe", // app name
+ pulse::stream::Direction::Record, // direction
+ Some(&source_name), // source device
+ "audio-capture", // stream description
+ &spec, // sample format
+ None, // default channel map
+ None, // default buffering
)
- .map_err(|e| anyhow!("failed to create PulseAudio recording stream for '{}': {:?}", source_name, e))?;
+ .map_err(|e| {
+ anyhow!(
+ "failed to create PulseAudio recording stream for '{}': {:?}",
+ source_name,
+ e
+ )
+ })?;
info!(
"PulseAudio recording stream created: source='{}', rate={}, channels={}",
@@ -369,7 +385,10 @@ pub fn spawn_pulse_capture_thread(
let simple = match create_pulse_record_stream(&device, sample_rate, channels as u8) {
Ok(s) => s,
Err(e) => {
- error!("failed to create PulseAudio stream for {}: {}", device_name, e);
+ error!(
+ "failed to create PulseAudio stream for {}: {}",
+ device_name, e
+ );
is_disconnected.store(true, Ordering::Relaxed);
return;
}
diff --git a/crates/screenpipe-audio/src/transcription/deepgram/batch.rs b/crates/screenpipe-audio/src/transcription/deepgram/batch.rs
index ece5508f0..9b1a8191c 100644
--- a/crates/screenpipe-audio/src/transcription/deepgram/batch.rs
+++ b/crates/screenpipe-audio/src/transcription/deepgram/batch.rs
@@ -34,7 +34,10 @@ pub async fn transcribe_with_deepgram(
custom_api_key
};
- debug!("deepgram api key: {}...", &api_key_to_use[..api_key_to_use.len().min(8)]);
+ debug!(
+ "deepgram api key: {}...",
+ &api_key_to_use[..api_key_to_use.len().min(8)]
+ );
let response =
get_deepgram_response(api_key_to_use, is_custom_endpoint, wav_data, query_params).await;
diff --git a/crates/screenpipe-audio/src/transcription/handle_new_transcript.rs b/crates/screenpipe-audio/src/transcription/handle_new_transcript.rs
index 05474813e..564099bc8 100644
--- a/crates/screenpipe-audio/src/transcription/handle_new_transcript.rs
+++ b/crates/screenpipe-audio/src/transcription/handle_new_transcript.rs
@@ -98,7 +98,11 @@ pub async fn handle_new_transcript(
info!(
"device {} received transcription ({} chars)",
transcription.input.device,
- transcription.transcription.as_ref().map(|t| t.len()).unwrap_or(0)
+ transcription
+ .transcription
+ .as_ref()
+ .map(|t| t.len())
+ .unwrap_or(0)
);
// Insert the new transcript after fetching
diff --git a/crates/screenpipe-core/Cargo.toml b/crates/screenpipe-core/Cargo.toml
index 9f84e8de4..5dd8b7a53 100644
--- a/crates/screenpipe-core/Cargo.toml
+++ b/crates/screenpipe-core/Cargo.toml
@@ -22,16 +22,13 @@ hf-hub = { workspace = true, features = [
"tokio",
"native-tls",
] }
-http-cache-reqwest = { workspace = true }
-reqwest-middleware = { workspace = true }
+
tokio = { workspace = true }
# Security
regex = { version = "1.10.6", features = ["std"], optional = true }
lazy_static = { version = "1.4.0", optional = true }
tempfile = "3.3.0"
-url = "2.4.0"
-
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
@@ -57,8 +54,6 @@ once_cell = "1.19.0"
cron = "0.13.0"
chrono = "0.4.38"
-sentry = { workspace = true }
-zip = "0.6.2"
[dev-dependencies]
reqwest = { workspace = true }
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index e32c01eaa..7c4529312 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -125,7 +125,7 @@ impl DatabaseManager {
// connections wait before returning SQLITE_BUSY ("database is locked").
.busy_timeout(Duration::from_secs(10))
.pragma("journal_mode", "WAL")
- .pragma("cache_size", "-64000") // 64 MB page cache
+ .pragma("cache_size", "-64000") // 64 MB page cache
.pragma("mmap_size", "268435456") // 256 MB memory-mapped I/O
.pragma("temp_store", "MEMORY")
// Checkpoint after 4000 pages (~16MB) instead of default 1000 (~4MB).
@@ -190,13 +190,11 @@ impl DatabaseManager {
// Update the checksum for any previously-applied migration to match the current file
let version = migration.version;
let checksum_bytes: &[u8] = &migration.checksum;
- sqlx::query(
- "UPDATE _sqlx_migrations SET checksum = ? WHERE version = ?"
- )
- .bind(checksum_bytes)
- .bind(version)
- .execute(pool)
- .await?;
+ sqlx::query("UPDATE _sqlx_migrations SET checksum = ? WHERE version = ?")
+ .bind(checksum_bytes)
+ .bind(version)
+ .execute(pool)
+ .await?;
}
tracing::info!("Migration checksums updated successfully");
Ok(())
@@ -209,14 +207,17 @@ impl DatabaseManager {
/// when a deferred reader tries to upgrade to writer after another commit.
///
/// Returns an `ImmediateTx` that automatically rolls back on drop if not committed.
- pub async fn begin_immediate_with_retry(
- &self,
- ) -> Result<ImmediateTx, sqlx::Error> {
+ pub async fn begin_immediate_with_retry(&self) -> Result<ImmediateTx, sqlx::Error> {
let max_retries = 5;
for attempt in 1..=max_retries {
let mut conn = self.pool.acquire().await?;
match sqlx::query("BEGIN IMMEDIATE").execute(&mut *conn).await {
- Ok(_) => return Ok(ImmediateTx { conn: Some(conn), committed: false }),
+ Ok(_) => {
+ return Ok(ImmediateTx {
+ conn: Some(conn),
+ committed: false,
+ })
+ }
Err(e) if attempt < max_retries && Self::is_busy_error(&e) => {
warn!(
"BEGIN IMMEDIATE busy (attempt {}/{}), retrying...",
@@ -494,7 +495,8 @@ impl DatabaseManager {
file_path: &str,
device_name: &str,
) -> Result<i64, sqlx::Error> {
- self.insert_video_chunk_with_fps(file_path, device_name, 0.5).await
+ self.insert_video_chunk_with_fps(file_path, device_name, 0.5)
+ .await
}
pub async fn insert_video_chunk_with_fps(
@@ -504,13 +506,15 @@ impl DatabaseManager {
fps: f64,
) -> Result<i64, sqlx::Error> {
let mut tx = self.begin_immediate_with_retry().await?;
- let id = sqlx::query("INSERT INTO video_chunks (file_path, device_name, fps) VALUES (?1, ?2, ?3)")
- .bind(file_path)
- .bind(device_name)
- .bind(fps)
- .execute(&mut **tx.conn())
- .await?
- .last_insert_rowid();
+ let id = sqlx::query(
+ "INSERT INTO video_chunks (file_path, device_name, fps) VALUES (?1, ?2, ?3)",
+ )
+ .bind(file_path)
+ .bind(device_name)
+ .bind(fps)
+ .execute(&mut **tx.conn())
+ .await?
+ .last_insert_rowid();
tx.commit().await?;
Ok(id)
}
@@ -3364,13 +3368,11 @@ LIMIT ? OFFSET ?
let mut tx = self.begin_immediate_with_retry().await?;
for (emb_id, old_speaker_id) in &similar_rows {
- sqlx::query(
- "UPDATE speaker_embeddings SET speaker_id = ? WHERE id = ?",
- )
- .bind(target_speaker_id)
- .bind(emb_id)
- .execute(&mut **tx.conn())
- .await?;
+ sqlx::query("UPDATE speaker_embeddings SET speaker_id = ? WHERE id = ?")
+ .bind(target_speaker_id)
+ .bind(emb_id)
+ .execute(&mut **tx.conn())
+ .await?;
embeddings_moved += 1;
sqlx::query(
diff --git a/crates/screenpipe-db/tests/keyword_search_order_test.rs b/crates/screenpipe-db/tests/keyword_search_order_test.rs
index 0b3143814..6dff94cea 100644
--- a/crates/screenpipe-db/tests/keyword_search_order_test.rs
+++ b/crates/screenpipe-db/tests/keyword_search_order_test.rs
@@ -1,8 +1,8 @@
#[cfg(test)]
mod tests {
- use std::sync::Arc;
use chrono::{Duration, Utc};
use screenpipe_db::{DatabaseManager, OcrEngine, Order};
+ use std::sync::Arc;
async fn setup_test_db() -> DatabaseManager {
let db = DatabaseManager::new("sqlite::memory:").await.unwrap();
@@ -49,14 +49,9 @@ mod tests {
.await
.unwrap();
- db.insert_ocr_text(
- frame_id,
- ocr_text,
- "[]",
- Arc::new(OcrEngine::AppleNative),
- )
- .await
- .unwrap();
+ db.insert_ocr_text(frame_id, ocr_text, "[]", Arc::new(OcrEngine::AppleNative))
+ .await
+ .unwrap();
frame_id
}
@@ -68,46 +63,18 @@ mod tests {
// All frames have "hello" in OCR text so FTS finds them.
// They differ in timestamp — we verify results come back newest-first.
// Frame A: 60 min ago, "hello" also in window_name (high relevance)
- let _frame_a = insert_frame_with_ocr(
- &db,
- "Arc",
- "hello world page",
- "hello from the browser",
- 60,
- )
- .await;
+ let _frame_a =
+ insert_frame_with_ocr(&db, "Arc", "hello world page", "hello from the browser", 60)
+ .await;
// Frame B: 10 min ago, "hello" only in OCR (low relevance)
- let _frame_b = insert_frame_with_ocr(
- &db,
- "WezTerm",
- "terminal",
- "echo hello",
- 10,
- )
- .await;
+ let _frame_b = insert_frame_with_ocr(&db, "WezTerm", "terminal", "echo hello", 10).await;
// Frame C: 30 min ago
- let _frame_c = insert_frame_with_ocr(
- &db,
- "Cursor",
- "editor",
- "println hello",
- 30,
- )
- .await;
+ let _frame_c = insert_frame_with_ocr(&db, "Cursor", "editor", "println hello", 30).await;
let results = db
- .search_with_text_positions(
- "hello",
- 10,
- 0,
- None,
- None,
- true,
- Order::Descending,
- None,
- )
+ .search_with_text_positions("hello", 10, 0, None, None, true, Order::Descending, None)
.await
.unwrap();
@@ -143,39 +110,22 @@ mod tests {
async fn test_keyword_search_sorted_by_timestamp_ascending() {
let db = setup_test_db().await;
- let _frame_old = insert_frame_with_ocr(
- &db,
- "Arc",
- "browser",
- "old content with hello",
- 120,
- )
- .await;
+ let _frame_old =
+ insert_frame_with_ocr(&db, "Arc", "browser", "old content with hello", 120).await;
- let _frame_new = insert_frame_with_ocr(
- &db,
- "WezTerm",
- "terminal",
- "new content hello world",
- 5,
- )
- .await;
+ let _frame_new =
+ insert_frame_with_ocr(&db, "WezTerm", "terminal", "new content hello world", 5).await;
let results = db
- .search_with_text_positions(
- "hello",
- 10,
- 0,
- None,
- None,
- true,
- Order::Ascending,
- None,
- )
+ .search_with_text_positions("hello", 10, 0, None, None, true, Order::Ascending, None)
.await
.unwrap();
- assert!(results.len() >= 2, "Expected at least 2 results, got {}", results.len());
+ assert!(
+ results.len() >= 2,
+ "Expected at least 2 results, got {}",
+ results.len()
+ );
// Ascending: oldest first
for i in 0..results.len() - 1 {
@@ -197,14 +147,8 @@ mod tests {
// Two frames at the same time, different relevance.
// Both have "hello" in OCR text so FTS finds both.
// Frame 1: "hello" only in OCR (relevance 1)
- let _frame_low = insert_frame_with_ocr(
- &db,
- "Terminal",
- "bash",
- "hello world from terminal",
- 10,
- )
- .await;
+ let _frame_low =
+ insert_frame_with_ocr(&db, "Terminal", "bash", "hello world from terminal", 10).await;
// Frame 2: "hello" in window_name too (relevance 3)
let _frame_high = insert_frame_with_ocr(
@@ -217,27 +161,19 @@ mod tests {
.await;
let results = db
- .search_with_text_positions(
- "hello",
- 10,
- 0,
- None,
- None,
- true,
- Order::Descending,
- None,
- )
+ .search_with_text_positions("hello", 10, 0, None, None, true, Order::Descending, None)
.await
.unwrap();
- assert!(results.len() >= 2, "Expected at least 2 results, got {}", results.len());
+ assert!(
+ results.len() >= 2,
+ "Expected at least 2 results, got {}",
+ results.len()
+ );
// Both have ~same timestamp, so within the same second,
// the one with "hello" in window_name (higher relevance) should come first
- let first_has_hello_in_window = results[0]
- .window_name
- .to_lowercase()
- .contains("hello");
+ let first_has_hello_in_window = results[0].window_name.to_lowercase().contains("hello");
assert!(
first_has_hello_in_window,
"Within same timestamp, higher relevance result should come first. Got: {} - {}",
diff --git a/crates/screenpipe-integrations/src/reminders.rs b/crates/screenpipe-integrations/src/reminders.rs
index ce232f4da..c084aa71f 100644
--- a/crates/screenpipe-integrations/src/reminders.rs
+++ b/crates/screenpipe-integrations/src/reminders.rs
@@ -6,11 +6,11 @@
//!
//! All operations are synchronous and safe to call from a tokio blocking task.
+use chrono::Datelike;
use eventkit::{
- AuthorizationStatus, CalendarInfo, EventKitError, RemindersManager, ReminderItem,
+ AuthorizationStatus, CalendarInfo, EventKitError, ReminderItem, RemindersManager,
Result as EKResult,
};
-use chrono::Datelike;
use objc2::rc::Retained;
use objc2::Message;
use objc2_event_kit::{EKCalendar, EKEntityType, EKEventStore, EKReminder, EKSource, EKSourceType};
@@ -176,10 +176,7 @@ impl ScreenpipeReminders {
// ── Private helpers ────────────────────────────────────────────────
- fn find_calendar_by_title(
- &self,
- title: &str,
- ) -> EKResult<Retained<EKCalendar>> {
+ fn find_calendar_by_title(&self, title: &str) -> EKResult<Retained<EKCalendar>> {
let calendars = unsafe { self.store.calendarsForEntityType(EKEntityType::Reminder) };
for cal in calendars.iter() {
let cal_title = unsafe { cal.title() };
@@ -341,7 +338,12 @@ mod tests {
// Create
let item = r
- .create_reminder("Test lifecycle", Some("notes here"), Some(list), Some("tomorrow"))
+ .create_reminder(
+ "Test lifecycle",
+ Some("notes here"),
+ Some(list),
+ Some("tomorrow"),
+ )
.expect("create failed");
println!("Created: {} ({})", item.title, item.identifier);
assert_eq!(item.title, "Test lifecycle");
@@ -356,7 +358,9 @@ mod tests {
assert_eq!(got.title, "Test lifecycle");
// Complete
- let completed = r.complete_reminder(&item.identifier).expect("complete failed");
+ let completed = r
+ .complete_reminder(&item.identifier)
+ .expect("complete failed");
assert!(completed.completed);
// Delete
diff --git a/crates/screenpipe-server/Cargo.toml b/crates/screenpipe-server/Cargo.toml
index 561fcc48a..d214843e3 100644
--- a/crates/screenpipe-server/Cargo.toml
+++ b/crates/screenpipe-server/Cargo.toml
@@ -21,7 +21,7 @@ screenpipe-core = { path = "../screenpipe-core", features = ["security", "cloud-
screenpipe-db = { path = "../screenpipe-db" }
screenpipe-accessibility = { path = "../screenpipe-accessibility", features = ["db"], optional = true }
screenpipe-apple-intelligence = { path = "../screenpipe-apple-intelligence", optional = true }
-killport = { version = "1.1.0" }
+
# Image processing
image = { workspace = true }
diff --git a/crates/screenpipe-server/src/apple_intelligence_api.rs b/crates/screenpipe-server/src/apple_intelligence_api.rs
index 49dfacd09..b70625f32 100644
--- a/crates/screenpipe-server/src/apple_intelligence_api.rs
+++ b/crates/screenpipe-server/src/apple_intelligence_api.rs
@@ -416,12 +416,11 @@ pub async fn chat_completions(
schema_str
);
- let result = tokio::task::spawn_blocking(move || {
- generate_text(Some(&json_instructions), &prompt)
- })
- .await
- .map_err(|e| mk_err(&e.to_string()))?
- .map_err(|e| mk_err(&e.to_string()))?;
+ let result =
+ tokio::task::spawn_blocking(move || generate_text(Some(&json_instructions), &prompt))
+ .await
+ .map_err(|e| mk_err(&e.to_string()))?
+ .map_err(|e| mk_err(&e.to_string()))?;
info!(
"apple intelligence json response: {} chars, {:.0}ms",
@@ -448,12 +447,11 @@ pub async fn chat_completions(
(json_text, true)
} else {
- let result = tokio::task::spawn_blocking(move || {
- generate_text(instructions.as_deref(), &prompt)
- })
- .await
- .map_err(|e| mk_err(&e.to_string()))?
- .map_err(|e| mk_err(&e.to_string()))?;
+ let result =
+ tokio::task::spawn_blocking(move || generate_text(instructions.as_deref(), &prompt))
+ .await
+ .map_err(|e| mk_err(&e.to_string()))?
+ .map_err(|e| mk_err(&e.to_string()))?;
info!(
"apple intelligence text response: {} chars, {:.0}ms",
diff --git a/crates/screenpipe-server/src/bin/screenpipe-server.rs b/crates/screenpipe-server/src/bin/screenpipe-server.rs
index 13ba31913..1149a4c66 100644
--- a/crates/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/crates/screenpipe-server/src/bin/screenpipe-server.rs
@@ -23,11 +23,9 @@ use screenpipe_server::{
analytics,
cli::{
get_or_create_machine_id, AudioCommand, Cli, CliAudioTranscriptionEngine, CliOcrEngine,
- Command, McpCommand, MigrationSubCommand, OutputFormat, SyncCommand,
- VisionCommand,
+ Command, McpCommand, MigrationSubCommand, OutputFormat, SyncCommand, VisionCommand,
},
- handle_index_command,
- start_continuous_recording, start_sleep_monitor, start_ui_recording,
+ handle_index_command, start_continuous_recording, start_sleep_monitor, start_ui_recording,
sync_provider::ScreenpipeSyncProvider,
vision_manager::{
start_monitor_watcher, stop_monitor_watcher, VisionManager, VisionManagerConfig,
@@ -292,41 +290,81 @@ async fn main() -> anyhow::Result<()> {
id: Some(analytics::get_distinct_id().to_string()),
..Default::default()
}));
- scope.set_context("cli_settings", sentry::protocol::Context::Other({
- let mut map = std::collections::BTreeMap::new();
- map.insert("fps".into(), json!(cli.fps));
- map.insert("adaptive_fps".into(), json!(cli.adaptive_fps));
- map.insert("audio_chunk_duration".into(), json!(cli.audio_chunk_duration));
- map.insert("port".into(), json!(cli.port));
- map.insert("disable_audio".into(), json!(cli.disable_audio));
- map.insert("audio_transcription_engine".into(), json!(format!("{:?}", cli.audio_transcription_engine)));
- map.insert("enable_realtime_audio_transcription".into(), json!(cli.enable_realtime_audio_transcription));
- map.insert("enable_realtime_vision".into(), json!(cli.enable_realtime_vision));
- map.insert("ocr_engine".into(), json!(format!("{:?}", cli.ocr_engine)));
- map.insert("monitor_ids".into(), json!(cli.monitor_id));
- map.insert("use_all_monitors".into(), json!(cli.use_all_monitors));
- map.insert("languages".into(), json!(cli.language.iter().map(|l| format!("{:?}", l)).collect::<Vec<_>>()));
- map.insert("use_pii_removal".into(), json!(cli.use_pii_removal));
- map.insert("disable_vision".into(), json!(cli.disable_vision));
- map.insert("vad_engine".into(), json!(format!("{:?}", cli.vad_engine)));
- map.insert("vad_sensitivity".into(), json!(format!("{:?}", cli.vad_sensitivity)));
- map.insert("video_chunk_duration".into(), json!(cli.video_chunk_duration));
- map.insert("enable_llm".into(), json!(cli.enable_llm));
- map.insert("enable_frame_cache".into(), json!(cli.enable_frame_cache));
- map.insert("capture_unfocused_windows".into(), json!(cli.capture_unfocused_windows));
-
- map.insert("enable_ui_events".into(), json!(cli.enable_ui_events));
- map.insert("enable_sync".into(), json!(cli.enable_sync));
- map.insert("sync_interval_secs".into(), json!(cli.sync_interval_secs));
- map.insert("debug".into(), json!(cli.debug));
- // Only send counts for privacy-sensitive lists (not actual values)
- map.insert("audio_device_count".into(), json!(cli.audio_device.len()));
- map.insert("realtime_audio_device_count".into(), json!(cli.realtime_audio_device.len()));
- map.insert("ignored_windows_count".into(), json!(cli.ignored_windows.len()));
- map.insert("included_windows_count".into(), json!(cli.included_windows.len()));
- map.insert("ignored_urls_count".into(), json!(cli.ignored_urls.len()));
- map
- }));
+ scope.set_context(
+ "cli_settings",
+ sentry::protocol::Context::Other({
+ let mut map = std::collections::BTreeMap::new();
+ map.insert("fps".into(), json!(cli.fps));
+ map.insert("adaptive_fps".into(), json!(cli.adaptive_fps));
+ map.insert(
+ "audio_chunk_duration".into(),
+ json!(cli.audio_chunk_duration),
+ );
+ map.insert("port".into(), json!(cli.port));
+ map.insert("disable_audio".into(), json!(cli.disable_audio));
+ map.insert(
+ "audio_transcription_engine".into(),
+ json!(format!("{:?}", cli.audio_transcription_engine)),
+ );
+ map.insert(
+ "enable_realtime_audio_transcription".into(),
+ json!(cli.enable_realtime_audio_transcription),
+ );
+ map.insert(
+ "enable_realtime_vision".into(),
+ json!(cli.enable_realtime_vision),
+ );
+ map.insert("ocr_engine".into(), json!(format!("{:?}", cli.ocr_engine)));
+ map.insert("monitor_ids".into(), json!(cli.monitor_id));
+ map.insert("use_all_monitors".into(), json!(cli.use_all_monitors));
+ map.insert(
+ "languages".into(),
+ json!(cli
+ .language
+ .iter()
+ .map(|l| format!("{:?}", l))
+ .collect::<Vec<_>>()),
+ );
+ map.insert("use_pii_removal".into(), json!(cli.use_pii_removal));
+ map.insert("disable_vision".into(), json!(cli.disable_vision));
+ map.insert("vad_engine".into(), json!(format!("{:?}", cli.vad_engine)));
+ map.insert(
+ "vad_sensitivity".into(),
+ json!(format!("{:?}", cli.vad_sensitivity)),
+ );
+ map.insert(
+ "video_chunk_duration".into(),
+ json!(cli.video_chunk_duration),
+ );
+ map.insert("enable_llm".into(), json!(cli.enable_llm));
+ map.insert("enable_frame_cache".into(), json!(cli.enable_frame_cache));
+ map.insert(
+ "capture_unfocused_windows".into(),
+ json!(cli.capture_unfocused_windows),
+ );
+
+ map.insert("enable_ui_events".into(), json!(cli.enable_ui_events));
+ map.insert("enable_sync".into(), json!(cli.enable_sync));
+ map.insert("sync_interval_secs".into(), json!(cli.sync_interval_secs));
+ map.insert("debug".into(), json!(cli.debug));
+ // Only send counts for privacy-sensitive lists (not actual values)
+ map.insert("audio_device_count".into(), json!(cli.audio_device.len()));
+ map.insert(
+ "realtime_audio_device_count".into(),
+ json!(cli.realtime_audio_device.len()),
+ );
+ map.insert(
+ "ignored_windows_count".into(),
+ json!(cli.ignored_windows.len()),
+ );
+ map.insert(
+ "included_windows_count".into(),
+ json!(cli.included_windows.len()),
+ );
+ map.insert("ignored_urls_count".into(), json!(cli.ignored_urls.len()));
+ map
+ }),
+ );
});
Some(guard)
diff --git a/crates/screenpipe-server/src/core.rs b/crates/screenpipe-server/src/core.rs
index a5a4b61af..17f4ce4e0 100644
--- a/crates/screenpipe-server/src/core.rs
+++ b/crates/screenpipe-server/src/core.rs
@@ -160,8 +160,14 @@ pub async fn record_video(
// Just spawn the task directly
tokio::spawn(async move {
- debug!("Inserting new video chunk: {} (fps={})", file_path, chunk_fps);
- if let Err(e) = db.insert_video_chunk_with_fps(&file_path, &device_name, chunk_fps).await {
+ debug!(
+ "Inserting new video chunk: {} (fps={})",
+ file_path, chunk_fps
+ );
+ if let Err(e) = db
+ .insert_video_chunk_with_fps(&file_path, &device_name, chunk_fps)
+ .await
+ {
error!("Failed to insert new video chunk: {}", e);
} else {
debug!("Successfully inserted video chunk: {}", file_path);
diff --git a/crates/screenpipe-server/src/lib.rs b/crates/screenpipe-server/src/lib.rs
index f26acfa1f..a844ea95f 100644
--- a/crates/screenpipe-server/src/lib.rs
+++ b/crates/screenpipe-server/src/lib.rs
@@ -40,7 +40,10 @@ pub use server::PaginatedResponse;
pub use server::SCServer;
pub use server::{api_list_monitors, MonitorInfo};
pub use sleep_monitor::start_sleep_monitor;
-pub use video::{FrameWriteInfo, FrameWriteTracker, VideoCapture, video_quality_to_crf, video_quality_to_jpeg_q, video_quality_to_preset};
+pub use video::{
+ video_quality_to_crf, video_quality_to_jpeg_q, video_quality_to_preset, FrameWriteInfo,
+ FrameWriteTracker, VideoCapture,
+};
pub mod embedding;
pub use cloud_search::{CloudSearchClient, CloudSearchMetadata, CloudStatus};
pub use ui_recorder::{start_ui_recording, UiRecorderConfig, UiRecorderHandle};
diff --git a/crates/screenpipe-server/src/server.rs b/crates/screenpipe-server/src/server.rs
index c63eb1ad2..08648685f 100644
--- a/crates/screenpipe-server/src/server.rs
+++ b/crates/screenpipe-server/src/server.rs
@@ -55,7 +55,9 @@ use tracing::{debug, error, info, warn};
use crate::sync_api::{self, SyncState};
-use screenpipe_vision::monitor::{get_monitor_by_id, list_monitors, list_monitors_detailed, MonitorListError};
+use screenpipe_vision::monitor::{
+ get_monitor_by_id, list_monitors, list_monitors_detailed, MonitorListError,
+};
use screenpipe_vision::OcrEngine;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::{json, Value};
@@ -725,15 +727,12 @@ pub async fn api_list_monitors(
}
}
-pub async fn api_vision_status(
-) -> JsonResponse<serde_json::Value> {
+pub async fn api_vision_status() -> JsonResponse<serde_json::Value> {
match list_monitors_detailed().await {
- Ok(monitors) if monitors.is_empty() => {
- JsonResponse(json!({
- "status": "no_monitors",
- "message": "No monitors found"
- }))
- }
+ Ok(monitors) if monitors.is_empty() => JsonResponse(json!({
+ "status": "no_monitors",
+ "message": "No monitors found"
+ })),
Ok(monitors) => {
let monitor_ids: Vec<u32> = monitors.iter().map(|m| m.id()).collect();
JsonResponse(json!({
@@ -742,24 +741,18 @@ pub async fn api_vision_status(
"monitor_ids": monitor_ids
}))
}
- Err(MonitorListError::PermissionDenied) => {
- JsonResponse(json!({
- "status": "permission_denied",
- "message": "Screen recording permission not granted. Grant access in System Settings > Privacy & Security > Screen Recording"
- }))
- }
- Err(MonitorListError::NoMonitorsFound) => {
- JsonResponse(json!({
- "status": "no_monitors",
- "message": "No monitors found"
- }))
- }
- Err(MonitorListError::Other(e)) => {
- JsonResponse(json!({
- "status": "error",
- "message": e
- }))
- }
+ Err(MonitorListError::PermissionDenied) => JsonResponse(json!({
+ "status": "permission_denied",
+ "message": "Screen recording permission not granted. Grant access in System Settings > Privacy & Security > Screen Recording"
+ })),
+ Err(MonitorListError::NoMonitorsFound) => JsonResponse(json!({
+ "status": "no_monitors",
+ "message": "No monitors found"
+ })),
+ Err(MonitorListError::Other(e)) => JsonResponse(json!({
+ "status": "error",
+ "message": e
+ })),
}
}
@@ -1186,7 +1179,6 @@ impl SCServer {
.post("/audio/start", start_audio)
.post("/audio/stop", stop_audio)
.get("/semantic-search", semantic_search_handler)
-
.get("/search/keyword", keyword_search_handler)
.post("/v1/embeddings", create_embeddings)
.post("/audio/device/start", start_audio_device)
@@ -1229,13 +1221,15 @@ impl SCServer {
.route("/ws/health", get(ws_health_handler))
.route("/frames/export", get(handle_video_export_ws))
.with_state(app_state.clone())
- .layer(axum::middleware::from_fn(move |req: axum::extract::Request, next: axum::middleware::Next| {
- let counter = app_state.api_request_count.clone();
- async move {
- counter.fetch_add(1, Ordering::Relaxed);
- next.run(req).await
- }
- }))
+ .layer(axum::middleware::from_fn(
+ move |req: axum::extract::Request, next: axum::middleware::Next| {
+ let counter = app_state.api_request_count.clone();
+ async move {
+ counter.fetch_add(1, Ordering::Relaxed);
+ next.run(req).await
+ }
+ },
+ ))
.layer(cors)
.layer(TraceLayer::new_for_http().make_span_with(DefaultMakeSpan::default()))
}
@@ -2857,11 +2851,16 @@ pub async fn get_frame_data(
}
Err(e) => {
let err_str = e.to_string();
-
+
// Check for corrupted/missing video errors - return 410 Gone
// This tells frontend the frame is permanently unavailable
- if err_str.contains("VIDEO_CORRUPTED") || err_str.contains("VIDEO_NOT_FOUND") {
- debug!("Frame {} unavailable (corrupted/missing video): {}", frame_id, e);
+ if err_str.contains("VIDEO_CORRUPTED")
+ || err_str.contains("VIDEO_NOT_FOUND")
+ {
+ debug!(
+ "Frame {} unavailable (corrupted/missing video): {}",
+ frame_id, e
+ );
return Err((
StatusCode::GONE, // 410 = permanently unavailable
JsonResponse(json!({
@@ -2873,7 +2872,7 @@ pub async fn get_frame_data(
})),
));
}
-
+
error!("Failed to extract frame {}: {}", frame_id, e);
Err((
StatusCode::INTERNAL_SERVER_ERROR,
diff --git a/crates/screenpipe-server/src/sync_api.rs b/crates/screenpipe-server/src/sync_api.rs
index a1e37531f..7d0478d3a 100644
--- a/crates/screenpipe-server/src/sync_api.rs
+++ b/crates/screenpipe-server/src/sync_api.rs
@@ -229,9 +229,7 @@ pub async fn sync_init(
// Wait a bit before first download to let upload complete first
tokio::time::sleep(tokio::time::Duration::from_secs(30)).await;
- let interval = tokio::time::Duration::from_secs(
- request.sync_interval_secs.unwrap_or(300),
- );
+ let interval = tokio::time::Duration::from_secs(request.sync_interval_secs.unwrap_or(300));
loop {
let end = chrono::Utc::now();
diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rs
index e221da3ab..5e7f22ea1 100644
--- a/crates/screenpipe-server/src/video.rs
+++ b/crates/screenpipe-server/src/video.rs
@@ -159,10 +159,7 @@ impl VideoCapture {
let capture_activity_feed = activity_feed;
let capture_thread = tokio::spawn(async move {
- info!(
- "Starting continuous_capture for monitor {}",
- monitor_id
- );
+ info!("Starting continuous_capture for monitor {}", monitor_id);
loop {
match continuous_capture(
@@ -178,10 +175,7 @@ impl VideoCapture {
.await
{
Ok(_) => {
- info!(
- "continuous_capture for monitor {} completed",
- monitor_id
- );
+ info!("continuous_capture for monitor {} completed", monitor_id);
break;
}
Err(e) => {
@@ -417,7 +411,11 @@ pub fn video_quality_to_jpeg_q(quality: &str) -> &'static str {
}
}
-pub async fn start_ffmpeg_process(output_file: &str, fps: f64, video_quality: &str) -> Result<Child, anyhow::Error> {
+pub async fn start_ffmpeg_process(
+ output_file: &str,
+ fps: f64,
+ video_quality: &str,
+) -> Result<Child, anyhow::Error> {
// Overriding fps with max fps if over the max and warning user
let fps = if fps > MAX_FPS {
warn!("Overriding FPS from {} to {}", fps, MAX_FPS);
@@ -453,14 +451,7 @@ pub async fn start_ffmpeg_process(output_file: &str, fps: f64, video_quality: &s
);
args.extend_from_slice(&[
- "-vcodec",
- "libx265",
- "-tag:v",
- "hvc1",
- "-preset",
- preset,
- "-crf",
- crf,
+ "-vcodec", "libx265", "-tag:v", "hvc1", "-preset", preset, "-crf", crf,
]);
// Use fragmented MP4 to allow reading frames while file is still being written
@@ -819,16 +810,16 @@ mod tests {
async fn get_video_dimensions(video_path: &str) -> Result<(u32, u32), anyhow::Error> {
let mut cmd = Command::new("ffprobe");
cmd.args([
- "-v",
- "error",
- "-select_streams",
- "v:0",
- "-show_entries",
- "stream=width,height",
- "-of",
- "csv=s=x:p=0",
- video_path,
- ]);
+ "-v",
+ "error",
+ "-select_streams",
+ "v:0",
+ "-show_entries",
+ "stream=width,height",
+ "-of",
+ "csv=s=x:p=0",
+ video_path,
+ ]);
#[cfg(target_os = "windows")]
{
use std::os::windows::process::CommandExt;
diff --git a/crates/screenpipe-server/src/video_utils.rs b/crates/screenpipe-server/src/video_utils.rs
index 2f5b3641c..70ce8d1f8 100644
--- a/crates/screenpipe-server/src/video_utils.rs
+++ b/crates/screenpipe-server/src/video_utils.rs
@@ -694,7 +694,11 @@ impl VideoMetadataOverride {
}
}
-pub async fn extract_frame_from_video(file_path: &str, offset_index: i64, jpeg_quality: &str) -> Result<String> {
+pub async fn extract_frame_from_video(
+ file_path: &str,
+ offset_index: i64,
+ jpeg_quality: &str,
+) -> Result<String> {
let ffmpeg_path = find_ffmpeg_path().expect("failed to find ffmpeg path");
// Check if file exists first
diff --git a/crates/screenpipe-server/tests/consumer_sleep_test.rs b/crates/screenpipe-server/tests/consumer_sleep_test.rs
index 8ec708fd6..1c3157b4b 100644
--- a/crates/screenpipe-server/tests/consumer_sleep_test.rs
+++ b/crates/screenpipe-server/tests/consumer_sleep_test.rs
@@ -9,7 +9,6 @@
///
/// This test simulates the producer/consumer pattern with an ArrayQueue and verifies
/// that all frames are consumed without drops under burst conditions.
-
use crossbeam::queue::ArrayQueue;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
@@ -132,7 +131,8 @@ async fn test_old_consumer_cannot_keep_up_with_burst() {
assert!(
total_lost > 0 || total_dropped > 0,
"Old consumer SHOULD lose frames: lost={}, dropped={}",
- total_lost, total_dropped
+ total_lost,
+ total_dropped
);
assert!(
total_processed < total_produced / 2,
diff --git a/crates/screenpipe-server/tests/health_debounce_test.rs b/crates/screenpipe-server/tests/health_debounce_test.rs
index 646350206..eb1e091c9 100644
--- a/crates/screenpipe-server/tests/health_debounce_test.rs
+++ b/crates/screenpipe-server/tests/health_debounce_test.rs
@@ -1,7 +1,6 @@
/// Standalone test for health check debouncing logic.
/// This mirrors the core logic from apps/screenpipe-app-tauri/src-tauri/src/health.rs
/// so we can test it without the full Tauri build.
-
use std::time::Duration;
const STARTUP_GRACE_PERIOD: Duration = Duration::from_secs(30);
@@ -64,11 +63,15 @@ fn is_unhealthy_icon(icon_key: &str) -> bool {
// ============ helpers ============
fn make_healthy_response() -> Result<HealthCheckResponse, anyhow::Error> {
- Ok(HealthCheckResponse { status: "healthy".to_string() })
+ Ok(HealthCheckResponse {
+ status: "healthy".to_string(),
+ })
}
fn make_unhealthy_response() -> Result<HealthCheckResponse, anyhow::Error> {
- Ok(HealthCheckResponse { status: "unhealthy".to_string() })
+ Ok(HealthCheckResponse {
+ status: "unhealthy".to_string(),
+ })
}
fn make_connection_error() -> Result<HealthCheckResponse, anyhow::Error> {
@@ -112,7 +115,12 @@ fn test_unhealthy_response_always_error() {
fn test_connection_error_during_grace_period_is_starting() {
for secs in [0, 15, 29] {
let result = make_connection_error();
- let status = decide_no_debounce(&result, Duration::from_secs(secs), STARTUP_GRACE_PERIOD, false);
+ let status = decide_no_debounce(
+ &result,
+ Duration::from_secs(secs),
+ STARTUP_GRACE_PERIOD,
+ false,
+ );
assert_eq!(status, RecordingStatus::Starting, "at {}s", secs);
}
}
@@ -121,7 +129,12 @@ fn test_connection_error_during_grace_period_is_starting() {
fn test_connection_error_after_grace_period_is_stopped() {
for secs in [31, 120] {
let result = make_connection_error();
- let status = decide_no_debounce(&result, Duration::from_secs(secs), STARTUP_GRACE_PERIOD, false);
+ let status = decide_no_debounce(
+ &result,
+ Duration::from_secs(secs),
+ STARTUP_GRACE_PERIOD,
+ false,
+ );
assert_eq!(status, RecordingStatus::Stopped, "at {}s", secs);
}
}
@@ -130,8 +143,12 @@ fn test_connection_error_after_grace_period_is_stopped() {
fn test_connection_error_after_previous_connection_is_stopped() {
let result = make_connection_error();
let status = decide_status(
- &result, Duration::from_secs(5), STARTUP_GRACE_PERIOD, true,
- CONSECUTIVE_FAILURES_THRESHOLD, CONSECUTIVE_FAILURES_THRESHOLD,
+ &result,
+ Duration::from_secs(5),
+ STARTUP_GRACE_PERIOD,
+ true,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ CONSECUTIVE_FAILURES_THRESHOLD,
RecordingStatus::Recording,
);
assert_eq!(status, RecordingStatus::Stopped);
@@ -140,10 +157,20 @@ fn test_connection_error_after_previous_connection_is_stopped() {
#[test]
fn test_grace_period_boundary() {
let grace = Duration::from_secs(30);
- let status = decide_no_debounce(&make_connection_error(), Duration::from_secs(29), grace, false);
+ let status = decide_no_debounce(
+ &make_connection_error(),
+ Duration::from_secs(29),
+ grace,
+ false,
+ );
assert_eq!(status, RecordingStatus::Starting);
- let status = decide_no_debounce(&make_connection_error(), Duration::from_secs(30), grace, false);
+ let status = decide_no_debounce(
+ &make_connection_error(),
+ Duration::from_secs(30),
+ grace,
+ false,
+ );
assert_eq!(status, RecordingStatus::Stopped);
}
@@ -152,39 +179,67 @@ fn test_grace_period_boundary() {
#[test]
fn test_single_failure_while_recording_holds_recording() {
let status = decide_status(
- &make_connection_error(), Duration::from_secs(60), STARTUP_GRACE_PERIOD,
- true, 1, CONSECUTIVE_FAILURES_THRESHOLD, RecordingStatus::Recording,
+ &make_connection_error(),
+ Duration::from_secs(60),
+ STARTUP_GRACE_PERIOD,
+ true,
+ 1,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ RecordingStatus::Recording,
+ );
+ assert_eq!(
+ status,
+ RecordingStatus::Recording,
+ "single failure while recording should NOT flip to Stopped"
);
- assert_eq!(status, RecordingStatus::Recording,
- "single failure while recording should NOT flip to Stopped");
}
#[test]
fn test_two_failures_while_recording_holds_recording() {
let status = decide_status(
- &make_connection_error(), Duration::from_secs(60), STARTUP_GRACE_PERIOD,
- true, 2, CONSECUTIVE_FAILURES_THRESHOLD, RecordingStatus::Recording,
+ &make_connection_error(),
+ Duration::from_secs(60),
+ STARTUP_GRACE_PERIOD,
+ true,
+ 2,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ RecordingStatus::Recording,
+ );
+ assert_eq!(
+ status,
+ RecordingStatus::Recording,
+ "two failures while recording should NOT flip to Stopped"
);
- assert_eq!(status, RecordingStatus::Recording,
- "two failures while recording should NOT flip to Stopped");
}
#[test]
fn test_threshold_failures_while_recording_transitions_to_stopped() {
let status = decide_status(
- &make_connection_error(), Duration::from_secs(60), STARTUP_GRACE_PERIOD,
- true, CONSECUTIVE_FAILURES_THRESHOLD, CONSECUTIVE_FAILURES_THRESHOLD,
+ &make_connection_error(),
+ Duration::from_secs(60),
+ STARTUP_GRACE_PERIOD,
+ true,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ CONSECUTIVE_FAILURES_THRESHOLD,
RecordingStatus::Recording,
);
- assert_eq!(status, RecordingStatus::Stopped,
- "should transition to Stopped after reaching failure threshold");
+ assert_eq!(
+ status,
+ RecordingStatus::Stopped,
+ "should transition to Stopped after reaching failure threshold"
+ );
}
#[test]
fn test_debounce_does_not_apply_when_not_recording() {
let status = decide_status(
- &make_connection_error(), Duration::from_secs(60), STARTUP_GRACE_PERIOD,
- true, 1, CONSECUTIVE_FAILURES_THRESHOLD, RecordingStatus::Stopped,
+ &make_connection_error(),
+ Duration::from_secs(60),
+ STARTUP_GRACE_PERIOD,
+ true,
+ 1,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ RecordingStatus::Stopped,
);
assert_eq!(status, RecordingStatus::Stopped);
}
@@ -192,8 +247,13 @@ fn test_debounce_does_not_apply_when_not_recording() {
#[test]
fn test_healthy_response_resets_after_failures() {
let status = decide_status(
- &make_healthy_response(), Duration::from_secs(60), STARTUP_GRACE_PERIOD,
- true, 2, CONSECUTIVE_FAILURES_THRESHOLD, RecordingStatus::Recording,
+ &make_healthy_response(),
+ Duration::from_secs(60),
+ STARTUP_GRACE_PERIOD,
+ true,
+ 2,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ RecordingStatus::Recording,
);
assert_eq!(status, RecordingStatus::Recording);
}
@@ -201,11 +261,19 @@ fn test_healthy_response_resets_after_failures() {
#[test]
fn test_unhealthy_response_bypasses_debounce() {
let status = decide_status(
- &make_unhealthy_response(), Duration::from_secs(60), STARTUP_GRACE_PERIOD,
- true, 0, CONSECUTIVE_FAILURES_THRESHOLD, RecordingStatus::Recording,
+ &make_unhealthy_response(),
+ Duration::from_secs(60),
+ STARTUP_GRACE_PERIOD,
+ true,
+ 0,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ RecordingStatus::Recording,
+ );
+ assert_eq!(
+ status,
+ RecordingStatus::Error,
+ "explicit unhealthy should bypass debounce"
);
- assert_eq!(status, RecordingStatus::Error,
- "explicit unhealthy should bypass debounce");
}
#[test]
@@ -216,32 +284,80 @@ fn test_flicker_scenario_simulation() {
let mut consecutive_failures: u32 = 0;
// tick 1: healthy
- current = decide_status(&make_healthy_response(), Duration::from_secs(60), grace, true, 0, threshold, current);
+ current = decide_status(
+ &make_healthy_response(),
+ Duration::from_secs(60),
+ grace,
+ true,
+ 0,
+ threshold,
+ current,
+ );
consecutive_failures = 0;
assert_eq!(current, RecordingStatus::Recording);
// tick 2: timeout (failure 1)
consecutive_failures += 1;
- current = decide_status(&make_connection_error(), Duration::from_secs(61), grace, true, consecutive_failures, threshold, current);
+ current = decide_status(
+ &make_connection_error(),
+ Duration::from_secs(61),
+ grace,
+ true,
+ consecutive_failures,
+ threshold,
+ current,
+ );
assert_eq!(current, RecordingStatus::Recording, "tick 2: should hold");
// tick 3: healthy again
consecutive_failures = 0;
- current = decide_status(&make_healthy_response(), Duration::from_secs(62), grace, true, consecutive_failures, threshold, current);
+ current = decide_status(
+ &make_healthy_response(),
+ Duration::from_secs(62),
+ grace,
+ true,
+ consecutive_failures,
+ threshold,
+ current,
+ );
assert_eq!(current, RecordingStatus::Recording);
// tick 4-5: two more timeouts
consecutive_failures += 1;
- current = decide_status(&make_connection_error(), Duration::from_secs(63), grace, true, consecutive_failures, threshold, current);
+ current = decide_status(
+ &make_connection_error(),
+ Duration::from_secs(63),
+ grace,
+ true,
+ consecutive_failures,
+ threshold,
+ current,
+ );
assert_eq!(current, RecordingStatus::Recording, "tick 4: hold");
consecutive_failures += 1;
- current = decide_status(&make_connection_error(), Duration::from_secs(64), grace, true, consecutive_failures, threshold, current);
+ current = decide_status(
+ &make_connection_error(),
+ Duration::from_secs(64),
+ grace,
+ true,
+ consecutive_failures,
+ threshold,
+ current,
+ );
assert_eq!(current, RecordingStatus::Recording, "tick 5: hold");
// tick 6: healthy
consecutive_failures = 0;
- current = decide_status(&make_healthy_response(), Duration::from_secs(65), grace, true, consecutive_failures, threshold, current);
+ current = decide_status(
+ &make_healthy_response(),
+ Duration::from_secs(65),
+ grace,
+ true,
+ consecutive_failures,
+ threshold,
+ current,
+ );
assert_eq!(current, RecordingStatus::Recording);
// NO flickering through this whole sequence!
}
@@ -254,11 +370,20 @@ fn test_real_crash_still_detected() {
for i in 1..=3 {
current = decide_status(
- &make_connection_error(), Duration::from_secs(59 + i), grace, true,
- i as u32, threshold, current,
+ &make_connection_error(),
+ Duration::from_secs(59 + i),
+ grace,
+ true,
+ i as u32,
+ threshold,
+ current,
);
}
- assert_eq!(current, RecordingStatus::Stopped, "should detect real crash after threshold");
+ assert_eq!(
+ current,
+ RecordingStatus::Stopped,
+ "should detect real crash after threshold"
+ );
}
// ============ icon mapping tests ============
@@ -277,12 +402,16 @@ fn test_recording_shows_healthy_icon() {
#[test]
fn test_stopped_shows_failed_icon() {
- assert!(is_unhealthy_icon(status_to_icon_key(RecordingStatus::Stopped)));
+ assert!(is_unhealthy_icon(status_to_icon_key(
+ RecordingStatus::Stopped
+ )));
}
#[test]
fn test_error_shows_failed_icon() {
- assert!(is_unhealthy_icon(status_to_icon_key(RecordingStatus::Error)));
+ assert!(is_unhealthy_icon(status_to_icon_key(
+ RecordingStatus::Error
+ )));
}
// ============ boot sequence ============
@@ -291,22 +420,41 @@ fn test_error_shows_failed_icon() {
fn test_boot_sequence_no_false_positive() {
let grace = Duration::from_secs(30);
- let s = decide_no_debounce(&make_connection_error(), Duration::from_secs(0), grace, false);
+ let s = decide_no_debounce(
+ &make_connection_error(),
+ Duration::from_secs(0),
+ grace,
+ false,
+ );
assert_eq!(s, RecordingStatus::Starting);
assert!(!is_unhealthy_icon(status_to_icon_key(s)));
- let s = decide_no_debounce(&make_connection_error(), Duration::from_secs(1), grace, false);
+ let s = decide_no_debounce(
+ &make_connection_error(),
+ Duration::from_secs(1),
+ grace,
+ false,
+ );
assert_eq!(s, RecordingStatus::Starting);
- let s = decide_no_debounce(&make_healthy_response(), Duration::from_secs(5), grace, false);
+ let s = decide_no_debounce(
+ &make_healthy_response(),
+ Duration::from_secs(5),
+ grace,
+ false,
+ );
assert_eq!(s, RecordingStatus::Recording);
}
#[test]
fn test_server_crash_after_boot_shows_error() {
let status = decide_status(
- &make_connection_error(), Duration::from_secs(60), Duration::from_secs(30),
- true, CONSECUTIVE_FAILURES_THRESHOLD, CONSECUTIVE_FAILURES_THRESHOLD,
+ &make_connection_error(),
+ Duration::from_secs(60),
+ Duration::from_secs(30),
+ true,
+ CONSECUTIVE_FAILURES_THRESHOLD,
+ CONSECUTIVE_FAILURES_THRESHOLD,
RecordingStatus::Recording,
);
assert_eq!(status, RecordingStatus::Stopped);
@@ -315,7 +463,12 @@ fn test_server_crash_after_boot_shows_error() {
#[test]
fn test_server_never_starts_shows_error_after_grace() {
- let status = decide_no_debounce(&make_connection_error(), Duration::from_secs(35), Duration::from_secs(30), false);
+ let status = decide_no_debounce(
+ &make_connection_error(),
+ Duration::from_secs(35),
+ Duration::from_secs(30),
+ false,
+ );
assert_eq!(status, RecordingStatus::Stopped);
assert!(is_unhealthy_icon(status_to_icon_key(status)));
}
diff --git a/crates/screenpipe-vision/benches/multi_monitor_bench.rs b/crates/screenpipe-vision/benches/multi_monitor_bench.rs
index 8dc9293cd..b2eb24e54 100644
--- a/crates/screenpipe-vision/benches/multi_monitor_bench.rs
+++ b/crates/screenpipe-vision/benches/multi_monitor_bench.rs
@@ -29,11 +29,31 @@ struct MonitorConfig {
}
const MONITORS: &[MonitorConfig] = &[
- MonitorConfig { name: "1080p", width: 1920, height: 1080 },
- MonitorConfig { name: "1440p", width: 2560, height: 1440 },
- MonitorConfig { name: "4K", width: 3840, height: 2160 },
- MonitorConfig { name: "ultrawide_49", width: 5120, height: 1440 },
- MonitorConfig { name: "superwide_38", width: 3840, height: 1440 },
+ MonitorConfig {
+ name: "1080p",
+ width: 1920,
+ height: 1080,
+ },
+ MonitorConfig {
+ name: "1440p",
+ width: 2560,
+ height: 1440,
+ },
+ MonitorConfig {
+ name: "4K",
+ width: 3840,
+ height: 2160,
+ },
+ MonitorConfig {
+ name: "ultrawide_49",
+ width: 5120,
+ height: 1440,
+ },
+ MonitorConfig {
+ name: "superwide_38",
+ width: 3840,
+ height: 1440,
+ },
];
// Realistic multi-monitor setups
@@ -124,17 +144,13 @@ fn bench_hash_full_vs_downscaled(c: &mut Criterion) {
group.throughput(Throughput::Bytes(bytes));
// Current: hash full resolution
- group.bench_with_input(
- BenchmarkId::new("full_res", mon.name),
- &image,
- |b, img| {
- b.iter(|| {
- let mut hasher = DefaultHasher::new();
- black_box(img).as_bytes().hash(&mut hasher);
- hasher.finish()
- });
- },
- );
+ group.bench_with_input(BenchmarkId::new("full_res", mon.name), &image, |b, img| {
+ b.iter(|| {
+ let mut hasher = DefaultHasher::new();
+ black_box(img).as_bytes().hash(&mut hasher);
+ hasher.finish()
+ });
+ });
// Proposed: hash after downscale (factor /4)
let quarter_w = (mon.width / 4).max(1);
@@ -245,9 +261,18 @@ fn bench_detection_accuracy(c: &mut Criterion) {
let changes: Vec<(&str, DynamicImage)> = vec![
("identical", create_code_screen(mon.width, mon.height, 0)),
("tiny_change", create_code_screen(mon.width, mon.height, 1)),
- ("small_change", create_code_screen(mon.width, mon.height, 10)),
- ("large_change", create_code_screen(mon.width, mon.height, 128)),
- ("different_content", create_chart_screen(mon.width, mon.height, 0)),
+ (
+ "small_change",
+ create_code_screen(mon.width, mon.height, 10),
+ ),
+ (
+ "large_change",
+ create_code_screen(mon.width, mon.height, 128),
+ ),
+ (
+ "different_content",
+ create_chart_screen(mon.width, mon.height, 0),
+ ),
];
for (change_name, changed) in &changes {
@@ -314,11 +339,26 @@ fn bench_multi_monitor_pipeline(c: &mut Criterion) {
.map(|&idx| {
let mon = &MONITORS[idx];
vec![
- (create_code_screen(mon.width, mon.height, 0), create_code_screen(mon.width, mon.height, 0)),
- (create_code_screen(mon.width, mon.height, 0), create_code_screen(mon.width, mon.height, 0)),
- (create_code_screen(mon.width, mon.height, 0), create_code_screen(mon.width, mon.height, 0)),
- (create_code_screen(mon.width, mon.height, 10), create_code_screen(mon.width, mon.height, 10)),
- (create_code_screen(mon.width, mon.height, 10), create_code_screen(mon.width, mon.height, 10)),
+ (
+ create_code_screen(mon.width, mon.height, 0),
+ create_code_screen(mon.width, mon.height, 0),
+ ),
+ (
+ create_code_screen(mon.width, mon.height, 0),
+ create_code_screen(mon.width, mon.height, 0),
+ ),
+ (
+ create_code_screen(mon.width, mon.height, 0),
+ create_code_screen(mon.width, mon.height, 0),
+ ),
+ (
+ create_code_screen(mon.width, mon.height, 10),
+ create_code_screen(mon.width, mon.height, 10),
+ ),
+ (
+ create_code_screen(mon.width, mon.height, 10),
+ create_code_screen(mon.width, mon.height, 10),
+ ),
]
})
.collect();
@@ -353,12 +393,14 @@ fn bench_multi_monitor_pipeline(c: &mut Criterion) {
|b, all_frames| {
b.iter(|| {
let mut comparers: Vec<FrameComparer> = (0..all_frames.len())
- .map(|_| FrameComparer::new(FrameComparisonConfig {
- downscale_factor: 0, // Legacy: use fixed 640x360
- comparison_width: 640,
- comparison_height: 360,
- ..Default::default()
- }))
+ .map(|_| {
+ FrameComparer::new(FrameComparisonConfig {
+ downscale_factor: 0, // Legacy: use fixed 640x360
+ comparison_width: 640,
+ comparison_height: 360,
+ ..Default::default()
+ })
+ })
.collect();
let mut total_ops = 0u64;
diff --git a/crates/screenpipe-vision/examples/websocket.rs b/crates/screenpipe-vision/examples/websocket.rs
index 2b7302257..9b79fae48 100644
--- a/crates/screenpipe-vision/examples/websocket.rs
+++ b/crates/screenpipe-vision/examples/websocket.rs
@@ -79,7 +79,9 @@ async fn main() -> Result<()> {
let ws_port = cli.ws_port;
- let monitor = get_default_monitor().await.expect("no monitor found — is screen recording permission granted?");
+ let monitor = get_default_monitor()
+ .await
+ .expect("no monitor found — is screen recording permission granted?");
let id = monitor.id();
let window_filters = Arc::new(WindowFilters::new(
&cli.ignored_windows,
diff --git a/crates/screenpipe-vision/src/apple.rs b/crates/screenpipe-vision/src/apple.rs
index 2b0a67b96..e3ada5fff 100644
--- a/crates/screenpipe-vision/src/apple.rs
+++ b/crates/screenpipe-vision/src/apple.rs
@@ -97,7 +97,10 @@ pub fn perform_ocr_apple(
// Guard against zero-dimension images that would cause CoreVideo errors
if width == 0 || height == 0 {
- error!("Cannot perform OCR on zero-dimension image ({}x{})", width, height);
+ error!(
+ "Cannot perform OCR on zero-dimension image ({}x{})",
+ width, height
+ );
return default_ocr_result;
}
@@ -123,7 +126,10 @@ pub fn perform_ocr_apple(
} {
Ok(buf) => buf,
Err(e) => {
- error!("Failed to create pixel buffer for OCR ({}x{}): {:?}", width, height, e);
+ error!(
+ "Failed to create pixel buffer for OCR ({}x{}): {:?}",
+ width, height, e
+ );
return default_ocr_result;
}
};
@@ -155,8 +161,9 @@ pub fn perform_ocr_apple(
};
let text = observation_result.string();
let confidence = observation_result.confidence() as f64;
- let Ok(bbox_result) = observation_result
- .bounding_box_for_range(ns::Range::new(0, text.len())) else {
+ let Ok(bbox_result) =
+ observation_result.bounding_box_for_range(ns::Range::new(0, text.len()))
+ else {
// Skip bounding box if it fails, still capture the text
overall_confidence += confidence;
ocr_text.push_str(text.to_string().as_str());
diff --git a/crates/screenpipe-vision/src/browser_utils/windows.rs b/crates/screenpipe-vision/src/browser_utils/windows.rs
index c2992a0ae..a54f2fb5c 100644
--- a/crates/screenpipe-vision/src/browser_utils/windows.rs
+++ b/crates/screenpipe-vision/src/browser_utils/windows.rs
@@ -26,9 +26,14 @@ impl WindowsUrlDetector {
}
fn get_active_url_from_window(pid: i32) -> Result<Option<String>> {
- let automation = UIAutomation::new()
- .map_err(|e| anyhow!("Failed to create UIAutomation (COM thread mode conflict?): {}", e))?;
- let root_ele = automation.get_root_element()
+ let automation = UIAutomation::new().map_err(|e| {
+ anyhow!(
+ "Failed to create UIAutomation (COM thread mode conflict?): {}",
+ e
+ )
+ })?;
+ let root_ele = automation
+ .get_root_element()
.map_err(|e| anyhow!("Failed to get root element: {}", e))?;
let condition = automation
.create_property_condition(ProcessId, Variant::from(pid as i32), None)
diff --git a/crates/screenpipe-vision/src/capture_screenshot_by_window.rs b/crates/screenpipe-vision/src/capture_screenshot_by_window.rs
index fc1bcad3e..911aee710 100644
--- a/crates/screenpipe-vision/src/capture_screenshot_by_window.rs
+++ b/crates/screenpipe-vision/src/capture_screenshot_by_window.rs
@@ -514,10 +514,7 @@ fn get_cg_window_list() -> (Vec<CGWindowInfo>, HashSet<u32>) {
};
// Track layers per PID for overlay detection
- pid_layers
- .entry(w_pid as u32)
- .or_default()
- .push(layer);
+ pid_layers.entry(w_pid as u32).or_default().push(layer);
// Extract bounds
let bounds_key = CFString::new("kCGWindowBounds");
@@ -529,8 +526,7 @@ fn get_cg_window_list() -> (Vec<CGWindowInfo>, HashSet<u32>) {
) != 0
&& !bounds_val.is_null()
{
- let bounds_dict =
- bounds_val as core_foundation::dictionary::CFDictionaryRef;
+ let bounds_dict = bounds_val as core_foundation::dictionary::CFDictionaryRef;
let x = get_cf_number_from_dict(bounds_dict, "X").unwrap_or(0.0);
let y = get_cf_number_from_dict(bounds_dict, "Y").unwrap_or(0.0);
let w = get_cf_number_from_dict(bounds_dict, "Width").unwrap_or(0.0);
@@ -1294,11 +1290,7 @@ mod tests {
#[test]
fn test_is_valid_rejects_ignored_by_app_name() {
- let filters = WindowFilters::new(
- &["wispr flow".to_string()],
- &[],
- &[],
- );
+ let filters = WindowFilters::new(&["wispr flow".to_string()], &[], &[]);
// "Wispr Flow" app should be rejected by ignore list (case-insensitive contains)
assert!(!filters.is_valid("Wispr Flow", "Status"));
assert!(!filters.is_valid("Wispr Flow", "Hub"));
@@ -1308,11 +1300,7 @@ mod tests {
#[test]
fn test_is_valid_rejects_ignored_by_window_title() {
- let filters = WindowFilters::new(
- &["status".to_string()],
- &[],
- &[],
- );
+ let filters = WindowFilters::new(&["status".to_string()], &[], &[]);
// Window title matching ignore list should be rejected
assert!(!filters.is_valid("Wispr Flow", "Status"));
assert!(!filters.is_valid("Any App", "Status Bar"));
@@ -1323,11 +1311,7 @@ mod tests {
#[test]
fn test_is_valid_overlay_apps_in_ignore_list() {
// Typical user config: ignoring overlay apps by name
- let filters = WindowFilters::new(
- &["wispr".to_string(), "bartender".to_string()],
- &[],
- &[],
- );
+ let filters = WindowFilters::new(&["wispr".to_string(), "bartender".to_string()], &[], &[]);
assert!(!filters.is_valid("Wispr Flow", "Status"));
assert!(!filters.is_valid("Bartender 4", "Menu"));
assert!(filters.is_valid("Arc", "Gmail"));
@@ -1335,11 +1319,7 @@ mod tests {
#[test]
fn test_is_valid_include_list_only_allows_matching() {
- let filters = WindowFilters::new(
- &[],
- &["arc".to_string(), "wezterm".to_string()],
- &[],
- );
+ let filters = WindowFilters::new(&[], &["arc".to_string(), "wezterm".to_string()], &[]);
// Only included apps should pass
assert!(filters.is_valid("Arc", "GitHub"));
assert!(filters.is_valid("WezTerm", "Terminal"));
@@ -1370,38 +1350,88 @@ mod tests {
#[test]
fn test_rect_overlaps_basic() {
- let a = Rect { x: 0, y: 0, width: 100, height: 100 };
- let b = Rect { x: 50, y: 50, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
+ let b = Rect {
+ x: 50,
+ y: 50,
+ width: 100,
+ height: 100,
+ };
assert!(a.overlaps(&b));
assert!(b.overlaps(&a));
}
#[test]
fn test_rect_no_overlap_right() {
- let a = Rect { x: 0, y: 0, width: 100, height: 100 };
- let b = Rect { x: 100, y: 0, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
+ let b = Rect {
+ x: 100,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
// Touching edges — no overlap (right edge of a == left edge of b)
assert!(!a.overlaps(&b));
}
#[test]
fn test_rect_no_overlap_below() {
- let a = Rect { x: 0, y: 0, width: 100, height: 100 };
- let b = Rect { x: 0, y: 100, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
+ let b = Rect {
+ x: 0,
+ y: 100,
+ width: 100,
+ height: 100,
+ };
assert!(!a.overlaps(&b));
}
#[test]
fn test_rect_no_overlap_far_away() {
- let a = Rect { x: 0, y: 0, width: 100, height: 100 };
- let b = Rect { x: 500, y: 500, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
+ let b = Rect {
+ x: 500,
+ y: 500,
+ width: 100,
+ height: 100,
+ };
assert!(!a.overlaps(&b));
}
#[test]
fn test_rect_contained() {
- let outer = Rect { x: 0, y: 0, width: 1920, height: 1080 };
- let inner = Rect { x: 100, y: 100, width: 400, height: 300 };
+ let outer = Rect {
+ x: 0,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let inner = Rect {
+ x: 100,
+ y: 100,
+ width: 400,
+ height: 300,
+ };
assert!(outer.overlaps(&inner));
assert!(inner.overlaps(&outer));
}
@@ -1409,47 +1439,112 @@ mod tests {
#[test]
fn test_rect_negative_coordinates() {
// macOS: secondary monitor can be at negative x (left of primary)
- let monitor = Rect { x: -1920, y: 0, width: 1920, height: 1080 };
- let window = Rect { x: -1000, y: 200, width: 800, height: 600 };
+ let monitor = Rect {
+ x: -1920,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let window = Rect {
+ x: -1000,
+ y: 200,
+ width: 800,
+ height: 600,
+ };
assert!(monitor.overlaps(&window));
}
#[test]
fn test_rect_window_spans_two_monitors() {
- let monitor1 = Rect { x: 0, y: 0, width: 1920, height: 1080 };
- let monitor2 = Rect { x: 1920, y: 0, width: 1920, height: 1080 };
+ let monitor1 = Rect {
+ x: 0,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let monitor2 = Rect {
+ x: 1920,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
// Window straddles the boundary
- let window = Rect { x: 1800, y: 100, width: 400, height: 600 };
+ let window = Rect {
+ x: 1800,
+ y: 100,
+ width: 400,
+ height: 600,
+ };
assert!(monitor1.overlaps(&window));
assert!(monitor2.overlaps(&window));
}
#[test]
fn test_rect_intersection_area() {
- let a = Rect { x: 0, y: 0, width: 100, height: 100 };
- let b = Rect { x: 50, y: 50, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
+ let b = Rect {
+ x: 50,
+ y: 50,
+ width: 100,
+ height: 100,
+ };
// Intersection: (50,50) to (100,100) = 50*50 = 2500
assert_eq!(a.intersection_area(&b), 2500);
}
#[test]
fn test_rect_intersection_area_no_overlap() {
- let a = Rect { x: 0, y: 0, width: 100, height: 100 };
- let b = Rect { x: 200, y: 200, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
+ let b = Rect {
+ x: 200,
+ y: 200,
+ width: 100,
+ height: 100,
+ };
assert_eq!(a.intersection_area(&b), 0);
}
#[test]
fn test_rect_intersection_area_contained() {
- let outer = Rect { x: 0, y: 0, width: 1920, height: 1080 };
- let inner = Rect { x: 100, y: 100, width: 400, height: 300 };
+ let outer = Rect {
+ x: 0,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let inner = Rect {
+ x: 100,
+ y: 100,
+ width: 400,
+ height: 300,
+ };
assert_eq!(outer.intersection_area(&inner), 400 * 300);
}
#[test]
fn test_rect_zero_dimension() {
- let a = Rect { x: 0, y: 0, width: 0, height: 100 };
- let b = Rect { x: 0, y: 0, width: 100, height: 100 };
+ let a = Rect {
+ x: 0,
+ y: 0,
+ width: 0,
+ height: 100,
+ };
+ let b = Rect {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ };
assert!(!a.overlaps(&b));
assert_eq!(a.intersection_area(&b), 0);
}
@@ -1462,26 +1557,55 @@ mod tests {
mod topmost_tests {
use super::*;
- fn make_window(pid: i32, layer: i32, x: i32, y: i32, w: u32, h: u32, owner: &str, title: &str) -> CGWindowInfo {
+ fn make_window(
+ pid: i32,
+ layer: i32,
+ x: i32,
+ y: i32,
+ w: u32,
+ h: u32,
+ owner: &str,
+ title: &str,
+ ) -> CGWindowInfo {
CGWindowInfo {
pid,
layer,
- bounds: Rect { x, y, width: w, height: h },
+ bounds: Rect {
+ x,
+ y,
+ width: w,
+ height: h,
+ },
owner_name: owner.to_string(),
window_name: title.to_string(),
}
}
fn monitor_1080p() -> Rect {
- Rect { x: 0, y: 0, width: 1920, height: 1080 }
+ Rect {
+ x: 0,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ }
}
#[test]
fn test_topmost_simple_single_window() {
- let windows = vec![
- make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
- ];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ let windows = vec![make_window(
+ 100,
+ 0,
+ 0,
+ 0,
+ 1920,
+ 1080,
+ "WezTerm",
+ "π - brain",
+ )];
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
@@ -1491,7 +1615,10 @@ mod tests {
make_window(200, 25, 0, 0, 300, 40, "Wispr Flow", "Status"),
make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
@@ -1500,7 +1627,10 @@ mod tests {
make_window(1, 0, 0, 0, 1920, 25, "SystemUIServer", "Menu Bar"),
make_window(100, 0, 0, 25, 1920, 1055, "WezTerm", "π - brain"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
@@ -1509,16 +1639,31 @@ mod tests {
make_window(999, 0, 0, 0, 1920, 1080, "screenpipe", "Main"),
make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
fn test_topmost_skips_screenpipe_dev() {
let windows = vec![
- make_window(999, 0, 0, 0, 1920, 1080, "screenpipe - Development", "Overlay"),
+ make_window(
+ 999,
+ 0,
+ 0,
+ 0,
+ 1920,
+ 1080,
+ "screenpipe - Development",
+ "Overlay",
+ ),
make_window(100, 0, 0, 0, 1920, 1080, "Arc", "GitHub"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
@@ -1528,14 +1673,27 @@ mod tests {
make_window(300, 0, 100, 0, 50, 50, "SomeApp", "StatusIcon"),
make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
fn test_topmost_multi_monitor_different_windows() {
// Monitor 1: primary at (0,0), Monitor 2: right at (1920,0)
- let monitor1 = Rect { x: 0, y: 0, width: 1920, height: 1080 };
- let monitor2 = Rect { x: 1920, y: 0, width: 1920, height: 1080 };
+ let monitor1 = Rect {
+ x: 0,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let monitor2 = Rect {
+ x: 1920,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
let windows = vec![
// Arc is on monitor 2
@@ -1557,7 +1715,10 @@ mod tests {
make_window(200, 0, 0, 0, 1920, 1080, "Arc", "PostHog"),
];
// WezTerm should be detected, NOT Arc
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
@@ -1568,7 +1729,10 @@ mod tests {
make_window(300, 0, 200, 200, 800, 600, "Finder", "Downloads"),
];
// WezTerm should be detected, NOT Finder
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
@@ -1579,16 +1743,31 @@ mod tests {
make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
];
// Both are WezTerm (same PID), first match wins
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
#[test]
fn test_topmost_no_windows_on_monitor() {
// All windows are on a different monitor
- let monitor_left = Rect { x: -1920, y: 0, width: 1920, height: 1080 };
- let windows = vec![
- make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
- ];
+ let monitor_left = Rect {
+ x: -1920,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let windows = vec![make_window(
+ 100,
+ 0,
+ 0,
+ 0,
+ 1920,
+ 1080,
+ "WezTerm",
+ "π - brain",
+ )];
assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_left), None);
}
@@ -1604,28 +1783,47 @@ mod tests {
make_window(300, 3, 0, 0, 1920, 25, "SystemUIServer", "Menu Bar"),
];
// All are overlay-level, no normal window
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), None);
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ None
+ );
}
#[test]
fn test_topmost_monitor_with_negative_coords() {
// Secondary monitor to the left of primary
- let monitor_left = Rect { x: -1920, y: 0, width: 1920, height: 1080 };
+ let monitor_left = Rect {
+ x: -1920,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
let windows = vec![
make_window(100, 0, -1920, 0, 1920, 1080, "Firefox", "Google"),
make_window(200, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_left), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_left),
+ Some(100)
+ );
}
#[test]
fn test_topmost_window_partially_on_monitor() {
// Window straddles two monitors — should match on both
- let monitor1 = Rect { x: 0, y: 0, width: 1920, height: 1080 };
- let monitor2 = Rect { x: 1920, y: 0, width: 1920, height: 1080 };
- let windows = vec![
- make_window(100, 0, 1800, 100, 400, 600, "Arc", "Tab"),
- ];
+ let monitor1 = Rect {
+ x: 0,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let monitor2 = Rect {
+ x: 1920,
+ y: 0,
+ width: 1920,
+ height: 1080,
+ };
+ let windows = vec![make_window(100, 0, 1800, 100, 400, 600, "Arc", "Tab")];
assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor1), Some(100));
assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor2), Some(100));
}
@@ -1637,7 +1835,10 @@ mod tests {
make_window(300, 0, 0, 0, 1920, 1080, "Finder", "Desktop"),
make_window(100, 0, 0, 0, 1920, 1080, "WezTerm", "π - brain"),
];
- assert_eq!(find_topmost_pid_on_monitor(&windows, &monitor_1080p()), Some(100));
+ assert_eq!(
+ find_topmost_pid_on_monitor(&windows, &monitor_1080p()),
+ Some(100)
+ );
}
}
}
diff --git a/crates/screenpipe-vision/src/core.rs b/crates/screenpipe-vision/src/core.rs
index b362e1658..aff6dbc79 100644
--- a/crates/screenpipe-vision/src/core.rs
+++ b/crates/screenpipe-vision/src/core.rs
@@ -310,11 +310,8 @@ pub async fn continuous_capture(
// 4b. Capture windows only for frames that passed the change threshold.
// This avoids expensive per-window screenshots + CGWindowList enumeration
// on unchanged frames (major CPU savings on multi-monitor setups).
- let window_images = capture_windows(
- &monitor,
- &window_filters,
- capture_unfocused_windows,
- ).await;
+ let window_images =
+ capture_windows(&monitor, &window_filters, capture_unfocused_windows).await;
// Track the frame with maximum difference for OCR processing
if current_diff > max_avg_value {
diff --git a/crates/screenpipe-vision/src/frame_comparison.rs b/crates/screenpipe-vision/src/frame_comparison.rs
index 60d032ca2..ea740c333 100644
--- a/crates/screenpipe-vision/src/frame_comparison.rs
+++ b/crates/screenpipe-vision/src/frame_comparison.rs
@@ -192,7 +192,10 @@ impl FrameComparer {
};
// First frame - no previous to compare
- if self.previous_hash.is_none() && self.previous_image_downscaled.is_none() && self.previous_image_full.is_none() {
+ if self.previous_hash.is_none()
+ && self.previous_image_downscaled.is_none()
+ && self.previous_image_full.is_none()
+ {
self.update_previous_internal(current_image, current_downscaled, current_hash);
return 1.0;
}
@@ -264,7 +267,8 @@ impl FrameComparer {
self.previous_hash = hash;
if self.config.downscale_comparison {
- self.previous_image_downscaled = downscaled.or_else(|| Some(self.downscale(full_image)));
+ self.previous_image_downscaled =
+ downscaled.or_else(|| Some(self.downscale(full_image)));
self.previous_image_full = None;
} else {
self.previous_image_full = Some(full_image.clone());
@@ -375,7 +379,11 @@ mod tests {
if is_text_line {
let char_width = 10;
let is_char = ((x + seed as u32) / char_width) % 3 != 0;
- if is_char { Rgb([30, 30, 30]) } else { Rgb([255, 255, 255]) }
+ if is_char {
+ Rgb([30, 30, 30])
+ } else {
+ Rgb([255, 255, 255])
+ }
} else {
Rgb([255, 255, 255])
}
@@ -496,7 +504,11 @@ mod tests {
comparer.compare(&image1);
let diff = comparer.compare(&image2);
- assert!(diff > 0.01, "Ultrawide content change should be detected: {}", diff);
+ assert!(
+ diff > 0.01,
+ "Ultrawide content change should be detected: {}",
+ diff
+ );
}
#[test]
@@ -526,23 +538,25 @@ mod tests {
let frame1 = create_text_pattern_image(1920, 1080, 0);
let frame2 = create_text_pattern_image(1920, 1080, 0); // identical
let frame3 = create_text_pattern_image(1920, 1080, 0); // identical
- let frame4 = create_gradient_image(1920, 1080); // different
+ let frame4 = create_gradient_image(1920, 1080); // different
let frame5 = create_solid_image(1920, 1080, 128, 128, 128); // different
let frame6 = create_solid_image(1920, 1080, 128, 128, 128); // identical
- let frame7 = create_solid_image(1920, 1080, 0, 0, 0); // different
-
- let results: Vec<f64> = [&frame1, &frame2, &frame3, &frame4, &frame5, &frame6, &frame7]
- .iter()
- .map(|f| comparer.compare(f))
- .collect();
-
- assert_eq!(results[0], 1.0); // first frame
- assert_eq!(results[1], 0.0); // hash hit
- assert_eq!(results[2], 0.0); // hash hit
- assert!(results[3] > 0.0); // different
- assert!(results[4] > 0.0); // different
- assert_eq!(results[5], 0.0); // hash hit
- assert!(results[6] > 0.3); // big change
+ let frame7 = create_solid_image(1920, 1080, 0, 0, 0); // different
+
+ let results: Vec<f64> = [
+ &frame1, &frame2, &frame3, &frame4, &frame5, &frame6, &frame7,
+ ]
+ .iter()
+ .map(|f| comparer.compare(f))
+ .collect();
+
+ assert_eq!(results[0], 1.0); // first frame
+ assert_eq!(results[1], 0.0); // hash hit
+ assert_eq!(results[2], 0.0); // hash hit
+ assert!(results[3] > 0.0); // different
+ assert!(results[4] > 0.0); // different
+ assert_eq!(results[5], 0.0); // hash hit
+ assert!(results[6] > 0.3); // big change
assert!(comparer.stats().hash_hits >= 3);
}
diff --git a/crates/screenpipe-vision/src/monitor.rs b/crates/screenpipe-vision/src/monitor.rs
index 031d12a37..42d9ce90f 100644
--- a/crates/screenpipe-vision/src/monitor.rs
+++ b/crates/screenpipe-vision/src/monitor.rs
@@ -190,7 +190,10 @@ impl SafeMonitor {
let monitor = match cached_sck {
Some(m) => m,
None => {
- tracing::debug!("sck-rs cache miss for monitor {}, re-enumerating", monitor_id);
+ tracing::debug!(
+ "sck-rs cache miss for monitor {}, re-enumerating",
+ monitor_id
+ );
SckMonitor::all()
.map_err(Error::from)?
.into_iter()
@@ -212,7 +215,10 @@ impl SafeMonitor {
let monitor = match cached_xcap {
Some(m) => m,
None => {
- tracing::debug!("xcap cache miss for monitor {}, re-enumerating", monitor_id);
+ tracing::debug!(
+ "xcap cache miss for monitor {}, re-enumerating",
+ monitor_id
+ );
XcapMonitor::all()
.map_err(Error::from)?
.into_iter()
@@ -273,41 +279,47 @@ impl SafeMonitor {
let monitor_id = self.monitor_id;
let use_sck = self.use_sck;
- let refreshed = tokio::task::spawn_blocking(move || -> Result<(Option<SckMonitor>, Option<XcapMonitor>, MonitorData)> {
- if use_sck {
- let monitor = SckMonitor::all()
- .map_err(Error::from)?
- .into_iter()
- .find(|m| m.id() == monitor_id)
- .ok_or_else(|| anyhow::anyhow!("Monitor {} not found during refresh", monitor_id))?;
-
- let data = MonitorData {
- width: monitor.width().unwrap_or(0),
- height: monitor.height().unwrap_or(0),
- x: monitor.x(),
- y: monitor.y(),
- name: monitor.name().to_string(),
- is_primary: monitor.is_primary(),
- };
- Ok((Some(monitor), None, data))
- } else {
- let monitor = XcapMonitor::all()
- .map_err(Error::from)?
- .into_iter()
- .find(|m| m.id().unwrap_or(0) == monitor_id)
- .ok_or_else(|| anyhow::anyhow!("Monitor {} not found during refresh", monitor_id))?;
-
- let data = MonitorData {
- width: monitor.width().unwrap_or(0),
- height: monitor.height().unwrap_or(0),
- x: monitor.x().unwrap_or(0),
- y: monitor.y().unwrap_or(0),
- name: monitor.name().unwrap_or_default().to_string(),
- is_primary: monitor.is_primary().unwrap_or(false),
- };
- Ok((None, Some(monitor), data))
- }
- })
+ let refreshed = tokio::task::spawn_blocking(
+ move || -> Result<(Option<SckMonitor>, Option<XcapMonitor>, MonitorData)> {
+ if use_sck {
+ let monitor = SckMonitor::all()
+ .map_err(Error::from)?
+ .into_iter()
+ .find(|m| m.id() == monitor_id)
+ .ok_or_else(|| {
+ anyhow::anyhow!("Monitor {} not found during refresh", monitor_id)
+ })?;
+
+ let data = MonitorData {
+ width: monitor.width().unwrap_or(0),
+ height: monitor.height().unwrap_or(0),
+ x: monitor.x(),
+ y: monitor.y(),
+ name: monitor.name().to_string(),
+ is_primary: monitor.is_primary(),
+ };
+ Ok((Some(monitor), None, data))
+ } else {
+ let monitor = XcapMonitor::all()
+ .map_err(Error::from)?
+ .into_iter()
+ .find(|m| m.id().unwrap_or(0) == monitor_id)
+ .ok_or_else(|| {
+ anyhow::anyhow!("Monitor {} not found during refresh", monitor_id)
+ })?;
+
+ let data = MonitorData {
+ width: monitor.width().unwrap_or(0),
+ height: monitor.height().unwrap_or(0),
+ x: monitor.x().unwrap_or(0),
+ y: monitor.y().unwrap_or(0),
+ name: monitor.name().unwrap_or_default().to_string(),
+ is_primary: monitor.is_primary().unwrap_or(false),
+ };
+ Ok((None, Some(monitor), data))
+ }
+ },
+ )
.await
.map_err(|e| anyhow::anyhow!("refresh task panicked: {}", e))??;
@@ -329,7 +341,9 @@ impl SafeMonitor {
.map_err(Error::from)?
.into_iter()
.find(|m| m.id().unwrap_or(0) == monitor_id)
- .ok_or_else(|| anyhow::anyhow!("Monitor {} not found during refresh", monitor_id))?;
+ .ok_or_else(|| {
+ anyhow::anyhow!("Monitor {} not found during refresh", monitor_id)
+ })?;
Ok(MonitorData {
width: monitor.width().unwrap_or(0),
@@ -430,12 +444,10 @@ pub async fn list_monitors_detailed() -> std::result::Result<Vec<SafeMonitor>, M
/// List monitors with detailed error information (permission denied vs no monitors)
#[cfg(not(target_os = "macos"))]
pub async fn list_monitors_detailed() -> std::result::Result<Vec<SafeMonitor>, MonitorListError> {
- tokio::task::spawn_blocking(|| {
- match XcapMonitor::all() {
- Ok(monitors) if monitors.is_empty() => Err(MonitorListError::NoMonitorsFound),
- Ok(monitors) => Ok(monitors.into_iter().map(SafeMonitor::new).collect()),
- Err(e) => Err(MonitorListError::Other(e.to_string())),
- }
+ tokio::task::spawn_blocking(|| match XcapMonitor::all() {
+ Ok(monitors) if monitors.is_empty() => Err(MonitorListError::NoMonitorsFound),
+ Ok(monitors) => Ok(monitors.into_iter().map(SafeMonitor::new).collect()),
+ Err(e) => Err(MonitorListError::Other(e.to_string())),
})
.await
.unwrap_or(Err(MonitorListError::Other("Task panicked".to_string())))
@@ -457,9 +469,17 @@ pub async fn list_monitors() -> Vec<SafeMonitor> {
pub async fn get_default_monitor() -> Option<SafeMonitor> {
tokio::task::spawn_blocking(|| {
if use_sck_rs() {
- SckMonitor::all().ok()?.into_iter().next().map(SafeMonitor::from_sck)
+ SckMonitor::all()
+ .ok()?
+ .into_iter()
+ .next()
+ .map(SafeMonitor::from_sck)
} else {
- XcapMonitor::all().ok()?.into_iter().next().map(SafeMonitor::from_xcap)
+ XcapMonitor::all()
+ .ok()?
+ .into_iter()
+ .next()
+ .map(SafeMonitor::from_xcap)
}
})
.await
@@ -469,7 +489,11 @@ pub async fn get_default_monitor() -> Option<SafeMonitor> {
#[cfg(not(target_os = "macos"))]
pub async fn get_default_monitor() -> Option<SafeMonitor> {
tokio::task::spawn_blocking(|| {
- XcapMonitor::all().ok()?.into_iter().next().map(SafeMonitor::new)
+ XcapMonitor::all()
+ .ok()?
+ .into_iter()
+ .next()
+ .map(SafeMonitor::new)
})
.await
.ok()?
diff --git a/crates/screenpipe-vision/tests/capture_retry_test.rs b/crates/screenpipe-vision/tests/capture_retry_test.rs
index 53b253ef0..5ba6bc45e 100644
--- a/crates/screenpipe-vision/tests/capture_retry_test.rs
+++ b/crates/screenpipe-vision/tests/capture_retry_test.rs
@@ -9,7 +9,6 @@
///
/// We replicate the exact control flow here with a mock capture function
/// to verify every branch.
-
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
@@ -148,7 +147,10 @@ fn test_success_on_last_retry() {
attempts_used: MAX_CAPTURE_RETRIES + 1
}
);
- assert_eq!(consecutive, 0, "consecutive must reset even on last-retry success");
+ assert_eq!(
+ consecutive, 0,
+ "consecutive must reset even on last-retry success"
+ );
assert_eq!(
refresh_count.load(Ordering::SeqCst),
MAX_CAPTURE_RETRIES,
@@ -403,7 +405,9 @@ fn test_intermittent_failure_never_bails() {
CycleOutcome::Success { .. } => {
assert_eq!(consecutive, 0);
}
- CycleOutcome::RetryExhausted { consecutive_failures } => {
+ CycleOutcome::RetryExhausted {
+ consecutive_failures,
+ } => {
assert!(
consecutive_failures < MAX_CONSECUTIVE_FAILURES,
"consecutive failures should stay low with intermittent success"
diff --git a/crates/screenpipe-vision/tests/monitor_cache_test.rs b/crates/screenpipe-vision/tests/monitor_cache_test.rs
index 00862247e..2740613e6 100644
--- a/crates/screenpipe-vision/tests/monitor_cache_test.rs
+++ b/crates/screenpipe-vision/tests/monitor_cache_test.rs
@@ -8,11 +8,9 @@
/// tokio blocking thread pool instead of creating a new OS thread per frame.
///
/// These tests verify the structural properties. Actual capture requires a real display.
-
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
-
/// Simulate the OLD behavior: enumerate all monitors and find by ID every frame.
/// Returns the number of enumerations performed.
fn old_capture_pattern(monitor_id: u32, frame_count: u32, enumerate_counter: &AtomicU32) {