Skip to content

A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.

feat(dock): add AI usage island and minimize options

CristianOlivera1d54048c0c440
diff --git a/Cargo.lock b/Cargo.lock
index 29edeee..4bf2eb6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8,6 +8,41 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+[[package]]
+name = "aead"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
+dependencies = [
+ "crypto-common",
+ "generic-array",
+]
+
+[[package]]
+name = "aes"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures 0.2.17",
+]
+
+[[package]]
+name = "aes-gcm"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
+dependencies = [
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ghash",
+ "subtle",
+]
+
[[package]]
name = "aho-corasick"
version = "1.1.5"
@@ -213,12 +248,41 @@ version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+[[package]]
+name = "aws-lc-rs"
+version = "1.18.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "faac5829c2b74c28f830747e7818ccfb684261b5f48a1118b1e2a13d36dfab13"
+dependencies = [
+ "aws-lc-sys",
+ "zeroize",
+]
+
+[[package]]
+name = "aws-lc-sys"
+version = "0.46.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1622d8446a2d4b2ce0c7eefc73dd43a99779028d5ee5c2dd8073a658ba8a2bc"
+dependencies = [
+ "cc",
+ "cmake",
+ "dunce",
+ "fs_extra",
+ "pkg-config",
+]
+
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
[[package]]
name = "base64"
version = "0.23.1"
@@ -433,6 +497,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
dependencies = [
"find-msvc-tools",
+ "jobserver",
+ "libc",
"shlex",
]
@@ -475,6 +541,17 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
+[[package]]
+name = "chacha20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "chrono"
version = "0.4.45"
@@ -487,6 +564,25 @@ dependencies = [
"windows-link",
]
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common",
+ "inout",
+]
+
+[[package]]
+name = "cmake"
+version = "0.1.58"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "combine"
version = "4.6.9"
@@ -584,6 +680,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "cpufeatures"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "crc32fast"
version = "1.5.5"
@@ -615,6 +720,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [
"generic-array",
+ "rand_core 0.6.4",
"typenum",
]
@@ -660,6 +766,15 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"
+[[package]]
+name = "ctr"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "darling"
version = "0.24.1"
@@ -820,7 +935,7 @@ checksum = "fac5fca71e65e94cc718a6e2af65d6e0f9c6027751c2aa562fbb5087fda639bc"
dependencies = [
"bit-set 0.8.0",
"cssparser 0.37.0",
- "foldhash",
+ "foldhash 0.2.0",
"html5ever 0.39.0",
"precomputed-hash",
"selectors 0.38.0",
@@ -835,7 +950,7 @@ checksum = "498c698ac51127148a3984450e51fca7f01805a91d7a1f7a24af0a5f761e3385"
dependencies = [
"bit-set 0.11.1",
"cssparser 0.38.0",
- "foldhash",
+ "foldhash 0.2.0",
"html5ever 0.40.1",
"precomputed-hash",
"selectors 0.41.0",
@@ -972,6 +1087,18 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "fallible-iterator"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
+
+[[package]]
+name = "fallible-streaming-iterator"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
+
[[package]]
name = "fastrand"
version = "2.5.0"
@@ -1030,6 +1157,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+[[package]]
+name = "foldhash"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+
[[package]]
name = "foldhash"
version = "0.2.0"
@@ -1072,6 +1205,12 @@ dependencies = [
"percent-encoding",
]
+[[package]]
+name = "fs_extra"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
+
[[package]]
name = "futures-channel"
version = "0.3.34"
@@ -1079,6 +1218,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
dependencies = [
"futures-core",
+ "futures-sink",
]
[[package]]
@@ -1272,8 +1412,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
dependencies = [
"cfg-if",
+ "js-sys",
"libc",
"wasi",
+ "wasm-bindgen",
]
[[package]]
@@ -1298,9 +1440,20 @@ dependencies = [
"js-sys",
"libc",
"r-efi 6.0.0",
+ "rand_core 0.10.1",
"wasm-bindgen",
]
+[[package]]
+name = "ghash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"
+dependencies = [
+ "opaque-debug",
+ "polyval",
+]
+
[[package]]
name = "gio"
version = "0.18.4"
@@ -1455,12 +1608,30 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "foldhash 0.1.5",
+]
+
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
+[[package]]
+name = "hashlink"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
+dependencies = [
+ "hashbrown 0.15.5",
+]
+
[[package]]
name = "heck"
version = "0.4.1"
@@ -1781,6 +1952,15 @@ dependencies = [
"cfb",
]
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "generic-array",
+]
+
[[package]]
name = "ipnet"
version = "2.12.2"
@@ -1942,6 +2122,16 @@ dependencies = [
"syn 2.0.119",
]
+[[package]]
+name = "jobserver"
+version = "0.1.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"
+dependencies = [
+ "getrandom 0.4.3",
+ "libc",
+]
+
[[package]]
name = "js-sys"
version = "0.3.107"
@@ -2043,6 +2233,17 @@ dependencies = [
"libc",
]
+[[package]]
+name = "libsqlite3-sys"
+version = "0.35.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f"
+dependencies = [
+ "cc",
+ "pkg-config",
+ "vcpkg",
+]
+
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
@@ -2070,6 +2271,12 @@ version = "0.4.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
+[[package]]
+name = "lru-slab"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"
+
[[package]]
name = "markup5ever"
version = "0.39.0"
@@ -2175,10 +2382,18 @@ dependencies = [
name = "muelle"
version = "0.1.5"
dependencies = [
+ "aes-gcm",
"anyhow",
+ "base64 0.22.1",
+ "chrono",
"muelle-config",
"muelle-core",
"muelle-shell",
+ "png",
+ "reqwest",
+ "rusqlite",
+ "serde",
+ "serde_json",
"windows",
"windows-core",
"windows-numerics",
@@ -2521,6 +2736,12 @@ version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+[[package]]
+name = "opaque-debug"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
+
[[package]]
name = "openssl-probe"
version = "0.2.2"
@@ -2786,6 +3007,18 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "polyval"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.2.17",
+ "opaque-debug",
+ "universal-hash",
+]
+
[[package]]
name = "portable-atomic"
version = "1.15.0"
@@ -2893,6 +3126,63 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "quinn"
+version = "0.11.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11"
+dependencies = [
+ "bytes",
+ "cfg_aliases",
+ "pin-project-lite",
+ "quinn-proto",
+ "quinn-udp",
+ "rustc-hash",
+ "rustls",
+ "socket2",
+ "thiserror 2.0.21",
+ "tokio",
+ "tracing",
+ "web-time",
+]
+
+[[package]]
+name = "quinn-proto"
+version = "0.11.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe"
+dependencies = [
+ "aws-lc-rs",
+ "bytes",
+ "getrandom 0.4.3",
+ "lru-slab",
+ "rand",
+ "rand_pcg",
+ "ring",
+ "rustc-hash",
+ "rustls",
+ "rustls-pki-types",
+ "slab",
+ "thiserror 2.0.21",
+ "tinyvec",
+ "tracing",
+ "web-time",
+]
+
+[[package]]
+name = "quinn-udp"
+version = "0.5.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016"
+dependencies = [
+ "cfg_aliases",
+ "libc",
+ "once_cell",
+ "socket2",
+ "tracing",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "quote"
version = "1.0.47"
@@ -2914,6 +3204,41 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+[[package]]
+name = "rand"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
+dependencies = [
+ "chacha20",
+ "getrandom 0.4.3",
+ "rand_core 0.10.1",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom 0.2.17",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
+
+[[package]]
+name = "rand_pcg"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"
+dependencies = [
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "raw-window-handle"
version = "0.6.2"
@@ -2996,6 +3321,7 @@ checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029"
dependencies = [
"base64 0.23.1",
"bytes",
+ "futures-channel",
"futures-core",
"futures-util",
"http",
@@ -3008,6 +3334,7 @@ dependencies = [
"log",
"percent-encoding",
"pin-project-lite",
+ "quinn",
"rustls",
"rustls-pki-types",
"rustls-platform-verifier",
@@ -3041,6 +3368,20 @@ dependencies = [
"windows-sys 0.52.0",
]
+[[package]]
+name = "rusqlite"
+version = "0.37.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f"
+dependencies = [
+ "bitflags 2.13.2",
+ "fallible-iterator",
+ "fallible-streaming-iterator",
+ "hashlink",
+ "libsqlite3-sys",
+ "smallvec",
+]
+
[[package]]
name = "rustc-hash"
version = "2.1.3"
@@ -3075,6 +3416,7 @@ version = "0.23.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
dependencies = [
+ "aws-lc-rs",
"once_cell",
"ring",
"rustls-pki-types",
@@ -3101,6 +3443,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
dependencies = [
+ "web-time",
"zeroize",
]
@@ -3137,6 +3480,7 @@ version = "0.103.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5"
dependencies = [
+ "aws-lc-rs",
"ring",
"rustls-pki-types",
"untrusted",
@@ -3467,7 +3811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest",
]
@@ -4497,6 +4841,16 @@ version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
+[[package]]
+name = "universal-hash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"
+dependencies = [
+ "crypto-common",
+ "subtle",
+]
+
[[package]]
name = "untrusted"
version = "0.9.0"
@@ -4555,6 +4909,12 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
[[package]]
name = "version-compare"
version = "0.2.1"
diff --git a/apps/dock/Cargo.toml b/apps/dock/Cargo.toml
index fbf797b..4b66ade 100644
--- a/apps/dock/Cargo.toml
+++ b/apps/dock/Cargo.toml
@@ -12,9 +12,17 @@ winresource = "0.1"
[dependencies]
anyhow.workspace = true
+aes-gcm = "0.10"
+base64 = "0.22"
+chrono = { version = "0.4", default-features = false, features = ["clock", "std", "serde"] }
muelle-config.workspace = true
muelle-core.workspace = true
muelle-shell.workspace = true
+png = "0.18"
+reqwest = { version = "0.13", default-features = false, features = ["blocking", "rustls", "system-proxy"] }
+rusqlite = { version = "0.37", features = ["bundled"] }
+serde.workspace = true
+serde_json = "1"
windows-core.workspace = true
windows-numerics.workspace = true
windows = { workspace = true, features = [
@@ -36,7 +44,10 @@ windows = { workspace = true, features = [
"Win32_Graphics_Dxgi_Common",
"Win32_Graphics_Gdi",
"Win32_Security",
+ "Win32_Security_Credentials",
+ "Win32_Security_Cryptography",
"Win32_System_Com",
+ "Win32_System_Diagnostics_ToolHelp",
"Win32_System_Console",
"Win32_System_LibraryLoader",
"Win32_System_Threading",
diff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rs
index 52765e9..ced8ab7 100644
--- a/apps/dock/src/app.rs
+++ b/apps/dock/src/app.rs
@@ -22,7 +22,7 @@ use std::{
};
use anyhow::{Context, Result};
-use muelle_config::{ActiveAppClick, Config};
+use muelle_config::Config;
use muelle_core::{
bounce,
layout::{ItemKind, Layout, Metrics, layout},
@@ -549,11 +549,15 @@ impl App {
);
}
entries.push(separator());
- entries.extend(
- self.minimized
- .iter()
- .map(|&hwnd| icon(&window_id(hwnd), Role::Window, false)),
- );
+ // Unless "show minimized windows" is on, minimized windows hide in
+ // their app's icon instead of getting a thumbnail here.
+ if self.config.show_minimized {
+ entries.extend(
+ self.minimized
+ .iter()
+ .map(|&hwnd| icon(&window_id(hwnd), Role::Window, false)),
+ );
+ }
if let Some(downloads) = &self.downloads {
entries.push(icon(downloads, Role::Folder, false));
}
@@ -885,11 +889,21 @@ impl App {
Ok(())
}
- /// Screen rectangle of a minimized window's slot, at rest, with the
- /// window's aspect ratio.
+ /// Screen rectangle, at rest and with the window's aspect ratio, where a
+ /// minimized window lives in the dock: its app's icon, or its own
+ /// thumbnail slot with "show minimized windows". The genie flies into it
+ /// and back out of it.
fn minimized_slot(&self, hwnd: isize, aspect: f32) -> Option<RECT> {
let stage = self.stage.as_ref()?;
- let id = window_id(hwnd);
+ let id = if !self.config.show_minimized {
+ self.windows
+ .iter()
+ .find(|window| window.hwnd == hwnd)?
+ .app_id
+ .clone()
+ } else {
+ window_id(hwnd)
+ };
let index = self
.entries
.iter()
@@ -922,12 +936,23 @@ impl App {
// the stand-in goes up before anything else, or the desktop shows.
self.show_stand_ins(&[hwnd]);
self.minimized.push(hwnd);
- self.thumbnails.sync(&self.minimized);
+ self.sync_thumbnails();
self.refresh()?;
self.aim_flights();
Ok(())
}
+ /// Live thumbnails exist only for minimized windows shown in the dock:
+ /// none while they hide in their app's icon, so DWM draws nothing extra.
+ fn sync_thumbnails(&mut self) {
+ let shown: &[isize] = if self.config.show_minimized {
+ &self.minimized
+ } else {
+ &[]
+ };
+ self.thumbnails.sync(shown);
+ }
+
/// Turns off the system's transitions for every tracked window. Windows
/// starts its own minimize animation before the dock hears about the
/// minimize, and it cannot be cancelled afterwards, so it has to be off in
@@ -1000,6 +1025,9 @@ impl App {
let Some(flight) = flight else {
return false;
};
+ if !self.config.show_minimized {
+ flight.tuck_under(self.visual);
+ }
self.snapshots.remove(position);
self.flights.push(flight);
self.last_frame = Instant::now();
@@ -1023,6 +1051,9 @@ impl App {
for (index, slot) in slots {
if let (Some(slot), Some(flight)) = (slot, self.flights.get_mut(index)) {
flight.aim(&self.gfx, slot);
+ if !self.config.show_minimized {
+ flight.tuck_under(self.visual);
+ }
}
}
}
@@ -1433,10 +1464,7 @@ impl App {
Some(Outside::Open(id))
}
Role::App if windows.contains(&tracker::foreground_window()) => {
- match self.config.active_app_click {
- ActiveAppClick::Minimize => Some(Outside::Minimize(windows)),
- ActiveAppClick::Nothing => None,
- }
+ Some(Outside::Minimize(windows))
}
Role::App => self.activating(windows),
Role::Start => Some(Outside::OpenStart),
@@ -1647,6 +1675,7 @@ impl App {
self.last_frame = Instant::now();
}
self.config = config;
+ self.sync_thumbnails();
self.apply_menu_bar_setting();
self.update_menu_bar_app()?;
self.calm_windows();
@@ -1734,7 +1763,7 @@ impl App {
self.minimized.push(hwnd);
}
}
- self.thumbnails.sync(&self.minimized);
+ self.sync_thumbnails();
let minimized = &self.minimized;
self.snapshots.retain(|(hwnd, _)| minimized.contains(hwnd));
@@ -1813,13 +1842,14 @@ impl App {
if !self.config.menu_bar {
self.menubar = None;
} else if self.menubar.is_none() {
- self.menubar = MenuBar::create(&self.gfx)
+ self.menubar = MenuBar::create(&self.gfx, self.config.ai_usage)
.inspect_err(|error| eprintln!("muelle: barra superior: {error:#}"))
.ok();
}
if let Some(bar) = &mut self.menubar {
let applied = bar
.set_auto_hide(self.config.menu_bar_auto_hide)
+ .and_then(|()| bar.set_usage_enabled(&self.gfx, self.config.ai_usage))
.and_then(|()| bar.set_visible(!self.fullscreen));
if let Err(error) = applied {
eprintln!("muelle: barra superior: {error:#}");
@@ -1955,10 +1985,10 @@ fn with_app_value<T: Default>(what: &str, action: impl FnOnce(&mut App) -> Resul
value
}
-pub fn menu_bar_clicked(x: f32) {
+pub fn menu_bar_clicked(x: f32, y: f32) {
with_app("barra superior", |app| {
- if let Some(bar) = &app.menubar {
- bar.click(x);
+ if let Some(bar) = &mut app.menubar {
+ bar.click(&app.gfx, x, y)?;
}
Ok(())
});
@@ -1966,7 +1996,7 @@ pub fn menu_bar_clicked(x: f32) {
pub fn menu_bar_hover(inside: bool) {
with_app("barra superior", |app| match &mut app.menubar {
- Some(bar) => bar.hover(inside),
+ Some(bar) => bar.hover(&app.gfx, inside),
None => Ok(()),
});
}
diff --git a/apps/dock/src/flight.rs b/apps/dock/src/flight.rs
index bf15a30..42b28ac 100644
--- a/apps/dock/src/flight.rs
+++ b/apps/dock/src/flight.rs
@@ -659,6 +659,20 @@ impl Flight {
let _ = clip_at_slot(gfx, &self.root, &self.genie, self.screen);
}
+ /// Puts the flight right under `dock` in the z-order, so a window flying
+ /// into (or out of) an app icon passes behind the dock's glass instead
+ /// of over it. The stand-in window stays just under the strips.
+ pub fn tuck_under(&self, dock: HWND) {
+ let flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE;
+ // SAFETY: Reorders our own live windows; nothing else changes.
+ unsafe {
+ let _ = SetWindowPos(self.overlay, Some(dock), 0, 0, 0, 0, flags);
+ if let Some(stand) = self.stand {
+ let _ = SetWindowPos(stand, Some(self.overlay), 0, 0, 0, 0, flags);
+ }
+ }
+ }
+
#[must_use]
pub fn needs_aim(&self) -> bool {
!self.aimed
diff --git a/apps/dock/src/gfx.rs b/apps/dock/src/gfx.rs
index acf9173..fb4b9e3 100644
--- a/apps/dock/src/gfx.rs
+++ b/apps/dock/src/gfx.rs
@@ -6,17 +6,21 @@ use muelle_shell::icons::IconImage;
use windows::{
Foundation::Size,
Graphics::DirectX::{DirectXAlphaMode, DirectXPixelFormat},
- UI::Composition::{
- CompositionDrawingSurface, CompositionGraphicsDevice, CompositionSurfaceBrush, Compositor,
+ UI::{
+ Color,
+ Composition::{
+ CompositionDrawingSurface, CompositionGraphicsDevice, CompositionSurfaceBrush,
+ Compositor,
+ },
},
Win32::{
Foundation::{HMODULE, POINT},
Graphics::{
Direct2D::{
Common::{
- D2D_RECT_F, D2D_SIZE_U, D2D1_ALPHA_MODE_PREMULTIPLIED, D2D1_COLOR_F,
- D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, D2D1_GRADIENT_STOP,
- D2D1_PIXEL_FORMAT,
+ D2D_RECT_F, D2D_SIZE_U, D2D1_ALPHA_MODE_PREMULTIPLIED, D2D1_BEZIER_SEGMENT,
+ D2D1_COLOR_F, D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED,
+ D2D1_GRADIENT_STOP, D2D1_PIXEL_FORMAT,
},
D2D1_BITMAP_OPTIONS_NONE, D2D1_BITMAP_PROPERTIES1,
D2D1_BUFFER_PRECISION_8BPC_UNORM, D2D1_COLOR_INTERPOLATION_MODE_PREMULTIPLIED,
@@ -197,6 +201,159 @@ impl Gfx {
})
}
+ /// Opaque island silhouette with curved shoulders at the screen edge.
+ pub fn island_mask(
+ &self,
+ width: f32,
+ height: f32,
+ scale: f32,
+ ) -> Result<CompositionSurfaceBrush> {
+ self.draw(width.ceil() as u32, height.ceil() as u32, |dc| {
+ let shoulder = 12.0 * scale;
+ let corner = 22.0 * scale;
+ // SAFETY: The geometry, sink and brush stay alive through the drawing calls.
+ unsafe {
+ let shape = dc.GetFactory()?.CreatePathGeometry()?;
+ let sink = shape.Open()?;
+ sink.BeginFigure(Vector2 { X: 0.0, Y: 0.0 }, D2D1_FIGURE_BEGIN_FILLED);
+ sink.AddLine(Vector2 { X: width, Y: 0.0 });
+ sink.AddBezier(&D2D1_BEZIER_SEGMENT {
+ point1: Vector2 {
+ X: width - shoulder,
+ Y: 0.0,
+ },
+ point2: Vector2 {
+ X: width - shoulder,
+ Y: shoulder * 0.7,
+ },
+ point3: Vector2 {
+ X: width - shoulder,
+ Y: shoulder,
+ },
+ });
+ sink.AddLine(Vector2 {
+ X: width - shoulder,
+ Y: height - corner,
+ });
+ sink.AddBezier(&D2D1_BEZIER_SEGMENT {
+ point1: Vector2 {
+ X: width - shoulder,
+ Y: height - corner * 0.35,
+ },
+ point2: Vector2 {
+ X: width - shoulder - corner * 0.35,
+ Y: height,
+ },
+ point3: Vector2 {
+ X: width - shoulder - corner,
+ Y: height,
+ },
+ });
+ sink.AddLine(Vector2 {
+ X: shoulder + corner,
+ Y: height,
+ });
+ sink.AddBezier(&D2D1_BEZIER_SEGMENT {
+ point1: Vector2 {
+ X: shoulder + corner * 0.35,
+ Y: height,
+ },
+ point2: Vector2 {
+ X: shoulder,
+ Y: height - corner * 0.35,
+ },
+ point3: Vector2 {
+ X: shoulder,
+ Y: height - corner,
+ },
+ });
+ sink.AddLine(Vector2 {
+ X: shoulder,
+ Y: shoulder,
+ });
+ sink.AddBezier(&D2D1_BEZIER_SEGMENT {
+ point1: Vector2 {
+ X: shoulder,
+ Y: shoulder * 0.7,
+ },
+ point2: Vector2 {
+ X: shoulder,
+ Y: 0.0,
+ },
+ point3: Vector2 { X: 0.0, Y: 0.0 },
+ });
+ sink.EndFigure(D2D1_FIGURE_END_CLOSED);
+ sink.Close()?;
+ let white = dc.CreateSolidColorBrush(&WHITE, None)?;
+ dc.FillGeometry(&shape, &white, None);
+ }
+ Ok(())
+ })
+ }
+
+ pub fn usage_ring(
+ &self,
+ used_percent: Option<u8>,
+ scale: f32,
+ accent: Color,
+ ) -> Result<LabelBrush> {
+ let side = (18.0 * scale).round();
+ let center = side / 2.0;
+ let radius = center - 2.0 * scale;
+ let stroke = (2.4 * scale).max(1.0);
+ let brush = self.draw(side as u32, side as u32, |dc| {
+ // SAFETY: Brushes remain alive for the drawing calls.
+ unsafe {
+ let track = dc.CreateSolidColorBrush(&rgb(0.53, 0.56, 0.6, 0.4), None)?;
+ dc.DrawEllipse(
+ &D2D1_ELLIPSE {
+ point: Vector2 {
+ X: center,
+ Y: center,
+ },
+ radiusX: radius,
+ radiusY: radius,
+ },
+ &track,
+ stroke,
+ None,
+ );
+ if let Some(percent) = used_percent {
+ let foreground = dc.CreateSolidColorBrush(
+ &rgb(
+ f32::from(accent.R) / 255.0,
+ f32::from(accent.G) / 255.0,
+ f32::from(accent.B) / 255.0,
+ 1.0,
+ ),
+ None,
+ )?;
+ let steps = usize::from(percent) * 36 / 100;
+ for index in 0..steps {
+ let start = -std::f32::consts::FRAC_PI_2
+ + index as f32 * std::f32::consts::TAU / 36.0;
+ let end = start + std::f32::consts::TAU / 36.0;
+ let a = Vector2 {
+ X: center + radius * start.cos(),
+ Y: center + radius * start.sin(),
+ };
+ let b = Vector2 {
+ X: center + radius * end.cos(),
+ Y: center + radius * end.sin(),
+ };
+ dc.DrawLine(a, b, &foreground, stroke, None);
+ }
+ }
+ }
+ Ok(())
+ })?;
+ Ok(LabelBrush {
+ brush,
+ width: side,
+ height: side,
+ })
+ }
+
/// Creates an app-name label: a dark pill (light in light theme) with a
/// downward-pointing arrow.
pub fn label_brush(&self, text: &str, scale: f32, light: bool) -> Result<LabelBrush> {
@@ -374,6 +531,18 @@ impl Gfx {
/// Plain text on a transparent background (menu bar).
pub fn text_brush(&self, text: &str, scale: f32, bold: bool, ink: Ink) -> Result<LabelBrush> {
+ self.text_brush_sized(text, scale, 13.0, bold, ink)
+ }
+
+ /// Text at a chosen logical font size for the expanded usage panel.
+ pub fn text_brush_sized(
+ &self,
+ text: &str,
+ scale: f32,
+ font_size: f32,
+ bold: bool,
+ ink: Ink,
+ ) -> Result<LabelBrush> {
let utf16: Vec<u16> = text.encode_utf16().collect();
let weight = if bold {
DWRITE_FONT_WEIGHT_SEMI_BOLD
@@ -388,7 +557,7 @@ impl Gfx {
weight,
DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL,
- 13.0 * scale,
+ font_size * scale,
w!(""),
)?;
let layout = self
diff --git a/apps/dock/src/main.rs b/apps/dock/src/main.rs
index 741b663..fe2ff9d 100644
--- a/apps/dock/src/main.rs
+++ b/apps/dock/src/main.rs
@@ -6,6 +6,7 @@
//! - `muelle --restore` restores the Windows taskbar
//! - `muelle --autostart on|off` enables or disables startup with Windows
//! - `muelle --guard <pid>` internal watchdog process
+//! - `muelle --usage-worker` internal one-shot quota reader
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
@@ -19,6 +20,7 @@ mod menubar;
mod scene;
mod strings;
mod thumbnails;
+mod usage;
use std::env;
@@ -63,6 +65,7 @@ fn main() -> Result<()> {
}
["--autostart", "off"] => Ok(autostart::set(None)?),
[guard::FLAG, pid] => guard::run(pid.parse().context("pid no válido")?),
+ ["--usage-worker"] => usage::worker_main(),
_ => bail!("uso: muelle [--quit | --restore | --autostart on|off]"),
}
}
diff --git a/apps/dock/src/menubar.rs b/apps/dock/src/menubar.rs
index 97ca44c..5fffad2 100644
--- a/apps/dock/src/menubar.rs
+++ b/apps/dock/src/menubar.rs
@@ -23,14 +23,17 @@ use muelle_shell::{
status::{self, AudioWatch, Network, NetworkWatch, TaskbarButtons, Volume},
system::{self, Battery, Monitor},
};
-use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::atomic::{AtomicBool, AtomicI32, Ordering};
use windows::{
UI::{
Color,
- Composition::{ContainerVisual, Desktop::DesktopWindowTarget, SpriteVisual},
+ Composition::{
+ CompositionBrush, Compositor, ContainerVisual, Desktop::DesktopWindowTarget,
+ SpriteVisual, VisualCollection,
+ },
},
Win32::{
- Foundation::{HWND, LPARAM, LRESULT, RECT, SYSTEMTIME, WPARAM},
+ Foundation::{HWND, LPARAM, LRESULT, POINT, RECT, SYSTEMTIME, WPARAM},
Graphics::Dwm::{DWMWA_USE_HOSTBACKDROPBRUSH, DwmSetWindowAttribute},
System::{
LibraryLoader::GetModuleHandleW, SystemInformation::GetLocalTime,
@@ -38,11 +41,11 @@ use windows::{
},
UI::Input::KeyboardAndMouse::{TME_LEAVE, TRACKMOUSEEVENT, TrackMouseEvent},
UI::WindowsAndMessaging::{
- CreateWindowExW, DefWindowProcW, DestroyWindow, HWND_TOPMOST, IDC_ARROW, LoadCursorW,
- PostMessageW, RegisterClassW, SWP_HIDEWINDOW, SWP_NOACTIVATE, SWP_SHOWWINDOW, SetTimer,
- SetWindowPos, WM_APP, WM_LBUTTONUP, WM_MOUSEMOVE, WM_SETTINGCHANGE, WM_TIMER,
- WNDCLASSW, WS_EX_NOACTIVATE, WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW,
- WS_EX_TOPMOST, WS_POPUP,
+ CreateWindowExW, DefWindowProcW, DestroyWindow, GetCursorPos, HWND_TOPMOST, IDC_ARROW,
+ IDC_HAND, LoadCursorW, PostMessageW, RegisterClassW, SWP_HIDEWINDOW, SWP_NOACTIVATE,
+ SWP_SHOWWINDOW, SetCursor, SetTimer, SetWindowPos, WM_APP, WM_LBUTTONUP, WM_MOUSEMOVE,
+ WM_NCHITTEST, WM_SETCURSOR, WM_SETTINGCHANGE, WM_TIMER, WNDCLASSW, WS_EX_NOACTIVATE,
+ WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW, WS_EX_TOPMOST, WS_POPUP,
},
},
core::{BOOL, Interface, w},
@@ -52,6 +55,10 @@ use windows_numerics::{Vector2, Vector3};
use crate::{
app,
gfx::{Gfx, Ink, LabelBrush},
+ strings,
+ usage::{
+ self, ActiveProviders, Monitor as UsageMonitor, Provider, ProviderUsage, Snapshot, State,
+ },
};
// Logical pixels.
@@ -65,6 +72,10 @@ const HIT_SLOP: f32 = 7.0;
const REVEAL_STRIP: i32 = 2;
const CLOCK_TIMER: usize = 1;
+const ISLAND_SINGLE_WIDTH: f32 = 145.0;
+const ISLAND_EXPANDED_WIDTH: f32 = 440.0;
+const ISLAND_ROW_HEIGHT: f32 = 118.0;
+const ISLAND_CARD_HEIGHT: f32 = 108.0;
const WM_POWERBROADCAST: u32 = 0x0218;
const WM_MOUSELEAVE: u32 = 0x02A3;
/// AppBar notifications need a message id; the bar ignores them.
@@ -73,11 +84,18 @@ const APPBAR_CALLBACK: u32 = WM_APP + 20;
const STATUS_CHANGED: u32 = WM_APP + 21;
/// Posted by the bar to itself to update from the message loop.
const TICK: u32 = WM_APP + 22;
+const USAGE_CHANGED: u32 = WM_APP + 23;
/// `wParam` of WM_SETTINGCHANGE when the work area changes, which every
/// AppBar reservation (the dock's, this bar's) causes.
const SPI_SETWORKAREA: usize = 0x002F;
/// A `TICK` is already posted.
static TICK_PENDING: AtomicBool = AtomicBool::new(false);
+static ISLAND_LEFT: AtomicI32 = AtomicI32::new(0);
+static ISLAND_RIGHT: AtomicI32 = AtomicI32::new(0);
+static BAR_TOP: AtomicI32 = AtomicI32::new(0);
+static BAR_BOTTOM: AtomicI32 = AtomicI32::new(0);
+static HEADER_BOTTOM: AtomicI32 = AtomicI32::new(0);
+static PANEL_BOTTOM: AtomicI32 = AtomicI32::new(0);
/// Segoe Fluent Icons code points.
mod glyph {
@@ -122,6 +140,11 @@ struct Look {
clock: String,
battery: Option<Battery>,
status: Status,
+ usage: Snapshot,
+ usage_enabled: bool,
+ active_providers: ActiveProviders,
+ expanded: bool,
+ usage_refreshing: bool,
}
pub struct MenuBar {
@@ -140,6 +163,12 @@ pub struct MenuBar {
root: Option<ContainerVisual>,
bounds: RECT,
status: Status,
+ usage: Option<UsageMonitor>,
+ expanded: bool,
+ visual_height: i32,
+ island_left: f32,
+ island_right: f32,
+ refresh_button: Option<(f32, f32, f32, f32)>,
/// Held for their callbacks; dropping them unsubscribes.
_network: Option<NetworkWatch>,
audio: Option<AudioWatch>,
@@ -149,10 +178,41 @@ unsafe extern "system" fn bar_proc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) -
match msg {
WM_LBUTTONUP => {
let x = (l.0 & 0xFFFF) as i16;
- app::menu_bar_clicked(f32::from(x));
+ let y = (l.0 >> 16) as i16;
+ app::menu_bar_clicked(f32::from(x), f32::from(y));
}
WM_MOUSEMOVE => app::menu_bar_hover(true),
WM_MOUSELEAVE => app::menu_bar_hover(false),
+ WM_SETCURSOR => {
+ let mut point = POINT::default();
+ // SAFETY: The point is a valid output for the current pointer location.
+ if unsafe { GetCursorPos(&mut point) }.is_ok()
+ && point.x >= ISLAND_LEFT.load(Ordering::Relaxed)
+ && point.x < ISLAND_RIGHT.load(Ordering::Relaxed)
+ && point.y >= BAR_TOP.load(Ordering::Relaxed)
+ && point.y < HEADER_BOTTOM.load(Ordering::Relaxed)
+ {
+ // SAFETY: The stock hand cursor is owned by Windows.
+ if let Ok(hand) = unsafe { LoadCursorW(None, IDC_HAND) } {
+ unsafe { SetCursor(Some(hand)) };
+ return LRESULT(1);
+ }
+ }
+ return unsafe { DefWindowProcW(hwnd, msg, w, l) };
+ }
+ WM_NCHITTEST => {
+ let x = (l.0 & 0xFFFF) as i16 as i32;
+ let y = (l.0 >> 16) as i16 as i32;
+ if y >= BAR_BOTTOM.load(Ordering::Relaxed)
+ && y < PANEL_BOTTOM.load(Ordering::Relaxed)
+ && (x < ISLAND_LEFT.load(Ordering::Relaxed)
+ || x >= ISLAND_RIGHT.load(Ordering::Relaxed))
+ {
+ return LRESULT(-1);
+ }
+ // SAFETY: Default hit testing for the bar and the island.
+ return unsafe { DefWindowProcW(hwnd, msg, w, l) };
+ }
// The minute changed, the charger was plugged or unplugged, the
// network or volume changed, or a Windows setting (taskbar buttons).
// Nothing the bar shows depends on the work area.
@@ -160,7 +220,7 @@ unsafe extern "system" fn bar_proc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) -
// Some of these are sent while the dock is busy reserving space, and
// updating then was dropped. From the message loop the dock is never
// busy, and a burst of them makes a single update.
- WM_TIMER | WM_POWERBROADCAST | STATUS_CHANGED | WM_SETTINGCHANGE => {
+ WM_TIMER | WM_POWERBROADCAST | STATUS_CHANGED | USAGE_CHANGED | WM_SETTINGCHANGE => {
if !TICK_PENDING.swap(true, Ordering::Relaxed) {
// SAFETY: Posting to our own live window.
unsafe {
@@ -187,8 +247,417 @@ fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color {
}
}
+fn add_visual(
+ compositor: &Compositor,
+ layers: &VisualCollection,
+ brush: &CompositionBrush,
+ x: f32,
+ y: f32,
+ width: f32,
+ height: f32,
+) -> Result<SpriteVisual> {
+ let visual = compositor.CreateSpriteVisual()?;
+ visual.SetSize(Vector2 {
+ X: width,
+ Y: height,
+ })?;
+ visual.SetOffset(Vector3 {
+ X: x.round(),
+ Y: y.round(),
+ Z: 0.0,
+ })?;
+ visual.SetBrush(brush)?;
+ layers.InsertAtTop(&visual)?;
+ Ok(visual)
+}
+
+#[expect(
+ clippy::too_many_arguments,
+ reason = "A rounded shape needs its rectangle, radius and two colors"
+)]
+fn add_rounded_box(
+ compositor: &Compositor,
+ layers: &VisualCollection,
+ x: f32,
+ y: f32,
+ width: f32,
+ height: f32,
+ radius: f32,
+ fill: Color,
+ border: Option<Color>,
+) -> Result<()> {
+ let geometry = compositor.CreateRoundedRectangleGeometry()?;
+ let inset = if border.is_some() { 0.5 } else { 0.0 };
+ geometry.SetOffset(Vector2 { X: inset, Y: inset })?;
+ geometry.SetSize(Vector2 {
+ X: (width - inset * 2.0).max(0.0),
+ Y: (height - inset * 2.0).max(0.0),
+ })?;
+ geometry.SetCornerRadius(Vector2 {
+ X: radius.min(width / 2.0),
+ Y: radius.min(height / 2.0),
+ })?;
+ let shape = compositor.CreateSpriteShapeWithGeometry(&geometry)?;
+ shape.SetFillBrush(&compositor.CreateColorBrushWithColor(fill)?)?;
+ if let Some(border) = border {
+ shape.SetStrokeBrush(&compositor.CreateColorBrushWithColor(border)?)?;
+ shape.SetStrokeThickness(1.0)?;
+ }
+ let visual = compositor.CreateShapeVisual()?;
+ visual.SetSize(Vector2 {
+ X: width,
+ Y: height,
+ })?;
+ visual.SetOffset(Vector3 {
+ X: x.round(),
+ Y: y.round(),
+ Z: 0.0,
+ })?;
+ visual.Shapes()?.Append(&shape)?;
+ layers.InsertAtTop(&visual)?;
+ Ok(())
+}
+
+#[expect(
+ clippy::too_many_arguments,
+ reason = "Typography and placement are chosen together for panel labels"
+)]
+fn add_panel_text(
+ gfx: &Gfx,
+ layers: &VisualCollection,
+ value: &str,
+ x: f32,
+ y: f32,
+ scale: f32,
+ font_size: f32,
+ bold: bool,
+ ink: Ink,
+ opacity: f32,
+) -> Result<LabelBrush> {
+ let label = gfx.text_brush_sized(value, scale, font_size, bold, ink)?;
+ add_visual(
+ &gfx.compositor,
+ layers,
+ &label.brush.cast()?,
+ x,
+ y,
+ label.width,
+ label.height,
+ )?
+ .SetOpacity(opacity)?;
+ Ok(label)
+}
+
+#[expect(
+ clippy::too_many_arguments,
+ reason = "Right-aligned panel labels choose typography and placement together"
+)]
+fn add_panel_text_right(
+ gfx: &Gfx,
+ layers: &VisualCollection,
+ value: &str,
+ right: f32,
+ y: f32,
+ scale: f32,
+ font_size: f32,
+ bold: bool,
+ ink: Ink,
+ opacity: f32,
+) -> Result<LabelBrush> {
+ let label = gfx.text_brush_sized(value, scale, font_size, bold, ink)?;
+ add_visual(
+ &gfx.compositor,
+ layers,
+ &label.brush.cast()?,
+ right - label.width,
+ y,
+ label.width,
+ label.height,
+ )?
+ .SetOpacity(opacity)?;
+ Ok(label)
+}
+
+#[expect(
+ clippy::too_many_arguments,
+ reason = "Each provider card draws its own colors, data and measured rectangle"
+)]
+fn draw_usage_card(
+ gfx: &Gfx,
+ layers: &VisualCollection,
+ provider: Provider,
+ usage: &ProviderUsage,
+ accent: Color,
+ scale: f32,
+ light: bool,
+ island_width: f32,
+ y: f32,
+) -> Result<()> {
+ let c = &gfx.compositor;
+ let px = |logical: f32| (logical * scale).round();
+ let ink = if light { Ink::Dark } else { Ink::Light };
+ let text = strings::text();
+ let left = px(23.0);
+ let width = island_width - px(46.0);
+ let right = left + width;
+ let card_fill = if light {
+ rgba(32, 52, 77, 13)
+ } else {
+ rgba(237, 244, 255, 16)
+ };
+ let card_border = if light {
+ rgba(41, 59, 82, 26)
+ } else {
+ rgba(222, 234, 251, 31)
+ };
+ add_rounded_box(
+ c,
+ layers,
+ left,
+ y,
+ width,
+ px(ISLAND_CARD_HEIGHT),
+ px(13.0),
+ card_fill,
+ Some(card_border),
+ )?;
+ add_rounded_box(
+ c,
+ layers,
+ left + px(12.0),
+ y + px(11.0),
+ px(32.0),
+ px(32.0),
+ px(10.0),
+ rgba(accent.R, accent.G, accent.B, if light { 31 } else { 41 }),
+ None,
+ )?;
+ if let Some(image) = usage::logo(provider) {
+ let icon_size = px(20.0) as u32;
+ let image_brush = gfx.icon_brush(image, icon_size)?;
+ let brush: CompositionBrush =
+ if !matches!(provider, Provider::Claude | Provider::Gemini) && light {
+ let tinted = c.CreateMaskBrush()?;
+ tinted.SetMask(&image_brush)?;
+ tinted.SetSource(&c.CreateColorBrushWithColor(rgba(27, 34, 45, 255))?)?;
+ tinted.cast()?
+ } else {
+ image_brush.cast()?
+ };
+ add_visual(
+ c,
+ layers,
+ &brush,
+ left + px(18.0),
+ y + px(17.0),
+ icon_size as f32,
+ icon_size as f32,
+ )?;
+ }
+ add_panel_text(
+ gfx,
+ layers,
+ provider.name(),
+ left + px(53.0),
+ y + px(10.0),
+ scale,
+ 14.0,
+ true,
+ ink,
+ 1.0,
+ )?;
+ if let Some(main) = usage.main_window() {
+ add_panel_text(
+ gfx,
+ layers,
+ &main.title(),
+ left + px(53.0),
+ y + px(30.0),
+ scale,
+ 11.5,
+ false,
+ ink,
+ 0.72,
+ )?;
+ add_panel_text_right(
+ gfx,
+ layers,
+ &format!("{}%", main.used_percent),
+ right - px(14.0),
+ y + px(6.0),
+ scale,
+ 20.0,
+ true,
+ ink,
+ 1.0,
+ )?;
+ add_panel_text_right(
+ gfx,
+ layers,
+ text.usage_used,
+ right - px(15.0),
+ y + px(31.0),
+ scale,
+ 11.0,
+ false,
+ ink,
+ 0.7,
+ )?;
+ let track_left = left + px(14.0);
+ let track_width = width - px(28.0);
+ let track_y = y + px(53.0);
+ add_rounded_box(
+ c,
+ layers,
+ track_left,
+ track_y,
+ track_width,
+ px(6.0),
+ px(3.0),
+ if light {
+ rgba(54, 73, 95, 43)
+ } else {
+ rgba(224, 235, 248, 48)
+ },
+ None,
+ )?;
+ let fill = track_width * f32::from(main.used_percent) / 100.0;
+ if fill > 0.0 {
+ add_rounded_box(
+ c,
+ layers,
+ track_left,
+ track_y,
+ fill,
+ px(6.0),
+ px(3.0),
+ accent,
+ None,
+ )?;
+ }
+ if let Some(reset) = main.reset_text() {
+ add_panel_text_right(
+ gfx,
+ layers,
+ &format!("{} {reset}", text.usage_resets),
+ right - px(14.0),
+ y + px(64.0),
+ scale,
+ 11.0,
+ false,
+ ink,
+ 0.78,
+ )?;
+ }
+ if usage.state == State::Unavailable
+ || usage.age_minutes().is_some_and(|minutes| minutes > 5)
+ {
+ add_panel_text(
+ gfx,
+ layers,
+ text.usage_stale,
+ left + px(14.0),
+ y + px(64.0),
+ scale,
+ 11.0,
+ false,
+ ink,
+ 0.7,
+ )?;
+ }
+ if let Some(secondary) = usage.windows.get(1) {
+ add_visual(
+ c,
+ layers,
+ &c.CreateColorBrushWithColor(if light {
+ rgba(50, 68, 88, 24)
+ } else {
+ rgba(228, 236, 247, 29)
+ })?
+ .cast()?,
+ left + px(14.0),
+ y + px(83.0),
+ width - px(28.0),
+ px(1.0),
+ )?;
+ add_panel_text(
+ gfx,
+ layers,
+ &format!("{} · {}%", secondary.title(), secondary.used_percent),
+ left + px(14.0),
+ y + px(87.0),
+ scale,
+ 11.5,
+ true,
+ ink,
+ 0.94,
+ )?;
+ if let Some(reset) = secondary.reset_text() {
+ add_panel_text_right(
+ gfx,
+ layers,
+ &format!("{} {reset}", text.usage_resets),
+ right - px(14.0),
+ y + px(87.0),
+ scale,
+ 11.5,
+ false,
+ ink,
+ 0.76,
+ )?;
+ }
+ }
+ } else {
+ let message = match usage.state {
+ State::Loading => text.usage_loading,
+ State::SignIn => text.usage_sign_in,
+ State::Ready | State::Unavailable => text.usage_unavailable,
+ };
+ add_panel_text(
+ gfx,
+ layers,
+ message,
+ left + px(53.0),
+ y + px(43.0),
+ scale,
+ 12.0,
+ false,
+ ink,
+ 0.72,
+ )?;
+ }
+ Ok(())
+}
+
+#[expect(
+ clippy::too_many_arguments,
+ reason = "Text placement needs its coordinates and typography at the call site"
+)]
+fn add_text(
+ gfx: &Gfx,
+ layers: &VisualCollection,
+ value: &str,
+ x: f32,
+ y: f32,
+ scale: f32,
+ bold: bool,
+ ink: Ink,
+) -> Result<LabelBrush> {
+ let label = gfx.text_brush(value, scale, bold, ink)?;
+ add_visual(
+ &gfx.compositor,
+ layers,
+ &label.brush.cast()?,
+ x,
+ y,
+ label.width,
+ label.height,
+ )?;
+ Ok(label)
+}
+
impl MenuBar {
- pub fn create(gfx: &Gfx) -> Result<Self> {
+ pub fn create(gfx: &Gfx, usage_enabled: bool) -> Result<Self> {
let class = w!("MuelleMenuBar");
// SAFETY: Standard class registration and window creation on the UI
// thread; the window is destroyed in `Drop`.
@@ -249,6 +718,12 @@ impl MenuBar {
volume: None,
buttons: TaskbarButtons::default(),
},
+ usage: usage_enabled.then(|| UsageMonitor::new(hwnd.0 as isize, USAGE_CHANGED)),
+ expanded: false,
+ visual_height: 0,
+ island_left: 0.0,
+ island_right: 0.0,
+ refresh_button: None,
_network: NetworkWatch::new(hwnd.0 as isize, STATUS_CHANGED),
audio: AudioWatch::new(hwnd.0 as isize, STATUS_CHANGED),
};
@@ -284,8 +759,21 @@ impl MenuBar {
self.place()
}
+ pub fn set_usage_enabled(&mut self, gfx: &Gfx, enabled: bool) -> Result<()> {
+ if self.usage.is_some() == enabled {
+ return Ok(());
+ }
+ self.usage = enabled.then(|| UsageMonitor::new(self.hwnd.0 as isize, USAGE_CHANGED));
+ self.expanded = false;
+ self.refresh(gfx)
+ }
+
/// The pointer reached the top edge or left the bar.
- pub fn hover(&mut self, inside: bool) -> Result<()> {
+ pub fn hover(&mut self, gfx: &Gfx, inside: bool) -> Result<()> {
+ if !inside && self.expanded {
+ self.expanded = false;
+ self.refresh(gfx)?;
+ }
if !self.auto_hide || self.revealed == inside {
return Ok(());
}
@@ -301,26 +789,30 @@ impl MenuBar {
// SAFETY: `track` is a valid structure with its size initialized.
unsafe { TrackMouseEvent(&mut track)? };
}
- Ok(())
+ self.refresh(gfx)
}
/// Positions the window and reserves (or frees) its strip of the screen.
fn place(&mut self) -> Result<()> {
let bounds = self.bounds;
- let height = bounds.bottom - bounds.top;
- if height <= 0 {
+ let bar_height = bounds.bottom - bounds.top;
+ if bar_height <= 0 {
return Ok(());
}
let hidden = self.auto_hide && !self.revealed;
if let Some(appbar) = &mut self.appbar {
// An auto-hiding bar leaves the whole screen to the windows.
- let strip = if self.auto_hide { 0 } else { height };
+ let strip = if self.auto_hide { 0 } else { bar_height };
appbar.reserve(Edge::Top, bounds, strip);
}
if let Some(root) = &self.root {
// Hidden: the content sits above the screen edge, and only the
// reveal strip of the window remains to catch the pointer.
- let lift = if hidden { -(height as f32) } else { 0.0 };
+ let lift = if hidden {
+ -(self.visual_height as f32)
+ } else {
+ 0.0
+ };
root.SetOffset(Vector3 {
X: 0.0,
Y: lift,
@@ -340,7 +832,11 @@ impl MenuBar {
bounds.left,
bounds.top,
bounds.right - bounds.left,
- if hidden { REVEAL_STRIP } else { height },
+ if hidden {
+ REVEAL_STRIP
+ } else {
+ self.visual_height
+ },
SWP_NOACTIVATE | show,
)?;
}
@@ -378,7 +874,49 @@ impl MenuBar {
}
}
- pub fn click(&self, x: f32) {
+ pub fn click(&mut self, gfx: &Gfx, x: f32, y: f32) -> Result<()> {
+ if x >= self.island_left && x < self.island_right {
+ let bar_height = self.bounds.bottom as f32 - self.bounds.top as f32;
+ if self.expanded
+ && self
+ .refresh_button
+ .is_some_and(|(left, top, right, bottom)| {
+ x >= left && x < right && y >= top && y < bottom
+ })
+ {
+ if let Some(usage) = &mut self.usage {
+ usage.refresh(true);
+ }
+ return self.refresh(gfx);
+ }
+ let header_bottom = if self.expanded {
+ 49.0 * self.look.as_ref().map_or(1.0, |look| look.scale)
+ } else {
+ bar_height
+ };
+ if y < header_bottom {
+ self.expanded = !self.expanded;
+ if self.expanded {
+ if let Some(usage) = &mut self.usage {
+ usage.refresh(false);
+ }
+ let mut track = TRACKMOUSEEVENT {
+ cbSize: size_of::<TRACKMOUSEEVENT>() as u32,
+ dwFlags: TME_LEAVE,
+ hwndTrack: self.hwnd,
+ dwHoverTime: 0,
+ };
+ // SAFETY: `track` describes our live window.
+ unsafe { TrackMouseEvent(&mut track)? };
+ }
+ return self.refresh(gfx);
+ }
+ return Ok(());
+ }
+ if self.expanded {
+ self.expanded = false;
+ self.refresh(gfx)?;
+ }
let hit = self
.zones
.iter()
@@ -392,6 +930,7 @@ impl MenuBar {
Some(Action::Widgets) => launcher::open_widgets(),
None => {}
}
+ Ok(())
}
/// Redraws the bar if anything it shows has changed.
@@ -399,6 +938,22 @@ impl MenuBar {
let Some(monitor) = system::primary_monitor() else {
return Ok(());
};
+ let active_providers = if self.usage.is_some() {
+ usage::active_providers()
+ } else {
+ ActiveProviders::default()
+ };
+ if !active_providers.any() {
+ self.expanded = false;
+ if let Some(usage) = &mut self.usage {
+ usage.mark_inactive();
+ }
+ } else if self.visible
+ && (!self.auto_hide || self.revealed)
+ && let Some(usage) = &mut self.usage
+ {
+ usage.refresh(false);
+ }
let look = Look {
screen: monitor.screen,
scale: monitor.scale,
@@ -408,6 +963,14 @@ impl MenuBar {
clock: system::clock_text(),
battery: system::battery(),
status: self.status,
+ usage: self
+ .usage
+ .as_ref()
+ .map_or_else(Snapshot::default, UsageMonitor::snapshot),
+ usage_enabled: self.usage.is_some() && active_providers.any(),
+ active_providers,
+ expanded: self.expanded,
+ usage_refreshing: self.usage.as_ref().is_some_and(UsageMonitor::is_refreshing),
};
if self.look.as_ref() == Some(&look) {
return Ok(());
@@ -423,12 +986,17 @@ impl MenuBar {
let px = |logical: f32| (logical * scale).round();
let screen = monitor.screen;
let (width, height) = ((screen.right - screen.left) as f32, px(HEIGHT));
+ let visual_height = if look.expanded {
+ px(74.0 + look.active_providers.count() as f32 * ISLAND_ROW_HEIGHT)
+ } else {
+ height
+ };
let ink = if look.light { Ink::Dark } else { Ink::Light };
let root = c.CreateContainerVisual()?;
root.SetSize(Vector2 {
X: width,
- Y: height,
+ Y: visual_height,
})?;
let layers = root.Children()?;
// Without transparency the bar is solid, as macOS draws it with
@@ -448,7 +1016,10 @@ impl MenuBar {
[c.CreateColorBrushWithColor(tint)?.cast()?];
for brush in backdrop.iter().chain(&fills) {
let fill = c.CreateSpriteVisual()?;
- fill.SetRelativeSizeAdjustment(Vector2 { X: 1.0, Y: 1.0 })?;
+ fill.SetSize(Vector2 {
+ X: width,
+ Y: height,
+ })?;
fill.SetBrush(brush)?;
layers.InsertAtTop(&fill)?;
}
@@ -473,9 +1044,11 @@ impl MenuBar {
};
self.zones.clear();
+ let mut left_end = px(SIDE_MARGIN);
if !look.app_name.is_empty() {
let name = gfx.text_brush(&look.app_name, scale, true, ink)?;
place(&layers, &name, px(SIDE_MARGIN))?;
+ left_end += name.width;
}
// Right side, from the edge inward.
@@ -530,14 +1103,348 @@ impl MenuBar {
right = left - px(ITEM_GAP);
}
+ if look.usage_enabled {
+ self.draw_island(gfx, look, &layers, width, height, left_end, right)?;
+ } else {
+ self.island_left = 0.0;
+ self.island_right = 0.0;
+ self.refresh_button = None;
+ }
+
self.target.SetRoot(&root)?;
self.root = Some(root);
+ self.visual_height = visual_height as i32;
self.bounds = RECT {
bottom: screen.top + height as i32,
..screen
};
+ ISLAND_LEFT.store(screen.left + self.island_left as i32, Ordering::Relaxed);
+ ISLAND_RIGHT.store(screen.left + self.island_right as i32, Ordering::Relaxed);
+ BAR_TOP.store(screen.top, Ordering::Relaxed);
+ BAR_BOTTOM.store(screen.top + height as i32, Ordering::Relaxed);
+ HEADER_BOTTOM.store(
+ screen.top
+ + if look.expanded {
+ px(49.0) as i32
+ } else {
+ height as i32
+ },
+ Ordering::Relaxed,
+ );
+ PANEL_BOTTOM.store(screen.top + self.visual_height, Ordering::Relaxed);
self.place()
}
+
+ #[expect(
+ clippy::too_many_arguments,
+ reason = "The island receives the measured bar bounds from the current layout"
+ )]
+ fn draw_island(
+ &mut self,
+ gfx: &Gfx,
+ look: &Look,
+ layers: &VisualCollection,
+ width: f32,
+ bar_height: f32,
+ left_end: f32,
+ right_start: f32,
+ ) -> Result<()> {
+ let c = &gfx.compositor;
+ let scale = look.scale;
+ let px = |logical: f32| (logical * scale).round();
+ let requested = px(if look.expanded {
+ ISLAND_EXPANDED_WIDTH
+ } else if look.active_providers.count() == 1 {
+ ISLAND_SINGLE_WIDTH
+ } else {
+ 134.0 * look.active_providers.count() as f32
+ });
+ let left_limit = left_end + px(8.0);
+ let usable = (right_start - left_limit - px(8.0)).max(px(145.0));
+ let island_width = requested.min(usable);
+ let island_left = ((width - island_width) / 2.0)
+ .max(left_limit)
+ .min((right_start - island_width - px(8.0)).max(left_limit));
+ let island_height = if look.expanded {
+ px(74.0 + look.active_providers.count() as f32 * ISLAND_ROW_HEIGHT)
+ } else {
+ bar_height
+ };
+ self.island_left = island_left;
+ self.island_right = island_left + island_width;
+
+ let island = c.CreateContainerVisual()?;
+ island.SetSize(Vector2 {
+ X: island_width,
+ Y: island_height,
+ })?;
+ island.SetOffset(Vector3 {
+ X: island_left.round(),
+ Y: 0.0,
+ Z: 0.0,
+ })?;
+ let content = island.Children()?;
+ let silhouette = gfx.island_mask(island_width, island_height, scale)?;
+ let shadow = c.CreateDropShadow()?;
+ shadow.SetMask(&silhouette)?;
+ shadow.SetBlurRadius(px(12.0))?;
+ shadow.SetOffset(Vector3 {
+ X: 0.0,
+ Y: px(5.0),
+ Z: 0.0,
+ })?;
+ shadow.SetColor(rgba(0, 0, 0, 92))?;
+ let shadow_host = c.CreateSpriteVisual()?;
+ shadow_host.SetSize(Vector2 {
+ X: island_width,
+ Y: island_height,
+ })?;
+ shadow_host.SetShadow(&shadow)?;
+ content.InsertAtTop(&shadow_host)?;
+
+ let tint = match (look.light, look.glass) {
+ (true, true) => rgba(247, 249, 252, 243),
+ (false, true) => rgba(7, 9, 13, 242),
+ (true, false) => rgba(247, 249, 252, 255),
+ (false, false) => rgba(10, 12, 17, 255),
+ };
+ if look.glass {
+ // The backdrop cannot be used as a mask-brush source. Inset its
+ // rounded clip so it stays entirely inside the curved silhouette.
+ let inset = px(12.0);
+ let glass_width = island_width - inset * 2.0;
+ let glass = c.CreateContainerVisual()?;
+ glass.SetSize(Vector2 {
+ X: glass_width,
+ Y: island_height,
+ })?;
+ glass.SetOffset(Vector3 {
+ X: inset,
+ Y: 0.0,
+ Z: 0.0,
+ })?;
+ let outline = c.CreateRoundedRectangleGeometry()?;
+ outline.SetSize(Vector2 {
+ X: glass_width,
+ Y: island_height + px(22.0),
+ })?;
+ outline.SetOffset(Vector2 {
+ X: 0.0,
+ Y: -px(22.0),
+ })?;
+ outline.SetCornerRadius(Vector2 {
+ X: px(22.0),
+ Y: px(22.0),
+ })?;
+ glass.SetClip(&c.CreateGeometricClipWithGeometry(&outline)?)?;
+ add_visual(
+ c,
+ &glass.Children()?,
+ &c.CreateHostBackdropBrush()?.cast()?,
+ 0.0,
+ 0.0,
+ glass_width,
+ island_height,
+ )?;
+ content.InsertAtTop(&glass)?;
+ }
+ let masked = c.CreateMaskBrush()?;
+ masked.SetSource(&c.CreateColorBrushWithColor(tint)?)?;
+ masked.SetMask(&silhouette)?;
+ add_visual(
+ c,
+ &content,
+ &masked.cast()?,
+ 0.0,
+ 0.0,
+ island_width,
+ island_height,
+ )?;
+
+ let ink = if look.light { Ink::Dark } else { Ink::Light };
+ let providers = Provider::ALL
+ .into_iter()
+ .filter(|provider| look.active_providers.has(*provider))
+ .map(|provider| {
+ let accent = match provider {
+ Provider::Claude => rgba(217, 119, 87, 255),
+ Provider::Codex => rgba(135, 190, 245, 255),
+ Provider::Copilot => rgba(147, 164, 186, 255),
+ Provider::Cursor => rgba(174, 180, 189, 255),
+ Provider::OpenCode => rgba(132, 196, 166, 255),
+ Provider::Gemini => rgba(111, 146, 255, 255),
+ };
+ (provider, provider.name(), look.usage.get(provider), accent)
+ })
+ .collect::<Vec<_>>();
+ if look.expanded {
+ let title = strings::text();
+ add_panel_text(
+ gfx,
+ &content,
+ title.usage_title,
+ px(28.0),
+ px(15.0),
+ scale,
+ 13.0,
+ true,
+ ink,
+ 0.94,
+ )?;
+ let button_text = if look.usage_refreshing {
+ title.usage_refreshing
+ } else {
+ title.usage_refresh
+ };
+ let button_label = gfx.text_brush_sized(button_text, scale, 11.5, true, ink)?;
+ let button_width = button_label.width + px(37.0);
+ let button_height = px(27.0);
+ let button_left = island_width - px(23.0) - button_width;
+ let button_top = px(8.0);
+ add_rounded_box(
+ c,
+ &content,
+ button_left,
+ button_top,
+ button_width,
+ button_height,
+ px(13.5),
+ if look.light {
+ rgba(28, 51, 79, 18)
+ } else {
+ rgba(235, 242, 252, 26)
+ },
+ Some(if look.light {
+ rgba(41, 62, 86, 36)
+ } else {
+ rgba(226, 237, 251, 43)
+ }),
+ )?;
+ let refresh_icon = gfx.text_brush_sized("↻", scale, 16.0, true, ink)?;
+ add_visual(
+ c,
+ &content,
+ &refresh_icon.brush.cast()?,
+ button_left + px(10.0),
+ button_top + (button_height - refresh_icon.height) / 2.0,
+ refresh_icon.width,
+ refresh_icon.height,
+ )?;
+ add_visual(
+ c,
+ &content,
+ &button_label.brush.cast()?,
+ button_left + px(29.0),
+ button_top + (button_height - button_label.height) / 2.0,
+ button_label.width,
+ button_label.height,
+ )?;
+ self.refresh_button = Some((
+ island_left + button_left,
+ button_top,
+ island_left + button_left + button_width,
+ button_top + button_height,
+ ));
+ for (index, (provider, _name, usage, accent)) in providers.iter().enumerate() {
+ draw_usage_card(
+ gfx,
+ &content,
+ *provider,
+ usage,
+ *accent,
+ scale,
+ look.light,
+ island_width,
+ px(53.0 + index as f32 * ISLAND_ROW_HEIGHT),
+ )?;
+ }
+ let newest_age = providers
+ .iter()
+ .filter_map(|provider| provider.2.age_minutes())
+ .min();
+ if let Some(minutes) = newest_age {
+ let status = format!("{} {minutes} min", title.usage_updated);
+ let label = gfx.text_brush_sized(&status, scale, 11.0, false, ink)?;
+ add_visual(
+ c,
+ &content,
+ &label.brush.cast()?,
+ (island_width - label.width) / 2.0,
+ island_height - px(21.0),
+ label.width,
+ label.height,
+ )?
+ .SetOpacity(0.53)?;
+ }
+ } else {
+ self.refresh_button = None;
+ let half = island_width / providers.len() as f32;
+ for (index, (provider, _name, usage, accent)) in providers.iter().enumerate() {
+ let icon_size = px(18.0) as u32;
+ let start = index as f32 * half
+ + if half < px(84.0) {
+ (half - icon_size as f32) / 2.0
+ } else {
+ px(21.0)
+ };
+ if let Some(image) = usage::logo(*provider) {
+ let image_brush = gfx.icon_brush(image, icon_size)?;
+ let brush: CompositionBrush =
+ if !matches!(provider, Provider::Claude | Provider::Gemini) && look.light {
+ let tinted = c.CreateMaskBrush()?;
+ tinted.SetMask(&image_brush)?;
+ tinted
+ .SetSource(&c.CreateColorBrushWithColor(rgba(27, 34, 45, 255))?)?;
+ tinted.cast()?
+ } else {
+ image_brush.cast()?
+ };
+ add_visual(
+ c,
+ &content,
+ &brush,
+ start,
+ (bar_height - icon_size as f32) / 2.0,
+ icon_size as f32,
+ icon_size as f32,
+ )?;
+ }
+ let percent = usage.main_window().map_or("—".to_owned(), |window| {
+ format!("{}%", window.used_percent)
+ });
+ if half > px(106.0) {
+ add_text(
+ gfx,
+ &content,
+ &percent,
+ start + px(25.0),
+ px(6.0),
+ scale,
+ true,
+ ink,
+ )?;
+ }
+ if half >= px(84.0) {
+ let ring = gfx.usage_ring(
+ usage.main_window().map(|window| window.used_percent),
+ scale,
+ *accent,
+ )?;
+ add_visual(
+ c,
+ &content,
+ &ring.brush.cast()?,
+ (index + 1) as f32 * half - px(16.0) - ring.width,
+ (bar_height - ring.height) / 2.0,
+ ring.width,
+ ring.height,
+ )?;
+ }
+ }
+ }
+ layers.InsertAtTop(&island)?;
+ Ok(())
+ }
}
impl Drop for MenuBar {
diff --git a/apps/dock/src/strings.rs b/apps/dock/src/strings.rs
index 7d1f936..6c64905 100644
--- a/apps/dock/src/strings.rs
+++ b/apps/dock/src/strings.rs
@@ -21,6 +21,16 @@ pub struct Strings {
pub remove: &'static str,
pub close_window: &'static str,
pub settings: &'static str,
+ pub usage_title: &'static str,
+ pub usage_refresh: &'static str,
+ pub usage_refreshing: &'static str,
+ pub usage_sign_in: &'static str,
+ pub usage_unavailable: &'static str,
+ pub usage_loading: &'static str,
+ pub usage_stale: &'static str,
+ pub usage_resets: &'static str,
+ pub usage_updated: &'static str,
+ pub usage_used: &'static str,
}
const ES: Strings = Strings {
@@ -37,6 +47,16 @@ const ES: Strings = Strings {
remove: "Quitar",
close_window: "&Cerrar",
settings: "&Ajustes de Muelle…",
+ usage_title: "Uso de IA",
+ usage_refresh: "Actualizar",
+ usage_refreshing: "Actualizando…",
+ usage_sign_in: "Inicia sesión",
+ usage_unavailable: "No disponible",
+ usage_loading: "Cargando…",
+ usage_stale: "Sin actualizar",
+ usage_resets: "Reinicia",
+ usage_updated: "Actualizado hace",
+ usage_used: "usado",
};
const EN: Strings = Strings {
@@ -53,6 +73,16 @@ const EN: Strings = Strings {
remove: "Remove",
close_window: "&Close",
settings: "Muelle &Settings…",
+ usage_title: "AI usage",
+ usage_refresh: "Refresh",
+ usage_refreshing: "Refreshing…",
+ usage_sign_in: "Sign in",
+ usage_unavailable: "Unavailable",
+ usage_loading: "Loading…",
+ usage_stale: "Not updated",
+ usage_resets: "Resets",
+ usage_updated: "Updated",
+ usage_used: "used",
};
/// 0 = not chosen yet (follow Windows), 1 = Spanish, 2 = English.
diff --git a/apps/dock/src/usage.rs b/apps/dock/src/usage.rs
new file mode 100644
index 0000000..d18a297
--- /dev/null
+++ b/apps/dock/src/usage.rs
@@ -0,0 +1,1570 @@
+//! Read-only plan quota snapshots for locally active AI clients.
+
+use std::{
+ env, fs,
+ io::{Read, Seek, SeekFrom},
+ os::windows::process::CommandExt,
+ path::PathBuf,
+ process::Command,
+ sync::{
+ Arc, Mutex,
+ atomic::{AtomicBool, Ordering},
+ },
+ thread,
+ time::{Duration, Instant, SystemTime, UNIX_EPOCH},
+};
+
+use aes_gcm::{Aes256Gcm, KeyInit, Nonce, aead::Aead};
+use chrono::{DateTime, Local, NaiveDate, Utc};
+use muelle_shell::icons::IconImage;
+use reqwest::blocking::Client;
+use rusqlite::{Connection, OpenFlags};
+use serde::{Deserialize, Serialize};
+use serde_json::Value;
+use windows::Win32::{
+ Foundation::{CloseHandle, HLOCAL, HWND, LPARAM, LocalFree, WPARAM},
+ Security::{
+ Credentials::{CRED_TYPE_GENERIC, CREDENTIALW, CredFree, CredReadW},
+ Cryptography::{CRYPT_INTEGER_BLOB, CryptUnprotectData},
+ },
+ System::Diagnostics::ToolHelp::{
+ CreateToolhelp32Snapshot, PROCESSENTRY32W, Process32FirstW, Process32NextW,
+ TH32CS_SNAPPROCESS,
+ },
+ System::Threading::{
+ OpenProcess, PROCESS_NAME_WIN32, PROCESS_QUERY_LIMITED_INFORMATION,
+ QueryFullProcessImageNameW,
+ },
+ UI::WindowsAndMessaging::PostMessageW,
+};
+use windows::core::{PWSTR, w};
+
+const REFRESH_INTERVAL: Duration = Duration::from_secs(5 * 60);
+
+#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub enum State {
+ Loading,
+ Ready,
+ SignIn,
+ Unavailable,
+}
+
+#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct Window {
+ #[serde(default)]
+ pub label: Option<String>,
+ pub minutes: i64,
+ pub used_percent: u8,
+ pub resets_at: Option<DateTime<Utc>>,
+}
+
+impl Window {
+ pub fn title(&self) -> String {
+ if let Some(label) = &self.label {
+ label.clone()
+ } else if self.minutes >= 25 * 24 * 60 {
+ "30 d".to_owned()
+ } else if self.minutes >= 2 * 24 * 60 {
+ "7 d".to_owned()
+ } else if self.minutes >= 60 {
+ format!("{} h", self.minutes / 60)
+ } else {
+ format!("{} min", self.minutes)
+ }
+ }
+
+ pub fn reset_text(&self) -> Option<String> {
+ self.resets_at
+ .map(|time| time.with_timezone(&Local).format("%d/%m %H:%M").to_string())
+ }
+}
+
+#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct ProviderUsage {
+ pub state: State,
+ pub windows: Vec<Window>,
+ pub fetched_at: Option<SystemTime>,
+}
+
+impl Default for ProviderUsage {
+ fn default() -> Self {
+ Self {
+ state: State::Loading,
+ windows: Vec::new(),
+ fetched_at: None,
+ }
+ }
+}
+
+impl ProviderUsage {
+ pub fn main_window(&self) -> Option<&Window> {
+ self.windows.first()
+ }
+
+ pub fn age_minutes(&self) -> Option<u64> {
+ Some(self.fetched_at?.elapsed().ok()?.as_secs() / 60)
+ }
+}
+
+#[derive(Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
+pub struct Snapshot {
+ pub providers: [ProviderUsage; Provider::COUNT],
+}
+
+impl Snapshot {
+ pub fn get(&self, provider: Provider) -> &ProviderUsage {
+ &self.providers[provider as usize]
+ }
+}
+
+#[derive(Clone, Copy, PartialEq, Eq)]
+#[repr(usize)]
+pub enum Provider {
+ Claude,
+ Codex,
+ Copilot,
+ Cursor,
+ OpenCode,
+ Gemini,
+}
+
+impl Provider {
+ pub const COUNT: usize = 6;
+ pub const ALL: [Self; Self::COUNT] = [
+ Self::Claude,
+ Self::Codex,
+ Self::Copilot,
+ Self::Cursor,
+ Self::OpenCode,
+ Self::Gemini,
+ ];
+
+ pub fn name(self) -> &'static str {
+ match self {
+ Self::Claude => "Claude",
+ Self::Codex => "Codex",
+ Self::Copilot => "Copilot",
+ Self::Cursor => "Cursor",
+ Self::OpenCode => "OpenCode",
+ Self::Gemini => "Gemini",
+ }
+ }
+}
+
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
+pub struct ActiveProviders(pub [bool; Provider::COUNT]);
+
+impl ActiveProviders {
+ pub fn any(self) -> bool {
+ self.0.iter().any(|active| *active)
+ }
+
+ pub fn count(self) -> usize {
+ self.0.iter().filter(|active| **active).count()
+ }
+
+ pub fn has(self, provider: Provider) -> bool {
+ self.0[provider as usize]
+ }
+}
+
+/// Only show a provider while its local client is running. A stored login by
+/// itself does not imply the client is in use.
+pub fn active_providers() -> ActiveProviders {
+ // SAFETY: The snapshot handle is closed before this function returns.
+ let Ok(snapshot) = (unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) }) else {
+ return ActiveProviders::default();
+ };
+ let mut entry = PROCESSENTRY32W {
+ dwSize: std::mem::size_of::<PROCESSENTRY32W>() as u32,
+ ..Default::default()
+ };
+ let mut active = ActiveProviders::default();
+ // SAFETY: `entry` has the documented size and belongs to this snapshot.
+ if unsafe { Process32FirstW(snapshot, &mut entry) }.is_ok() {
+ loop {
+ let name_len = entry
+ .szExeFile
+ .iter()
+ .position(|&unit| unit == 0)
+ .unwrap_or(entry.szExeFile.len());
+ let name = String::from_utf16_lossy(&entry.szExeFile[..name_len]);
+ if let Some(provider) = match name.to_ascii_lowercase().as_str() {
+ "claude.exe" => Some(Provider::Claude),
+ "codex.exe" => Some(Provider::Codex),
+ "copilot.exe" if github_copilot_process(entry.th32ProcessID) => {
+ Some(Provider::Copilot)
+ }
+ "copilot-runtime.exe" => Some(Provider::Copilot),
+ "cursor.exe" | "cursor-agent.exe" => Some(Provider::Cursor),
+ "opencode.exe" => Some(Provider::OpenCode),
+ "gemini.exe" | "antigravity.exe" | "agy.exe" => Some(Provider::Gemini),
+ _ => None,
+ } {
+ active.0[provider as usize] = true;
+ }
+ if active.count() == Provider::COUNT {
+ break;
+ }
+ // SAFETY: The snapshot and entry remain valid for this iteration.
+ if unsafe { Process32NextW(snapshot, &mut entry) }.is_err() {
+ break;
+ }
+ }
+ }
+ // SAFETY: `snapshot` came from CreateToolhelp32Snapshot above.
+ unsafe {
+ let _ = CloseHandle(snapshot);
+ }
+ active
+}
+
+fn github_copilot_process(pid: u32) -> bool {
+ // Microsoft Copilot also runs as copilot.exe; it has no GitHub quota.
+ // SAFETY: The process handle is closed on every successful open.
+ let Ok(process) = (unsafe { OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) })
+ else {
+ return false;
+ };
+ let mut buffer = [0u16; 1024];
+ let mut length = buffer.len() as u32;
+ // SAFETY: `buffer` remains live and `length` states its capacity.
+ let found = unsafe {
+ QueryFullProcessImageNameW(
+ process,
+ PROCESS_NAME_WIN32,
+ PWSTR(buffer.as_mut_ptr()),
+ &mut length,
+ )
+ }
+ .is_ok();
+ // SAFETY: OpenProcess returned this handle.
+ unsafe {
+ let _ = CloseHandle(process);
+ }
+ found
+ && String::from_utf16_lossy(&buffer[..length as usize])
+ .to_ascii_lowercase()
+ .contains("github")
+}
+
+pub fn logo(provider: Provider) -> Option<&'static IconImage> {
+ static CLAUDE: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
+ static CODEX: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
+ static COPILOT: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
+ static CURSOR: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
+ static OPENCODE: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
+ static GEMINI: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
+ match provider {
+ Provider::Claude => CLAUDE
+ .get_or_init(|| decode_logo(include_bytes!("../../../assets/usage/claude.png")))
+ .as_ref(),
+ Provider::Codex => CODEX
+ .get_or_init(|| decode_logo(include_bytes!("../../../assets/usage/codex.png")))
+ .as_ref(),
+ Provider::Copilot => COPILOT
+ .get_or_init(|| decode_logo(include_bytes!("../../../assets/usage/copilot.png")))
+ .as_ref(),
+ Provider::Cursor => CURSOR
+ .get_or_init(|| decode_logo(include_bytes!("../../../assets/usage/cursor.png")))
+ .as_ref(),
+ Provider::OpenCode => OPENCODE
+ .get_or_init(|| decode_logo(include_bytes!("../../../assets/usage/opencode.png")))
+ .as_ref(),
+ Provider::Gemini => GEMINI
+ .get_or_init(|| decode_logo(include_bytes!("../../../assets/usage/gemini.png")))
+ .as_ref(),
+ }
+}
+
+fn decode_logo(bytes: &[u8]) -> Option<IconImage> {
+ let mut reader = png::Decoder::new(std::io::Cursor::new(bytes))
+ .read_info()
+ .ok()?;
+ let mut rgba = vec![0; reader.output_buffer_size()?];
+ let output = reader.next_frame(&mut rgba).ok()?;
+ if output.color_type != png::ColorType::Rgba || output.bit_depth != png::BitDepth::Eight {
+ return None;
+ }
+ let mut bgra = Vec::with_capacity(output.buffer_size());
+ for pixel in rgba[..output.buffer_size()].as_chunks::<4>().0 {
+ let alpha = u16::from(pixel[3]);
+ bgra.extend_from_slice(&[
+ (u16::from(pixel[2]) * alpha / 255) as u8,
+ (u16::from(pixel[1]) * alpha / 255) as u8,
+ (u16::from(pixel[0]) * alpha / 255) as u8,
+ pixel[3],
+ ]);
+ }
+ Some(IconImage {
+ width: output.width,
+ height: output.height,
+ bgra,
+ })
+}
+
+pub struct Monitor {
+ current: Arc<Mutex<Snapshot>>,
+ running: Arc<AtomicBool>,
+ alive: Arc<AtomicBool>,
+ last_started: Option<Instant>,
+ last_active: ActiveProviders,
+ hwnd: isize,
+ changed_message: u32,
+}
+
+impl Monitor {
+ pub fn new(hwnd: isize, changed_message: u32) -> Self {
+ Self {
+ current: Arc::new(Mutex::new(Snapshot::default())),
+ running: Arc::new(AtomicBool::new(false)),
+ alive: Arc::new(AtomicBool::new(true)),
+ last_started: None,
+ last_active: ActiveProviders::default(),
+ hwnd,
+ changed_message,
+ }
+ }
+
+ pub fn snapshot(&self) -> Snapshot {
+ self.current
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .clone()
+ }
+
+ pub fn is_refreshing(&self) -> bool {
+ self.running.load(Ordering::Acquire)
+ }
+
+ pub fn mark_inactive(&mut self) {
+ self.last_active = ActiveProviders::default();
+ }
+
+ pub fn refresh(&mut self, force: bool) {
+ if self.running.swap(true, Ordering::AcqRel) {
+ return;
+ }
+ let active = active_providers();
+ if !force
+ && active == self.last_active
+ && self
+ .last_started
+ .is_some_and(|then| then.elapsed() < REFRESH_INTERVAL)
+ {
+ self.running.store(false, Ordering::Release);
+ return;
+ }
+ self.last_started = Some(Instant::now());
+ self.last_active = active;
+ let current = Arc::clone(&self.current);
+ let running = Arc::clone(&self.running);
+ let alive = Arc::clone(&self.alive);
+ let hwnd = self.hwnd;
+ let message = self.changed_message;
+ thread::spawn(move || {
+ let fetched = fetch_in_child();
+ {
+ let mut stored = current
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ for (previous, fetched) in stored.providers.iter_mut().zip(fetched.providers) {
+ merge(previous, fetched);
+ }
+ }
+ running.store(false, Ordering::Release);
+ if alive.load(Ordering::Acquire) {
+ // SAFETY: The window is owned by the live menu bar; posting is asynchronous.
+ unsafe {
+ let _ = PostMessageW(Some(HWND(hwnd as *mut _)), message, WPARAM(0), LPARAM(0));
+ }
+ }
+ });
+ }
+}
+
+pub fn worker_main() -> anyhow::Result<()> {
+ serde_json::to_writer(std::io::stdout().lock(), &fetch_all())?;
+ Ok(())
+}
+
+fn fetch_in_child() -> Snapshot {
+ let Ok(executable) = env::current_exe() else {
+ return unavailable_snapshot();
+ };
+ let Ok(output) = Command::new(executable)
+ .arg("--usage-worker")
+ .creation_flags(0x0800_0000)
+ .output()
+ else {
+ return unavailable_snapshot();
+ };
+ if !output.status.success() {
+ return unavailable_snapshot();
+ }
+ serde_json::from_slice(&output.stdout).unwrap_or_else(|_| unavailable_snapshot())
+}
+
+impl Drop for Monitor {
+ fn drop(&mut self) {
+ self.alive.store(false, Ordering::Release);
+ }
+}
+
+fn merge(previous: &mut ProviderUsage, fetched: ProviderUsage) {
+ if fetched.state == State::Unavailable && !previous.windows.is_empty() {
+ previous.state = State::Unavailable;
+ } else {
+ *previous = fetched;
+ }
+}
+
+fn fetch_all() -> Snapshot {
+ let Ok(client) = Client::builder().timeout(Duration::from_secs(6)).build() else {
+ return unavailable_snapshot();
+ };
+ let active = active_providers();
+ Snapshot {
+ providers: std::array::from_fn(|index| {
+ let provider = Provider::ALL[index];
+ if !active.has(provider) {
+ return ProviderUsage::default();
+ }
+ match provider {
+ Provider::Claude => fetch_claude(&client),
+ Provider::Codex => fetch_codex(&client),
+ Provider::Copilot => fetch_copilot(&client),
+ Provider::Cursor => fetch_cursor(&client),
+ Provider::OpenCode => fetch_opencode(&client),
+ Provider::Gemini => fetch_gemini(&client),
+ }
+ }),
+ }
+}
+
+fn unavailable_snapshot() -> Snapshot {
+ Snapshot {
+ providers: std::array::from_fn(|_| unavailable()),
+ }
+}
+
+fn unavailable() -> ProviderUsage {
+ ProviderUsage {
+ state: State::Unavailable,
+ ..ProviderUsage::default()
+ }
+}
+
+fn sign_in() -> ProviderUsage {
+ ProviderUsage {
+ state: State::SignIn,
+ ..ProviderUsage::default()
+ }
+}
+
+fn ready(windows: Vec<Window>) -> ProviderUsage {
+ ProviderUsage {
+ state: State::Ready,
+ windows,
+ fetched_at: Some(SystemTime::now()),
+ }
+}
+
+fn home() -> Option<PathBuf> {
+ env::var_os("USERPROFILE").map(PathBuf::from)
+}
+
+fn credential_text(target: windows::core::PCWSTR) -> Option<String> {
+ let mut credential: *mut CREDENTIALW = std::ptr::null_mut();
+ // SAFETY: Windows allocates `credential` on success; it is freed below.
+ unsafe { CredReadW(target, CRED_TYPE_GENERIC, None, &mut credential).ok()? };
+ if credential.is_null() {
+ return None;
+ }
+ // SAFETY: CredReadW returned a valid blob of CredentialBlobSize bytes.
+ let token = unsafe {
+ let item = &*credential;
+ if item.CredentialBlob.is_null() || item.CredentialBlobSize == 0 {
+ None
+ } else {
+ let bytes =
+ std::slice::from_raw_parts(item.CredentialBlob, item.CredentialBlobSize as usize);
+ String::from_utf8(bytes.to_vec()).ok()
+ }
+ };
+ // SAFETY: `credential` belongs to this successful CredReadW call.
+ unsafe { CredFree(credential.cast()) };
+ token.map(|value| value.trim_matches('\0').trim().to_owned())
+}
+
+fn vscode_github_tokens() -> Vec<String> {
+ let Some(root) = home() else {
+ return Vec::new();
+ };
+ let Some(profile) = env::var_os("APPDATA").map(PathBuf::from) else {
+ return Vec::new();
+ };
+ let key_file = profile.join("Code/Local State");
+ let Ok(key_file) = fs::read(key_file) else {
+ return Vec::new();
+ };
+ let Ok(key_json) = serde_json::from_slice::<Value>(&key_file) else {
+ return Vec::new();
+ };
+ let Some(key_b64) = key_json
+ .pointer("/os_crypt/encrypted_key")
+ .and_then(Value::as_str)
+ else {
+ return Vec::new();
+ };
+ use base64::Engine;
+ let Ok(wrapped) = base64::engine::general_purpose::STANDARD.decode(key_b64) else {
+ return Vec::new();
+ };
+ let Some(wrapped) = wrapped.strip_prefix(b"DPAPI") else {
+ return Vec::new();
+ };
+ let Some(key) = dpapi_unprotect(wrapped) else {
+ return Vec::new();
+ };
+ let db_path = root.join(".vscode-shared/sharedStorage/state.vscdb");
+ let Ok(db) = Connection::open_with_flags(db_path, OpenFlags::SQLITE_OPEN_READ_ONLY) else {
+ return Vec::new();
+ };
+ let Ok(blob) = db.query_row(
+ "SELECT value FROM ItemTable WHERE key = ?1 LIMIT 1",
+ [r#"secret://{"extensionId":"vscode.github-authentication","key":"github.auth"}"#],
+ |row| row.get::<_, String>(0),
+ ) else {
+ return Vec::new();
+ };
+ let Ok(wrapper) = serde_json::from_str::<Value>(&blob) else {
+ return Vec::new();
+ };
+ let Some(bytes) = wrapper.get("data").and_then(Value::as_array) else {
+ return Vec::new();
+ };
+ let Some(encrypted) = bytes
+ .iter()
+ .map(|value| value.as_u64().and_then(|byte| u8::try_from(byte).ok()))
+ .collect::<Option<Vec<_>>>()
+ else {
+ return Vec::new();
+ };
+ if encrypted.len() < 3 + 12 + 16 || !encrypted.starts_with(b"v10") {
+ return Vec::new();
+ }
+ let Ok(cipher) = Aes256Gcm::new_from_slice(&key) else {
+ return Vec::new();
+ };
+ let Ok(plain) = cipher.decrypt(Nonce::from_slice(&encrypted[3..15]), &encrypted[15..]) else {
+ return Vec::new();
+ };
+ let Ok(sessions) = serde_json::from_slice::<Value>(&plain) else {
+ return Vec::new();
+ };
+ let mut tokens = Vec::new();
+ collect_github_tokens(&sessions, &mut tokens);
+ tokens
+}
+
+fn dpapi_unprotect(encrypted: &[u8]) -> Option<Vec<u8>> {
+ let input = CRYPT_INTEGER_BLOB {
+ cbData: u32::try_from(encrypted.len()).ok()?,
+ pbData: encrypted.as_ptr().cast_mut(),
+ };
+ let mut output = CRYPT_INTEGER_BLOB::default();
+ // SAFETY: Both blobs have valid buffers; Windows owns and frees the output.
+ unsafe { CryptUnprotectData(&input, None, None, None, None, 0, &mut output).ok()? };
+ if output.pbData.is_null() {
+ return None;
+ }
+ // SAFETY: CryptUnprotectData returned `cbData` bytes at `pbData`.
+ let plain =
+ unsafe { std::slice::from_raw_parts(output.pbData, output.cbData as usize).to_vec() };
+ // SAFETY: CryptUnprotectData allocated this buffer with LocalAlloc.
+ unsafe {
+ let _ = LocalFree(Some(HLOCAL(output.pbData.cast())));
+ }
+ Some(plain)
+}
+
+fn collect_github_tokens(value: &Value, tokens: &mut Vec<String>) {
+ match value {
+ Value::Object(object) => {
+ if let Some(token) = object
+ .get("accessToken")
+ .or_else(|| object.get("access_token"))
+ .and_then(Value::as_str)
+ .filter(|token| token.starts_with("gh") && token.len() < 512)
+ {
+ tokens.push(token.to_owned());
+ }
+ for item in object.values() {
+ collect_github_tokens(item, tokens);
+ }
+ }
+ Value::Array(items) => {
+ for item in items {
+ collect_github_tokens(item, tokens);
+ }
+ }
+ _ => {}
+ }
+}
+
+fn fetch_claude(client: &Client) -> ProviderUsage {
+ let Some(root) = env::var_os("CLAUDE_CONFIG_DIR")
+ .map(PathBuf::from)
+ .or_else(|| home().map(|path| path.join(".claude")))
+ else {
+ return sign_in();
+ };
+ let Ok(contents) = fs::read(root.join(".credentials.json")) else {
+ return sign_in();
+ };
+ let Ok(credentials) = serde_json::from_slice::<Value>(&contents) else {
+ return unavailable();
+ };
+ let Some(token) = credentials
+ .pointer("/claudeAiOauth/accessToken")
+ .and_then(Value::as_str)
+ .filter(|token| !token.is_empty())
+ else {
+ return sign_in();
+ };
+ let Ok(response) = client
+ .get("https://api.anthropic.com/api/oauth/usage")
+ .bearer_auth(token)
+ .header("anthropic-beta", "oauth-2025-04-20")
+ .send()
+ else {
+ return unavailable();
+ };
+ if response.status().as_u16() == 401 || response.status().as_u16() == 403 {
+ return sign_in();
+ }
+ let Ok(body) = response.error_for_status().and_then(|value| value.text()) else {
+ return unavailable();
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ return unavailable();
+ };
+ ready(parse_claude(&value))
+}
+
+fn fetch_codex(client: &Client) -> ProviderUsage {
+ let Some(root) = env::var_os("CODEX_HOME")
+ .map(PathBuf::from)
+ .or_else(|| home().map(|path| path.join(".codex")))
+ else {
+ return sign_in();
+ };
+ let Ok(contents) = fs::read(root.join("auth.json")) else {
+ return local_codex(&root).unwrap_or_else(sign_in);
+ };
+ let Ok(credentials) = serde_json::from_slice::<Value>(&contents) else {
+ return local_codex(&root).unwrap_or_else(unavailable);
+ };
+ let Some(token) = credentials
+ .pointer("/tokens/access_token")
+ .and_then(Value::as_str)
+ .filter(|token| !token.is_empty())
+ else {
+ return local_codex(&root).unwrap_or_else(sign_in);
+ };
+ let mut request = client
+ .get("https://chatgpt.com/backend-api/wham/usage")
+ .bearer_auth(token);
+ if let Some(account) = credentials
+ .pointer("/tokens/account_id")
+ .and_then(Value::as_str)
+ .filter(|account| !account.is_empty())
+ {
+ request = request.header("ChatGPT-Account-ID", account);
+ }
+ let Ok(response) = request.send() else {
+ return local_codex(&root).unwrap_or_else(unavailable);
+ };
+ if response.status().as_u16() == 401 || response.status().as_u16() == 403 {
+ return local_codex(&root).unwrap_or_else(sign_in);
+ }
+ let Ok(body) = response.error_for_status().and_then(|value| value.text()) else {
+ return local_codex(&root).unwrap_or_else(unavailable);
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ return local_codex(&root).unwrap_or_else(unavailable);
+ };
+ let windows = parse_codex(&value);
+ if windows.is_empty() {
+ local_codex(&root).unwrap_or_else(|| ready(windows))
+ } else {
+ ready(windows)
+ }
+}
+
+fn fetch_copilot(client: &Client) -> ProviderUsage {
+ let mut tokens = [
+ env::var("COPILOT_GITHUB_TOKEN").ok(),
+ env::var("GH_TOKEN").ok(),
+ env::var("GITHUB_TOKEN").ok(),
+ credential_text(w!("copilot-cli")),
+ credential_text(w!("copilot-language-server/oauth-token-key")),
+ ]
+ .into_iter()
+ .flatten()
+ .collect::<Vec<_>>();
+ tokens.extend(vscode_github_tokens());
+ for token in tokens.into_iter().filter(|value| !value.is_empty()) {
+ let response = client
+ .get("https://api.github.com/copilot_internal/user")
+ .header("Authorization", format!("token {token}"))
+ .header("Accept", "application/json")
+ .header("Editor-Version", "vscode/1.96.2")
+ .header("Editor-Plugin-Version", "copilot-chat/0.26.7")
+ .header("User-Agent", "GitHubCopilotChat/0.26.7")
+ .header("X-Github-Api-Version", "2025-04-01")
+ .send();
+ let Ok(response) = response else {
+ return unavailable();
+ };
+ if matches!(response.status().as_u16(), 401 | 403) {
+ continue;
+ }
+ let Ok(body) = response
+ .error_for_status()
+ .and_then(|response| response.text())
+ else {
+ return unavailable();
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ return unavailable();
+ };
+ let windows = parse_copilot(&value);
+ return if windows.is_empty() {
+ unavailable()
+ } else {
+ ready(windows)
+ };
+ }
+ sign_in()
+}
+
+fn parse_copilot(value: &Value) -> Vec<Window> {
+ let quotas = value
+ .get("quota_snapshots")
+ .or_else(|| value.get("quotaSnapshots"));
+ let reset = value
+ .get("quota_reset_date_utc")
+ .or_else(|| value.get("quota_reset_date"))
+ .and_then(Value::as_str)
+ .and_then(|text| {
+ DateTime::parse_from_rfc3339(text)
+ .ok()
+ .map(|date| date.with_timezone(&Utc))
+ .or_else(|| {
+ NaiveDate::parse_from_str(text, "%Y-%m-%d")
+ .ok()?
+ .and_hms_opt(0, 0, 0)
+ .map(|date| date.and_utc())
+ })
+ });
+ [
+ ("premium_interactions", "premiumInteractions"),
+ ("chat", "chat"),
+ ]
+ .into_iter()
+ .filter_map(|(snake, camel)| {
+ let quotas = quotas?;
+ let quota = quotas.get(snake).or_else(|| quotas.get(camel))?;
+ if quota.get("unlimited").and_then(Value::as_bool) == Some(true) {
+ return None;
+ }
+ let remaining = percent(
+ quota
+ .get("percent_remaining")
+ .or_else(|| quota.get("percentRemaining"))?,
+ )?;
+ Some(Window {
+ label: Some(if snake == "chat" { "Chat" } else { "Premium" }.to_owned()),
+ minutes: 30 * 24 * 60,
+ used_percent: 100 - remaining,
+ resets_at: reset,
+ })
+ })
+ .collect()
+}
+
+fn fetch_cursor(client: &Client) -> ProviderUsage {
+ let Some(path) = env::var_os("APPDATA")
+ .map(PathBuf::from)
+ .map(|path| path.join("Cursor/User/globalStorage/state.vscdb"))
+ else {
+ return sign_in();
+ };
+ if !path.is_file() {
+ return sign_in();
+ }
+ let Ok(db) = Connection::open_with_flags(path, OpenFlags::SQLITE_OPEN_READ_ONLY) else {
+ return unavailable();
+ };
+ let Ok(token) = db.query_row(
+ "SELECT value FROM ItemTable WHERE key = 'cursorAuth/accessToken' LIMIT 1",
+ [],
+ |row| row.get::<_, String>(0),
+ ) else {
+ return sign_in();
+ };
+ let Some(cookie) = cursor_cookie(&token) else {
+ return sign_in();
+ };
+ let Ok(response) = client
+ .get("https://cursor.com/api/usage-summary")
+ .header("Cookie", cookie)
+ .header("Accept", "application/json")
+ .send()
+ else {
+ return unavailable();
+ };
+ if matches!(response.status().as_u16(), 401 | 403) {
+ return sign_in();
+ }
+ let Ok(body) = response
+ .error_for_status()
+ .and_then(|response| response.text())
+ else {
+ return unavailable();
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ return unavailable();
+ };
+ let windows = parse_cursor(&value);
+ if windows.is_empty() {
+ unavailable()
+ } else {
+ ready(windows)
+ }
+}
+
+fn cursor_cookie(token: &str) -> Option<String> {
+ use base64::Engine;
+ let parts = token.split('.').collect::<Vec<_>>();
+ let payload = parts.get(1)?;
+ let decoded = base64::engine::general_purpose::URL_SAFE_NO_PAD
+ .decode(payload)
+ .ok()?;
+ let claims = serde_json::from_slice::<Value>(&decoded).ok()?;
+ let expiry = claims.get("exp")?.as_i64()?;
+ if expiry < Utc::now().timestamp() + 60 {
+ return None;
+ }
+ let user = claims.get("sub")?.as_str()?.rsplit('|').next()?;
+ if user.is_empty()
+ || !user
+ .bytes()
+ .all(|byte| byte.is_ascii_alphanumeric() || b"._-".contains(&byte))
+ {
+ return None;
+ }
+ Some(format!("WorkosCursorSessionToken={user}%3A%3A{token}"))
+}
+
+fn parse_cursor(value: &Value) -> Vec<Window> {
+ let plan = value
+ .pointer("/individualUsage/plan")
+ .or_else(|| value.pointer("/individual_usage/plan"));
+ let Some(plan) = plan else {
+ return Vec::new();
+ };
+ let used = plan.get("totalPercentUsed").and_then(percent).or_else(|| {
+ let amount = plan.get("used")?.as_f64()?;
+ let limit = plan.get("limit")?.as_f64()?;
+ (limit > 0.0).then(|| (amount * 100.0 / limit).clamp(0.0, 100.0).round() as u8)
+ });
+ let Some(used_percent) = used else {
+ return Vec::new();
+ };
+ let resets_at = value
+ .get("billingCycleEnd")
+ .and_then(Value::as_str)
+ .and_then(|text| DateTime::parse_from_rfc3339(text).ok())
+ .map(|date| date.with_timezone(&Utc));
+ let minutes = value
+ .get("billingCycleStart")
+ .and_then(Value::as_str)
+ .and_then(|text| DateTime::parse_from_rfc3339(text).ok())
+ .zip(resets_at)
+ .map_or(30 * 24 * 60, |(start, end)| {
+ (end.signed_duration_since(start).num_minutes()).max(1)
+ });
+ vec![Window {
+ label: None,
+ minutes,
+ used_percent,
+ resets_at,
+ }]
+}
+
+fn fetch_opencode(client: &Client) -> ProviderUsage {
+ let Some(path) = home().map(|path| path.join(".local/share/opencode/auth.json")) else {
+ return sign_in();
+ };
+ let token = env::var("OPENCODE_API_KEY").ok().or_else(|| {
+ let contents = fs::read(path).ok()?;
+ let auth: Value = serde_json::from_slice(&contents).ok()?;
+ auth.pointer("/opencode/key")
+ .and_then(Value::as_str)
+ .map(str::to_owned)
+ });
+ let Some(token) = token.filter(|token| !token.is_empty()) else {
+ return sign_in();
+ };
+ let Ok(response) = client
+ .get("https://opencode.ai/zen/go/v1/usage")
+ .bearer_auth(token)
+ .header("Accept", "application/json")
+ .send()
+ else {
+ return unavailable();
+ };
+ if response.status().as_u16() == 401 {
+ return sign_in();
+ }
+ let Ok(body) = response
+ .error_for_status()
+ .and_then(|response| response.text())
+ else {
+ return unavailable();
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ return unavailable();
+ };
+ let windows = parse_opencode(&value);
+ if windows.is_empty() {
+ unavailable()
+ } else {
+ ready(windows)
+ }
+}
+
+fn parse_opencode(value: &Value) -> Vec<Window> {
+ let Some(usage) = value.get("usage") else {
+ return Vec::new();
+ };
+ [
+ ("rolling", 300),
+ ("weekly", 10_080),
+ ("monthly", 30 * 24 * 60),
+ ]
+ .into_iter()
+ .filter_map(|(name, minutes)| {
+ let lane = usage.get(name)?;
+ let used_percent = lane.get("percent").and_then(percent).or_else(|| {
+ let used = lane.get("used")?.as_f64()?;
+ let limit = lane.get("limit")?.as_f64()?;
+ (limit > 0.0).then(|| (used * 100.0 / limit).clamp(0.0, 100.0).round() as u8)
+ })?;
+ let resets_at = lane
+ .get("resetInSec")
+ .or_else(|| lane.get("reset_in_sec"))
+ .and_then(Value::as_i64)
+ .filter(|seconds| *seconds >= 0)
+ .and_then(|seconds| DateTime::from_timestamp(Utc::now().timestamp() + seconds, 0));
+ Some(Window {
+ label: None,
+ minutes,
+ used_percent,
+ resets_at,
+ })
+ })
+ .collect()
+}
+
+fn fetch_gemini(client: &Client) -> ProviderUsage {
+ // Antigravity and Gemini CLI have distinct accounts and quotas. Prefer the
+ // running desktop app's own local quota service when it is available.
+ if let Some(usage) = fetch_antigravity() {
+ return usage;
+ }
+ let Some(path) = home().map(|path| path.join(".gemini/oauth_creds.json")) else {
+ return unavailable();
+ };
+ let Ok(contents) = fs::read(path) else {
+ return unavailable();
+ };
+ let Ok(auth) = serde_json::from_slice::<Value>(&contents) else {
+ return unavailable();
+ };
+ let Some(token) = auth
+ .get("access_token")
+ .and_then(Value::as_str)
+ .filter(|token| !token.is_empty())
+ else {
+ return sign_in();
+ };
+ if auth
+ .get("expiry_date")
+ .and_then(Value::as_i64)
+ .is_some_and(|expiry_ms| expiry_ms < Utc::now().timestamp_millis() + 60_000)
+ {
+ return sign_in();
+ }
+ let project = client
+ .post("https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist")
+ .bearer_auth(token)
+ .header("Content-Type", "application/json")
+ .body(r#"{"metadata":{"ideType":"GEMINI_CLI","pluginType":"GEMINI"}}"#)
+ .send()
+ .ok()
+ .filter(|response| response.status().is_success())
+ .and_then(|response| response.text().ok())
+ .and_then(|body| serde_json::from_str::<Value>(&body).ok())
+ .and_then(|value| value.get("cloudaicompanionProject").cloned())
+ .and_then(|value| value.as_str().map(str::to_owned));
+ let body = project.map_or_else(
+ || "{}".to_owned(),
+ |project| serde_json::json!({"project": project}).to_string(),
+ );
+ let Ok(response) = client
+ .post("https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota")
+ .bearer_auth(token)
+ .header("Content-Type", "application/json")
+ .body(body)
+ .send()
+ else {
+ return unavailable();
+ };
+ if matches!(response.status().as_u16(), 401 | 403) {
+ return unavailable();
+ }
+ let Ok(body) = response
+ .error_for_status()
+ .and_then(|response| response.text())
+ else {
+ return unavailable();
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ return unavailable();
+ };
+ let windows = parse_gemini(&value);
+ if windows.is_empty() {
+ unavailable()
+ } else {
+ ready(windows)
+ }
+}
+
+fn fetch_antigravity() -> Option<ProviderUsage> {
+ let daemon = home()?.join(".gemini/antigravity/daemon");
+ let mut files = fs::read_dir(daemon)
+ .ok()?
+ .flatten()
+ .filter(|entry| {
+ entry
+ .file_name()
+ .to_str()
+ .is_some_and(|name| name.starts_with("hub_") && name.ends_with(".json"))
+ })
+ .filter_map(|entry| Some((entry.metadata().ok()?.modified().ok()?, entry.path())))
+ .collect::<Vec<_>>();
+ files.sort_unstable_by_key(|(modified, _)| std::cmp::Reverse(*modified));
+ let client = Client::builder()
+ .timeout(Duration::from_millis(700))
+ .danger_accept_invalid_certs(true)
+ .build()
+ .ok()?;
+ for (_, path) in files.into_iter().take(8) {
+ let Ok(contents) = fs::read(path) else {
+ continue;
+ };
+ let Ok(info) = serde_json::from_slice::<Value>(&contents) else {
+ continue;
+ };
+ let Some(token) = info.get("csrfToken").and_then(Value::as_str) else {
+ continue;
+ };
+ if token.is_empty() || token.len() > 512 {
+ continue;
+ }
+ for (scheme, port) in [
+ ("https", info.get("httpsPort").and_then(Value::as_u64)),
+ ("http", info.get("httpPort").and_then(Value::as_u64)),
+ ] {
+ let Some(port) = port.filter(|port| (1..=65535).contains(port)) else {
+ continue;
+ };
+ for method in [
+ "RetrieveUserQuotaSummary",
+ "GetUserStatus",
+ "GetCommandModelConfigs",
+ ] {
+ let endpoint = format!(
+ "{scheme}://127.0.0.1:{port}/exa.language_server_pb.LanguageServerService/{method}"
+ );
+ let Ok(response) = client
+ .post(endpoint)
+ .header("X-Codeium-Csrf-Token", token)
+ .header("Connect-Protocol-Version", "1")
+ .header("Content-Type", "application/json")
+ .body(r#"{"metadata":{"ideName":"antigravity","extensionName":"antigravity","locale":"en","ideVersion":"unknown"}}"#)
+ .send()
+ else {
+ continue;
+ };
+ let Ok(body) = response.error_for_status().and_then(|value| value.text()) else {
+ continue;
+ };
+ let Ok(value) = serde_json::from_str::<Value>(&body) else {
+ continue;
+ };
+ let windows = if method == "RetrieveUserQuotaSummary" {
+ parse_antigravity(&value)
+ } else {
+ parse_antigravity_legacy(&value)
+ };
+ if !windows.is_empty() {
+ return Some(ready(windows));
+ }
+ }
+ }
+ }
+ None
+}
+
+fn parse_antigravity(value: &Value) -> Vec<Window> {
+ let groups = value
+ .pointer("/response/groups")
+ .or_else(|| value.get("groups"))
+ .and_then(Value::as_array);
+ let Some(groups) = groups else {
+ return Vec::new();
+ };
+ let mut windows = Vec::new();
+ for group in groups {
+ let name = group
+ .get("displayName")
+ .and_then(Value::as_str)
+ .unwrap_or("");
+ if !name.to_ascii_lowercase().contains("gemini") {
+ continue;
+ }
+ let Some(buckets) = group.get("buckets").and_then(Value::as_array) else {
+ continue;
+ };
+ for bucket in buckets {
+ let id = bucket.get("bucketId").and_then(Value::as_str).unwrap_or("");
+ let cadence = bucket.get("window").and_then(Value::as_str).unwrap_or(id);
+ let minutes = match cadence.to_ascii_lowercase().as_str() {
+ "5h" | "gemini-5h" => 300,
+ "weekly" | "week" | "7d" | "gemini-weekly" => 10_080,
+ _ => continue,
+ };
+ let fraction = bucket
+ .pointer("/remaining/remainingFraction")
+ .or_else(|| bucket.get("remainingFraction"))
+ .and_then(Value::as_f64);
+ let Some(fraction) =
+ fraction.filter(|value| value.is_finite() && (0.0..=1.0).contains(value))
+ else {
+ continue;
+ };
+ let resets_at = bucket
+ .pointer("/remaining/resetTime")
+ .or_else(|| bucket.get("resetTime"))
+ .and_then(Value::as_str)
+ .and_then(|time| DateTime::parse_from_rfc3339(time).ok())
+ .map(|time| time.with_timezone(&Utc));
+ windows.push(Window {
+ label: None,
+ minutes,
+ used_percent: ((1.0 - fraction) * 100.0).round() as u8,
+ resets_at,
+ });
+ }
+ }
+ windows.sort_unstable_by_key(|window| window.minutes);
+ windows
+}
+
+fn parse_antigravity_legacy(value: &Value) -> Vec<Window> {
+ let configs = value
+ .pointer("/userStatus/cascadeModelConfigData/clientModelConfigs")
+ .or_else(|| value.get("clientModelConfigs"))
+ .and_then(Value::as_array);
+ let Some(configs) = configs else {
+ return Vec::new();
+ };
+ ["Pro", "Flash"]
+ .into_iter()
+ .filter_map(|family| {
+ let (_, model) = configs
+ .iter()
+ .filter(|model| {
+ let label = model
+ .get("label")
+ .or_else(|| model.get("displayName"))
+ .and_then(Value::as_str)
+ .unwrap_or("")
+ .to_ascii_lowercase();
+ label.contains("gemini")
+ && label.contains(&family.to_ascii_lowercase())
+ && !label.contains("lite")
+ && !label.contains("image")
+ })
+ .filter_map(|model| {
+ let fraction = model.pointer("/quotaInfo/remainingFraction")?.as_f64()?;
+ (fraction.is_finite() && (0.0..=1.0).contains(&fraction))
+ .then_some((fraction, model))
+ })
+ .min_by(|left, right| left.0.total_cmp(&right.0))?;
+ let fraction = model.pointer("/quotaInfo/remainingFraction")?.as_f64()?;
+ let resets_at = model
+ .pointer("/quotaInfo/resetTime")
+ .and_then(Value::as_str)
+ .and_then(|time| DateTime::parse_from_rfc3339(time).ok())
+ .map(|time| time.with_timezone(&Utc));
+ Some(Window {
+ label: Some(family.to_owned()),
+ minutes: 0,
+ used_percent: ((1.0 - fraction) * 100.0).round() as u8,
+ resets_at,
+ })
+ })
+ .collect()
+}
+
+fn parse_gemini(value: &Value) -> Vec<Window> {
+ let Some(buckets) = value.get("buckets").and_then(Value::as_array) else {
+ return Vec::new();
+ };
+ ["Pro", "Flash"]
+ .into_iter()
+ .filter_map(|family| {
+ let bucket = buckets
+ .iter()
+ .filter(|bucket| {
+ bucket
+ .get("modelId")
+ .and_then(Value::as_str)
+ .is_some_and(|model| {
+ let model = model.to_ascii_lowercase();
+ if family == "Pro" {
+ model.contains("pro")
+ } else {
+ model.contains("flash") && !model.contains("flash-lite")
+ }
+ })
+ })
+ .filter_map(|bucket| {
+ let remaining = bucket.get("remainingFraction")?.as_f64()?;
+ (remaining.is_finite() && (0.0..=1.0).contains(&remaining))
+ .then_some((remaining, bucket))
+ })
+ .min_by(|left, right| left.0.total_cmp(&right.0))?;
+ let resets_at = bucket
+ .1
+ .get("resetTime")
+ .and_then(Value::as_str)
+ .and_then(|time| DateTime::parse_from_rfc3339(time).ok())
+ .map(|time| time.with_timezone(&Utc));
+ Some(Window {
+ label: Some(family.to_owned()),
+ minutes: 0,
+ used_percent: ((1.0 - bucket.0) * 100.0).round() as u8,
+ resets_at,
+ })
+ })
+ .collect()
+}
+
+fn local_codex(root: &std::path::Path) -> Option<ProviderUsage> {
+ let mut recent = Vec::new();
+ let mut pending = vec![root.join("sessions"), root.join("archived_sessions")];
+ while let Some(folder) = pending.pop() {
+ let Ok(entries) = fs::read_dir(folder) else {
+ continue;
+ };
+ for entry in entries.flatten() {
+ let path = entry.path();
+ if path.is_dir() {
+ pending.push(path);
+ } else if path
+ .extension()
+ .is_some_and(|extension| extension == "jsonl")
+ {
+ let modified = entry
+ .metadata()
+ .ok()
+ .and_then(|metadata| metadata.modified().ok());
+ if let Some(modified) = modified {
+ recent.push((modified, path));
+ }
+ }
+ }
+ }
+ recent.sort_unstable_by_key(|entry| std::cmp::Reverse(entry.0));
+ for (_, path) in recent.into_iter().take(8) {
+ if let Some(snapshot) = scan_rollout(&path) {
+ return Some(snapshot);
+ }
+ }
+ None
+}
+
+fn scan_rollout(path: &std::path::Path) -> Option<ProviderUsage> {
+ let mut file = fs::File::open(path).ok()?;
+ let length = file.metadata().ok()?.len();
+ let start = length.saturating_sub(256 * 1024);
+ file.seek(SeekFrom::Start(start)).ok()?;
+ let mut tail = Vec::new();
+ file.read_to_end(&mut tail).ok()?;
+ let lines = tail.split(|byte| *byte == b'\n');
+ for line in lines.rev() {
+ if !line.windows(13).any(|part| part == b"\"rate_limits\"") {
+ continue;
+ }
+ let Ok(record) = serde_json::from_slice::<Value>(line) else {
+ continue;
+ };
+ if record.pointer("/payload/type").and_then(Value::as_str) != Some("token_count") {
+ continue;
+ }
+ let Some(limits) = record.pointer("/payload/rate_limits") else {
+ continue;
+ };
+ let windows = parse_local_codex(limits);
+ if windows.is_empty() {
+ continue;
+ }
+ let fetched_at = record
+ .get("timestamp")
+ .and_then(Value::as_str)
+ .and_then(|text| DateTime::parse_from_rfc3339(text).ok())
+ .and_then(|time| u64::try_from(time.timestamp()).ok())
+ .map(|seconds| UNIX_EPOCH + Duration::from_secs(seconds));
+ return Some(ProviderUsage {
+ state: State::Ready,
+ windows,
+ fetched_at,
+ });
+ }
+ None
+}
+
+fn parse_local_codex(limits: &Value) -> Vec<Window> {
+ ["primary", "secondary"]
+ .into_iter()
+ .filter_map(|key| {
+ let entry = limits.get(key)?;
+ let used_percent = percent(entry.get("used_percent")?)?;
+ let minutes = entry.get("window_minutes")?.as_i64()?;
+ let resets_at = entry
+ .get("resets_at")
+ .and_then(Value::as_i64)
+ .and_then(|seconds| DateTime::from_timestamp(seconds, 0));
+ Some(Window {
+ label: None,
+ minutes,
+ used_percent,
+ resets_at,
+ })
+ })
+ .collect()
+}
+
+fn percent(value: &Value) -> Option<u8> {
+ let number = value.as_f64()?;
+ (number.is_finite() && (0.0..=100.0).contains(&number)).then(|| number.round() as u8)
+}
+
+fn parse_claude(value: &Value) -> Vec<Window> {
+ [("five_hour", 300), ("seven_day", 10_080)]
+ .into_iter()
+ .filter_map(|(key, minutes)| {
+ let entry = value.get(key)?;
+ let used_percent = percent(entry.get("utilization")?)?;
+ let resets_at = entry
+ .get("resets_at")
+ .and_then(Value::as_str)
+ .and_then(|text| DateTime::parse_from_rfc3339(text).ok())
+ .map(|time| time.with_timezone(&Utc));
+ Some(Window {
+ label: None,
+ minutes,
+ used_percent,
+ resets_at,
+ })
+ })
+ .collect()
+}
+
+fn parse_codex(value: &Value) -> Vec<Window> {
+ ["primary_window", "secondary_window"]
+ .into_iter()
+ .filter_map(|key| {
+ let entry = value.get("rate_limit")?.get(key)?;
+ let used_percent = percent(entry.get("used_percent")?)?;
+ let minutes = entry.get("limit_window_seconds")?.as_i64()? / 60;
+ let resets_at = entry
+ .get("reset_at")
+ .and_then(Value::as_i64)
+ .and_then(|seconds| DateTime::from_timestamp(seconds, 0));
+ Some(Window {
+ label: None,
+ minutes,
+ used_percent,
+ resets_at,
+ })
+ })
+ .collect()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ #[test]
+ fn claude_missing_window_does_not_become_zero() {
+ let windows = parse_claude(
+ &json!({"five_hour": null, "seven_day": {"utilization": 24.6, "resets_at": "2026-11-16T13:00:00Z"}}),
+ );
+ assert_eq!(windows.len(), 1);
+ assert_eq!(windows[0].used_percent, 25);
+ }
+
+ #[test]
+ fn codex_weekly_only_primary_keeps_its_duration() {
+ let windows = parse_codex(
+ &json!({"rate_limit": {"primary_window": {"used_percent": 61, "limit_window_seconds": 604800, "reset_at": 1794834000}, "secondary_window": null}}),
+ );
+ assert_eq!(windows[0].title(), "7 d");
+ }
+
+ #[test]
+ fn invalid_percentage_is_ignored() {
+ let windows = parse_codex(
+ &json!({"rate_limit": {"primary_window": {"used_percent": 143, "limit_window_seconds": 18000}}}),
+ );
+ assert!(windows.is_empty());
+ }
+
+ #[test]
+ fn local_codex_weekly_window_is_classified_by_duration() {
+ let windows = parse_local_codex(
+ &json!({"primary": {"used_percent": 33, "window_minutes": 10080, "resets_at": 1794834000}}),
+ );
+ assert_eq!(windows[0].title(), "7 d");
+ }
+
+ #[test]
+ fn copilot_uses_remaining_quota_and_monthly_reset() {
+ let windows = parse_copilot(&json!({
+ "quota_reset_date": "2026-12-01",
+ "quota_snapshots": {
+ "premium_interactions": {"percent_remaining": 73},
+ "chat": {"unlimited": true}
+ }
+ }));
+ assert_eq!(windows.len(), 1);
+ assert_eq!(windows[0].used_percent, 27);
+ assert_eq!(windows[0].title(), "Premium");
+ assert!(windows[0].resets_at.is_some());
+ let camel = parse_copilot(&json!({"quotaSnapshots": {
+ "premiumInteractions": {"percentRemaining": 62}
+ }}));
+ assert_eq!(camel[0].used_percent, 38);
+ }
+
+ #[test]
+ fn github_session_parser_only_returns_tokens() {
+ let mut tokens = Vec::new();
+ collect_github_tokens(
+ &json!({"sessions": [
+ {"accessToken": "gho_test", "account": {"id": "private"}},
+ {"accessToken": "unrelated", "account": {"id": "private"}}
+ ]}),
+ &mut tokens,
+ );
+ assert_eq!(tokens, ["gho_test"]);
+ }
+
+ #[test]
+ fn cursor_rejects_expired_session_and_parses_billing_cycle() {
+ use base64::Engine;
+ let claims = json!({"sub": "auth0|abc123", "exp": 1});
+ let payload = base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(claims.to_string());
+ assert!(cursor_cookie(&format!("x.{payload}.y")).is_none());
+ let windows = parse_cursor(&json!({
+ "individualUsage": {"plan": {"totalPercentUsed": 45}},
+ "billingCycleStart": "2026-11-01T00:00:00Z",
+ "billingCycleEnd": "2026-12-01T00:00:00Z"
+ }));
+ assert_eq!(windows[0].used_percent, 45);
+ assert_eq!(windows[0].title(), "30 d");
+ assert!(windows[0].resets_at.is_some());
+ }
+
+ #[test]
+ fn opencode_ignores_unmeasured_lanes() {
+ let windows = parse_opencode(&json!({"usage": {
+ "rolling": {"percent": 19, "resetInSec": 1200},
+ "weekly": {"resetInSec": 6000},
+ "monthly": {"percent": 33}
+ }}));
+ assert_eq!(windows.len(), 2);
+ assert_eq!(windows[0].title(), "5 h");
+ assert!(windows[0].resets_at.is_some());
+ assert_eq!(windows[1].title(), "30 d");
+ }
+
+ #[test]
+ fn antigravity_only_reports_measured_gemini_buckets() {
+ let windows = parse_antigravity(&json!({"response": {"groups": [
+ {"displayName": "Gemini Models", "buckets": [
+ {"bucketId": "gemini-weekly", "window": "weekly", "remainingFraction": 0.75, "resetTime": "2026-11-20T00:00:00Z"},
+ {"bucketId": "gemini-5h", "window": "5h", "remaining": {"remainingFraction": 0.2, "resetTime": "2026-11-15T20:00:00Z"}},
+ {"bucketId": "gemini-missing", "window": "5h"}
+ ]},
+ {"displayName": "Claude and GPT models", "buckets": [
+ {"bucketId": "3p-5h", "window": "5h", "remainingFraction": 0.1}
+ ]}
+ ]}}));
+ assert_eq!(windows.len(), 2);
+ assert_eq!(windows[0].title(), "5 h");
+ assert_eq!(windows[0].used_percent, 80);
+ assert_eq!(windows[1].title(), "7 d");
+ assert_eq!(windows[1].used_percent, 25);
+ }
+
+ #[test]
+ fn antigravity_ide_uses_model_quota_without_inventing_cadence() {
+ let windows = parse_antigravity_legacy(&json!({"userStatus": {
+ "cascadeModelConfigData": {"clientModelConfigs": [
+ {"label": "Gemini 3 Pro (High)", "quotaInfo": {"remainingFraction": 0.4, "resetTime": "2026-11-16T02:00:00Z"}},
+ {"label": "Gemini 3 Flash", "quotaInfo": {"remainingFraction": 0.9}},
+ {"label": "Claude Sonnet", "quotaInfo": {"remainingFraction": 0.1}},
+ {"label": "Gemini 3 Flash Lite", "quotaInfo": {"remainingFraction": 0.05}}
+ ]}
+ }}));
+ assert_eq!(windows.len(), 2);
+ assert_eq!(windows[0].title(), "Pro");
+ assert_eq!(windows[0].used_percent, 60);
+ assert_eq!(windows[1].title(), "Flash");
+ assert_eq!(windows[1].used_percent, 10);
+ }
+
+ #[test]
+ fn gemini_cli_keeps_pro_and_flash_distinct() {
+ let windows = parse_gemini(&json!({"buckets": [
+ {"modelId": "gemini-3-pro", "remainingFraction": 0.4, "resetTime": "2026-11-16T00:00:00Z"},
+ {"modelId": "gemini-3-flash", "remainingFraction": 0.9},
+ {"modelId": "gemini-3-flash-lite", "remainingFraction": 0.1}
+ ]}));
+ assert_eq!(windows.len(), 2);
+ assert_eq!(windows[0].title(), "Pro");
+ assert_eq!(windows[0].used_percent, 60);
+ assert_eq!(windows[1].title(), "Flash");
+ assert_eq!(windows[1].used_percent, 10);
+ }
+}
diff --git a/apps/settings/src-tauri/capabilities/default.json b/apps/settings/src-tauri/capabilities/default.json
index 3932492..15bcf6d 100644
--- a/apps/settings/src-tauri/capabilities/default.json
+++ b/apps/settings/src-tauri/capabilities/default.json
@@ -7,6 +7,7 @@
"core:default",
"core:window:allow-close",
"core:window:allow-minimize",
+ "core:window:allow-toggle-maximize",
"core:window:allow-start-dragging"
]
}
diff --git a/apps/settings/src-tauri/gen/schemas/capabilities.json b/apps/settings/src-tauri/gen/schemas/capabilities.json
index e97ea5a..c37e696 100644
--- a/apps/settings/src-tauri/gen/schemas/capabilities.json
+++ b/apps/settings/src-tauri/gen/schemas/capabilities.json
@@ -1 +1 @@
-{"default":{"identifier":"default","description":"What the settings window may do.","local":true,"windows":["main"],"permissions":["core:default","core:window:allow-close","core:window:allow-minimize","core:window:allow-start-dragging"]}}
\ No newline at end of file
+{"default":{"identifier":"default","description":"What the settings window may do.","local":true,"windows":["main"],"permissions":["core:default","core:window:allow-close","core:window:allow-minimize","core:window:allow-toggle-maximize","core:window:allow-start-dragging"]}}
\ No newline at end of file
diff --git a/apps/settings/src-tauri/tauri.conf.json b/apps/settings/src-tauri/tauri.conf.json
index 1f1ccbf..f8be729 100644
--- a/apps/settings/src-tauri/tauri.conf.json
+++ b/apps/settings/src-tauri/tauri.conf.json
@@ -15,8 +15,10 @@
"title": "Muelle",
"width": 780,
"height": 560,
- "resizable": false,
- "maximizable": false,
+ "minWidth": 680,
+ "minHeight": 480,
+ "resizable": true,
+ "maximizable": true,
"decorations": false,
"transparent": true,
"shadow": true,
diff --git a/apps/settings/src/App.tsx b/apps/settings/src/App.tsx
index 34c6bcf..dcc1d58 100644
--- a/apps/settings/src/App.tsx
+++ b/apps/settings/src/App.tsx
@@ -3,7 +3,6 @@ import { listen } from "@tauri-apps/api/event";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { useCallback, useEffect, useRef, useState } from "react";
import {
- type ActiveAppClick,
type Config,
type Language,
type UpdateInfo,
@@ -19,11 +18,11 @@ import {
setAutostart,
} from "./config";
import { Card, Row, Segmented, Slider, SubRow, Toggle } from "./controls";
+import { type SectionId, SectionIcon } from "./icons";
import { UpdateBanner } from "./UpdateBanner";
import en from "./i18n/en.json";
import es from "./i18n/es.json";
-type Section = "dock" | "system";
type UpdateState =
| { kind: "off" }
| { kind: "checking" }
@@ -62,7 +61,7 @@ function textsFor(language: Language): Texts {
export function App() {
const [config, setConfig] = useState<Config | null>(null);
const [autostart, setAutostartState] = useState(false);
- const [section, setSection] = useState<Section>("dock");
+ const [section, setSection] = useState<SectionId>("dock");
const [failed, setFailed] = useState(false);
const [version, setVersion] = useState("");
const [updateState, setUpdateState] = useState<UpdateState>({ kind: "checking" });
@@ -190,26 +189,31 @@ export function App() {
aria-label={t.minimize}
onClick={() => appWindow.minimize()}
/>
- <span className="light light-idle" />
+ <button
+ type="button"
+ className="light light-zoom"
+ aria-label={t.zoom}
+ onClick={() => appWindow.toggleMaximize()}
+ />
</div>
<nav>
- <NavItem active={section === "dock"} onSelect={() => setSection("dock")} glyph="▭">
- {t.dock}
- </NavItem>
- <NavItem
- active={section === "system"}
- onSelect={() => setSection("system")}
- glyph="⚙"
- badge={waiting ? t.updateBadge : undefined}
- >
- {t.system}
- </NavItem>
+ {SECTIONS.map((id) => (
+ <NavItem
+ key={id}
+ section={id}
+ active={section === id}
+ onSelect={() => setSection(id)}
+ badge={id === "system" && waiting ? t.updateBadge : undefined}
+ >
+ {sectionTitle(t, id)}
+ </NavItem>
+ ))}
</nav>
</aside>
<main className="content">
<header className="content-title" data-tauri-drag-region>
- {section === "dock" ? t.dock : t.system}
+ {sectionTitle(t, section)}
</header>
{showBanner && waiting ? (
<UpdateBanner
@@ -257,7 +261,7 @@ export function App() {
/>
</SubRow>
</Card>
- <Card>
+ <Card title={t.groupBehavior}>
<Row label={t.autoHide} hint={t.autoHideHint}>
<Toggle
label={t.autoHide}
@@ -265,33 +269,13 @@ export function App() {
onChange={(autoHide) => update({ autoHide })}
/>
</Row>
- <Row label={t.menuBar} hint={t.menuBarHint}>
- <Toggle
- label={t.menuBar}
- checked={config.menuBar}
- onChange={(menuBar) => update({ menuBar })}
- />
- </Row>
- <SubRow
- label={t.menuBarAutoHide}
- hint={t.menuBarAutoHideHint}
- open={config.menuBar}
- >
- <Toggle
- label={t.menuBarAutoHide}
- checked={config.menuBarAutoHide}
- onChange={(menuBarAutoHide) => update({ menuBarAutoHide })}
- />
- </SubRow>
- <Row label={t.genie} hint={t.genieHint}>
+ <Row label={t.bounceOnOpen}>
<Toggle
- label={t.genie}
- checked={config.genie}
- onChange={(genie) => update({ genie })}
+ label={t.bounceOnOpen}
+ checked={config.bounceOnOpen}
+ onChange={(bounceOnOpen) => update({ bounceOnOpen })}
/>
</Row>
- </Card>
- <Card>
<Row label={t.showIndicators}>
<Toggle
label={t.showIndicators}
@@ -306,81 +290,106 @@ export function App() {
onChange={(showRecents) => update({ showRecents })}
/>
</Row>
- <Row label={t.bounceOnOpen}>
+ </Card>
+ </>
+ ) : section === "windows" ? (
+ <>
+ <Card title={t.groupMinimize}>
+ <Row label={t.genie} hint={t.genieHint}>
<Toggle
- label={t.bounceOnOpen}
- checked={config.bounceOnOpen}
- onChange={(bounceOnOpen) => update({ bounceOnOpen })}
+ label={t.genie}
+ checked={config.genie}
+ onChange={(genie) => update({ genie })}
/>
</Row>
- <Row label={t.activeAppClick} hint={t.activeAppClickHint}>
- <Segmented<ActiveAppClick>
- label={t.activeAppClick}
- value={config.activeAppClick}
- options={[
- { value: "minimize", label: t.activeAppMinimize },
- { value: "nothing", label: t.activeAppNothing },
- ]}
- onChange={(activeAppClick) => update({ activeAppClick })}
+ <Row label={t.showMinimized} hint={t.showMinimizedHint}>
+ <Toggle
+ label={t.showMinimized}
+ checked={config.showMinimized}
+ onChange={(showMinimized) => update({ showMinimized })}
/>
</Row>
</Card>
</>
- ) : (
- <>
+ ) : section === "menubar" ? (
<Card>
- <Row label={t.autostart}>
- <Toggle label={t.autostart} checked={autostart} onChange={changeAutostart} />
- </Row>
- <Row label={t.language}>
- <Segmented<Language>
- label={t.language}
- value={config.language}
- options={[
- { value: "auto", label: t.languageAuto },
- { value: "es", label: "Español" },
- { value: "en", label: "English" },
- ]}
- onChange={(language) => update({ language })}
+ <Row label={t.menuBarShow} hint={t.menuBarHint}>
+ <Toggle
+ label={t.menuBarShow}
+ checked={config.menuBar}
+ onChange={(menuBar) => update({ menuBar })}
/>
</Row>
- </Card>
- <Card>
- <Row label={t.checkUpdates} hint={t.checkUpdatesHint}>
+ <SubRow label={t.menuBarAutoHide} hint={t.menuBarAutoHideHint} open={config.menuBar}>
<Toggle
- label={t.checkUpdates}
- checked={config.checkUpdates}
- onChange={(checkUpdates) => update({ checkUpdates })}
+ label={t.menuBarAutoHide}
+ checked={config.menuBarAutoHide}
+ onChange={(menuBarAutoHide) => update({ menuBarAutoHide })}
/>
- </Row>
- <Row label={t.updates} hint={updateHint(t, updateState, version)}>
- {waiting && updateState.kind !== "installing" ? (
- <button type="button" className="push push-primary" onClick={() => install(waiting)}>
- {t.updatesInstall}
- </button>
- ) : (
+ </SubRow>
+ <SubRow label={t.aiUsage} hint={t.aiUsageHint} open={config.menuBar}>
+ <Toggle
+ label={t.aiUsage}
+ checked={config.aiUsage}
+ onChange={(aiUsage) => update({ aiUsage })}
+ />
+ </SubRow>
+ </Card>
+ ) : (
+ <>
+ <Card>
+ <Row label={t.autostart}>
+ <Toggle label={t.autostart} checked={autostart} onChange={changeAutostart} />
+ </Row>
+ <Row label={t.language}>
+ <Segmented<Language>
+ label={t.language}
+ value={config.language}
+ options={[
+ { value: "auto", label: t.languageAuto },
+ { value: "es", label: "Español" },
+ { value: "en", label: "English" },
+ ]}
+ onChange={(language) => update({ language })}
+ />
+ </Row>
+ </Card>
+ <Card title={t.updates}>
+ <Row label={t.checkUpdates} hint={t.checkUpdatesHint}>
+ <Toggle
+ label={t.checkUpdates}
+ checked={config.checkUpdates}
+ onChange={(checkUpdates) => update({ checkUpdates })}
+ />
+ </Row>
+ <Row label={t.updatesNow} hint={updateHint(t, updateState, version)}>
+ {waiting && updateState.kind !== "installing" ? (
+ <button type="button" className="push push-primary" onClick={() => install(waiting)}>
+ {t.updatesInstall}
+ </button>
+ ) : (
+ <button
+ type="button"
+ className="push"
+ disabled={updateState.kind === "checking" || updateState.kind === "installing"}
+ onClick={recheck}
+ >
+ {t.updatesCheck}
+ </button>
+ )}
+ </Row>
+ </Card>
+ <Card>
+ <Row label={t.reset} hint={confirmingReset ? t.resetConfirmHint : t.resetHint}>
<button
type="button"
- className="push"
- disabled={updateState.kind === "checking" || updateState.kind === "installing"}
- onClick={recheck}
+ className={confirmingReset ? "push push-danger" : "push"}
+ onClick={reset}
>
- {t.updatesCheck}
+ {confirmingReset ? t.resetConfirm : t.resetButton}
</button>
- )}
- </Row>
- </Card>
- <Card>
- <Row label={t.reset} hint={confirmingReset ? t.resetConfirmHint : t.resetHint}>
- <button
- type="button"
- className={confirmingReset ? "push push-danger" : "push"}
- onClick={reset}
- >
- {confirmingReset ? t.resetConfirm : t.resetButton}
- </button>
- </Row>
- </Card>
+ </Row>
+ </Card>
</>
)}
{failed ? (
@@ -413,16 +422,31 @@ function updateHint(t: Texts, state: UpdateState, version: string): string {
}
}
+const SECTIONS: readonly SectionId[] = ["dock", "windows", "menubar", "system"];
+
+function sectionTitle(t: Texts, section: SectionId): string {
+ switch (section) {
+ case "dock":
+ return t.dock;
+ case "windows":
+ return t.windows;
+ case "menubar":
+ return t.menuBar;
+ case "system":
+ return t.system;
+ }
+}
+
interface NavItemProps {
+ section: SectionId;
active: boolean;
- glyph: string;
onSelect: () => void;
/** Accessible text of a red badge, as macOS shows for a pending update. */
badge?: string;
children: string;
}
-function NavItem({ active, glyph, onSelect, badge, children }: NavItemProps) {
+function NavItem({ section, active, onSelect, badge, children }: NavItemProps) {
return (
<button
type="button"
@@ -430,9 +454,7 @@ function NavItem({ active, glyph, onSelect, badge, children }: NavItemProps) {
aria-current={active ? "page" : undefined}
onClick={onSelect}
>
- <span className="nav-glyph" aria-hidden="true">
- {glyph}
- </span>
+ <SectionIcon section={section} />
{children}
{badge ? (
<span className="nav-badge" role="img" aria-label={badge}>
diff --git a/apps/settings/src/config.ts b/apps/settings/src/config.ts
index 97833a0..96807c7 100644
--- a/apps/settings/src/config.ts
+++ b/apps/settings/src/config.ts
@@ -1,7 +1,6 @@
import { invoke } from "@tauri-apps/api/core";
export type Language = "auto" | "es" | "en";
-export type ActiveAppClick = "minimize" | "nothing";
/** Mirrors `muelle_config::Config`. */
export interface Config {
@@ -13,9 +12,10 @@ export interface Config {
magnification: boolean;
magnifiedSize: number;
genie: boolean;
+ showMinimized: boolean;
menuBar: boolean;
menuBarAutoHide: boolean;
- activeAppClick: ActiveAppClick;
+ aiUsage: boolean;
showIndicators: boolean;
showRecents: boolean;
bounceOnOpen: boolean;
diff --git a/apps/settings/src/controls.tsx b/apps/settings/src/controls.tsx
index 7736a43..b07356c 100644
--- a/apps/settings/src/controls.tsx
+++ b/apps/settings/src/controls.tsx
@@ -1,7 +1,19 @@
import type { ReactNode } from "react";
-export function Card({ children }: { children: ReactNode }) {
- return <section className="card">{children}</section>;
+interface CardProps {
+ /** Heading above the group, as macOS System Settings labels its groups. */
+ title?: string;
+ children: ReactNode;
+}
+
+export function Card({ title, children }: CardProps) {
+ if (!title) return <section className="card">{children}</section>;
+ return (
+ <section className="card-group" aria-label={title}>
+ <h2 className="card-title">{title}</h2>
+ <div className="card">{children}</div>
+ </section>
+ );
}
interface RowProps {
diff --git a/apps/settings/src/i18n/en.json b/apps/settings/src/i18n/en.json
index 753f37f..95477ac 100644
--- a/apps/settings/src/i18n/en.json
+++ b/apps/settings/src/i18n/en.json
@@ -9,12 +9,16 @@
"magnifiedSize": "Magnified size",
"autoHide": "Automatically hide and show the Dock",
"autoHideHint": "It reappears when you touch the bottom edge of the screen.",
- "genie": "Genie effect when minimizing",
+ "genie": "Genie effect",
"genieHint": "While it is on, windows do not use the Windows animations for maximizing or closing.",
+ "showMinimized": "Show minimized windows",
+ "showMinimizedHint": "As thumbnails on the right side of the Dock, instead of inside their app's icon.",
"menuBar": "Menu bar",
"menuBarHint": "Time, battery, and access to the Windows quick settings and notifications.",
"menuBarAutoHide": "Automatically hide and show the menu bar",
"menuBarAutoHideHint": "It reappears when you touch the top edge of the screen.",
+ "aiUsage": "Show AI provider usage",
+ "aiUsageHint": "Reads your existing sessions. Queries each provider directly every five minutes and does not save credentials.",
"autostart": "Open Muelle at login",
"language": "Language",
"languageAuto": "Automatic",
@@ -22,7 +26,7 @@
"minimize": "Minimize",
"saveError": "The settings could not be saved.",
"checkUpdates": "Check for updates automatically",
- "checkUpdatesHint": "When Settings opens, it asks GitHub whether there is a newer version. It sends nothing else.",
+ "checkUpdatesHint": "When Settings opens, it asks GitHub whether there is a newer version.",
"updatesOff": "Automatic checks are off.",
"updates": "Updates",
"updatesChecking": "Checking for updates…",
@@ -36,10 +40,6 @@
"showRecents": "Show recent apps",
"showRecentsHint": "The last three you opened that are not pinned.",
"bounceOnOpen": "Animate opening apps",
- "activeAppClick": "Clicking the active app",
- "activeAppClickHint": "Minimize is what the Windows taskbar does; do nothing is what macOS does.",
- "activeAppMinimize": "Minimize",
- "activeAppNothing": "Do nothing",
"reset": "Restore defaults",
"resetHint": "Back to the out-of-the-box look and behavior. Your pinned apps stay.",
"resetConfirmHint": "Click again to confirm.",
@@ -54,5 +54,11 @@
"updateDownloading": "Downloading… {percent}%",
"updateDownloadingUnknown": "Downloading…",
"updateInstallError": "The update could not be installed. Check your connection and try again.",
- "updateBadge": "Update available"
+ "updateBadge": "Update available",
+ "windows": "Windows",
+ "menuBarShow": "Show the menu bar",
+ "groupBehavior": "Behavior",
+ "groupMinimize": "Minimizing",
+ "zoom": "Zoom",
+ "updatesNow": "This version"
}
diff --git a/apps/settings/src/i18n/es.json b/apps/settings/src/i18n/es.json
index 08984a0..dcaa8a3 100644
--- a/apps/settings/src/i18n/es.json
+++ b/apps/settings/src/i18n/es.json
@@ -9,12 +9,16 @@
"magnifiedSize": "Tamaño ampliado",
"autoHide": "Ocultar y mostrar el Dock automáticamente",
"autoHideHint": "Reaparece al tocar el borde inferior de la pantalla.",
- "genie": "Efecto genio al minimizar",
+ "genie": "Efecto genio",
"genieHint": "Mientras está activo, las ventanas no usan las animaciones de Windows al maximizar ni al cerrar.",
+ "showMinimized": "Mostrar ventanas minimizadas",
+ "showMinimizedHint": "Como miniaturas a la derecha del Dock, en lugar de dentro del icono de su app.",
"menuBar": "Barra superior",
"menuBarHint": "Hora, batería y acceso a los ajustes rápidos y las notificaciones de Windows.",
"menuBarAutoHide": "Ocultar y mostrar la barra superior automáticamente",
"menuBarAutoHideHint": "Reaparece al tocar el borde superior de la pantalla.",
+ "aiUsage": "Mostrar uso de proveedores de IA",
+ "aiUsageHint": "Lee la cuota de las sesiones que ya tienes abiertas. Consulta directamente a cada proveedor cada cinco minutos y no guarda credenciales.",
"autostart": "Abrir Muelle al iniciar sesión",
"language": "Idioma",
"languageAuto": "Automático",
@@ -22,7 +26,7 @@
"minimize": "Minimizar",
"saveError": "No se pudieron guardar los ajustes.",
"checkUpdates": "Buscar actualizaciones automáticamente",
- "checkUpdatesHint": "Al abrir Ajustes, pregunta a GitHub si hay una versión nueva. No envía nada más.",
+ "checkUpdatesHint": "Al abrir Ajustes, pregunta a GitHub si hay una versión nueva.",
"updatesOff": "La búsqueda automática está desactivada.",
"updates": "Actualizaciones",
"updatesChecking": "Buscando actualizaciones…",
@@ -36,10 +40,6 @@
"showRecents": "Mostrar apps recientes",
"showRecentsHint": "Las tres últimas que abriste sin tenerlas fijadas.",
"bounceOnOpen": "Animar al abrir apps",
- "activeAppClick": "Al hacer clic en la app activa",
- "activeAppClickHint": "Minimizar es lo que hace la barra de tareas de Windows; no hacer nada, lo que hace macOS.",
- "activeAppMinimize": "Minimizar",
- "activeAppNothing": "No hacer nada",
"reset": "Restablecer valores",
"resetHint": "Vuelve al aspecto y comportamiento de fábrica. Tus apps fijadas se mantienen.",
"resetConfirmHint": "Pulsa otra vez para confirmar.",
@@ -54,5 +54,11 @@
"updateDownloading": "Descargando… {percent} %",
"updateDownloadingUnknown": "Descargando…",
"updateInstallError": "No se pudo instalar la actualización. Revisa la conexión e inténtalo de nuevo.",
- "updateBadge": "Actualización disponible"
+ "updateBadge": "Actualización disponible",
+ "windows": "Ventanas",
+ "menuBarShow": "Mostrar la barra superior",
+ "groupBehavior": "Comportamiento",
+ "groupMinimize": "Al minimizar",
+ "zoom": "Ampliar",
+ "updatesNow": "Esta versión"
}
diff --git a/apps/settings/src/icons.tsx b/apps/settings/src/icons.tsx
new file mode 100644
index 0000000..8b10062
--- /dev/null
+++ b/apps/settings/src/icons.tsx
@@ -0,0 +1,70 @@
+/**
+ * Sidebar icons in the style of macOS System Settings: a white glyph on a
+ * rounded tile of the section's colour. Static markup, so it lives outside
+ * the components that use it.
+ */
+
+import type { ReactNode } from "react";
+
+export type SectionId = "dock" | "windows" | "menubar" | "system";
+
+const TILES: Record<SectionId, [string, string]> = {
+ dock: ["#4aa3ff", "#0a6cf0"],
+ windows: ["#b57bff", "#7d3ff0"],
+ menubar: ["#ff9f45", "#f0640a"],
+ system: ["#a1a1a6", "#6e6e73"],
+};
+
+const GLYPHS: Record<SectionId, ReactNode> = {
+ // A dock: three icons on a shelf.
+ dock: (
+ <>
+ <rect x="4" y="14.5" width="16" height="5" rx="1.6" fill="#fff" opacity="0.55" />
+ <rect x="6" y="10.5" width="3.4" height="3.4" rx="0.9" fill="#fff" />
+ <rect x="10.3" y="10.5" width="3.4" height="3.4" rx="0.9" fill="#fff" />
+ <rect x="14.6" y="10.5" width="3.4" height="3.4" rx="0.9" fill="#fff" />
+ </>
+ ),
+ // Two overlapping windows.
+ windows: (
+ <>
+ <rect x="4.5" y="5.5" width="11" height="8.5" rx="1.4" fill="#fff" opacity="0.55" />
+ <rect x="8.5" y="9.5" width="11" height="9" rx="1.4" fill="#fff" />
+ <rect x="8.5" y="9.5" width="11" height="2.2" rx="1" fill="#000" opacity="0.18" />
+ </>
+ ),
+ // A bar across the top of a screen.
+ menubar: (
+ <>
+ <rect x="4" y="5" width="16" height="14" rx="2" fill="#fff" opacity="0.55" />
+ <rect x="4" y="5" width="16" height="3.6" rx="1.6" fill="#fff" />
+ <circle cx="16.8" cy="6.8" r="0.9" fill="#f0640a" />
+ </>
+ ),
+ // A gear.
+ system: (
+ <path
+ fill="#fff"
+ fillRule="evenodd"
+ d="M10.6 3.5h2.8l.4 2.1c.5.2 1 .4 1.4.8l2-.8 1.4 2.4-1.6 1.4a6 6 0 0 1 0 1.6l1.6 1.4-1.4 2.4-2-.8c-.4.3-.9.6-1.4.8l-.4 2.1h-2.8l-.4-2.1c-.5-.2-1-.5-1.4-.8l-2 .8-1.4-2.4 1.6-1.4a6 6 0 0 1 0-1.6L5.4 8l1.4-2.4 2 .8c.4-.4.9-.6 1.4-.8zM12 9.4a2.6 2.6 0 1 0 0 5.2 2.6 2.6 0 0 0 0-5.2z"
+ transform="translate(0 0.5)"
+ />
+ ),
+};
+
+export function SectionIcon({ section }: { section: SectionId }) {
+ const [top, bottom] = TILES[section];
+ const gradient = `tile-${section}`;
+ return (
+ <svg className="nav-icon" viewBox="0 0 24 24" width="22" height="22" aria-hidden="true">
+ <defs>
+ <linearGradient id={gradient} x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor={top} />
+ <stop offset="1" stopColor={bottom} />
+ </linearGradient>
+ </defs>
+ <rect width="24" height="24" rx="5.5" fill={`url(#${gradient})`} />
+ {GLYPHS[section]}
+ </svg>
+ );
+}
diff --git a/apps/settings/src/styles.css b/apps/settings/src/styles.css
index d69508c..34e9112 100644
--- a/apps/settings/src/styles.css
+++ b/apps/settings/src/styles.css
@@ -94,8 +94,8 @@ input:focus-visible {
background: #febc2e;
}
-.light-idle {
- background: var(--track);
+.light-zoom {
+ background: #28c840;
}
.nav-item {
@@ -117,14 +117,25 @@ input:focus-visible {
color: #fff;
}
-.nav-glyph {
- display: grid;
- place-items: center;
- width: 22px;
- height: 22px;
- border-radius: 6px;
- background: rgba(127, 127, 127, 0.25);
+.nav-icon {
+ flex: none;
+ filter: drop-shadow(0 0.5px 0.5px rgba(0, 0, 0, 0.18));
+}
+
+/* A titled group: the heading sits above its card, as in macOS. */
+.card-group {
+ margin-bottom: 16px;
+}
+
+.card-group .card {
+ margin-bottom: 0;
+}
+
+.card-title {
+ margin: 0 0 6px 4px;
font-size: 12px;
+ font-weight: 600;
+ color: var(--text-dim);
}
.content {
diff --git a/assets/usage/claude.png b/assets/usage/claude.png
new file mode 100644
index 0000000..66d92cd
Binary files /dev/null and b/assets/usage/claude.png differ
diff --git a/assets/usage/claude.svg b/assets/usage/claude.svg
new file mode 100644
index 0000000..218ce55
--- /dev/null
+++ b/assets/usage/claude.svg
@@ -0,0 +1,3 @@
+<?xml version='1.0' encoding='utf-8'?>
+<ns0:svg xmlns:ns0="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"><ns0:path fill="#d97757" d="m25.144 85.096 25.159-14.118.421-1.23-.421-.68h-1.23l-4.21-.26-14.377-.388-12.466-.518-12.078-.648-3.044-.648-2.85-3.755.292-1.879 2.558-1.716 3.659.324 8.095.55 12.143.842 8.807.519 13.05 1.36h2.072l.292-.842-.713-.518-.55-.519-12.564-8.516-13.6-9.002-7.123-5.18-3.853-2.623-1.943-2.461-.842-5.375 3.497-3.853 4.695.323 1.198.324 4.76 3.659 10.168 7.869 13.276 9.779 1.943 1.619.777-.55.097-.39-.875-1.457-7.22-13.049-7.707-13.276-3.432-5.504-.907-3.304c-.323-1.36-.55-2.492-.55-3.885L33.53.712 35.73 0l5.311.713 2.235 1.942 3.302 7.545 5.343 11.884 8.29 16.158 2.428 4.792 1.295 4.436.486 1.36h.842v-.777l.68-9.099 1.263-11.172 1.23-14.377.421-4.047L70.864 4.5l3.983-2.623 3.109 1.49 2.558 3.658-.356 2.364-1.522 9.876-2.979 15.478-1.943 10.362h1.133l1.296-1.295 5.245-6.962 8.808-11.01 3.886-4.37 4.533-4.825 2.914-2.3h5.505l4.047 6.023-1.813 6.218-5.666 7.188-4.696 6.087-6.735 9.067-4.21 7.253.39.583 1.003-.097 15.219-3.238 8.224-1.49 9.811-1.683 4.437 2.072.485 2.105-1.748 4.306-10.491 2.59-12.305 2.461-18.328 4.34-.226.162.259.323 8.257.778 3.53.194h8.645l16.093 1.198 4.21 2.784 2.525 3.4-.421 2.59-6.476 3.304-8.743-2.073-20.4-4.857-6.993-1.749h-.972v.583l5.829 5.7 10.685 9.649 13.373 12.434.68 3.076-1.716 2.429-1.813-.26-11.754-8.84-4.534-3.982-10.264-8.646h-.68v.907l2.364 3.465 12.499 18.78.647 5.764-.906 1.878-3.238 1.133-3.562-.647-7.318-10.265-7.545-11.56-6.087-10.361-.745.421-3.595 38.694-1.683 1.975-3.886 1.49-3.238-2.46-1.716-3.984 1.716-7.868 2.072-10.265 1.684-8.16 1.522-10.135.906-3.368-.064-.226-.745.097-7.642 10.492-11.624 15.704-9.197 9.843-2.201.875-3.82-1.976.355-3.53 2.137-3.14 12.726-16.19 7.674-10.038 4.954-5.796-.033-.842h-.29L22.066 98.987l-6.023.777-2.59-2.429.324-3.982 1.23-1.296 10.168-6.994Z" />
+ </ns0:svg>
\ No newline at end of file
diff --git a/assets/usage/codex.png b/assets/usage/codex.png
new file mode 100644
index 0000000..713222d
Binary files /dev/null and b/assets/usage/codex.png differ
diff --git a/assets/usage/codex.svg b/assets/usage/codex.svg
new file mode 100644
index 0000000..1443001
--- /dev/null
+++ b/assets/usage/codex.svg
@@ -0,0 +1,3 @@
+<?xml version='1.0' encoding='utf-8'?>
+<ns0:svg xmlns:ns0="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 24 24"><ns0:path fill="#f5f7fa" fill-rule="evenodd" d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.8.8 0 0 0-.856 0zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.43.43 0 0 1 .476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142a.45.45 0 0 1-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.48 4.48 0 0 1 4.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.43.43 0 0 1-.476 0m-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71a.79.79 0 0 0 .856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523m5.899 2.83a5.95 5.95 0 0 0 5.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947a5.7 5.7 0 0 0-1.88.31A5.96 5.96 0 0 0 10.205 0a5.95 5.95 0 0 0-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 0 0 4.162 1.713z" />
+ </ns0:svg>
\ No newline at end of file
diff --git a/assets/usage/copilot.png b/assets/usage/copilot.png
new file mode 100644
index 0000000..c7ff5db
Binary files /dev/null and b/assets/usage/copilot.png differ
diff --git a/assets/usage/copilot.svg b/assets/usage/copilot.svg
new file mode 100644
index 0000000..d369efe
--- /dev/null
+++ b/assets/usage/copilot.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 16 16">
+ <path fill="#f5f7fa" fill-rule="evenodd" d="M7.06 9.66v1.41c0 .39-.31.7-.7.7s-.7-.31-.7-.7V9.66c0-.39.31-.7.7-.7s.7.31.7.7m2.58-.7c-.39 0-.7.31-.7.7v1.41c0 .39.31.7.7.7s.7-.31.7-.7V9.66c0-.39-.31-.7-.7-.7m5.86.31v1.76c0 .72-3.14 3.56-7.5 3.56S.62 11.85.5 11.06V9.23c.08-.59.63-1.58 1.49-1.94c.01-.07.02-.13.03-.21c.03-.17.06-.36.12-.57c-.19-.48-.24-1.02-.24-1.55c0-.82.12-1.66.65-2.33c.54-.69 1.4-1.05 2.55-1.18c1.13-.13 2.12.03 2.76.72c.05.05.09.1.13.15c.04-.05.09-.11.13-.15c.64-.69 1.63-.84 2.76-.72c1.15.13 2.01.5 2.55 1.18c.53.67.65 1.51.65 2.33c0 .54-.05 1.08-.24 1.55c.06.21.09.4.12.57l.03.21c.87.36 1.43 1.38 1.49 1.96zM3.31 4.97c0 .74.12 1.1.29 1.29c.15.17.49.36 1.35.36c.8 0 1.26-.22 1.54-.51c.3-.3.49-.78.58-1.46c.11-.88-.03-1.31-.23-1.51c-.18-.19-.6-.39-1.58-.28c-.96.11-1.39.38-1.61.66c-.23.29-.35.74-.35 1.46zm9.38 2.88l-.02-.11c-.46.2-1.01.27-1.62.27c-1.07 0-1.93-.31-2.54-.93c-.2-.21-.37-.44-.51-.7c-.14.25-.31.49-.51.7c-.61.62-1.47.93-2.54.93c-.61 0-1.16-.08-1.62-.27l-.02.11v3.99c.39.3 2.55 1.34 4.69 1.34s4.3-1.04 4.69-1.34zm0-2.88c0-.72-.12-1.16-.35-1.46c-.22-.28-.65-.55-1.61-.66c-.98-.11-1.39.09-1.58.28c-.19.21-.34.64-.23 1.51c.09.68.28 1.15.58 1.46c.28.29.73.51 1.54.51c.86 0 1.2-.19 1.35-.36c.17-.19.29-.54.29-1.29z" clip-rule="evenodd"/>
+</svg>
diff --git a/assets/usage/cursor.png b/assets/usage/cursor.png
new file mode 100644
index 0000000..d178288
Binary files /dev/null and b/assets/usage/cursor.png differ
diff --git a/assets/usage/cursor.svg b/assets/usage/cursor.svg
new file mode 100644
index 0000000..a7c96a5
--- /dev/null
+++ b/assets/usage/cursor.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 24 24">
+ <path fill="#f5f7fa" d="m20.42 6.73l-8-4.62a.82.82 0 0 0-.83 0L3.58 6.73c-.22.12-.35.36-.35.61v9.32c0 .25.13.48.35.61l8.01 4.62c.26.15.57.15.83 0l8.01-4.62c.22-.12.35-.36.35-.61V7.34c0-.25-.13-.48-.35-.61Zm-.5.98L12.19 21.1c-.05.09-.19.05-.19-.05v-8.77c0-.18-.09-.34-.25-.43L4.16 7.47c-.09-.05-.05-.19.05-.19h15.46c.22 0 .36.24.25.43"/>
+</svg>
diff --git a/assets/usage/gemini.png b/assets/usage/gemini.png
new file mode 100644
index 0000000..01bdba4
Binary files /dev/null and b/assets/usage/gemini.png differ
diff --git a/assets/usage/gemini.svg b/assets/usage/gemini.svg
new file mode 100644
index 0000000..316f89f
--- /dev/null
+++ b/assets/usage/gemini.svg
@@ -0,0 +1,99 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256">
+ <path d="M0 0h256v256H0z" fill="none" />
+ <defs>
+ <filter id="SVGqoIxVV2h" width="39.274" height="43.217" x="-19.824" y="13.152" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="2.46" />
+ </filter>
+ <filter id="SVGOahAkcjC" width="84.868" height="85.688" x="-15.001" y="-40.257" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="11.891" />
+ </filter>
+ <filter id="SVGyT4fLePl" width="79.454" height="90.917" x="-20.776" y="11.927" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="10.109" />
+ </filter>
+ <filter id="SVGonSETbRF" width="79.731" height="81.505" x="-19.845" y="15.459" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="10.109" />
+ </filter>
+ <filter id="SVGSN7ofz6B" width="75.117" height="73.758" x="29.832" y="-11.552" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="9.606" />
+ </filter>
+ <filter id="SVGHvbpPvOn" width="78.135" height="78.758" x="-38.583" y="-16.253" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="8.706" />
+ </filter>
+ <filter id="SVG7JmfweRd" width="78.877" height="77.539" x="8.107" y="-5.966" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="7.775" />
+ </filter>
+ <filter id="SVGgGkiybCN" width="56.272" height="51.81" x="13.587" y="-18.488" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="6.957" />
+ </filter>
+ <filter id="SVGxEY6lcrm" width="70.856" height="69.306" x="-15.526" y="-31.297" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="5.876" />
+ </filter>
+ <filter id="SVGMZLCp0yD" width="55.502" height="51.571" x="-14.168" y="20.964" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
+ <feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
+ <feGaussianBlur result="effect1_foregroundBlur_10859_4895" stdDeviation="7.273" />
+ </filter>
+ <linearGradient id="SVG1oAMmOOu" x1="18.447" x2="52.153" y1="43.42" y2="15.004" gradientUnits="userSpaceOnUse">
+ <stop stop-color="#4893fc" />
+ <stop offset=".27" stop-color="#4893fc" />
+ <stop offset=".777" stop-color="#969dff" />
+ <stop offset="1" stop-color="#bd99fe" />
+ </linearGradient>
+ </defs>
+ <path fill="#fff" d="M228.265 114.441c-19.721-8.49-36.974-20.134-51.776-34.927c-14.792-14.789-26.436-32.056-34.93-51.779a154 154 0 0 1-7.884-23.295A5.86 5.86 0 0 0 127.999 0a5.86 5.86 0 0 0-5.674 4.44a154 154 0 0 1-7.882 23.295c-8.494 19.723-20.141 36.99-34.929 51.779c-14.794 14.793-32.058 26.437-51.779 34.927a154 154 0 0 1-23.297 7.889A5.855 5.855 0 0 0 0 127.999a5.86 5.86 0 0 0 4.438 5.678a154 154 0 0 1 23.297 7.886c19.721 8.49 36.978 20.139 51.779 34.93c14.795 14.789 26.435 32.055 34.929 51.774a154 154 0 0 1 7.882 23.297a5.854 5.854 0 0 0 5.674 4.436a5.85 5.85 0 0 0 5.676-4.436a154 154 0 0 1 7.884-23.297q12.742-29.58 34.93-51.774c14.793-14.791 32.055-26.44 51.776-34.93a154 154 0 0 1 23.297-7.886a5.86 5.86 0 0 0 4.438-5.678a5.855 5.855 0 0 0-4.438-5.669a154.4 154.4 0 0 1-23.297-7.889" />
+ <g filter="url(#SVGqoIxVV2h)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="14.407" cy="16.95" fill="#ffe432" rx="14.407" ry="16.95" transform="rotate(19.552 -44.576 -16.496)" />
+ </g>
+ <g filter="url(#SVGOahAkcjC)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="27.433" cy="2.587" fill="#fc413d" rx="18.652" ry="19.062" />
+ </g>
+ <g filter="url(#SVGyT4fLePl)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="18.951" cy="57.386" fill="#00b95c" rx="19.493" ry="25.253" transform="rotate(-2.799 18.951 57.386)" />
+ </g>
+ <g filter="url(#SVGyT4fLePl)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="18.951" cy="57.386" fill="#00b95c" rx="19.493" ry="25.253" transform="rotate(-2.799 18.951 57.386)" />
+ </g>
+ <g filter="url(#SVGonSETbRF)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="20.02" cy="56.211" fill="#00b95c" rx="19.107" ry="21.035" transform="rotate(-31.318 20.02 56.211)" />
+ </g>
+ <g filter="url(#SVGSN7ofz6B)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="67.391" cy="25.327" fill="#3186ff" rx="18.346" ry="17.667" />
+ </g>
+ <g filter="url(#SVGHvbpPvOn)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="21.222" cy="22.384" fill="#fbbc04" rx="21.222" ry="22.384" transform="rotate(37.252 9.752 -8.009)" />
+ </g>
+ <g filter="url(#SVG7JmfweRd)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="24.469" cy="22.604" fill="#3186ff" rx="24.469" ry="22.604" transform="rotate(34.51 19.587 64.852)" />
+ </g>
+ <g filter="url(#SVGgGkiybCN)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <path fill="#749bff" d="M54.984-2.336c2.833 3.852-.808 11.34-8.131 16.727s-15.557 6.631-18.39 2.78c-2.833-3.853.807-11.342 8.13-16.728s15.558-6.631 18.39-2.78" />
+ </g>
+ <g filter="url(#SVGxEY6lcrm)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="19.902" cy="3.356" fill="#fc413d" rx="27.971" ry="17.388" transform="rotate(-42.848 19.902 3.356)" />
+ </g>
+ <g filter="url(#SVGMZLCp0yD)" mask="url(#SVGWpw6Gcvj)" transform="translate(-.101 -.049)scale(3.9436)">
+ <ellipse cx="13.583" cy="46.75" fill="#ffee48" rx="14.989" ry="8.717" transform="rotate(35.592 13.583 46.75)" />
+ </g>
+ <mask id="SVGWpw6Gcvj" width="65" height="65" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha">
+ <path d="M32.447 0c.68 0 1.273.465 1.439 1.125a39 39 0 0 0 1.999 5.905q3.23 7.5 8.854 13.125q5.627 5.626 13.125 8.855a39 39 0 0 0 5.906 1.999c.66.166 1.124.758 1.124 1.438s-.464 1.273-1.125 1.439a39 39 0 0 0-5.905 1.999q-7.5 3.23-13.125 8.854q-5.625 5.627-8.854 13.125a39 39 0 0 0-2 5.906a1.485 1.485 0 0 1-1.438 1.124c-.68 0-1.272-.464-1.438-1.125a39 39 0 0 0-2-5.905q-3.227-7.5-8.854-13.125q-5.625-5.625-13.125-8.854a39 39 0 0 0-5.905-2A1.485 1.485 0 0 1 0 32.448c0-.68.465-1.272 1.125-1.438a39 39 0 0 0 5.905-2q7.5-3.228 13.125-8.854q5.626-5.624 8.855-13.125a39 39 0 0 0 1.999-5.905A1.485 1.485 0 0 1 32.447 0" />
+ <path fill="url(#SVG1oAMmOOu)" d="M32.447 0c.68 0 1.273.465 1.439 1.125a39 39 0 0 0 1.999 5.905q3.23 7.5 8.854 13.125q5.627 5.626 13.125 8.855a39 39 0 0 0 5.906 1.999c.66.166 1.124.758 1.124 1.438s-.464 1.273-1.125 1.439a39 39 0 0 0-5.905 1.999q-7.5 3.23-13.125 8.854q-5.625 5.627-8.854 13.125a39 39 0 0 0-2 5.906a1.485 1.485 0 0 1-1.438 1.124c-.68 0-1.272-.464-1.438-1.125a39 39 0 0 0-2-5.905q-3.227-7.5-8.854-13.125q-5.625-5.625-13.125-8.854a39 39 0 0 0-5.905-2A1.485 1.485 0 0 1 0 32.448c0-.68.465-1.272 1.125-1.438a39 39 0 0 0 5.905-2q7.5-3.228 13.125-8.854q5.626-5.624 8.855-13.125a39 39 0 0 0 1.999-5.905A1.485 1.485 0 0 1 32.447 0" />
+ </mask>
+</svg>
\ No newline at end of file
diff --git a/assets/usage/opencode.png b/assets/usage/opencode.png
new file mode 100644
index 0000000..bb31c55
Binary files /dev/null and b/assets/usage/opencode.png differ
diff --git a/assets/usage/opencode.svg b/assets/usage/opencode.svg
new file mode 100644
index 0000000..3fc6a21
--- /dev/null
+++ b/assets/usage/opencode.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 24 24">
+ <path fill="#f5f7fa" fill-rule="evenodd" d="M16 6H8v12h8zm4 16H4V2h16z"/>
+</svg>
diff --git a/crates/muelle-config/src/lib.rs b/crates/muelle-config/src/lib.rs
index 4abcf3a..7dea165 100644
--- a/crates/muelle-config/src/lib.rs
+++ b/crates/muelle-config/src/lib.rs
@@ -48,12 +48,15 @@ pub struct Config {
/// Genie effect when minimizing. On by default; while enabled, the dock
/// turns off the system's own window transitions (see plan, "Efecto genio").
pub genie: bool,
+ /// Minimized windows get a live thumbnail in the right section of the
+ /// dock. Off by default: they go into their app's icon instead.
+ pub show_minimized: bool,
/// macOS-style bar across the top with the clock and status items.
pub menu_bar: bool,
/// Keep the menu bar off screen until the pointer touches the top edge.
pub menu_bar_auto_hide: bool,
- /// What clicking the icon of the app already in front does.
- pub active_app_click: ActiveAppClick,
+ /// Show supported AI providers' plan usage in the menu bar.
+ pub ai_usage: bool,
/// The dot under apps that have windows open.
pub show_indicators: bool,
/// The section of recently used apps that are not pinned.
@@ -66,16 +69,6 @@ pub struct Config {
pub language: Language,
}
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
-#[serde(rename_all = "lowercase")]
-pub enum ActiveAppClick {
- /// As the Windows taskbar does.
- #[default]
- Minimize,
- /// As macOS does.
- Nothing,
-}
-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Language {
@@ -122,9 +115,10 @@ impl Default for Config {
magnification: true,
magnified_size: 77,
genie: true,
+ show_minimized: false,
menu_bar: true,
menu_bar_auto_hide: false,
- active_app_click: ActiveAppClick::Minimize,
+ ai_usage: true,
show_indicators: true,
show_recents: true,
bounce_on_open: true,
@@ -226,9 +220,19 @@ mod tests {
fs::write(&path, r#"{"version":1,"iconSize":56}"#).ok();
let config = load(&path).ok().flatten().unwrap_or_default();
assert_eq!(config.icon_size, 56);
- assert_eq!(config.active_app_click, ActiveAppClick::Minimize);
assert!(config.show_indicators && config.show_recents && config.bounce_on_open);
assert!(config.check_updates);
+ assert!(config.ai_usage);
+ assert!(!config.show_minimized);
+ }
+
+ #[test]
+ fn load_should_read_show_minimized() {
+ let path = scratch("show-minimized");
+ save(&path, &Config::default()).ok();
+ fs::write(&path, r#"{"showMinimized":true}"#).ok();
+ let config = load(&path).ok().flatten().unwrap_or_default();
+ assert!(config.show_minimized);
}
#[test]
@@ -250,7 +254,6 @@ mod tests {
)
.ok();
let config = load(&path).ok().flatten().unwrap_or_default();
- assert_eq!(config.active_app_click, ActiveAppClick::Nothing);
assert!(!config.show_recents && !config.bounce_on_open);
}