From fe2999d5b0a02cb0f1184b4f9143548b67b1f522 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:27:52 +0100 Subject: [PATCH 01/19] feat(gui): native Slint GUI with ksni tray, replacing grove-bridge Folds the bridge library into grove-gui (src/bridge.rs) and drops the HTTP server. Co-Authored-By: Claude Sonnet 5.5 --- Cargo.lock | 3939 ++++++++++++++++- Cargo.toml | 2 +- assets/grove.png | Bin 0 -> 209 bytes crates/grove-bridge/Cargo.toml | 12 - crates/grove-bridge/src/main.rs | 155 - crates/grove-gui/Cargo.toml | 22 + crates/grove-gui/build.rs | 5 + .../src/lib.rs => grove-gui/src/bridge.rs} | 16 +- crates/grove-gui/src/instance.rs | 107 + crates/grove-gui/src/main.rs | 979 ++++ crates/grove-gui/src/model.rs | 402 ++ crates/grove-gui/src/tray.rs | 236 + crates/grove-gui/ui/app.slint | 1093 +++++ 13 files changed, 6753 insertions(+), 215 deletions(-) create mode 100644 assets/grove.png delete mode 100644 crates/grove-bridge/Cargo.toml delete mode 100644 crates/grove-bridge/src/main.rs create mode 100644 crates/grove-gui/Cargo.toml create mode 100644 crates/grove-gui/build.rs rename crates/{grove-bridge/src/lib.rs => grove-gui/src/bridge.rs} (94%) create mode 100644 crates/grove-gui/src/instance.rs create mode 100644 crates/grove-gui/src/main.rs create mode 100644 crates/grove-gui/src/model.rs create mode 100644 crates/grove-gui/src/tray.rs create mode 100644 crates/grove-gui/ui/app.slint diff --git a/Cargo.lock b/Cargo.lock index fcf4733..6596a0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,22 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ab_glyph" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" + [[package]] name = "adler2" version = "2.0.1" @@ -73,7 +89,7 @@ dependencies = [ "i18n-embed-fl", "lazy_static", "ml-kem", - "nom", + "nom 8.0.0", "p256", "pin-project", "rand", @@ -99,12 +115,25 @@ dependencies = [ "hkdf 0.12.4", "hpke", "io_tee", - "nom", + "nom 8.0.0", "rand", "secrecy", "sha2 0.10.9", ] +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.5" @@ -114,6 +143,57 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-activity" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags 2.13.2", + "cc", + "jni", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror 2.0.21", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "annotate-snippets" +version = "0.12.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0258346f92c78dbc5b336b9a5b27c64447aa10643bc64e651db2edb145361564" +dependencies = [ + "anstyle", + "memchr", + "unicode-width", +] + [[package]] name = "anstream" version = "1.0.0" @@ -181,6 +261,24 @@ dependencies = [ "security-framework", ] +[[package]] +name = "arboard" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", +] + [[package]] name = "arc-swap" version = "1.9.5" @@ -190,6 +288,33 @@ dependencies = [ "rustversion", ] +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading", +] + [[package]] name = "async-broadcast" version = "0.7.2" @@ -241,7 +366,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix", + "rustix 1.1.6", "slab", "windows-sys 0.61.2", ] @@ -272,7 +397,7 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix", + "rustix 1.1.6", ] [[package]] @@ -298,7 +423,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix", + "rustix 1.1.6", "signal-hook-registry", "slab", "windows-sys 0.61.2", @@ -366,11 +491,65 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" +[[package]] +name = "bincode" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" +dependencies = [ + "serde", + "unty", +] + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools 0.13.0", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 2.1.3", + "shlex 1.3.0", + "syn 2.0.119", +] + +[[package]] +name = "bit-set" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] [[package]] name = "block-buffer" @@ -399,6 +578,24 @@ dependencies = [ "hybrid-array 0.4.15", ] +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.3", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2 0.6.5", +] + [[package]] name = "blocking" version = "1.7.0" @@ -412,24 +609,104 @@ dependencies = [ "piper", ] +[[package]] +name = "borsh" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" +dependencies = [ + "bytes", + "cfg_aliases", +] + [[package]] name = "bumpalo" version = "3.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" +[[package]] +name = "by_address" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "bytes" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "calloop" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" +dependencies = [ + "bitflags 2.13.2", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror 1.0.69", +] + +[[package]] +name = "calloop" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" +dependencies = [ + "bitflags 2.13.2", + "polling", + "rustix 1.1.6", + "tracing", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" +dependencies = [ + "calloop 0.13.0", + "rustix 0.38.44", + "wayland-backend", + "wayland-client", +] + [[package]] name = "cbc" version = "0.2.1" @@ -446,7 +723,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" dependencies = [ "find-msvc-tools", - "shlex", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom 7.1.3", ] [[package]] @@ -455,6 +743,21 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + [[package]] name = "chacha20" version = "0.9.1" @@ -479,6 +782,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "cipher" version = "0.4.4" @@ -500,6 +816,17 @@ dependencies = [ "inout 0.2.6", ] +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "4.6.7" @@ -540,18 +867,61 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" +[[package]] +name = "clipboard-win" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +dependencies = [ + "error-code", +] + +[[package]] +name = "clru" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197fd99cb113a8d5d9b6376f3aa817f32c1078f2343b714fff7d2ca44fdf67d5" +dependencies = [ + "hashbrown 0.16.1", +] + [[package]] name = "cmov" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "colorchoice" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -561,6 +931,27 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-field-offset" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d535c69e75b4e3c69e17205b5b37a91936c54086cecd339b70071500786acb9c" +dependencies = [ + "const-field-offset-macro", + "field-offset", +] + +[[package]] +name = "const-field-offset-macro" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d5848843a221ac268cfdd6bfd14e68d5d3dfa79d52c880aafab93f9517fb74" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -573,6 +964,15 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cookie" version = "0.18.2" @@ -611,6 +1011,16 @@ dependencies = [ "url", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation" version = "0.10.1" @@ -627,6 +1037,36 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "libc", +] + +[[package]] +name = "countme" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" + [[package]] name = "cpubits" version = "0.1.1" @@ -660,12 +1100,61 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -698,6 +1187,15 @@ dependencies = [ "hybrid-array 0.4.15", ] +[[package]] +name = "ctor" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83cf0d42651b16c6dfe68685716d18480d18a9c39c62d76e8cf3eb6ed5d8bcbf" +dependencies = [ + "dtor", +] + [[package]] name = "ctr" version = "0.9.2" @@ -716,6 +1214,12 @@ dependencies = [ "cmov", ] +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -742,6 +1246,12 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + [[package]] name = "der" version = "0.7.10" @@ -758,6 +1268,29 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.119", + "unicode-xid", +] + [[package]] name = "digest" version = "0.10.7" @@ -781,6 +1314,22 @@ dependencies = [ "ctutils", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", +] + [[package]] name = "displaydoc" version = "0.2.7" @@ -792,6 +1341,15 @@ dependencies = [ "syn 3.0.10", ] +[[package]] +name = "dlib" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" +dependencies = [ + "libloading", +] + [[package]] name = "document-features" version = "0.2.12" @@ -801,6 +1359,70 @@ dependencies = [ "litrs", ] +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" + +[[package]] +name = "drm" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "drm-ffi", + "drm-fourcc", + "libc", + "rustix 0.38.44", +] + +[[package]] +name = "drm-ffi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51a91c9b32ac4e8105dec255e849e0d66e27d7c34d184364fb93e469db08f690" +dependencies = [ + "drm-sys", + "rustix 1.1.6", +] + +[[package]] +name = "drm-fourcc" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" + +[[package]] +name = "drm-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8e1361066d91f5ffccff060a3c3be9c3ecde15be2959c1937595f7a82a9f8" +dependencies = [ + "libc", + "linux-raw-sys 0.9.4", +] + +[[package]] +name = "dtor" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edf234dd1594d6dd434a8fb8cada51ddbbc593e40e4a01556a0b31c62da2775b" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + [[package]] name = "elliptic-curve" version = "0.13.8" @@ -863,6 +1485,21 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + +[[package]] +name = "euclid" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" +dependencies = [ + "num-traits", +] + [[package]] name = "event-listener" version = "5.4.2" @@ -889,6 +1526,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + [[package]] name = "ff" version = "0.13.1" @@ -905,6 +1551,26 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "field-offset" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "filetime" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" +dependencies = [ + "cfg-if", + "libc", +] + [[package]] name = "find-crate" version = "0.6.3" @@ -920,6 +1586,23 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" +[[package]] +name = "fixed_decimal" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2214fb00f669ee96bee5bb29dfb1ddabe058b2bc426817efc79afa03c9bc55ae" +dependencies = [ + "displaydoc", + "smallvec", + "writeable", +] + +[[package]] +name = "fixedbitset" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175" + [[package]] name = "flate2" version = "1.1.11" @@ -927,10 +1610,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.9.1", "zlib-rs", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + [[package]] name = "fluent" version = "0.17.0" @@ -951,7 +1640,7 @@ dependencies = [ "fluent-syntax", "intl-memoizer", "intl_pluralrules", - "rustc-hash", + "rustc-hash 2.1.3", "self_cell", "smallvec", "unic-langid", @@ -976,6 +1665,87 @@ dependencies = [ "thiserror 2.0.21", ] +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "font-types" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "fontdb" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f" +dependencies = [ + "log", + "slotmap", + "tinyvec", +] + +[[package]] +name = "fontique" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6688bc1294fe7117d788937b6c53480169b29c566954af490830d4c09da9516a" +dependencies = [ + "hashbrown 0.17.1", + "linebender_resource_handle", + "memmap2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-text", + "objc2-foundation 0.3.2", + "parlance", + "read-fonts", + "roxmltree", + "smallvec", + "windows", + "windows-core", + "yeslogic-fontconfig-sys", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -1097,6 +1867,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "gethostname" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" +dependencies = [ + "rustix 1.1.6", + "windows-link", +] + [[package]] name = "getrandom" version = "0.2.17" @@ -1108,6 +1888,18 @@ dependencies = [ "wasi", ] +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + [[package]] name = "getrandom" version = "0.4.3" @@ -1116,7 +1908,7 @@ checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", - "r-efi", + "r-efi 6.0.0", ] [[package]] @@ -1129,6 +1921,131 @@ dependencies = [ "polyval", ] +[[package]] +name = "gif" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "glow" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "263218b0ba2b0715c3370fb04674f5f8aa331594b521c94ff0a8e4a8472d1386" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" +dependencies = [ + "bitflags 2.13.2", + "cfg_aliases", + "cgl", + "dispatch2", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "raw-window-handle", + "wayland-sys", + "windows-sys 0.52.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2" +dependencies = [ + "gl_generator", + "windows-sys 0.52.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-allocator" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" +dependencies = [ + "ash", + "hashbrown 0.16.1", + "log", + "presser", + "thiserror 2.0.21", + "windows", +] + +[[package]] +name = "grid" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b40ca9252762c466af32d0b1002e91e4e1bc5398f77455e55474deb466355ff5" + [[package]] name = "group" version = "0.13.0" @@ -1154,16 +2071,6 @@ dependencies = [ "toml 1.2.1+spec-1.1.0", ] -[[package]] -name = "grove-bridge" -version = "0.1.0" -dependencies = [ - "anyhow", - "grove-daemon", - "serde_json", - "toml 1.2.1+spec-1.1.0", -] - [[package]] name = "grove-core" version = "0.1.0" @@ -1183,6 +2090,19 @@ dependencies = [ "serde_json", ] +[[package]] +name = "grove-gui" +version = "0.1.0" +dependencies = [ + "anyhow", + "grove-daemon", + "ksni", + "serde_json", + "slint", + "slint-build", + "toml 1.2.1+spec-1.1.0", +] + [[package]] name = "grove-providers" version = "0.1.0" @@ -1194,11 +2114,64 @@ dependencies = [ "ureq", ] +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "harfrust" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "read-fonts", + "smallvec", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[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.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + [[package]] name = "hashbrown" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash 0.2.0", +] [[package]] name = "heck" @@ -1206,6 +2179,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hermit-abi" version = "0.5.3" @@ -1274,6 +2253,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "htmlparser" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48ce8546b993eaf241d69ded33b1be6d205dd9857ec879d9d18bd05d3676e144" + [[package]] name = "http" version = "1.5.0" @@ -1308,6 +2293,270 @@ dependencies = [ "typenum", ] +[[package]] +name = "i-slint-backend-linuxkms" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f519a8611a4982921e46e391015e5e40ceac5cc63813333ef91ada77df180d8" +dependencies = [ + "bytemuck", + "calloop 0.14.5", + "cfg_aliases", + "drm", + "i-slint-common", + "i-slint-core", + "i-slint-renderer-software", + "input", + "libseat", + "memmap2", + "nix", + "xkbcommon", +] + +[[package]] +name = "i-slint-backend-selector" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb974705d61ba56034f6129ff61f3e6282a2c0c07752f25e6cb417d81c0f0958" +dependencies = [ + "cfg-if", + "cfg_aliases", + "i-slint-backend-linuxkms", + "i-slint-backend-testing", + "i-slint-backend-winit", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", +] + +[[package]] +name = "i-slint-backend-testing" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01943d6c5ea5bc913d497bdaa423c309e7627afff47a6794bfd13be5c564209f" +dependencies = [ + "cfg_aliases", + "i-slint-common", + "i-slint-core", + "i-slint-renderer-software", + "vtable", +] + +[[package]] +name = "i-slint-backend-winit" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dae4fcf1b19e9cb109984d2af87d2b9485388c619265bff71dd523133888bee2" +dependencies = [ + "arboard", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "futures", + "glutin", + "glutin-winit", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", + "i-slint-renderer-skia", + "i-slint-renderer-software", + "imgref", + "lyon_path", + "muda", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-ui-kit 0.3.2", + "pin-weak", + "raw-window-handle", + "rgb", + "scoped-tls-hkt", + "scopeguard", + "softbuffer", + "strum", + "vtable", + "wasm-bindgen", + "web-sys", + "webbrowser", + "windows", + "winit", + "zbus", +] + +[[package]] +name = "i-slint-common" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a578f3e4b681b2b9cbd326d3be19716e2fac51d00a8a5b00c0ef4ae923b5e6" +dependencies = [ + "derive_more", + "fontique", + "htmlparser", + "icu_decimal", + "icu_locale_core", + "icu_provider", + "pulldown-cmark", + "resvg", + "skrifa", +] + +[[package]] +name = "i-slint-compiler" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55d48ebef05e2bf09ba5a1fc67bcb11033b9e12a2a50ed3105c7d25e2b539d0" +dependencies = [ + "annotate-snippets", + "by_address", + "data-url", + "derive_more", + "i-slint-common", + "icu_normalizer", + "icu_properties", + "image", + "indexmap", + "itertools 0.15.0", + "lyon_extra", + "lyon_path", + "num_enum", + "proc-macro2", + "quote", + "rayon", + "resvg", + "rowan", + "rspolib", + "skrifa", + "smol_str 0.3.7", + "strum", + "swash", + "typed-index-collections", + "unicode-segmentation", + "url", +] + +[[package]] +name = "i-slint-core" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2ea15059d70bc31b1a8b1eb4c34f2c5df04cb7e53f36179b43c0261231d646" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "chrono", + "clru", + "const-field-offset", + "derive_more", + "euclid", + "i-slint-common", + "i-slint-core-macros", + "icu_normalizer", + "image", + "js-sys", + "lyon_algorithms", + "lyon_extra", + "lyon_geom", + "lyon_path", + "num-traits", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "once_cell", + "parley", + "pin-project", + "pin-weak", + "portable-atomic", + "raw-window-handle", + "resvg", + "rgb", + "scopeguard", + "skrifa", + "slab", + "strum", + "swash", + "sys-locale", + "taffy", + "unicode-linebreak", + "unicode-script", + "unicode-segmentation", + "vtable", + "wasm-bindgen", + "web-sys", + "web-time", + "wgpu", + "windows", +] + +[[package]] +name = "i-slint-core-macros" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f5a8a076de52f53be80caa826599ed2107b54c9d4a421e66dc06cf893a984c" +dependencies = [ + "quote", + "serde_json", + "syn 3.0.10", +] + +[[package]] +name = "i-slint-renderer-skia" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc9c1cf02385f1d26fc1f423544e52390a8e5c2d89420a8042aa94b4fe109d1f" +dependencies = [ + "bytemuck", + "cfg-if", + "cfg_aliases", + "clru", + "const-field-offset", + "glow", + "glutin", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", + "lyon_path", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "pin-weak", + "raw-window-handle", + "read-fonts", + "scoped-tls-hkt", + "skia-safe", + "softbuffer", + "spin_on", + "unicode-segmentation", + "vtable", + "wgpu", + "wgpu-hal", + "windows", + "windows-core", + "write-fonts", +] + +[[package]] +name = "i-slint-renderer-software" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f8c641e138a2cc96537cac4481f5c7c8bb8dcc66d09acaed269329c8738628a" +dependencies = [ + "bytemuck", + "clru", + "derive_more", + "euclid", + "i-slint-common", + "i-slint-core", + "lyon_path", + "num-traits", + "skrifa", + "swash", + "zeno", +] + [[package]] name = "i18n-config" version = "0.4.8" @@ -1374,6 +2623,30 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "2.4.0" @@ -1388,6 +2661,29 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_decimal" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1150ad5e272740670464934ee76facda43ef2e11f85c27b7ba76ccb33edf2d05" +dependencies = [ + "displaydoc", + "fixed_decimal", + "icu_decimal_data", + "icu_locale_core", + "icu_locale_fallback", + "icu_plurals", + "icu_provider", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_decimal_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5595ab78370d48abd24a062f3db115d5108dd0b65634352036cae532aebb0df8" + [[package]] name = "icu_locale_core" version = "2.4.0" @@ -1396,11 +2692,32 @@ checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" dependencies = [ "displaydoc", "litemap", + "serde", "tinystr", "writeable", "zerovec", ] +[[package]] +name = "icu_locale_fallback" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" + [[package]] name = "icu_normalizer" version = "2.4.0" @@ -1421,6 +2738,25 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" +[[package]] +name = "icu_plurals" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef046647b445acf95ce0f8083fa292467d3df649959fa9a20f3f8abfd957c5d" +dependencies = [ + "fixed_decimal", + "icu_locale_fallback", + "icu_plurals_data", + "icu_provider", + "zerovec", +] + +[[package]] +name = "icu_plurals_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43ff7df2c1a1d41588a6ddcba354d513d4a3e10eec22c06fe56d13c12a848ea" + [[package]] name = "icu_properties" version = "2.4.0" @@ -1450,6 +2786,8 @@ checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" dependencies = [ "displaydoc", "icu_locale_core", + "serde", + "stable_deref_trait", "writeable", "yoke", "zerofrom", @@ -1457,6 +2795,29 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_segmenter" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b195dc605f81aa181bec9b3bd14e26cc71b903e4644f6af578ca9772c7a710" +dependencies = [ + "icu_collections", + "icu_locale_fallback", + "icu_provider", + "icu_segmenter_data", + "potential_utf", + "smallvec", + "utf8_iter", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_segmenter_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913a7d294ad056474749152107309fdee3ec17d2482d1ab70fdc61a81c64b9a3" + [[package]] name = "idna" version = "1.1.0" @@ -1478,6 +2839,43 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imagesize" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b27460c2c92b037f3f94c538ed9a3342f3fdf923606781629ccb35f82d042a" + +[[package]] +name = "imgref" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f" + [[package]] name = "indexmap" version = "2.14.2" @@ -1485,7 +2883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.17.1", ] [[package]] @@ -1494,7 +2892,7 @@ version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cc00ea907cab49550b7da656f80ebb97be1b997d931fbcd28d39734e17ce592" dependencies = [ - "bitflags", + "bitflags 2.13.2", "inotify-sys", "libc", ] @@ -1527,6 +2925,25 @@ dependencies = [ "hybrid-array 0.4.15", ] +[[package]] +name = "input" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9793345a65d71317763a33066b5d8351f8760dde8d4930fe9e39b5f14a7959d" +dependencies = [ + "bitflags 2.13.2", + "input-sys", + "libc", + "log", + "udev", +] + +[[package]] +name = "input-sys" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36eee07d8e02bd95bf52b2e642cf13d33701b94c6e4b04fbf1d1fb07e9cb19e7" + [[package]] name = "intl-memoizer" version = "0.5.3" @@ -1546,6 +2963,17 @@ dependencies = [ "unic-langid", ] +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "io_tee" version = "0.1.1" @@ -1558,12 +2986,98 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "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" @@ -1594,6 +3108,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.13.2", + "serde", + "unicode-segmentation", +] + [[package]] name = "keyring" version = "4.2.0" @@ -1615,6 +3140,12 @@ dependencies = [ "log", ] +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "kqueue" version = "1.2.1" @@ -1631,10 +3162,42 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" dependencies = [ - "bitflags", + "bitflags 2.13.2", "libc", ] +[[package]] +name = "ksni" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bcc1cb43797140f74b711f1c4a49f48a7a7429f211c5fb78264e7bcd1e99caf" +dependencies = [ + "arc-swap", + "async-executor", + "async-io", + "async-lock", + "crossbeam-queue", + "futures-channel", + "futures-lite", + "futures-util", + "pastey", + "serde", + "task-local", + "zbus", +] + +[[package]] +name = "kurbo" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b60dfc32f652b926df6192e55525b16d186c69d47876c3ead4da5cc9f8450e2" +dependencies = [ + "arrayvec", + "euclid", + "polycool", + "smallvec", +] + [[package]] name = "lazy_static" version = "1.5.1" @@ -1647,6 +3210,82 @@ version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags 2.13.2", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "libseat" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6656c69b6e0366ffb83faa232f3e4fda5fc91161722d140f2c95ce2e90b1ef31" +dependencies = [ + "errno", + "libseat-sys", + "log", +] + +[[package]] +name = "libseat-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a484fa48be5f62a8d3ffed767779d0ab808cfead91de98ef4362d469097dfb" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "linebender_resource_handle" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -1680,12 +3319,62 @@ version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" +[[package]] +name = "lyon_algorithms" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" +dependencies = [ + "lyon_path", + "num-traits", +] + +[[package]] +name = "lyon_extra" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7755f08423275157ad1680aaecc9ccb7e0cc633da3240fea2d1522935cc15c72" +dependencies = [ + "lyon_path", + "thiserror 2.0.21", +] + +[[package]] +name = "lyon_geom" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82dd26aa4dc0b5b70b9115de59824842bcb43cf4a28e1b1e6d0ad148c93f93e" +dependencies = [ + "arrayvec", + "euclid", + "num-traits", +] + +[[package]] +name = "lyon_path" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c463f9c428b7fc5ec885dcd39ce4aa61e29111d0e33483f6f98c74e89d8621e" +dependencies = [ + "lyon_geom", + "num-traits", +] + [[package]] name = "memchr" version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.9.1" @@ -1711,6 +3400,22 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + [[package]] name = "miniz_oxide" version = "0.9.1" @@ -1745,6 +3450,131 @@ dependencies = [ "sha3", ] +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "muda" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd04e60bc0b07438a6771710ee1698f98f6ebbc7f89b61264af1563b8aeb878" +dependencies = [ + "crossbeam-channel", + "dpi", + "keyboard-types", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "png", + "thiserror 2.0.21", + "windows-sys 0.61.2", +] + +[[package]] +name = "naga" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0dd362bf26c0ffdd143df6da66a25d287e196eff482f117771010b207ad163" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.1", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14474170feb673cfb18b3565111a9869797cc1d290fb9ec969c53f5e1e231c6d" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] + +[[package]] +name = "natord" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308d96db8debc727c3fd9744aac51751243420e46edf401010908da7f8d5e57c" + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nom" version = "8.0.0" @@ -1760,7 +3590,7 @@ version = "8.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41a04a5f59df9322cc657286dd2d79f90816119b22c5f847607c850110205ab" dependencies = [ - "bitflags", + "bitflags 2.13.2", "inotify", "kqueue", "libc", @@ -1779,7 +3609,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbd044e85df3d939d8e32a1c35a3b737c7d0a4eeb7acd737bd207644e00f4e5f" dependencies = [ - "bitflags", + "bitflags 2.13.2", ] [[package]] @@ -1858,6 +3688,120 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "libc", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", ] [[package]] @@ -1866,7 +3810,46 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags", + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-contacts", + "objc2-foundation 0.2.2", ] [[package]] @@ -1879,11 +3862,199 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.13.2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "dispatch", + "libc", + "objc2 0.5.3", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core 0.2.2", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + [[package]] name = "once_cell" version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +dependencies = [ + "critical-section", + "portable-atomic", +] [[package]] name = "once_cell_polyfill" @@ -1897,6 +4068,25 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "orbclient" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +dependencies = [ + "libc", + "libredox", +] + +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -1907,6 +4097,25 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "os_pipe" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +dependencies = [ + "ttf-parser", +] + [[package]] name = "p256" version = "0.13.2" @@ -1941,11 +4150,50 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.18", "smallvec", "windows-link", ] +[[package]] +name = "parlance" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73072a9470554c8e794778acece2312661218aaabb635600957d952cf01c716e" + +[[package]] +name = "parley" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22d2ff88bd3f7d68d1d9b09c7e6209f9a8e8c05088295140a2bcf2e9b17038c5" +dependencies = [ + "fontique", + "harfrust", + "hashbrown 0.17.1", + "icu_normalizer", + "icu_properties", + "icu_segmenter", + "linebender_resource_handle", + "parlance", + "parley_data", + "skrifa", +] + +[[package]] +name = "parley_data" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1567535334d6ba2d3cde19221ba9a7bd0fabb3cbd99046ddfb10ae061cfcc889" +dependencies = [ + "icu_properties", +] + +[[package]] +name = "pastey" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" + [[package]] name = "pbkdf2" version = "0.12.2" @@ -1962,6 +4210,23 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project" version = "1.1.13" @@ -1988,6 +4253,18 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "pin-utils" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113" + +[[package]] +name = "pin-weak" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b330c9d1b92dfe68442ca20b009c717d5f0b1e3cf4965e62f704c3c6e95a1305" + [[package]] name = "piper" version = "0.2.5" @@ -1999,6 +4276,31 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + [[package]] name = "polling" version = "3.11.0" @@ -2007,9 +4309,9 @@ checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi", + "hermit-abi 0.5.3", "pin-project-lite", - "rustix", + "rustix 1.1.6", "windows-sys 0.61.2", ] @@ -2024,6 +4326,15 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "polycool" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50596ddc09eb5ad5f75cacd40209568e66df71baf86e1499a0e99c4cff12a5a6" +dependencies = [ + "arrayvec", +] + [[package]] name = "polyval" version = "0.6.2" @@ -2036,12 +4347,32 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" +dependencies = [ + "critical-section", +] + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + [[package]] name = "potential_utf" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ + "serde_core", + "writeable", "zerovec", ] @@ -2060,6 +4391,22 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -2109,6 +4456,44 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" + +[[package]] +name = "pulldown-cmark" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db2be46835f013dd3f4fa7f5f7402c537787b54ebb6fe2b94bbdd7e2669bb7b" +dependencies = [ + "bitflags 2.13.2", + "memchr", + "unicase", +] + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.47" @@ -2118,6 +4503,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "r-efi" version = "6.0.0" @@ -2154,13 +4545,86 @@ dependencies = [ "getrandom 0.2.17", ] +[[package]] +name = "range-alloc" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "raw-window-metal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" +dependencies = [ + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "read-fonts" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags", + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", ] [[package]] @@ -2192,6 +4656,39 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "resvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e3803f97b999e80cbf7c6ecdd07a8102204d92e1633cf48783720c521196bd" +dependencies = [ + "bytemuck", + "gif", + "image-webp", + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia 0.12.0", + "usvg", + "zune-jpeg", +] + +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.17.14" @@ -2206,6 +4703,41 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rowan" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b574c58582fa59fa43a2feb6608b8744184659f08a2e0117e4b8224d95ed61" +dependencies = [ + "countme", + "hashbrown 0.14.5", + "memoffset", + "rustc-hash 1.1.0", + "text-size", +] + +[[package]] +name = "roxmltree" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" +dependencies = [ + "memchr", +] + +[[package]] +name = "rspolib" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fda9a7796aff63a7b1b39ccc93fffaaf65e20042984b4843041a49ca4677535" +dependencies = [ + "lazy_static", + "natord", + "snafu", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "rust-embed" version = "8.14.0" @@ -2241,6 +4773,12 @@ dependencies = [ "walkdir", ] +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hash" version = "2.1.3" @@ -2256,16 +4794,29 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.52.0", +] + [[package]] name = "rustix" version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ - "bitflags", + "bitflags 2.13.2", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.12.1", "windows-sys 0.61.2", ] @@ -2328,6 +4879,18 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scoped-tls-hkt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9603871ffe5df3ac39cb624790c296dbd47a400d202f56bf3e414045099524d" + [[package]] name = "scopeguard" version = "1.2.0" @@ -2345,6 +4908,19 @@ dependencies = [ "sha2 0.10.9", ] +[[package]] +name = "sctk-adwaita" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit", + "tiny-skia 0.11.4", +] + [[package]] name = "sec1" version = "0.7.3" @@ -2392,8 +4968,8 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags", - "core-foundation", + "bitflags 2.13.2", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -2516,6 +5092,12 @@ dependencies = [ "keccak", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "shlex" version = "2.0.1" @@ -2538,36 +5120,331 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "skia-bindings" +version = "0.153.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb325787c91b3f6c34a7c6f2b8a2297b20292d733ca53a08c233e5028aec49af" +dependencies = [ + "bindgen", + "cc", + "flate2", + "heck", + "pkg-config", + "regex", + "serde_json", + "tar", + "toml 1.2.1+spec-1.1.0", +] + +[[package]] +name = "skia-safe" +version = "0.153.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61cb643dac43067f3eb76c866635a74377ac0abca0ff2590674e1e295514c3d" +dependencies = [ + "bitflags 2.13.2", + "skia-bindings", + "windows", +] + +[[package]] +name = "skrifa" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" +dependencies = [ + "bytemuck", + "read-fonts", +] + [[package]] name = "slab" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" +[[package]] +name = "slint" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e477d5ff6fec20909100ff8f7062432ebfbda7a62a0f37d0252aa126f38c83" +dependencies = [ + "const-field-offset", + "i-slint-backend-linuxkms", + "i-slint-backend-selector", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", + "i-slint-renderer-software", + "num-traits", + "once_cell", + "pin-weak", + "slint-macros", + "unicode-segmentation", + "vtable", +] + +[[package]] +name = "slint-build" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ea28d4e1ad47d829b91e227f17037fac07a8001668a93fee47ac04f88718ebc" +dependencies = [ + "derive_more", + "fontique", + "i-slint-compiler", + "spin_on", + "toml_edit", +] + +[[package]] +name = "slint-macros" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e74b13d20884dc480ce37d0fabbf02cb4bc0df2a595434feac96ca7c2a0f15" +dependencies = [ + "i-slint-compiler", + "proc-macro2", + "quote", + "spin_on", +] + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + [[package]] name = "smallvec" version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" +[[package]] +name = "smithay-client-toolkit" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" +dependencies = [ + "bitflags 2.13.2", + "calloop 0.13.0", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 0.38.44", + "thiserror 1.0.69", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "smol_str" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb7109d23f319619d4cc0de5464613c8b7b1a09db2774a58101459cf6be2f10" +dependencies = [ + "borsh", + "serde_core", +] + +[[package]] +name = "snafu" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e84b3f4eacbf3a1ce05eac6763b4d629d60cbc94d632e4092c54ade71f1e1a2" +dependencies = [ + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c97747dbf44bb1ca44a561ece23508e99cb592e862f22222dcf42f51d1e451" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "softbuffer" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3" +dependencies = [ + "as-raw-xcb-connection", + "bytemuck", + "fastrand", + "js-sys", + "memmap2", + "ndk", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "raw-window-handle", + "redox_syscall 0.5.18", + "rustix 1.1.6", + "tiny-xlib", + "tracing", + "wasm-bindgen", + "wayland-backend", + "wayland-client", + "wayland-sys", + "web-sys", + "windows-sys 0.61.2", + "x11rb", +] + +[[package]] +name = "spin_on" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076e103ed41b9864aa838287efe5f4e3a7a0362dd00671ae62a212e5e4612da2" +dependencies = [ + "pin-utils", +] + +[[package]] +name = "spirv" +version = "0.4.0+sdk-1.4.341.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" +dependencies = [ + "bitflags 2.13.2", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "svgtypes" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f12b12995e3638c70618c1facb1ce65302f6a6f706b675f07c58a5d7391120e" +dependencies = [ + "kurbo", + "siphasher", +] + +[[package]] +name = "swash" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2499c2d826531388872b2268718aed907a39bd785ab0dcfe57fab26283f92e" +dependencies = [ + "skrifa", + "yazi", + "zeno", +] + [[package]] name = "syn" version = "2.0.119" @@ -2601,6 +5478,50 @@ dependencies = [ "syn 3.0.10", ] +[[package]] +name = "sys-locale" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" +dependencies = [ + "js-sys", + "libc", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "taffy" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aea22054047c16c3f34d3ac473a2170be1424b1115b2a3adcf28cfb067c88859" +dependencies = [ + "arrayvec", + "grid", + "serde", + "slotmap", +] + +[[package]] +name = "tar" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "task-local" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2972044a9e5e448a506a7ff6f0d03b566d8ef4cd6918a58fc59835a0f8666626" +dependencies = [ + "pin-project-lite", +] + [[package]] name = "tempfile" version = "3.27.0" @@ -2610,10 +5531,16 @@ dependencies = [ "fastrand", "getrandom 0.4.3", "once_cell", - "rustix", + "rustix 1.1.6", "windows-sys 0.61.2", ] +[[package]] +name = "text-size" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" + [[package]] name = "thiserror" version = "1.0.69" @@ -2684,6 +5611,70 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path 0.11.4", +] + +[[package]] +name = "tiny-skia" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ffee5eaaf5527f630fb0e356b90ebdec84d5d18d937c5e440350f88c5a91ea" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png", + "tiny-skia-path 0.12.0", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tiny-skia-path" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca365c3faccca67d06593c5980fa6c57687de727a03131735bb85f01fdeeb9" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tiny-xlib" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a90a0ca3ee6a69f2ad28fd11621a4c3f03b371f366be500b64df260c4ffbafb4" +dependencies = [ + "as-raw-xcb-connection", + "ctor", + "libloading", + "pkg-config", + "tracing", +] + [[package]] name = "tinystr" version = "0.8.5" @@ -2695,6 +5686,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + [[package]] name = "toml" version = "0.5.11" @@ -2737,6 +5743,7 @@ dependencies = [ "indexmap", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] @@ -2761,6 +5768,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2786,13 +5794,40 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tree_magic_mini" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" +dependencies = [ + "memchr", + "nom 8.0.0", + "petgraph", +] + +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + [[package]] name = "type-map" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90" dependencies = [ - "rustc-hash", + "rustc-hash 2.1.3", +] + +[[package]] +name = "typed-index-collections" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898160f1dfd383b4e92e17f0512a7d62f3c51c44937b23b6ffc3a1614a8eaccd" +dependencies = [ + "bincode", + "serde", ] [[package]] @@ -2801,6 +5836,18 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" +[[package]] +name = "udev" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af4e37e9ea4401fc841ff54b9ddfc9be1079b1e89434c1a6a865dd68980f7e9f" +dependencies = [ + "io-lifetimes", + "libc", + "libudev-sys", + "pkg-config", +] + [[package]] name = "uds_windows" version = "1.2.1" @@ -2837,12 +5884,54 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + [[package]] name = "unicode-ident" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-script" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-vo" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "universal-hash" version = "0.5.1" @@ -2859,6 +5948,12 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "unty" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" + [[package]] name = "ureq" version = "3.5.2" @@ -2903,6 +5998,34 @@ dependencies = [ "serde", ] +[[package]] +name = "usvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977d0a4abdef933f424a99fe09f95576e089b90aebc6f016a3bc813762493e91" +dependencies = [ + "base64 0.23.1", + "data-url", + "flate2", + "fontdb", + "harfrust", + "imagesize", + "kurbo", + "log", + "pico-args", + "roxmltree", + "simplecss", + "siphasher", + "skrifa", + "strict-num", + "svgtypes", + "tiny-skia-path 0.12.0", + "unicode-bidi", + "unicode-script", + "unicode-vo", + "xmlwriter", +] + [[package]] name = "utf8-zero" version = "0.8.1" @@ -2938,6 +6061,29 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "vtable" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b61cfbcacfc3669ee9afb88566e2b5eb7de86ebcf7b81409c3f8a767e0e0e7ce" +dependencies = [ + "const-field-offset", + "portable-atomic", + "stable_deref_trait", + "vtable-macro", +] + +[[package]] +name = "vtable-macro" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a8daeaea1a2d710306a00be752bda09b11011e4aa0e816ad768348491a1ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "walkdir" version = "2.5.0" @@ -2954,6 +6100,15 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.130" @@ -2966,6 +6121,17 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.130" @@ -2998,6 +6164,151 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wayland-backend" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "rustix 1.1.6", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" +dependencies = [ + "bitflags 2.13.2", + "rustix 1.1.6", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.13.2", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" +dependencies = [ + "rustix 1.1.6", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "1.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73e91ccd4698f2647d6137e8eb17a3f1dcfd63810be9029fb2398f507279b95b" +dependencies = [ + "jni", + "log", + "ndk-context", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "url", + "web-sys", +] + [[package]] name = "webpki-roots" version = "1.0.12" @@ -3007,6 +6318,158 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146fc3d654250e6207921a66c87534c621bc886c70df83dcf466c1d66813810e" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "log", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad661da2ee99f208c30090b585284b2ab5b8bf2358ddf2d2215592808ec62f1a" +dependencies = [ + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "indexmap", + "log", + "naga", + "naga-types", + "once_cell", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-apple", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-core-deps-apple" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d3f2f24aee039ffe9ef527300daf6b7428c58edeefdaa1700f4fa0fd754df16" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1331b08fa2362c5d454eccc4448e6e4f01eccfea569a00e310adbfc4415f2bdc" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a57452fe453658e141aafdb09de1028afa498805fab518238ddf372a518813ff" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "gpu-allocator", + "hashbrown 0.17.1", + "libc", + "libloading", + "log", + "naga", + "naga-types", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "raw-window-metal", + "renderdoc-sys", + "smallvec", + "static_assertions", + "thiserror 2.0.21", + "wgpu-naga-bridge", + "wgpu-types", + "windows", + "windows-core", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44a62ead68aad7cd40ac9e2cd2b8ec64f32dfbad2765f429b9fb74b8b735869f" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f6ee0bd50f5ab79fb8c25e3f33afb27126f034af4ba5909c7a0967058659e6" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", +] + [[package]] name = "winapi-util" version = "0.1.11" @@ -3016,6 +6479,73 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "windows-link" version = "0.2.1" @@ -3035,13 +6565,50 @@ dependencies = [ "zeroize", ] +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core", + "windows-link", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3053,34 +6620,76 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -3093,30 +6702,106 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winit" +version = "0.30.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.13.2", + "block2 0.5.1", + "bytemuck", + "calloop 0.13.0", + "cfg_aliases", + "concurrent-queue", + "core-foundation 0.9.4", + "core-graphics", + "cursor-icon", + "dpi", + "js-sys", + "libc", + "memmap2", + "ndk", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit 0.2.2", + "orbclient", + "percent-encoding", + "pin-project", + "raw-window-handle", + "redox_syscall 0.4.1", + "rustix 0.38.44", + "sctk-adwaita", + "smithay-client-toolkit", + "smol_str 0.2.2", + "tracing", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.52.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", +] + [[package]] name = "winnow" version = "1.0.5" @@ -3126,12 +6811,81 @@ dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wl-clipboard-rs" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959c7ac3b8afde864f7a7448ac16f29b2b83350b7eccbf77fb781c3999aa6848" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 1.1.6", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "write-fonts" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae90d1d9f6d1d36ef116b0b1e651a6d7c12ba925439d4d06ff9adc94662a3d8" +dependencies = [ + "font-types", + "indexmap", + "kurbo", + "log", + "read-fonts", +] + [[package]] name = "writeable" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" +dependencies = [ + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading", + "once_cell", + "rustix 1.1.6", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + [[package]] name = "x25519-dalek" version = "2.0.1" @@ -3144,6 +6898,81 @@ dependencies = [ "zeroize", ] +[[package]] +name = "xattr" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963d6fab92d5504b971dc8bd90ca743c2575e590bc8071ea5bc571598667ae08" +dependencies = [ + "libc", + "rustix 1.1.6", +] + +[[package]] +name = "xcursor" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" + +[[package]] +name = "xkbcommon" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d" +dependencies = [ + "libc", + "memmap2", + "xkeysym", +] + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.13.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + +[[package]] +name = "yazi" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac366ea532fa8ee6a992cec9dea525b1dc284e69702f36c2ab5fbebadc81ec86" + +[[package]] +name = "yeslogic-fontconfig-sys" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8b8abf912b9a29ff112e1671c97c33636903d13a69712037190e6805af4f76" +dependencies = [ + "dlib", + "once_cell", + "pkg-config", +] + [[package]] name = "yoke" version = "0.8.4" @@ -3189,7 +7018,7 @@ dependencies = [ "hex", "libc", "ordered-stream", - "rustix", + "rustix 1.1.6", "serde", "serde_repr", "tracing", @@ -3248,6 +7077,12 @@ dependencies = [ "serde", ] +[[package]] +name = "zeno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" + [[package]] name = "zerocopy" version = "0.8.63" @@ -3318,6 +7153,7 @@ dependencies = [ "displaydoc", "yoke", "zerofrom", + "zerovec", ] [[package]] @@ -3355,6 +7191,21 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] + [[package]] name = "zvariant" version = "5.15.1" diff --git a/Cargo.toml b/Cargo.toml index a315bd8..615032b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "3" -members = ["crates/grove-core", "crates/grove", "crates/grove-daemon", "crates/grove-providers", "crates/grove-bridge"] +members = ["crates/grove-core", "crates/grove", "crates/grove-daemon", "crates/grove-providers", "crates/grove-gui"] [workspace.package] edition = "2024" diff --git a/assets/grove.png b/assets/grove.png new file mode 100644 index 0000000000000000000000000000000000000000..76c0e695f7f1deda97063e59d8d56b29cf8a6e21 GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Gdx`!Ln`LHy5ZwTyJ)zGW<1$0TbS9?K1MBZH@_pUXO@ GgeCy22}BA2 literal 0 HcmV?d00001 diff --git a/crates/grove-bridge/Cargo.toml b/crates/grove-bridge/Cargo.toml deleted file mode 100644 index 508e322..0000000 --- a/crates/grove-bridge/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "grove-bridge" -description = "Backend of the grove GUI: daemon IPC + allow-listed CLI calls, and a localhost dev server" -edition.workspace = true -version.workspace = true -license.workspace = true - -[dependencies] -anyhow = "1.0.104" -grove-daemon = { version = "0.1.0", path = "../grove-daemon" } -serde_json = "1.0.154" -toml = "1.2.1" diff --git a/crates/grove-bridge/src/main.rs b/crates/grove-bridge/src/main.rs deleted file mode 100644 index 5c7c126..0000000 --- a/crates/grove-bridge/src/main.rs +++ /dev/null @@ -1,155 +0,0 @@ -//! Localhost dev server for the GUI frontend: static files plus the `Bridge` calls over HTTP. -//! Binds to 127.0.0.1 only. POSTs need the `X-Grove: 1` header (not sendable cross-origin -//! without a preflight, which is never answered); the Host must be exactly 127.0.0.1: or -//! localhost: and any Origin must match too (DNS rebinding). - -use anyhow::{Context, Result}; -use grove_bridge::Bridge; -use serde_json::{Value, json}; -use std::io::{BufRead, BufReader, Read, Write}; -use std::net::{TcpListener, TcpStream}; -use std::path::PathBuf; -use std::sync::Arc; - -fn arg(name: &str) -> Option { - let a: Vec = std::env::args().collect(); - a.iter() - .position(|x| x == name) - .and_then(|i| a.get(i + 1)) - .cloned() -} - -fn main() -> Result<()> { - let ui = PathBuf::from(arg("--ui").unwrap_or_else(|| "gui/ui".into())); - let port: u16 = arg("--port") - .map_or(Ok(4780), |p| p.parse()) - .context("bad --port")?; - let bridge = Arc::new(Bridge { - grove_bin: arg("--grove-bin").map_or_else(|| "grove".into(), PathBuf::from), - config: arg("--config").map(PathBuf::from), - socket: arg("--socket") - .map(PathBuf::from) - .unwrap_or_else(grove_daemon::ipc::default_socket_path), - }); - let l = TcpListener::bind(("127.0.0.1", port)).with_context(|| format!("port {port}"))?; - eprintln!( - "grove GUI dev server on http://127.0.0.1:{port}/ (ui: {})", - ui.display() - ); - for s in l.incoming().filter_map(Result::ok) { - let (b, ui) = (bridge.clone(), ui.clone()); - let _ = s.set_read_timeout(Some(std::time::Duration::from_secs(10))); - std::thread::spawn(move || { - let _ = handle(s, &b, &ui, port); - }); - } - Ok(()) -} - -fn respond(s: &mut TcpStream, status: &str, ctype: &str, body: &[u8]) -> std::io::Result<()> { - write!( - s, - "HTTP/1.1 {status}\r\nContent-Type: {ctype}\r\nContent-Length: {}\r\nCache-Control: no-store\r\nConnection: close\r\n\r\n", - body.len() - )?; - s.write_all(body) -} - -fn handle(mut s: TcpStream, b: &Bridge, ui: &std::path::Path, port: u16) -> std::io::Result<()> { - // Cap what a client can make us buffer while reading the request head. - let mut r = BufReader::new(s.try_clone()?.take(64 * 1024)); - let mut line = String::new(); - r.read_line(&mut line)?; - let mut it = line.split_whitespace(); - let (method, path) = ( - it.next().unwrap_or("").to_string(), - it.next().unwrap_or("/").to_string(), - ); - let (mut len, mut host, mut marker, mut origin) = (0usize, String::new(), false, None); - loop { - let mut h = String::new(); - if r.read_line(&mut h)? == 0 || h.trim().is_empty() { - break; - } - let lower = h.to_ascii_lowercase(); - if let Some(v) = lower.strip_prefix("content-length:") { - len = v.trim().parse().unwrap_or(0); - } else if let Some(v) = lower.strip_prefix("host:") { - host = v.trim().to_string(); - } else if let Some(v) = lower.strip_prefix("origin:") { - origin = Some(v.trim().to_string()); - } else if lower.starts_with("x-grove:") { - marker = true; - } - } - // Exact match: a prefix check would accept `localhost.evil.com` (DNS rebinding). - let local = [format!("127.0.0.1:{port}"), format!("localhost:{port}")]; - if !local.contains(&host) { - return respond(&mut s, "403 Forbidden", "text/plain", b"bad host"); - } - if let Some(o) = &origin - && !local.iter().any(|h| *o == format!("http://{h}")) - { - return respond(&mut s, "403 Forbidden", "text/plain", b"bad origin"); - } - if method == "POST" { - if !marker || len > 1 << 20 { - return respond(&mut s, "403 Forbidden", "text/plain", b"forbidden"); - } - r.get_mut().set_limit(1 << 20); // head parsed; allow the (capped) body - let mut body = vec![0u8; len]; - r.read_exact(&mut body)?; - let req: Value = serde_json::from_slice(&body).unwrap_or(Value::Null); - let out = match path.as_str() { - "/api/ipc" => b.ipc(&req), - "/api/cli" => { - let args: Vec = req["args"] - .as_array() - .map(|a| { - a.iter() - .filter_map(|x| x.as_str().map(String::from)) - .collect() - }) - .unwrap_or_default(); - b.cli(&args, req["stdin"].as_str().unwrap_or("")) - } - _ => return respond(&mut s, "404 Not Found", "text/plain", b"not found"), - }; - return respond( - &mut s, - "200 OK", - "application/json", - out.to_string().as_bytes(), - ); - } - if path == "/api/config" { - let body = match b.config_json() { - Some(c) => json!({"exists": true, "config": c}), - None => json!({"exists": false}), - }; - return respond( - &mut s, - "200 OK", - "application/json", - body.to_string().as_bytes(), - ); - } - let name = match path.split('?').next().unwrap_or("/") { - "/" => "index.html", - p => p.trim_start_matches('/'), - }; - if name.contains("..") { - return respond(&mut s, "403 Forbidden", "text/plain", b"forbidden"); - } - let ctype = match name.rsplit('.').next() { - Some("html") => "text/html; charset=utf-8", - Some("js") => "text/javascript; charset=utf-8", - Some("css") => "text/css; charset=utf-8", - Some("svg") => "image/svg+xml", - _ => "application/octet-stream", - }; - match std::fs::read(ui.join(name)) { - Ok(data) => respond(&mut s, "200 OK", ctype, &data), - Err(_) => respond(&mut s, "404 Not Found", "text/plain", b"not found"), - } -} diff --git a/crates/grove-gui/Cargo.toml b/crates/grove-gui/Cargo.toml new file mode 100644 index 0000000..af5d492 --- /dev/null +++ b/crates/grove-gui/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "grove-gui" +description = "Native desktop GUI for grove: tray icon, window, daemon IPC" +edition.workspace = true +version.workspace = true +license.workspace = true + +[[bin]] +name = "grove-gui" +path = "src/main.rs" + +[dependencies] +anyhow = "1.0.104" +grove-daemon = { version = "0.1.0", path = "../grove-daemon" } +# async-io instead of the default tokio: no second async runtime in a small tray app. +ksni = { version = "0.3.7", default-features = false, features = ["async-io", "blocking"] } +serde_json = "1.0.154" +slint = { version = "=1.18.1", default-features = false, features = ["std", "backend-winit", "renderer-software", "compat-1-2"] } +toml = "1.2.1" + +[build-dependencies] +slint-build = "=1.18.1" diff --git a/crates/grove-gui/build.rs b/crates/grove-gui/build.rs new file mode 100644 index 0000000..c742d55 --- /dev/null +++ b/crates/grove-gui/build.rs @@ -0,0 +1,5 @@ +fn main() { + // `fluent` is a pure-Slint style: no Qt needed on the machine. + let config = slint_build::CompilerConfiguration::new().with_style("fluent".into()); + slint_build::compile_with_config("ui/app.slint", config).expect("slint compile"); +} diff --git a/crates/grove-bridge/src/lib.rs b/crates/grove-gui/src/bridge.rs similarity index 94% rename from crates/grove-bridge/src/lib.rs rename to crates/grove-gui/src/bridge.rs index 997974f..6d2b73c 100644 --- a/crates/grove-bridge/src/lib.rs +++ b/crates/grove-gui/src/bridge.rs @@ -1,5 +1,4 @@ -//! Everything the GUI needs from the machine, behind three calls. The Tauri shell and the -//! localhost dev server both expose exactly these. +//! Everything the GUI needs from the machine: daemon IPC, allow-listed `grove` calls, config. use serde_json::{Value, json}; use std::io::Write; @@ -91,7 +90,18 @@ impl Bridge { /// Per-command flag table: (flags without value, flags taking one value). fn flag_spec(sub: &str) -> (&'static [&'static str], &'static [&'static str]) { match sub { - "init" => (&[], &["--machine", "--root", "--provider", "--kind", "--group", "--config-repo", "--url"]), + "init" => ( + &[], + &[ + "--machine", + "--root", + "--provider", + "--kind", + "--group", + "--config-repo", + "--url", + ], + ), "new" => (&["--public"], &[]), "resolve" => (&["--take-remote", "--keep-local"], &["--save-as"]), _ => (&[], &[]), diff --git a/crates/grove-gui/src/instance.rs b/crates/grove-gui/src/instance.rs new file mode 100644 index 0000000..d3a45c5 --- /dev/null +++ b/crates/grove-gui/src/instance.rs @@ -0,0 +1,107 @@ +//! Single instance: the first process listens on a Unix socket; a second launch asks it to show +//! its window and exits. + +use std::io::{BufRead, BufReader, Write}; +use std::os::unix::net::{UnixListener, UnixStream}; +use std::path::{Path, PathBuf}; +use std::time::Duration; + +/// `$XDG_RUNTIME_DIR/grove/gui.sock` (same private directory as the daemon socket). +pub fn default_socket_path() -> PathBuf { + let base = std::env::var_os("XDG_RUNTIME_DIR") + .map(PathBuf::from) + .unwrap_or_else(std::env::temp_dir); + base.join("grove").join("gui.sock") +} + +pub enum Role { + /// Another instance is running and has been told to show (or ignore, when `show` is false). + Secondary, + /// This process owns the socket. + Primary(UnixListener), +} + +/// Tries to hand over to a running instance; otherwise becomes the primary one. +pub fn acquire(path: &Path, show: bool) -> std::io::Result { + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + for _ in 0..3 { + if notify(path, if show { "show" } else { "ping" }).is_ok() { + return Ok(Role::Secondary); + } + // Nobody answers: a stale socket from a crash is replaced. + let _ = std::fs::remove_file(path); + match UnixListener::bind(path) { + Ok(l) => return Ok(Role::Primary(l)), + Err(e) if e.kind() == std::io::ErrorKind::AddrInUse => continue, + Err(e) => return Err(e), + } + } + Err(std::io::Error::other("cannot acquire the instance socket")) +} + +fn notify(path: &Path, msg: &str) -> std::io::Result<()> { + let mut c = UnixStream::connect(path)?; + c.set_read_timeout(Some(Duration::from_secs(2)))?; + writeln!(c, "{msg}")?; + let mut line = String::new(); + BufReader::new(c).read_line(&mut line)?; + if line.trim() == "ok" { + Ok(()) + } else { + Err(std::io::Error::other("unexpected answer")) + } +} + +/// Serves the primary socket forever; calls `on_show` for every `show` request. +pub fn serve(listener: UnixListener, on_show: impl Fn() + Send + 'static) { + for conn in listener.incoming().flatten() { + let _ = conn.set_read_timeout(Some(Duration::from_secs(2))); + let mut line = String::new(); + let mut conn = BufReader::new(conn); + if conn.read_line(&mut line).is_err() { + continue; + } + if line.trim() == "show" { + on_show(); + } + let _ = writeln!(conn.get_mut(), "ok"); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::mpsc; + + fn tmp_sock(tag: &str) -> PathBuf { + let d = std::env::temp_dir().join(format!("gg-{tag}-{}", std::process::id())); + std::fs::create_dir_all(&d).unwrap(); + d.join("gui.sock") + } + + #[test] + fn second_launch_asks_first_to_show() { + let p = tmp_sock("show"); + let Role::Primary(l) = acquire(&p, true).unwrap() else { + panic!("first must be primary"); + }; + let (tx, rx) = mpsc::channel(); + std::thread::spawn(move || serve(l, move || tx.send(()).unwrap())); + assert!(matches!(acquire(&p, true).unwrap(), Role::Secondary)); + rx.recv_timeout(Duration::from_secs(2)) + .expect("show callback"); + // A hidden (autostart) relaunch does not pop the window. + assert!(matches!(acquire(&p, false).unwrap(), Role::Secondary)); + assert!(rx.recv_timeout(Duration::from_millis(200)).is_err()); + } + + #[test] + fn stale_socket_is_replaced() { + let p = tmp_sock("stale"); + drop(UnixListener::bind(&p).unwrap()); // leaves the socket file behind + assert!(p.exists()); + assert!(matches!(acquire(&p, true).unwrap(), Role::Primary(_))); + } +} diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs new file mode 100644 index 0000000..e99a2b7 --- /dev/null +++ b/crates/grove-gui/src/main.rs @@ -0,0 +1,979 @@ +//! grove-gui: native desktop GUI (Slint) with a StatusNotifierItem tray. +//! +//! Threads: the Slint event loop (main), a worker that polls the daemon, a subscriber that wakes +//! the worker on daemon events, the tray service, the single-instance listener, and short-lived +//! threads for CLI calls. Nothing runs on a timer while the daemon is quiet. + +mod bridge; +mod instance; +mod model; +mod tray; + +use anyhow::{Context, Result}; +use bridge::Bridge; +use model::{Aggregate, TrayState}; +use serde_json::{Value, json}; +use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel, Weak}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::io::{BufRead, BufReader, Write}; +use std::os::unix::net::UnixStream; +use std::path::PathBuf; +use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; +use tray::Action; + +slint::include_modules!(); + +/// Fallback poll interval; daemon events wake the worker earlier. +const POLL_VISIBLE: Duration = Duration::from_secs(5); +const POLL_HIDDEN: Duration = Duration::from_secs(30); +const MIN_GAP: Duration = Duration::from_millis(500); +const RECONNECT: Duration = Duration::from_secs(5); + +/// Everything the UI shows, taken from one refresh. +struct Snapshot { + status: Option, + log: Vec, + config: Option, + alerts: Vec<(String, String)>, +} + +/// State shared between threads. +struct Core { + bridge: Bridge, + tx: Mutex>, + paused: AtomicBool, + visible: AtomicBool, + tray_ok: AtomicBool, +} + +impl Core { + fn wake(&self) { + let _ = self.tx.lock().unwrap().send(()); + } + + fn set_visible(&self, v: bool) { + self.visible.store(v, Ordering::SeqCst); + let _ = self.tx.lock().unwrap().send(()); + } + + /// Fire-and-forget daemon command; `then` runs on the UI thread with the answer. + fn ipc_bg(self: &Arc, req: Value, then: impl FnOnce(&Value) + Send + 'static) { + let core = self.clone(); + std::thread::spawn(move || { + let r = core.bridge.ipc(&req); + let _ = slint::invoke_from_event_loop(move || then(&r)); + core.wake(); + }); + } + + fn toggle_pause(self: &Arc) { + let cmd = if self.paused.load(Ordering::SeqCst) { + "resume" + } else { + "pause" + }; + self.ipc_bg(json!({"v": 1, "cmd": cmd}), |_| {}); + } + + fn sync(self: &Arc, repo: Option<&str>, weak: Weak) { + let mut req = json!({"v": 1, "cmd": "sync"}); + let msg = if let Some(r) = repo { + req["repo"] = json!(r); + "Sync queued" + } else { + "Sync queued for all repositories" + }; + self.ipc_bg(req, move |r| { + if let Some(ui) = weak.upgrade() { + let ok = r["ok"] == true; + toast( + &ui, + if ok { + msg + } else { + r["error"].as_str().unwrap_or("failed") + }, + !ok, + ); + } + }); + } +} + +#[derive(Clone)] +struct Ctx { + core: Arc, + weak: Weak, +} + +/// UI-thread state. +struct UiState { + snap: Option, + outputs: HashMap, + filter: String, + pending: Option>, + picks: Rc>, + toast_gen: u32, + last_groups: Vec, + last_providers: Vec, +} + +thread_local! { + static ST: RefCell = RefCell::new(UiState { + snap: None, + outputs: HashMap::new(), + filter: String::new(), + pending: None, + picks: Rc::new(VecModel::default()), + toast_gen: 0, + last_groups: Vec::new(), + last_providers: Vec::new(), + }); +} + +fn s(v: &Value, k: &str) -> String { + v.get(k).and_then(Value::as_str).unwrap_or("").to_string() +} + +fn utc_offset_s() -> i64 { + let out = std::process::Command::new("date").arg("+%z").output().ok(); + let z = out + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) + .unwrap_or_default(); + if z.len() == 5 { + let sign = if z.starts_with('-') { -1 } else { 1 }; + if let (Ok(h), Ok(m)) = (z[1..3].parse::(), z[3..5].parse::()) { + return sign * (h * 3600 + m * 60); + } + } + 0 +} + +fn pill_key(t: TrayState) -> &'static str { + match t { + TrayState::Ok => "ok", + TrayState::Syncing => "warn", + TrayState::Attention => "bad", + TrayState::Paused => "paused", + TrayState::Offline => "offline", + } +} + +fn str_model(v: &[String]) -> ModelRc { + ModelRc::from(Rc::new(VecModel::from( + v.iter().map(SharedString::from).collect::>(), + ))) +} + +fn render(ui: &MainWindow) { + ST.with(|st| { + let mut st = st.borrow_mut(); + let st = &mut *st; + let Some(snap) = &st.snap else { + return; + }; + let agg = model::aggregate(snap.status.as_ref()); + let now = snap + .status + .as_ref() + .and_then(|s| s["now"].as_u64()) + .unwrap_or(0); + ui.set_loading(false); + ui.set_offline(snap.status.is_none()); + ui.set_paused(agg.state == TrayState::Paused); + ui.set_pill_text(agg.text.clone().into()); + ui.set_pill_key(pill_key(agg.state).into()); + ui.set_machine( + snap.status + .as_ref() + .map(|s| s["machine"].as_str().unwrap_or("").to_string()) + .unwrap_or_default() + .into(), + ); + ui.set_repo_count(agg.repos as i32); + ui.set_wt_count(agg.worktrees as i32); + ui.set_attention_count(agg.attention as i32); + ui.set_has_config(snap.config.is_some()); + + let empty = Vec::new(); + let repos: Vec = snap + .status + .as_ref() + .and_then(|s| s["repos"].as_array()) + .unwrap_or(&empty) + .iter() + .map(|r| { + let wts: Vec = r["worktrees"] + .as_array() + .unwrap_or(&empty) + .iter() + .map(|w| { + let state = s(w, "state"); + let key = model::state_name(&state).to_string(); + let path = s(w, "path"); + let (out, out_ok) = st + .outputs + .get(&path) + .map(|(ok, t)| (t.clone(), *ok)) + .unwrap_or_default(); + let branch = s(w, "branch"); + Wt { + branch: if branch.is_empty() { + "(detached)".into() + } else { + branch.into() + }, + path: path.into(), + label: model::state_label(&state).into(), + plan: model::state_plan(&state).into(), + state: key.into(), + out: out.into(), + out_ok, + } + }) + .collect(); + let path = s(r, "path"); + Repo { + name: model::short(&path).into(), + phase: s(r, "phase").into(), + last_sync: model::ago(r["last_sync"].as_u64().unwrap_or(0), now).into(), + error: r["last_error"].as_str().unwrap_or("").into(), + path: path.into(), + wts: ModelRc::from(Rc::new(VecModel::from(wts))), + } + }) + .collect(); + + let selected = ui.get_selected_path().to_string(); + if let Some(r) = repos.iter().find(|r| r.path == selected) { + ui.set_detail(r.clone()); + ui.set_detail_found(true); + } else { + ui.set_detail_found(false); + } + // Long errors are cut in the list; the detail view shows them in full. + let repos: Vec = repos + .into_iter() + .map(|mut r| { + if r.error.chars().count() > 160 { + r.error = format!("{}…", r.error.chars().take(160).collect::()).into(); + } + r + }) + .collect(); + ui.set_repos(ModelRc::from(Rc::new(VecModel::from(repos)))); + + // The activity log is only built while its view is open. + if ui.get_view() == "activity" { + let f = st.filter.to_lowercase(); + let off = utc_offset_s(); + let rows: Vec = snap + .log + .iter() + .rev() + .filter(|e| { + f.is_empty() + || format!("{} {} {}", s(e, "kind"), s(e, "repo"), s(e, "msg")) + .to_lowercase() + .contains(&f) + }) + .map(|e| LogRow { + time: model::clock(e["ts"].as_u64().unwrap_or(0), off).into(), + kind: s(e, "kind").into(), + repo: e["repo"].as_str().unwrap_or("–").into(), + msg: s(e, "msg").lines().next().unwrap_or("").into(), + }) + .collect(); + ui.set_log(ModelRc::from(Rc::new(VecModel::from(rows)))); + } + + if let Some(cfg) = &snap.config { + let groups: Vec = cfg["groups"] + .as_array() + .unwrap_or(&empty) + .iter() + .map(|g| format!("{} → {}", s(g, "name"), s(g, "primary"))) + .collect(); + let providers: Vec = cfg["providers"] + .as_object() + .map(|m| m.keys().cloned().collect()) + .unwrap_or_default(); + // Re-setting a combo model would reset its selection: only on change. + if groups != st.last_groups { + ui.set_groups(str_model(&groups)); + st.last_groups = groups; + } + if providers != st.last_providers { + ui.set_providers(str_model(&providers)); + st.last_providers = providers; + } + let secs: Vec
= model::settings_sections(cfg) + .into_iter() + .map(|(title, rows)| Section { + title: title.into(), + rows: ModelRc::from(Rc::new(VecModel::from( + rows.into_iter() + .map(|(k, v)| Kv { + key: k.into(), + value: v.into(), + }) + .collect::>(), + ))), + }) + .collect(); + ui.set_sections(ModelRc::from(Rc::new(VecModel::from(secs)))); + } + }); +} + +fn toast(ui: &MainWindow, msg: &str, bad: bool) { + let gen_ = ST.with(|st| { + let mut st = st.borrow_mut(); + st.toast_gen += 1; + st.toast_gen + }); + ui.set_toast_text(msg.into()); + ui.set_toast_bad(bad); + let weak = ui.as_weak(); + slint::Timer::single_shot(Duration::from_secs(5), move || { + if let Some(ui) = weak.upgrade() + && ST.with(|st| st.borrow().toast_gen) == gen_ + { + ui.set_toast_text("".into()); + } + }); +} + +fn show_window(ui: &MainWindow, core: &Core) { + let _ = ui.show(); + // On Wayland a window shown from an idle (hidden) loop is not mapped until another event + // arrives; a one-shot redraw request provides it. + let w = ui.as_weak(); + slint::Timer::single_shot(Duration::from_millis(100), move || { + if let Some(ui) = w.upgrade() { + ui.window().request_redraw(); + } + }); + core.set_visible(true); + render(ui); +} + +/// Runs an allow-listed `grove` subcommand off the UI thread; `done` runs on the UI thread. +fn run_cli( + ctx: &Ctx, + ui: &MainWindow, + args: Vec, + stdin: String, + done: impl FnOnce(&MainWindow, bool, String) + Send + 'static, +) { + ui.set_busy(true); + let (core, weak) = (ctx.core.clone(), ctx.weak.clone()); + std::thread::spawn(move || { + let r = core.bridge.cli(&args, &stdin); + let ok = r["ok"] == true; + let text = r["output"].as_str().unwrap_or("").to_string(); + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = weak.upgrade() { + ui.set_busy(false); + done(&ui, ok, text); + } + }); + core.wake(); + }); +} + +fn out(ok: bool, text: String) -> Out { + Out { + ok, + text: text.into(), + } +} + +fn scan(ctx: &Ctx, ui: &MainWindow, group: String) { + ui.set_import_note("Scanning…".into()); + ui.set_import_out(out(true, String::new())); + ST.with(|st| st.borrow().picks.set_vec(vec![])); + run_cli( + ctx, + ui, + vec!["import".into(), group], + String::new(), + |ui, ok, text| { + ui.set_import_note("".into()); + if !ok { + ui.set_import_out(out(false, text)); + return; + } + let names = model::parse_import_listing(&text); + if names.is_empty() { + ui.set_import_note( + "Nothing to import: every remote repository is already on this machine.".into(), + ); + } + ST.with(|st| { + st.borrow().picks.set_vec( + names + .into_iter() + .map(|n| Pick { + name: n.into(), + checked: false, + }) + .collect::>(), + ) + }); + }, + ); +} + +fn first_or(v: &str, list: &ModelRc) -> String { + if v.is_empty() { + list.row_data(0).map(|x| x.to_string()).unwrap_or_default() + } else { + v.to_string() + } +} + +fn wire(ui: &MainWindow, ctx: &Ctx) { + ST.with(|st| ui.set_picks(ModelRc::from(st.borrow().picks.clone()))); + + ui.on_view_changed({ + let c = ctx.clone(); + move |_| c.core.wake() + }); + ui.on_open_repo({ + let w = ui.as_weak(); + move |p| { + if let Some(ui) = w.upgrade() { + ui.set_selected_path(p); + ui.set_view("repo".into()); + render(&ui); + } + } + }); + ui.on_sync_repo({ + let c = ctx.clone(); + move |p| c.core.sync(Some(p.as_str()), c.weak.clone()) + }); + ui.on_sync_all({ + let c = ctx.clone(); + move || c.core.sync(None, c.weak.clone()) + }); + ui.on_toggle_pause({ + let c = ctx.clone(); + move || c.core.toggle_pause() + }); + ui.on_filter_changed({ + let w = ui.as_weak(); + move |t| { + ST.with(|st| st.borrow_mut().filter = t.to_string()); + if let Some(ui) = w.upgrade() { + render(&ui); + } + } + }); + + ui.on_create_repo({ + let c = ctx.clone(); + move |group, name, public| { + let Some(ui) = c.weak.upgrade() else { return }; + let group = model::group_name(&first_or(group.as_str(), &ui.get_groups())).to_string(); + let mut args = vec!["new".to_string(), group, name.trim().to_string()]; + if public { + args.push("--public".into()); + } + ui.set_new_out(out(true, String::new())); + run_cli(&c, &ui, args, String::new(), |ui, ok, text| { + ui.set_new_out(out(ok, text)); + if ok { + toast(ui, "Repository created", false); + } + }); + } + }); + + ui.on_scan_import({ + let c = ctx.clone(); + move |group| { + let Some(ui) = c.weak.upgrade() else { return }; + let group = model::group_name(&first_or(group.as_str(), &ui.get_groups())).to_string(); + scan(&c, &ui, group); + } + }); + ui.on_pick_toggled(|i, checked| { + ST.with(|st| { + let m = st.borrow().picks.clone(); + if let Some(mut p) = m.row_data(i as usize) { + p.checked = checked; + m.set_row_data(i as usize, p); + } + }); + }); + ui.on_import_selected({ + let c = ctx.clone(); + move |group| { + let Some(ui) = c.weak.upgrade() else { return }; + let group = model::group_name(&first_or(group.as_str(), &ui.get_groups())).to_string(); + let picked: Vec = ST.with(|st| { + st.borrow() + .picks + .iter() + .filter(|p| p.checked) + .map(|p| p.name.to_string()) + .collect() + }); + if picked.is_empty() { + return; + } + let mut args = vec!["import".to_string(), group.clone()]; + args.extend(picked); + let c2 = c.clone(); + run_cli(&c, &ui, args, String::new(), move |ui, ok, text| { + ui.set_import_out(out(ok, text)); + if ok { + scan(&c2, ui, group); + } + }); + } + }); + + ui.on_resolve({ + let w = ui.as_weak(); + move |path, mode, branch| { + let Some(ui) = w.upgrade() else { return }; + let (flags, label): (Vec, String) = match mode.as_str() { + "save" => { + let b = branch.trim().to_string(); + if b.is_empty() { + toast(&ui, "Enter a branch name first", true); + return; + } + ( + vec!["--save-as".into(), b.clone()], + format!("Keep your commits on branch “{b}” and move this branch to the remote tip."), + ) + } + "remote" => (vec!["--take-remote".into()], "Discard your local commits and take the remote tip.".into()), + _ => (vec!["--keep-local".into()], "Overwrite the remote branch with your local commits.".into()), + }; + let mut args = vec!["resolve".to_string(), path.to_string()]; + args.extend(flags); + ST.with(|st| st.borrow_mut().pending = Some(args)); + ui.set_confirm_text(label.into()); + } + }); + ui.on_confirm_cancel({ + let w = ui.as_weak(); + move || { + ST.with(|st| st.borrow_mut().pending = None); + if let Some(ui) = w.upgrade() { + ui.set_confirm_text("".into()); + } + } + }); + ui.on_confirm_accept({ + let c = ctx.clone(); + move || { + let Some(ui) = c.weak.upgrade() else { return }; + ui.set_confirm_text("".into()); + let Some(args) = ST.with(|st| st.borrow_mut().pending.take()) else { + return; + }; + let path = args[1].clone(); + run_cli(&c, &ui, args, String::new(), move |ui, ok, text| { + ST.with(|st| st.borrow_mut().outputs.insert(path, (ok, text))); + render(ui); + }); + } + }); + + ui.on_run_settings({ + let c = ctx.clone(); + move |what| { + let Some(ui) = c.weak.upgrade() else { return }; + let args: Vec = what.split('-').map(String::from).collect(); + let args = if args[0] == "config" { + vec!["config-repo-init".to_string()] + } else { + args + }; + run_cli(&c, &ui, args, String::new(), |ui, ok, text| { + ui.set_settings_out(out(ok, text)) + }); + } + }); + ui.on_login({ + let c = ctx.clone(); + move |provider, token| { + let Some(ui) = c.weak.upgrade() else { return }; + let provider = first_or(provider.as_str(), &ui.get_providers()); + run_cli( + &c, + &ui, + vec!["login".into(), provider], + format!("{token}\n"), + |ui, ok, text| { + ui.set_settings_out(out(ok, text)); + }, + ); + } + }); + + ui.on_onboard({ + let c = ctx.clone(); + move |machine, root, kind, provider, url, group, crepo, token| { + let Some(ui) = c.weak.upgrade() else { return }; + let mut init: Vec = [ + "init", + "--machine", + &machine, + "--root", + &root, + "--provider", + &provider, + "--kind", + &kind, + "--group", + &group, + "--config-repo", + &crepo, + ] + .iter() + .map(|x| x.to_string()) + .collect(); + if !url.is_empty() { + init.push("--url".into()); + init.push(url.to_string()); + } + let token = format!("{token}\n"); + ui.set_busy(true); + ui.set_onboard_out(out(true, String::new())); + let (core, weak) = (c.core.clone(), c.weak.clone()); + std::thread::spawn(move || { + let mut steps: Vec<(Vec, String)> = Vec::new(); + // A previous attempt may already have written the config. + if core.bridge.config_json().is_none() { + steps.push((init, String::new())); + } + steps.push((vec!["login".into(), provider.to_string()], token)); + steps.push((vec!["bootstrap".into()], String::new())); + let mut lines: Vec = Vec::new(); + let mut all_ok = true; + for (args, stdin) in steps { + let r = core.bridge.cli(&args, &stdin); + let ok = r["ok"] == true; + lines.push(format!( + "$ grove {}\n{}", + args[0], + r["output"].as_str().unwrap_or("") + )); + let text = lines.join("\n\n"); + let w = weak.clone(); + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = w.upgrade() { + ui.set_onboard_out(out(ok, text)); + } + }); + if !ok { + all_ok = false; + break; + } + } + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = weak.upgrade() { + ui.set_busy(false); + if all_ok { + toast(&ui, "All set", false); + ui.set_view("repos".into()); + } + } + }); + core.wake(); + }); + } + }); +} + +// ---- worker: daemon polling ----------------------------------------------------------------- + +fn worker( + core: Arc, + rx: Receiver<()>, + tray: Option, + weak: Weak, +) { + let mut last_states: HashMap = HashMap::new(); + let mut last_agg: Option = None; + let mut last_run = Instant::now() - MIN_GAP; + loop { + let interval = if core.visible.load(Ordering::SeqCst) { + POLL_VISIBLE + } else { + POLL_HIDDEN + }; + match rx.recv_timeout(interval) { + Ok(_) | Err(RecvTimeoutError::Timeout) => {} + Err(RecvTimeoutError::Disconnected) => return, + } + // Coalesce bursts of events. + let gap = last_run.elapsed(); + if gap < MIN_GAP { + std::thread::sleep(MIN_GAP - gap); + } + while rx.try_recv().is_ok() {} + last_run = Instant::now(); + + let visible = core.visible.load(Ordering::SeqCst); + let st = core.bridge.ipc(&json!({"v": 1, "cmd": "status"})); + let status = (st["ok"] == true).then(|| st["data"].clone()); + let agg = model::aggregate(status.as_ref()); + core.paused + .store(agg.state == TrayState::Paused, Ordering::SeqCst); + + let mut alerts = Vec::new(); + if let Some(s_) = &status { + for r in s_["repos"].as_array().into_iter().flatten() { + for w in r["worktrees"].as_array().into_iter().flatten() { + let path = s(r, "path"); + let branch = s(w, "branch"); + let key = format!("{path}|{branch}"); + let n = model::state_name(w["state"].as_str().unwrap_or("")).to_string(); + if let Some(prev) = last_states.get(&key) + && *prev != n + && (n == "diverged" || n == "error") + { + let title = if n == "diverged" { + "Diverged" + } else { + "Sync error" + }; + alerts.push(( + title.to_string(), + format!("{} · {branch}", model::short(&path)), + )); + } + last_states.insert(key, n); + } + } + } + if !visible { + for (t, b) in &alerts { + let _ = std::process::Command::new("notify-send") + .args(["-a", "Grove", "-i", "grove", t, b]) + .spawn() + .map(|mut c| std::thread::spawn(move || c.wait())); + } + } + + if let Some(t) = &tray + && last_agg.as_ref() != Some(&agg) + { + tray::set_state(t, &agg); + } + last_agg = Some(agg); + + if visible { + let log = if status.is_some() { + let l = core + .bridge + .ipc(&json!({"v": 1, "cmd": "log", "limit": 200})); + l["data"].as_array().cloned().unwrap_or_default() + } else { + Vec::new() + }; + let snap = Snapshot { + status, + log, + config: core.bridge.config_json(), + alerts, + }; + let w = weak.clone(); + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = w.upgrade() { + for (t, b) in &snap.alerts { + toast(&ui, &format!("{t}: {b}"), true); + } + ST.with(|st| st.borrow_mut().snap = Some(snap)); + render(&ui); + } + }); + } else { + // Keep the last status for the moment the window opens; drop the heavy parts. + let snap = Snapshot { + status, + log: Vec::new(), + config: core.bridge.config_json(), + alerts: Vec::new(), + }; + let _ = slint::invoke_from_event_loop(move || { + ST.with(|st| st.borrow_mut().snap = Some(snap)) + }); + } + } +} + +/// Wakes the worker whenever the daemon emits an activity event. +fn subscriber(core: Arc) { + loop { + if let Ok(mut c) = UnixStream::connect(&core.bridge.socket) { + if writeln!(c, r#"{{"v":1,"cmd":"subscribe"}}"#).is_ok() { + for line in BufReader::new(c).lines() { + if line.is_err() { + break; + } + core.wake(); + } + } + core.wake(); // connection ended: the daemon went away + } + std::thread::sleep(RECONNECT); + } +} + +// ---- entry ---------------------------------------------------------------------------------- + +fn default_grove_bin() -> PathBuf { + std::env::current_exe() + .ok() + .and_then(|p| p.parent().map(|d| d.join("grove"))) + .filter(|p| p.exists()) + .unwrap_or_else(|| "grove".into()) +} + +fn main() -> Result<()> { + let args: Vec = std::env::args().skip(1).collect(); + let arg = |name: &str| { + args.iter() + .position(|a| a == name) + .and_then(|i| args.get(i + 1)) + .cloned() + }; + if args.iter().any(|a| a == "--help" || a == "-h") { + println!( + "grove-gui [--hidden] [--config PATH] [--socket PATH] [--grove-bin PATH] [--view NAME]\n --hidden start in the tray without opening the window" + ); + return Ok(()); + } + let hidden = args.iter().any(|a| a == "--hidden"); + let inst_path = arg("--instance-socket") + .map(PathBuf::from) + .unwrap_or_else(instance::default_socket_path); + let listener = match instance::acquire(&inst_path, !hidden).context("single-instance check")? { + instance::Role::Secondary => return Ok(()), + instance::Role::Primary(l) => l, + }; + + let bridge = Bridge { + grove_bin: arg("--grove-bin") + .map(PathBuf::from) + .unwrap_or_else(default_grove_bin), + config: arg("--config").map(PathBuf::from), + socket: arg("--socket") + .map(PathBuf::from) + .unwrap_or_else(grove_daemon::ipc::default_socket_path), + }; + let (tx, rx) = mpsc::channel(); + let core = Arc::new(Core { + bridge, + tx: Mutex::new(tx), + paused: AtomicBool::new(false), + visible: AtomicBool::new(false), + tray_ok: AtomicBool::new(false), + }); + + slint::set_xdg_app_id("grove").ok(); + let ui = MainWindow::new().context("create window")?; + let ctx = Ctx { + core: core.clone(), + weak: ui.as_weak(), + }; + wire(&ui, &ctx); + if let Some(v) = arg("--view") { + // Start on a given view (`repo:` for a repository); handy for screenshots. + match v.split_once(':') { + Some(("repo", p)) => { + ui.set_selected_path(p.into()); + ui.set_view("repo".into()); + } + _ => ui.set_view(v.into()), + } + } + + // Tray actions arrive on the tray's thread. + let on_action: Arc = { + let ctx = ctx.clone(); + Arc::new(move |a| match a { + Action::Show => { + let c = ctx.clone(); + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = c.weak.upgrade() { + show_window(&ui, &c.core); + } + }); + } + Action::SyncNow => ctx.core.sync(None, ctx.weak.clone()), + Action::TogglePause => ctx.core.toggle_pause(), + Action::Quit => { + let _ = slint::invoke_from_event_loop(|| { + let _ = slint::quit_event_loop(); + }); + } + }) + }; + let tray = match tray::spawn(on_action) { + Ok(h) => { + core.tray_ok.store(true, Ordering::SeqCst); + Some(h) + } + Err(e) => { + eprintln!("grove-gui: no system tray ({e}); closing the window will quit"); + None + } + }; + + ui.window().on_close_requested({ + let c = ctx.clone(); + move || { + c.core.set_visible(false); + if !c.core.tray_ok.load(Ordering::SeqCst) { + let _ = slint::quit_event_loop(); + } + slint::CloseRequestResponse::HideWindow + } + }); + + { + let (c, w) = (core.clone(), ui.as_weak()); + std::thread::spawn(move || worker(c, rx, tray, w)); + } + { + let c = core.clone(); + std::thread::spawn(move || subscriber(c)); + } + { + let c = ctx.clone(); + std::thread::spawn(move || { + instance::serve(listener, move || { + let c = c.clone(); + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = c.weak.upgrade() { + show_window(&ui, &c.core); + } + }); + }) + }); + } + + if !hidden || !core.tray_ok.load(Ordering::SeqCst) { + show_window(&ui, &core); + } else { + core.wake(); + } + slint::run_event_loop_until_quit().context("event loop")?; + let _ = std::fs::remove_file(&inst_path); + Ok(()) +} diff --git a/crates/grove-gui/src/model.rs b/crates/grove-gui/src/model.rs new file mode 100644 index 0000000..5972187 --- /dev/null +++ b/crates/grove-gui/src/model.rs @@ -0,0 +1,402 @@ +//! UI-independent logic: daemon status -> aggregate state, formatting, CLI output parsing. + +use serde_json::Value; + +/// What the tray icon and the status pill show. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] +pub enum TrayState { + Ok, + Syncing, + Attention, + Paused, + #[default] + Offline, +} + +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Aggregate { + pub state: TrayState, + pub text: String, + pub repos: usize, + pub worktrees: usize, + pub attention: usize, +} + +/// `error: ` states collapse to `error`. +pub fn state_name(s: &str) -> &str { + if s.starts_with("error") { "error" } else { s } +} + +pub fn state_label(s: &str) -> &'static str { + match state_name(s) { + "synced" => "Synced", + "dirty" => "Editing", + "ahead" => "Ahead", + "behind" => "Behind", + "behinddirty" => "Behind + editing", + "diverged" => "Diverged", + "error" => "Error", + _ => "Unknown", + } +} + +/// What the next sync pass will do for a worktree in this state. +pub fn state_plan(s: &str) -> &'static str { + match state_name(s) { + "synced" => "Nothing to do.", + "dirty" => "Snapshot the working changes and push the snapshot ref.", + "ahead" => "Nothing automatic: push your commits yourself.", + "behind" => "Fast-forward to the remote tip.", + "behinddirty" => "Keep your edits; adopt the remote tip only if the content is identical.", + "diverged" => "Nothing automatic: choose how to resolve it.", + "error" => "Retry with backoff; see the error.", + _ => "", + } +} + +fn str_of<'a>(v: &'a Value, key: &str) -> &'a str { + v.get(key).and_then(Value::as_str).unwrap_or("") +} + +/// Summarises the `status` answer of the daemon. `None` means the daemon is unreachable. +pub fn aggregate(status: Option<&Value>) -> Aggregate { + let Some(s) = status else { + return Aggregate { + state: TrayState::Offline, + text: "Daemon offline".into(), + ..Default::default() + }; + }; + let empty = Vec::new(); + let repos = s.get("repos").and_then(Value::as_array).unwrap_or(&empty); + let (mut attention, mut dirty, mut total) = (0, 0, 0); + for r in repos { + let wts = r + .get("worktrees") + .and_then(Value::as_array) + .unwrap_or(&empty); + let has_err = wts + .iter() + .any(|w| state_name(str_of(w, "state")) == "error"); + if r.get("last_error").is_some_and(|e| !e.is_null()) && !has_err { + attention += 1; + } + for w in wts { + total += 1; + match state_name(str_of(w, "state")) { + "diverged" | "error" => attention += 1, + "synced" => {} + _ => dirty += 1, + } + } + } + let (state, text) = if s.get("paused").and_then(Value::as_bool) == Some(true) { + (TrayState::Paused, "Paused".to_string()) + } else if attention > 0 { + let verb = if attention == 1 { "needs" } else { "need" }; + ( + TrayState::Attention, + format!("{attention} {verb} attention"), + ) + } else if dirty > 0 { + (TrayState::Syncing, format!("{dirty} syncing")) + } else { + (TrayState::Ok, "All synced".to_string()) + }; + Aggregate { + state, + text, + repos: repos.len(), + worktrees: total, + attention, + } +} + +/// Last two path components, e.g. `work/api`. +pub fn short(path: &str) -> String { + let parts: Vec<&str> = path.split('/').filter(|p| !p.is_empty()).collect(); + parts[parts.len().saturating_sub(2)..].join("/") +} + +pub fn ago(ts: u64, now: u64) -> String { + if ts == 0 { + return "never".into(); + } + let d = now.saturating_sub(ts); + match d { + 0..=4 => "just now".into(), + 5..=59 => format!("{d}s ago"), + 60..=3599 => format!("{} min ago", (d + 30) / 60), + 3600..=86399 => format!("{} h ago", (d + 1800) / 3600), + _ => format!("{} d ago", (d + 43200) / 86400), + } +} + +/// `HH:MM:SS` (UTC offset applied by the caller) for the activity log. +pub fn clock(ts: u64, utc_offset_s: i64) -> String { + let t = (ts as i64 + utc_offset_s).rem_euclid(86400); + format!("{:02}:{:02}:{:02}", t / 3600, (t / 60) % 60, t % 60) +} + +/// Repository names from `grove import ` listing lines: ` owner/name on [ (private)]`. +pub fn parse_import_listing(output: &str) -> Vec { + let mut names = Vec::new(); + for line in output.lines() { + if !line.starts_with(char::is_whitespace) { + continue; + } + let mut words = line.split_whitespace(); + let Some(first) = words.next() else { continue }; + let Some((_, name)) = first.split_once('/') else { + continue; + }; + let rest: Vec<&str> = words.collect(); + let ok = matches!( + rest.as_slice(), + [] | ["(private)"] | ["on", _] | ["on", _, "(private)"] + ); + if ok && !name.is_empty() && !name.contains('/') { + names.push(name.to_string()); + } + } + names +} + +fn names(v: Option<&Value>) -> Vec { + v.and_then(Value::as_array) + .map(|a| { + a.iter() + .filter_map(|x| x.as_str().map(String::from)) + .collect() + }) + .unwrap_or_default() +} + +/// One line per group: routes (private + public), owners and layout. +pub fn group_summary(g: &Value) -> String { + let mut s = format!("primary {}", str_of(g, "primary")); + let mirrors = names(g.get("mirror_to")); + if !mirrors.is_empty() { + s += &format!(" · mirrors: {}", mirrors.join(", ")); + } + if let Some(p) = g.get("public").filter(|p| p.is_object()) { + s += &format!(" · public: {}", str_of(p, "primary")); + let pm = names(p.get("mirror_to")); + if !pm.is_empty() { + s += &format!(" → {}", pm.join(", ")); + } + } + if let Some(o) = g + .get("owners") + .and_then(Value::as_object) + .filter(|o| !o.is_empty()) + { + let list: Vec = o + .iter() + .map(|(k, v)| format!("{k}={}", v.as_str().unwrap_or(""))) + .collect(); + s += &format!(" · owners: {}", list.join(", ")); + } + let layout = g + .get("layout") + .and_then(Value::as_str) + .unwrap_or("bare-worktrees"); + format!("{s} · {layout}") +} + +pub type Section = (String, Vec<(String, String)>); + +/// The settings view: sections of key/value rows, from `config.toml` as JSON. +pub fn settings_sections(cfg: &Value) -> Vec
{ + let sync = cfg.get("sync"); + let num = |k: &str, d: u64| { + sync.and_then(|s| s.get(k)) + .and_then(Value::as_u64) + .unwrap_or(d) + }; + let machine = vec![ + ( + "Name".to_string(), + str_of(&cfg["machine"], "name").to_string(), + ), + ( + "Workspace root".into(), + str_of(&cfg["root"], "path").to_string(), + ), + ( + "Fetch interval".into(), + format!("{} s", num("fetch_interval_s", 60)), + ), + ( + "Largest synced file".into(), + format!("{} MiB", num("max_file_mb", 50)), + ), + ]; + let providers = cfg + .get("providers") + .and_then(Value::as_object) + .map(|m| { + m.iter() + .map(|(id, p)| { + let url = str_of(p, "url"); + let url = if url.is_empty() { + String::new() + } else { + format!(" · {url}") + }; + (id.clone(), format!("{}{url}", str_of(p, "kind"))) + }) + .collect() + }) + .unwrap_or_default(); + let groups = cfg + .get("groups") + .and_then(Value::as_array) + .map(|a| { + a.iter() + .map(|g| (str_of(g, "name").to_string(), group_summary(g))) + .collect() + }) + .unwrap_or_default(); + let crepo = match cfg.get("config_repo").filter(|c| c.is_object()) { + Some(c) => format!("{} on {}", str_of(c, "name"), str_of(c, "provider")), + None => "not configured".into(), + }; + vec![ + ("This machine".into(), machine), + ("Providers".into(), providers), + ("Groups".into(), groups), + ( + "Config repository".into(), + vec![("Repository".into(), crepo)], + ), + ] +} + +/// Group name from a combo entry (`name → primary`). +pub fn group_name(entry: &str) -> &str { + entry.split(" → ").next().unwrap_or(entry) +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + fn status(paused: bool, states: &[&str], last_error: Option<&str>) -> Value { + let wts: Vec = states + .iter() + .map(|s| json!({"branch": "main", "state": s, "path": "/w/a/main"})) + .collect(); + json!({"machine": "m", "paused": paused, "now": 100, + "repos": [{"path": "/w/a", "phase": "idle", "last_sync": 90, + "last_error": last_error, "worktrees": wts}]}) + } + + #[test] + fn offline_when_no_status() { + let a = aggregate(None); + assert_eq!(a.state, TrayState::Offline); + assert_eq!(a.text, "Daemon offline"); + } + + #[test] + fn state_to_tray_mapping() { + let agg = |s: Value| aggregate(Some(&s)); + assert_eq!(agg(status(false, &["synced"], None)).state, TrayState::Ok); + assert_eq!( + agg(json!({"paused": false, "repos": []})).state, + TrayState::Ok + ); + assert_eq!( + agg(status(false, &["synced", "dirty"], None)).state, + TrayState::Syncing + ); + assert_eq!( + agg(status(false, &["behind"], None)).state, + TrayState::Syncing + ); + assert_eq!( + agg(status(false, &["diverged"], None)).state, + TrayState::Attention + ); + assert_eq!( + agg(status(false, &["error: boom"], None)).state, + TrayState::Attention + ); + assert_eq!( + agg(status(false, &["synced"], Some("fetch failed"))).state, + TrayState::Attention + ); + // Paused wins over everything else. + assert_eq!( + agg(status(true, &["diverged"], None)).state, + TrayState::Paused + ); + } + + #[test] + fn attention_counts_and_text() { + let a = aggregate(Some(&status( + false, + &["diverged", "error: x", "dirty"], + None, + ))); + assert_eq!((a.attention, a.worktrees, a.repos), (2, 3, 1)); + assert_eq!(a.text, "2 need attention"); + let a = aggregate(Some(&status(false, &["diverged"], None))); + assert_eq!(a.text, "1 needs attention"); + // An error on the repo that no worktree shows counts once. + let a = aggregate(Some(&status(false, &["error: x"], Some("x")))); + assert_eq!(a.attention, 1); + } + + #[test] + fn import_listing_parses_every_line_shape() { + let out = "remote repositories in group work not on this machine:\n me/alpha on main\n me/beta on main (private)\n me/gamma\n me/delta (private)\nnot indented/line on x\n nonsense line here\n"; + assert_eq!( + parse_import_listing(out), + ["alpha", "beta", "gamma", "delta"] + ); + assert!(parse_import_listing("nothing to import").is_empty()); + } + + #[test] + fn formatting() { + assert_eq!(short("/home/u/Workspace/work/api"), "work/api"); + assert_eq!(short("api"), "api"); + assert_eq!(ago(0, 100), "never"); + assert_eq!(ago(98, 100), "just now"); + assert_eq!(ago(70, 100), "30s ago"); + assert_eq!(ago(100, 400), "5 min ago"); + assert_eq!(ago(1, 7201), "2 h ago"); + assert_eq!(clock(3661, 0), "01:01:01"); + assert_eq!(clock(3600 * 23, 7200), "01:00:00"); + assert_eq!(state_label("error: x"), "Error"); + assert!(state_plan("diverged").contains("resolve")); + } + + #[test] + fn settings_show_public_route_and_owners() { + let cfg = json!({ + "machine": {"name": "pca"}, "root": {"path": "/w"}, + "providers": {"gitea": {"kind": "gitea", "url": "https://g.example"}, "gh": {"kind": "github"}}, + "groups": [{"name": "work", "primary": "gitea", "mirror_to": ["gh"], + "owners": {"gitea": "Org", "gh": "org-gh"}, + "public": {"primary": "gh", "mirror_to": ["gitea"]}}], + "config_repo": {"name": "grove-config", "provider": "gitea"} + }); + let s = settings_sections(&cfg); + assert_eq!(s[0].1[0], ("Name".into(), "pca".into())); + assert_eq!(s[0].1[2].1, "60 s"); + // Providers come out sorted by id. + assert_eq!(s[1].1[0].1, "github"); + assert_eq!(s[1].1[1].1, "gitea · https://g.example"); + assert_eq!( + s[2].1[0].1, + "primary gitea · mirrors: gh · public: gh → gitea · owners: gh=org-gh, gitea=Org · bare-worktrees" + ); + assert_eq!(s[3].1[0].1, "grove-config on gitea"); + assert_eq!(group_name("work → gitea"), "work"); + } +} diff --git a/crates/grove-gui/src/tray.rs b/crates/grove-gui/src/tray.rs new file mode 100644 index 0000000..d493654 --- /dev/null +++ b/crates/grove-gui/src/tray.rs @@ -0,0 +1,236 @@ +//! StatusNotifierItem tray (ksni). Icons are drawn in code, one per state, so no image decoder +//! is needed. + +use crate::model::{Aggregate, TrayState}; +use ksni::blocking::{Handle, TrayMethods}; +use ksni::menu::StandardItem; +use ksni::{Icon, MenuItem, Status, ToolTip}; +use std::sync::Arc; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Action { + Show, + SyncNow, + TogglePause, + Quit, +} + +pub struct GroveTray { + agg: Aggregate, + on_action: Arc, +} + +pub type TrayHandle = Handle; + +/// Starts the tray service. Fails when there is no D-Bus session. +pub fn spawn(on_action: Arc) -> Result { + GroveTray { + agg: Aggregate::default(), + on_action, + } + .spawn() +} + +pub fn set_state(handle: &TrayHandle, agg: &Aggregate) { + let agg = agg.clone(); + handle.update(move |t| { + if t.agg != agg { + t.agg = agg; + } + }); +} + +impl ksni::Tray for GroveTray { + fn id(&self) -> String { + "grove".into() + } + + fn title(&self) -> String { + "Grove".into() + } + + fn status(&self) -> Status { + match self.agg.state { + TrayState::Attention => Status::NeedsAttention, + _ => Status::Active, + } + } + + fn icon_pixmap(&self) -> Vec { + icons(self.agg.state) + } + + fn attention_icon_pixmap(&self) -> Vec { + icons(TrayState::Attention) + } + + fn tool_tip(&self) -> ToolTip { + ToolTip { + title: format!("Grove: {}", self.agg.text), + ..Default::default() + } + } + + fn activate(&mut self, _x: i32, _y: i32) { + (self.on_action)(Action::Show); + } + + fn menu(&self) -> Vec> { + let online = self.agg.state != TrayState::Offline; + let paused = self.agg.state == TrayState::Paused; + let item = |label: &str, enabled: bool, a: Action| { + StandardItem { + label: label.into(), + enabled, + activate: Box::new(move |t: &mut Self| (t.on_action)(a)), + ..Default::default() + } + .into() + }; + vec![ + StandardItem { + label: self.agg.text.clone(), + enabled: false, + ..Default::default() + } + .into(), + MenuItem::Separator, + item("Open Grove", true, Action::Show), + item("Sync now", online && !paused, Action::SyncNow), + item( + if paused { "Resume sync" } else { "Pause sync" }, + online, + Action::TogglePause, + ), + MenuItem::Separator, + item("Quit", true, Action::Quit), + ] + } +} + +// ---- icon drawing ---------------------------------------------------------------------------- + +fn colour(s: TrayState) -> [u8; 3] { + match s { + TrayState::Ok => [0x2e, 0x9e, 0x5b], + TrayState::Syncing => [0x2f, 0x7d, 0xd1], + TrayState::Attention => [0xd9, 0x48, 0x3b], + TrayState::Paused => [0x8a, 0x8f, 0x98], + TrayState::Offline => [0x4a, 0x4f, 0x58], + } +} + +fn seg(px: f32, py: f32, a: (f32, f32), b: (f32, f32), half: f32) -> bool { + let (dx, dy) = (b.0 - a.0, b.1 - a.1); + let t = (((px - a.0) * dx + (py - a.1) * dy) / (dx * dx + dy * dy)).clamp(0.0, 1.0); + let (cx, cy) = (a.0 + t * dx, a.1 + t * dy); + (px - cx).hypot(py - cy) <= half +} + +/// Glyph in a 32x32 box, white on the coloured disc. +fn glyph(s: TrayState, x: f32, y: f32) -> bool { + match s { + TrayState::Ok => { + seg(x, y, (9.0, 16.5), (14.0, 21.5), 1.6) || seg(x, y, (14.0, 21.5), (23.0, 11.0), 1.6) + } + TrayState::Syncing => { + // Ring with a gap at the upper right, like a refresh symbol. + let (dx, dy) = (x - 16.0, y - 16.0); + let r = dx.hypot(dy); + let gap = dx > 0.0 && dy < 0.0 && dx.abs() * 0.6 < dy.abs() * 1.6; + (5.0..=8.0).contains(&r) && !gap + } + TrayState::Attention => { + (14.4..=17.6).contains(&x) && (8.0..=18.0).contains(&y) + || (x - 16.0).hypot(y - 22.5) <= 2.0 + } + TrayState::Paused => { + (10.0..=14.0).contains(&x) && (9.0..=23.0).contains(&y) + || (18.0..=22.0).contains(&x) && (9.0..=23.0).contains(&y) + } + TrayState::Offline => { + seg(x, y, (10.0, 10.0), (22.0, 22.0), 1.5) || seg(x, y, (22.0, 10.0), (10.0, 22.0), 1.5) + } + } +} + +/// ARGB32 (network byte order) pixmap of `size` x `size`, 3x3 supersampled. +pub fn render(s: TrayState, size: u32) -> Icon { + let [r, g, b] = colour(s); + let scale = 32.0 / size as f32; + let mut data = Vec::with_capacity((size * size * 4) as usize); + for py in 0..size { + for px in 0..size { + let (mut disc, mut mark) = (0u32, 0u32); + for sy in 0..3 { + for sx in 0..3 { + let x = (px as f32 + (sx as f32 + 0.5) / 3.0) * scale; + let y = (py as f32 + (sy as f32 + 0.5) / 3.0) * scale; + if (x - 16.0).hypot(y - 16.0) <= 15.0 { + disc += 1; + if glyph(s, x, y) { + mark += 1; + } + } + } + } + let a = (disc * 255 / 9) as u8; + // Blend the white glyph over the disc colour by its share of the covered samples. + let w = (mark * 255).checked_div(disc).unwrap_or(0); + let mix = |c: u8| ((c as u32 * (255 - w) + 255 * w) / 255) as u8; + data.extend_from_slice(&[a, mix(r), mix(g), mix(b)]); + } + } + Icon { + width: size as i32, + height: size as i32, + data, + } +} + +fn icons(s: TrayState) -> Vec { + vec![render(s, 22), render(s, 32), render(s, 64)] +} + +#[cfg(test)] +mod tests { + use super::*; + + const ALL: [TrayState; 5] = [ + TrayState::Ok, + TrayState::Syncing, + TrayState::Attention, + TrayState::Paused, + TrayState::Offline, + ]; + + #[test] + fn every_state_has_a_distinct_non_empty_icon() { + let imgs: Vec<_> = ALL.iter().map(|s| render(*s, 32)).collect(); + for (i, a) in imgs.iter().enumerate() { + assert_eq!(a.data.len(), 32 * 32 * 4); + assert!(a.data.chunks(4).any(|p| p[0] == 255), "opaque pixels"); + assert_eq!(a.data[0], 0, "corner is transparent"); + for b in &imgs[i + 1..] { + assert_ne!(a.data, b.data); + } + } + } + + #[test] + fn glyph_is_drawn_in_white() { + let ok = render(TrayState::Ok, 32); + let white = ok + .data + .chunks(4) + .filter(|p| p[0] == 255 && p[1] == 255 && p[2] == 255) + .count(); + assert!(white > 20, "{white}"); + } + + #[test] + fn pixmap_sizes() { + let sizes: Vec<_> = icons(TrayState::Ok).iter().map(|i| i.width).collect(); + assert_eq!(sizes, [22, 32, 64]); + } +} diff --git a/crates/grove-gui/ui/app.slint b/crates/grove-gui/ui/app.slint new file mode 100644 index 0000000..d5826d8 --- /dev/null +++ b/crates/grove-gui/ui/app.slint @@ -0,0 +1,1093 @@ +import { Button, CheckBox, ComboBox, LineEdit, Palette, ScrollView } from "std-widgets.slint"; + +export struct Wt { + branch: string, + path: string, + state: string, + label: string, + plan: string, + out: string, + out-ok: bool, +} + +export struct Repo { + name: string, + path: string, + phase: string, + last-sync: string, + error: string, + wts: [Wt], +} + +export struct LogRow { + time: string, + kind: string, + repo: string, + msg: string, +} + +export struct Kv { + key: string, + value: string, +} + +export struct Section { + title: string, + rows: [Kv], +} + +export struct Pick { + name: string, + checked: bool, +} + +export struct Out { + text: string, + ok: bool, +} + +// Pill / badge colour by state key. +global Tone { + pure public function of(key: string) -> color { + if key == "synced" || key == "ok" { + return #2e9e5b; + } + if key == "diverged" || key == "error" || key == "bad" { + return #d9483b; + } + if key == "paused" || key == "offline" || key == "muted" { + return #8a8f98; + } + return #d98e1f; + } +} + +component Card inherits Rectangle { + background: Palette.control-background; + border-radius: 8px; + border-width: 1px; + border-color: Palette.border; + VerticalLayout { + padding: 14px; + spacing: 8px; + alignment: start; + @children + } +} + +component Badge inherits Rectangle { + in property text; + in property key; + background: Tone.of(key).with-alpha(0.18); + border-radius: 10px; + height: 20px; + width: label.preferred-width + 16px; + label := Text { + text: root.text; + color: Tone.of(root.key); + font-size: 11px; + font-weight: 700; + horizontal-alignment: center; + vertical-alignment: center; + } +} + +component H1 inherits VerticalLayout { + in property title; + in property sub; + spacing: 2px; + alignment: start; + Text { + text: root.title; + font-size: 22px; + font-weight: 700; + } + + Text { + text: root.sub; + color: Palette.foreground.with-alpha(0.65); + wrap: word-wrap; + } +} + +component Muted inherits Text { + color: Palette.foreground.with-alpha(0.65); + wrap: word-wrap; +} + +component Term inherits Rectangle { + in property out; + visible: out.text != ""; + height: out.text == "" ? 0px : label.preferred-height + 20px; + background: out.ok ? Palette.control-background : #d9483b.with-alpha(0.14); + border-radius: 6px; + border-width: 1px; + border-color: out.ok ? Palette.border : #d9483b; + label := Text { + x: 10px; + y: 10px; + width: parent.width - 20px; + text: root.out.text; + font-family: "monospace"; + font-size: 12px; + wrap: word-wrap; + } +} + +component NavItem inherits Rectangle { + in property text; + in property active; + callback clicked; + height: 34px; + border-radius: 6px; + background: active ? Palette.accent-background.with-alpha(0.22) : ta.has-hover ? Palette.foreground.with-alpha(0.08) : transparent; + Text { + x: 12px; + text: root.text; + vertical-alignment: center; + font-weight: root.active ? 700 : 400; + } + + ta := TouchArea { + clicked => { + root.clicked(); + } + } +} + +export component MainWindow inherits Window { + title: "Grove"; + icon: @image-url("../../../assets/grove.png"); + min-width: 760px; + min-height: 520px; + preferred-width: 980px; + preferred-height: 700px; + + // ---- state pushed from Rust ---- + in-out property view: "repos"; + in property loading: true; + in property offline: false; + in property paused: false; + in property has-config: true; + in property pill-text: "Connecting…"; + in property pill-key: "muted"; + in property machine; + in property repo-count; + in property wt-count; + in property attention-count; + in property <[Repo]> repos; + in property <[LogRow]> log; + in property <[string]> groups; + in property <[string]> providers; + in property <[Section]> sections; + in property <[Pick]> picks; + in property import-note; + in property busy; + in property toast-text; + in property toast-bad; + in property confirm-text; + in property detail; + in property detail-found; + in-out property selected-path; + in property new-out; + in property import-out; + in property settings-out; + in property onboard-out; + + // ---- actions towards Rust ---- + callback open-repo(string); + callback sync-repo(string); + callback sync-all(); + callback toggle-pause(); + callback filter-changed(string); + callback create-repo(string, string, bool); + callback scan-import(string); + callback import-selected(string); + callback pick-toggled(int, bool); + callback resolve(string, string, string); + callback confirm-accept(); + callback confirm-cancel(); + callback run-settings(string); + callback login(string, string); + callback onboard(string, string, string, string, string, string, string, string); + callback view-changed(string); + + function go(v: string) { + root.view = v; + root.selected-path = ""; + root.view-changed(v); + } + + background: Palette.background; + + HorizontalLayout { + // ---- sidebar ---- + Rectangle { + width: 200px; + background: Palette.control-background; + VerticalLayout { + padding: 12px; + spacing: 4px; + Text { + text: "Grove"; + font-size: 20px; + font-weight: 800; + color: #2e9e5b; + } + + Rectangle { + height: 10px; + } + + NavItem { + text: "Repositories"; + active: root.view == "repos"; + clicked => { + root.go("repos"); + } + } + + NavItem { + text: "Activity"; + active: root.view == "activity"; + clicked => { + root.go("activity"); + } + } + + NavItem { + text: "New repository"; + active: root.view == "new"; + clicked => { + root.go("new"); + } + } + + NavItem { + text: "Import"; + active: root.view == "import"; + clicked => { + root.go("import"); + } + } + + NavItem { + text: "Settings"; + active: root.view == "settings"; + clicked => { + root.go("settings"); + } + } + + Rectangle { } + + Muted { + text: root.machine == "" ? "" : "Machine " + root.machine; + font-size: 11px; + } + } + } + + // ---- main column ---- + VerticalLayout { + // top bar + Rectangle { + height: 52px; + HorizontalLayout { + padding-left: 20px; + padding-right: 20px; + spacing: 8px; + alignment: end; + Badge { + y: (parent.height - self.height) / 2; + text: root.pill-text; + key: root.pill-key; + } + + Rectangle { + horizontal-stretch: 1; + } + + Button { + y: (parent.height - self.height) / 2; + text: root.paused ? "Resume sync" : "Pause sync"; + enabled: !root.offline; + clicked => { + root.toggle-pause(); + } + } + + Button { + y: (parent.height - self.height) / 2; + text: "Sync now"; + primary: true; + enabled: !root.offline && !root.paused; + clicked => { + root.sync-all(); + } + } + } + } + + ScrollView { + VerticalLayout { + padding: 20px; + padding-top: 4px; + spacing: 12px; + alignment: start; + + // ---------- repositories ---------- + if root.view == "repos": VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: "Repositories"; + sub: "Everything grove keeps in sync on this machine."; + } + + if root.offline: Card { + Text { + text: "The grove daemon is not running."; + font-weight: 700; + } + + Muted { + text: "Start it with `systemctl --user start groved` (or run `groved` in a terminal)."; + } + } + if !root.offline && root.loading: Muted { + text: "Loading…"; + } + if !root.offline && !root.loading && root.repos.length == 0: Card { + Muted { + text: "No repositories yet. Create one under “New repository” or clone existing ones with “Import”."; + } + } + if !root.offline && !root.loading && root.repos.length > 0: VerticalLayout { + spacing: 12px; + alignment: start; + HorizontalLayout { + spacing: 12px; + for s[i] in [ + {n: root.repo-count, l: "Repositories"}, + {n: root.wt-count, l: "Worktrees"}, + {n: root.attention-count, l: "Need attention"}, + ]: Card { + Text { + text: s.n; + font-size: 26px; + font-weight: 700; + } + + Muted { + text: s.l; + } + } + } + + for r in root.repos: Rectangle { + height: rcard.preferred-height; + rcard := Card { + HorizontalLayout { + spacing: 12px; + VerticalLayout { + horizontal-stretch: 1; + Text { + text: r.name; + font-weight: 700; + font-size: 15px; + } + + Muted { + text: r.path; + font-size: 11px; + } + + if r.error != "": Text { + text: r.error; + color: #d9483b; + wrap: word-wrap; + } + } + + VerticalLayout { + alignment: center; + spacing: 4px; + for w in r.wts: HorizontalLayout { + spacing: 6px; + alignment: end; + Muted { + text: w.branch; + vertical-alignment: center; + } + + Badge { + text: w.label; + key: w.state; + } + } + } + + VerticalLayout { + width: 90px; + alignment: center; + Muted { + text: r.phase; + horizontal-alignment: right; + } + + Muted { + text: r.last-sync; + horizontal-alignment: right; + font-size: 11px; + } + } + } + + } + + TouchArea { + clicked => { + root.open-repo(r.path); + } + } + } + } + } + + // ---------- repository detail ---------- + if root.view == "repo": VerticalLayout { + spacing: 12px; + alignment: start; + HorizontalLayout { + alignment: start; + Button { + text: "← Repositories"; + clicked => { + root.go("repos"); + } + } + } + + if root.offline: Card { + Text { + text: "The grove daemon is not running."; + font-weight: 700; + } + } + if !root.offline && !root.detail-found: Muted { + text: "Repository not found."; + } + if !root.offline && root.detail-found: VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: root.detail.name; + sub: root.detail.path; + } + + HorizontalLayout { + alignment: start; + Button { + text: "Sync this repository"; + clicked => { + root.sync-repo(root.detail.path); + } + } + } + + if root.detail.error != "": Text { + text: root.detail.error; + color: #d9483b; + wrap: word-wrap; + } + Text { + text: "Worktrees"; + font-size: 16px; + font-weight: 700; + } + + for w in root.detail.wts: Card { + HorizontalLayout { + spacing: 12px; + VerticalLayout { + horizontal-stretch: 1; + Text { + text: w.branch; + font-weight: 700; + } + + Muted { + text: w.path; + font-size: 11px; + } + } + + Badge { + y: 2px; + text: w.label; + key: w.state; + } + } + + Muted { + text: w.plan; + } + + if w.state == "diverged": diverged := VerticalLayout { + spacing: 8px; + alignment: start; + property branch-name: w.branch + "-local"; + Text { + text: "Diverged: " + w.branch + " has commits here and on the remote"; + font-weight: 700; + color: #d9483b; + } + + Muted { + text: "Grove never merges for you. Pick what should win:"; + } + + if w.path == "": Muted { + text: "This daemon does not report the worktree path. Update groved."; + } + if w.path != "": VerticalLayout { + spacing: 8px; + alignment: start; + HorizontalLayout { + spacing: 8px; + Button { + text: "Save mine as a branch"; + clicked => { + root.resolve(w.path, "save", diverged.branch-name); + } + } + + LineEdit { + horizontal-stretch: 1; + text: diverged.branch-name; + placeholder-text: "branch name"; + accessible-label: "New branch name"; + edited(t) => { + diverged.branch-name = t; + } + } + } + + HorizontalLayout { + spacing: 8px; + alignment: start; + Button { + text: "Take remote"; + clicked => { + root.resolve(w.path, "remote", ""); + } + } + + Button { + text: "Keep mine (overwrite remote)"; + clicked => { + root.resolve(w.path, "local", ""); + } + } + } + + Muted { + text: "To inspect both sides first, run `grove resolve " + w.path + " --compare` in a terminal."; + font-size: 11px; + } + } + } + Term { + out: {text: w.out, ok: w.out-ok}; + } + } + } + } + + // ---------- activity ---------- + if root.view == "activity": VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: "Activity"; + sub: "What the daemon did, newest first."; + } + + if root.offline: Card { + Text { + text: "The grove daemon is not running."; + font-weight: 700; + } + } + if !root.offline: VerticalLayout { + spacing: 12px; + alignment: start; + LineEdit { + placeholder-text: "Filter…"; + accessible-label: "Filter activity"; + edited(t) => { + root.filter-changed(t); + } + } + + if root.log.length == 0: Muted { + text: "No activity yet."; + } + Card { + for e in root.log: HorizontalLayout { + spacing: 10px; + Muted { + width: 64px; + text: e.time; + font-size: 12px; + } + + Text { + width: 90px; + text: e.kind; + color: Tone.of(e.kind == "error" || e.kind == "watch_error" ? "error" : e.kind == "state" ? "warn" : "ok"); + font-size: 12px; + font-weight: 700; + } + + Muted { + width: 130px; + text: e.repo; + font-size: 12px; + overflow: elide; + } + + Text { + horizontal-stretch: 1; + text: e.msg; + font-size: 12px; + overflow: elide; + } + } + } + } + } + + // ---------- new repository ---------- + if root.view == "new": VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: "New repository"; + sub: "Creates the remote, the local checkout, the mirrors and registers it for your other machines."; + } + + if !root.has-config: Card { + Muted { + text: "Finish onboarding first (Settings)."; + } + } + if root.has-config: VerticalLayout { + spacing: 12px; + alignment: start; + Card { + Muted { + text: "Group"; + } + + new-group := ComboBox { + model: root.groups; + } + + Muted { + text: "Name"; + } + + new-name := LineEdit { + placeholder-text: "my-project"; + accessible-label: "Repository name"; + } + + Muted { + text: "Created on the group’s primary forge, with an initial commit and the bare + worktrees layout."; + font-size: 11px; + } + + new-public := CheckBox { + text: "Public repository"; + } + + HorizontalLayout { + alignment: start; + Button { + text: root.busy ? "Working…" : "Create repository"; + primary: true; + enabled: !root.busy && new-name.text != ""; + clicked => { + root.create-repo(new-group.current-value, new-name.text, new-public.checked); + } + } + } + } + + Term { + out: root.new-out; + } + } + } + + // ---------- import ---------- + if root.view == "import": VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: "Import"; + sub: "Clone repositories that exist on your forge but not on this machine."; + } + + if !root.has-config: Card { + Muted { + text: "Finish onboarding first (Settings)."; + } + } + if root.has-config: VerticalLayout { + spacing: 12px; + alignment: start; + HorizontalLayout { + spacing: 8px; + alignment: start; + imp-group := ComboBox { + model: root.groups; + width: 260px; + } + + Button { + text: "Scan remote"; + enabled: !root.busy; + clicked => { + root.scan-import(imp-group.current-value); + } + } + } + + if root.import-note != "": Muted { + text: root.import-note; + } + if root.picks.length > 0: Card { + for p[i] in root.picks: CheckBox { + text: p.name; + checked: p.checked; + toggled => { + root.pick-toggled(i, self.checked); + } + } + + HorizontalLayout { + alignment: start; + Button { + text: "Import selected"; + primary: true; + enabled: !root.busy; + clicked => { + root.import-selected(imp-group.current-value); + } + } + } + } + Term { + out: root.import-out; + } + } + } + + // ---------- settings ---------- + if root.view == "settings" && root.has-config: VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: "Settings"; + sub: "Read from config.toml. Tokens live in the system keyring, never in the file."; + } + + for sec in root.sections: VerticalLayout { + spacing: 6px; + alignment: start; + Text { + text: sec.title; + font-size: 16px; + font-weight: 700; + } + + Card { + for kv in sec.rows: HorizontalLayout { + spacing: 12px; + Muted { + width: 170px; + text: kv.key; + } + + Text { + horizontal-stretch: 1; + text: kv.value; + wrap: word-wrap; + } + } + } + } + + HorizontalLayout { + spacing: 8px; + alignment: start; + Button { + text: "Register repos on disk"; + enabled: !root.busy; + clicked => { + root.run-settings("config-repo-init"); + } + } + + Button { + text: "Bootstrap from config repo"; + enabled: !root.busy; + clicked => { + root.run-settings("bootstrap"); + } + } + } + + Text { + text: "Sign in to a provider"; + font-size: 16px; + font-weight: 700; + } + + Card { + Muted { + text: "Provider"; + } + + tok-prov := ComboBox { + model: root.providers; + } + + Muted { + text: "Token"; + } + + tok := LineEdit { + input-type: password; + placeholder-text: "API token"; + accessible-label: "API token"; + } + + Muted { + text: "Needs repository read/write scope. Sent to the forge only."; + font-size: 11px; + } + + HorizontalLayout { + alignment: start; + Button { + text: "Verify and store"; + primary: true; + enabled: !root.busy && tok.text != ""; + clicked => { + root.login(tok-prov.current-value, tok.text); + tok.text = ""; + } + } + } + } + + Text { + text: "Encrypted files (.env)"; + font-size: 16px; + font-weight: 700; + } + + HorizontalLayout { + spacing: 8px; + alignment: start; + Button { + text: "Create this machine’s key"; + enabled: !root.busy; + clicked => { + root.run-settings("secrets-init"); + } + } + + Button { + text: "Pull secrets"; + enabled: !root.busy; + clicked => { + root.run-settings("secrets-pull"); + } + } + + Button { + text: "Re-encrypt for all machines"; + enabled: !root.busy; + clicked => { + root.run-settings("secrets-rekey"); + } + } + } + + Term { + out: root.settings-out; + } + } + + // ---------- onboarding ---------- + if root.view == "settings" && !root.has-config: VerticalLayout { + spacing: 12px; + alignment: start; + H1 { + title: "Welcome to Grove"; + sub: "Set up this machine. On a second computer this is all you do: sign in and your workspace appears."; + } + + Card { + Muted { + text: "Machine name (letters, digits, - and _; unique per computer)"; + } + + ob-machine := LineEdit { + text: "my-laptop"; + } + + Muted { + text: "Workspace folder"; + } + + ob-root := LineEdit { + text: "~/Workspace"; + } + + Muted { + text: "Forge type"; + } + + ob-kind := ComboBox { + model: ["gitea", "forgejo", "github"]; + } + + Muted { + text: "Provider id"; + } + + ob-provider := LineEdit { + text: "main"; + } + + Muted { + text: "Forge URL (empty for github.com)"; + } + + ob-url := LineEdit { + placeholder-text: "https://git.example.com"; + } + + Muted { + text: "First group"; + } + + ob-group := LineEdit { + text: "work"; + } + + Muted { + text: "Config repository (private repo holding the list of your repos, so a new machine only needs to sign in)"; + } + + ob-crepo := LineEdit { + text: "grove-config"; + } + + Muted { + text: "API token"; + } + + ob-token := LineEdit { + input-type: password; + accessible-label: "API token"; + } + + HorizontalLayout { + alignment: start; + Button { + text: root.busy ? "Working…" : "Set up grove"; + primary: true; + enabled: !root.busy && ob-token.text != ""; + clicked => { + root.onboard(ob-machine.text, ob-root.text, ob-kind.current-value, ob-provider.text, ob-url.text, ob-group.text, ob-crepo.text, ob-token.text); + ob-token.text = ""; + } + } + } + } + + Term { + out: root.onboard-out; + } + } + } + } + } + } + + // ---- toast ---- + if root.toast-text != "": Rectangle { + x: parent.width - self.width - 20px; + y: parent.height - self.height - 20px; + width: min(420px, parent.width - 40px); + height: toast-label.preferred-height + 24px; + background: root.toast-bad ? #d9483b : #2e9e5b; + border-radius: 8px; + toast-label := Text { + x: 12px; + y: 12px; + width: parent.width - 24px; + text: root.toast-text; + color: white; + wrap: word-wrap; + } + } + + // ---- confirmation ---- + if root.confirm-text != "": Rectangle { + background: #00000088; + TouchArea { } + + Card { + width: min(460px, parent.width - 40px); + height: self.preferred-height; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + background: Palette.background; + Text { + text: root.confirm-text; + wrap: word-wrap; + } + + Muted { + text: "A backup ref is written first, so nothing is lost."; + } + + HorizontalLayout { + spacing: 8px; + alignment: end; + Button { + text: "Cancel"; + clicked => { + root.confirm-cancel(); + } + } + + Button { + text: "Continue"; + primary: true; + clicked => { + root.confirm-accept(); + } + } + } + } + } +} From 951e3d844e5ed96ef354be23edfadebbb21f3129 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:27:52 +0100 Subject: [PATCH 02/19] chore: remove the HTML/JS frontend and the Tauri shell Co-Authored-By: Claude Sonnet 5.5 --- gui/src-tauri/.gitignore | 2 - gui/src-tauri/Cargo.toml | 19 -- gui/src-tauri/build.rs | 3 - gui/src-tauri/capabilities/default.json | 7 - gui/src-tauri/icons/icon.png | Bin 209 -> 0 bytes gui/src-tauri/src/main.rs | 79 ----- gui/src-tauri/tauri.conf.json | 20 -- gui/ui/app.js | 367 ------------------------ gui/ui/index.html | 36 --- gui/ui/logo.svg | 1 - gui/ui/style.css | 98 ------- 11 files changed, 632 deletions(-) delete mode 100644 gui/src-tauri/.gitignore delete mode 100644 gui/src-tauri/Cargo.toml delete mode 100644 gui/src-tauri/build.rs delete mode 100644 gui/src-tauri/capabilities/default.json delete mode 100644 gui/src-tauri/icons/icon.png delete mode 100644 gui/src-tauri/src/main.rs delete mode 100644 gui/src-tauri/tauri.conf.json delete mode 100644 gui/ui/app.js delete mode 100644 gui/ui/index.html delete mode 100644 gui/ui/logo.svg delete mode 100644 gui/ui/style.css diff --git a/gui/src-tauri/.gitignore b/gui/src-tauri/.gitignore deleted file mode 100644 index 4cacddf..0000000 --- a/gui/src-tauri/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/gen diff --git a/gui/src-tauri/Cargo.toml b/gui/src-tauri/Cargo.toml deleted file mode 100644 index 66ee7d6..0000000 --- a/gui/src-tauri/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -# Tauri shell for the grove GUI. Deliberately NOT a member of the root workspace: it needs the -# webkit2gtk/libsoup system packages (see docs/phase3.md) and must not break `cargo test` without them. -[package] -name = "grove-gui" -version = "0.1.0" -edition = "2024" -license = "MIT" -description = "grove desktop GUI (Tauri shell around gui/ui)" - -[workspace] - -[dependencies] -grove-bridge = { path = "../../crates/grove-bridge" } -grove-daemon = { path = "../../crates/grove-daemon" } -serde_json = "1" -tauri = { version = "2", features = ["tray-icon"] } - -[build-dependencies] -tauri-build = "2" diff --git a/gui/src-tauri/build.rs b/gui/src-tauri/build.rs deleted file mode 100644 index d860e1e..0000000 --- a/gui/src-tauri/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - tauri_build::build() -} diff --git a/gui/src-tauri/capabilities/default.json b/gui/src-tauri/capabilities/default.json deleted file mode 100644 index e9b9f39..0000000 --- a/gui/src-tauri/capabilities/default.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "../gen/schemas/desktop-schema.json", - "identifier": "default", - "description": "Main window: only the app's own commands, no filesystem or shell access.", - "windows": ["main"], - "permissions": ["core:default"] -} diff --git a/gui/src-tauri/icons/icon.png b/gui/src-tauri/icons/icon.png deleted file mode 100644 index 76c0e695f7f1deda97063e59d8d56b29cf8a6e21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Gdx`!Ln`LHy5ZwTyJ)zGW<1$0TbS9?K1MBZH@_pUXO@ GgeCy22}BA2 diff --git a/gui/src-tauri/src/main.rs b/gui/src-tauri/src/main.rs deleted file mode 100644 index 2af493c..0000000 --- a/gui/src-tauri/src/main.rs +++ /dev/null @@ -1,79 +0,0 @@ -//! Tauri shell: serves `gui/ui` and exposes the same three calls the dev bridge offers -//! (`ipc`, `cli`, `config`) as Tauri commands, backed by the shared `grove-bridge` library. -//! Also a tray icon with open / pause-resume / quit so the window can be closed. - -use grove_bridge::Bridge; -use serde_json::{Value, json}; -use tauri::menu::{Menu, MenuItem}; -use tauri::tray::TrayIconBuilder; -use tauri::{Manager, WindowEvent}; - -fn bridge() -> Bridge { - Bridge { - grove_bin: std::env::var_os("GROVE_BIN") - .map(Into::into) - .unwrap_or_else(|| "grove".into()), - config: None, - socket: grove_daemon::ipc::default_socket_path(), - } -} - -#[tauri::command] -fn ipc(req: Value) -> Value { - bridge().ipc(&req) -} - -#[tauri::command] -fn cli(args: Vec, stdin: Option) -> Value { - bridge().cli(&args, &stdin.unwrap_or_default()) -} - -#[tauri::command] -fn config() -> Value { - match bridge().config_json() { - Some(c) => json!({"exists": true, "config": c}), - None => json!({"exists": false}), - } -} - -fn main() { - tauri::Builder::default() - .invoke_handler(tauri::generate_handler![ipc, cli, config]) - .setup(|app| { - let open = MenuItem::with_id(app, "open", "Open Grove", true, None::<&str>)?; - let pause = MenuItem::with_id(app, "pause", "Pause / resume sync", true, None::<&str>)?; - let quit = MenuItem::with_id(app, "quit", "Quit GUI (daemon keeps running)", true, None::<&str>)?; - let menu = Menu::with_items(app, &[&open, &pause, &quit])?; - TrayIconBuilder::new() - .icon(app.default_window_icon().cloned().expect("window icon")) - .menu(&menu) - .on_menu_event(|app, ev| match ev.id.as_ref() { - "open" => { - if let Some(w) = app.get_webview_window("main") { - let _ = w.show(); - let _ = w.set_focus(); - } - } - "pause" => { - let b = bridge(); - let paused = b.ipc(&json!({"v":1,"cmd":"status"}))["data"]["paused"] - .as_bool() - .unwrap_or(false); - b.ipc(&json!({"v":1,"cmd": if paused {"resume"} else {"pause"}})); - } - "quit" => app.exit(0), - _ => {} - }) - .build(app)?; - Ok(()) - }) - // Closing the window hides it; the tray keeps the app (and its notifications) alive. - .on_window_event(|w, ev| { - if let WindowEvent::CloseRequested { api, .. } = ev { - api.prevent_close(); - let _ = w.hide(); - } - }) - .run(tauri::generate_context!()) - .expect("error while running grove-gui"); -} diff --git a/gui/src-tauri/tauri.conf.json b/gui/src-tauri/tauri.conf.json deleted file mode 100644 index d52dad4..0000000 --- a/gui/src-tauri/tauri.conf.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "https://schema.tauri.app/config/2", - "productName": "Grove", - "version": "0.1.0", - "identifier": "es.zenvairo.grove", - "build": { "frontendDist": "../ui" }, - "app": { - "withGlobalTauri": true, - "windows": [{ "title": "Grove", "width": 1100, "height": 720, "minWidth": 720, "minHeight": 480 }], - "security": { - "csp": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" - } - }, - "bundle": { - "active": true, - "targets": ["deb", "appimage"], - "icon": ["icons/icon.png"], - "category": "DeveloperTool" - } -} diff --git a/gui/ui/app.js b/gui/ui/app.js deleted file mode 100644 index c305147..0000000 --- a/gui/ui/app.js +++ /dev/null @@ -1,367 +0,0 @@ -'use strict'; -// ---- backend adapter: Tauri shell (invoke) or the localhost dev bridge (fetch) ---------------- -const tauri = window.__TAURI__ && window.__TAURI__.core; -async function post(path, body) { - const r = await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Grove': '1' }, body: JSON.stringify(body) }); - if (!r.ok) throw new Error(r.status + ' ' + (await r.text())); - return r.json(); -} -// Backend failures never throw into the UI: they come back as {ok:false, ...}. -const safe = (p, fail) => p.catch((e) => fail(String((e && e.message) || e))); -const ipc = (req) => safe(tauri ? tauri.invoke('ipc', { req }) : post('/api/ipc', req), (m) => ({ ok: false, offline: true, error: m })); -const cli = (args, stdin = '') => safe(tauri ? tauri.invoke('cli', { args, stdin }) : post('/api/cli', { args, stdin }), (m) => ({ ok: false, output: m })); -async function getConfig() { - if (tauri) return tauri.invoke('config'); - return (await fetch('/api/config')).json(); -} - -// ---- tiny DOM helper (text is always set via textContent, never innerHTML) -------------------- -function h(tag, attrs, ...kids) { - const e = document.createElement(tag); - for (const [k, v] of Object.entries(attrs || {})) { - if (k === 'class') e.className = v; - else if (k.startsWith('on')) e.addEventListener(k.slice(2), v); - else if (v === true) e.setAttribute(k, ''); - else if (v !== false && v != null) e.setAttribute(k, v); - } - for (const c of kids.flat()) if (c != null && c !== false) e.append(c.nodeType ? c : document.createTextNode(c)); - return e; -} -const $ = (s) => document.querySelector(s); - -// ---- state --------------------------------------------------------------------------------- -const S = { out: {}, branchName: {}, busy: false, status: null, offline: false, config: undefined, log: [], logFilter: '', lastStates: new Map() }; -const stateName = (s) => (s.startsWith('error') ? 'error' : s); -const STATE_LABEL = { synced: 'Synced', dirty: 'Editing', ahead: 'Ahead', behind: 'Behind', behinddirty: 'Behind + editing', diverged: 'Diverged', error: 'Error' }; -const PLAN = { - synced: 'Nothing to do.', - dirty: 'Snapshot the working changes and push the snapshot ref.', - ahead: 'Nothing automatic: push your commits yourself.', - behind: 'Fast-forward to the remote tip.', - behinddirty: 'Keep your edits; adopt the remote tip only if the content is identical.', - diverged: 'Nothing automatic: choose how to resolve it.', - error: 'Retry with backoff; see the error.', -}; -const short = (p) => p.split('/').slice(-2).join('/'); -function ago(ts, now) { - if (!ts) return 'never'; - const d = Math.max(0, (now || Date.now() / 1000) - ts); - if (d < 5) return 'just now'; - if (d < 60) return Math.round(d) + 's ago'; - if (d < 3600) return Math.round(d / 60) + ' min ago'; - if (d < 86400) return Math.round(d / 3600) + ' h ago'; - return Math.round(d / 86400) + ' d ago'; -} -function toast(msg, bad) { - const t = h('div', { class: 'toast' + (bad ? ' bad' : ''), role: 'status' }, msg); - $('#toasts').append(t); - setTimeout(() => t.remove(), 5000); -} -function notify(title, body) { - toast(title + ': ' + body, true); - try { - if ('Notification' in window && Notification.permission === 'granted') new Notification(title, { body }); - } catch (_) { /* notifications are optional */ } -} -const badge = (st) => h('span', { class: 'badge b-' + stateName(st) }, STATE_LABEL[stateName(st)] || st); - -// ---- aggregate ------------------------------------------------------------------------------- -function aggregate() { - const s = S.status; - if (S.offline || !s) return { cls: 'pill-muted', text: S.offline ? 'Daemon offline' : 'Connecting…', bad: 0 }; - let attention = 0, dirty = 0, total = 0; - for (const r of s.repos) { - if (r.last_error && !r.worktrees.some((w) => stateName(w.state) === 'error')) attention++; - for (const w of r.worktrees) { - total++; - const n = stateName(w.state); - if (n === 'diverged' || n === 'error') attention++; - else if (n !== 'synced') dirty++; - } - } - if (s.paused) return { cls: 'pill-muted', text: 'Paused', total, attention }; - if (attention) return { cls: 'pill-bad', text: attention + ' need' + (attention === 1 ? 's' : '') + ' attention', total, attention }; - if (dirty) return { cls: 'pill-warn', text: dirty + ' syncing', total, attention }; - return { cls: 'pill-ok', text: 'All synced', total, attention }; -} -function renderTop() { - const a = aggregate(); - $('#pill').className = 'pill ' + a.cls; - $('#pill-text').textContent = a.text; - const paused = S.status && S.status.paused; - $('#btn-pause').textContent = paused ? 'Resume sync' : 'Pause sync'; - $('#btn-pause').disabled = S.offline; - $('#btn-sync').disabled = S.offline || paused; - const m = $('#machine'); - m.textContent = ''; - if (S.status) m.append('Machine ', h('b', {}, S.status.machine)); - document.title = (a.attention ? '(' + a.attention + ') ' : '') + 'Grove'; -} - -// ---- views --------------------------------------------------------------------------------- -const views = {}; -views.repos = () => { - const s = S.status; - if (S.offline) return offline(); - if (!s) return h('p', { class: 'muted' }, 'Loading…'); - const a = aggregate(); - const stats = h('div', { class: 'grid2' }, - stat(s.repos.length, 'Repositories'), - stat(a.total || 0, 'Worktrees'), - stat(a.attention || 0, 'Need attention')); - if (!s.repos.length) return h('div', {}, head('Repositories', 'Everything grove keeps in sync on this machine.'), h('div', { class: 'card empty' }, 'No repositories yet. Create one under “New repository” or clone existing ones with “Import”.')); - const rows = s.repos.map((r) => h('tr', { class: 'row', tabindex: 0, onclick: () => (location.hash = '#/repo/' + encodeURIComponent(r.path)), onkeydown: (e) => { if (e.key === 'Enter') location.hash = '#/repo/' + encodeURIComponent(r.path); } }, - h('td', {}, h('div', { class: 'repo-name' }, short(r.path)), h('div', { class: 'path' }, r.path)), - h('td', {}, r.worktrees.map((w) => h('span', { title: w.branch || '' }, badge(w.state), h('span', { class: 'muted' }, (w.branch || '(detached)') + ' ')))), - h('td', {}, h('span', { class: 'muted' }, r.phase)), - h('td', {}, h('span', { class: 'muted' }, ago(r.last_sync, s.now)), r.last_error && h('div', { class: 'err' }, r.last_error)))); - return h('div', {}, head('Repositories', 'Everything grove keeps in sync on this machine.'), stats, - h('div', { class: 'card' }, h('table', { class: 'table' }, - h('thead', {}, h('tr', {}, h('th', {}, 'Repository'), h('th', {}, 'Worktrees'), h('th', {}, 'Phase'), h('th', {}, 'Last sync'))), - h('tbody', {}, rows)))); -}; -const stat = (n, label) => h('div', { class: 'card stat' }, h('b', {}, String(n)), h('span', {}, label)); -const head = (t, sub) => h('div', {}, h('h1', {}, t), h('p', { class: 'sub' }, sub)); -const offline = () => h('div', { class: 'card empty' }, h('b', {}, 'The grove daemon is not running.'), h('p', {}, 'Start it with ', h('code', {}, 'systemctl --user start groved'), ' (or run ', h('code', {}, 'groved'), ' in a terminal).')); - -views.repo = (path) => { - const r = S.status && S.status.repos.find((x) => x.path === path); - if (S.offline) return offline(); - if (!r) return h('div', {}, h('a', { class: 'back', href: '#/repos' }, '← Repositories'), h('p', { class: 'muted' }, 'Repository not found.')); - const rows = r.worktrees.map((w) => { - const n = stateName(w.state); - return h('tr', {}, - h('td', {}, h('div', { class: 'repo-name' }, w.branch || '(detached)'), h('div', { class: 'path' }, w.path || '')), - h('td', {}, badge(w.state)), - h('td', { class: 'muted' }, PLAN[n] || '')); - }); - const diverged = r.worktrees.filter((w) => stateName(w.state) === 'diverged'); - return h('div', {}, - h('a', { class: 'back', href: '#/repos' }, '← Repositories'), - h('h1', {}, short(r.path)), - h('p', { class: 'sub path' }, r.path), - h('div', { class: 'actions' }, h('button', { class: 'btn', onclick: () => syncRepo(r.path) }, 'Sync this repository')), - r.last_error && h('div', { class: 'err' }, r.last_error), - h('h2', {}, 'Worktrees'), - h('div', { class: 'card' }, h('table', { class: 'table' }, - h('thead', {}, h('tr', {}, h('th', {}, 'Branch'), h('th', {}, 'State'), h('th', {}, 'Next sync pass'))), h('tbody', {}, rows))), - diverged.map((w) => resolvePanel(w)), - r.worktrees.filter((w) => stateName(w.state) !== 'diverged' && S.out[w.path]).map((w) => h('div', { class: 'term' + (S.out[w.path].ok ? '' : ' fail') }, S.out[w.path].text))); -}; -function resolvePanel(w) { - const out = h('div'); - const run = async (flag, label) => { - if (!confirm(label + '\n\nA backup ref is written first, so nothing is lost. Continue?')) return; - const r = await cli(['resolve', w.path, ...flag]); - S.out[w.path] = { ok: r.ok, text: r.output }; - render(true); - refresh(); - }; - if (!w.path) return h('div', { class: 'callout' }, 'Diverged, but this daemon does not report the worktree path. Update groved.'); - const prev = S.out[w.path]; - if (prev) out.append(h('div', { class: 'term' + (prev.ok ? '' : ' fail') }, prev.text)); - const branchName = h('input', { type: 'text', id: 'brname', placeholder: 'branch name', 'aria-label': 'New branch name', value: S.branchName[w.path] ?? (w.branch || 'work') + '-local', oninput: (e) => { S.branchName[w.path] = e.target.value; } }); - return h('div', { class: 'callout' }, - h('h3', {}, 'Diverged: ' + (w.branch || '') + ' has commits here and on the remote'), - h('p', {}, 'Grove never merges for you. Pick what should win:'), - h('div', { class: 'actions' }, - h('button', { class: 'btn', onclick: () => run(['--save-as', branchName.value], 'Keep your commits on branch “' + branchName.value + '” and move this branch to the remote tip') }, 'Save mine as a branch'), branchName, - h('button', { class: 'btn', onclick: () => run(['--take-remote'], 'Discard your local commits and take the remote tip') }, 'Take remote'), - h('button', { class: 'btn btn-danger', onclick: () => run(['--keep-local'], 'Overwrite the remote branch with your local commits') }, 'Keep mine (overwrite remote)')), - h('p', { class: 'muted' }, 'To inspect both sides first, run ', h('code', {}, 'grove resolve ' + w.path + ' --compare'), ' in a terminal.'), - out); -} - -views.activity = () => { - if (S.offline) return offline(); - const f = S.logFilter.toLowerCase(); - const items = S.log.slice().reverse().filter((e) => !f || (e.kind + ' ' + (e.repo || '') + ' ' + e.msg).toLowerCase().includes(f)); - const filter = h('input', { type: 'text', id: 'flt', placeholder: 'Filter…', 'aria-label': 'Filter activity', value: S.logFilter, oninput: (e) => { S.logFilter = e.target.value; render(true); } }); - const body = items.length - ? h('table', { class: 'table' }, h('thead', {}, h('tr', {}, h('th', {}, 'Time'), h('th', {}, 'Event'), h('th', {}, 'Repository'), h('th', {}, 'Details'))), - h('tbody', {}, items.map((e) => h('tr', {}, - h('td', { class: 'muted' }, new Date(e.ts * 1000).toLocaleTimeString('en-GB')), - h('td', {}, h('span', { class: 'kind k-' + e.kind }, e.kind)), - h('td', { class: 'muted' }, e.repo || '–'), - h('td', {}, e.msg))))) - : h('div', { class: 'empty' }, 'No activity yet.'); - return h('div', {}, head('Activity', 'What the daemon did, newest first.'), h('div', { class: 'actions' }, filter), h('div', { class: 'card', style: 'margin-top:12px' }, body)); -}; - -function groupSelect() { - const groups = (S.config && S.config.groups) || []; - return h('select', { id: 'group', 'aria-label': 'Group' }, groups.map((g) => h('option', { value: g.name }, g.name + ' → ' + g.primary))); -} -function needConfig() { - return S.config && S.config.exists ? null : h('div', { class: 'card empty' }, 'Finish onboarding first (Settings).'); -} -views.new = () => { - if (needConfig()) return needConfig(); - const out = h('div'); - const name = h('input', { type: 'text', id: 'name', placeholder: 'my-project', pattern: '[A-Za-z0-9._-]+' }); - const pub = h('input', { type: 'checkbox', id: 'public' }); - const btn = h('button', { class: 'btn btn-primary', type: 'submit' }, 'Create repository'); - const form = h('form', { class: 'card form', onsubmit: async (e) => { - e.preventDefault(); - if (!name.value.trim()) return; - btn.disabled = true; btn.textContent = 'Creating…'; - const args = ['new', $('#group').value, name.value.trim()].concat(pub.checked ? ['--public'] : []); - const r = await cli(args); - out.replaceChildren(h('div', { class: 'term' + (r.ok ? '' : ' fail') }, r.output)); - btn.disabled = false; btn.textContent = 'Create repository'; - if (r.ok) { toast('Repository created'); name.value = ''; refresh(); } - } }, - h('label', {}, 'Group', groupSelect()), - h('label', {}, 'Name', name, h('span', { class: 'hint' }, 'Created on the group’s primary forge, with an initial commit and the bare + worktrees layout.')), - h('label', { class: 'check' }, pub, 'Public repository'), btn); - return h('div', {}, head('New repository', 'Creates the remote, the local checkout, the mirrors and registers it for your other machines.'), form, out); -}; - -views.import = () => { - if (needConfig()) return needConfig(); - const out = h('div'), list = h('div'); - const sel = groupSelect(); - const scan = async () => { - list.replaceChildren(h('p', { class: 'muted' }, 'Scanning…')); - out.replaceChildren(); - const r = await cli(['import', sel.value]); - const names = (r.output.match(/^\s+\S+\/(\S+?)(?: on \S+)?(?: \(private\))?$/gm) || []).map((l) => l.trim().split(/\s+/)[0].split('/')[1]); - if (!r.ok) return list.replaceChildren(h('div', { class: 'term fail' }, r.output)); - if (!names.length) return list.replaceChildren(h('p', { class: 'muted' }, 'Nothing to import: every remote repository is already on this machine.')); - const boxes = names.map((n) => h('label', { class: 'check' }, h('input', { type: 'checkbox', value: n }), n)); - const go = h('button', { class: 'btn btn-primary', onclick: async () => { - const picked = [...list.querySelectorAll('input:checked')].map((i) => i.value); - if (!picked.length) return; - go.disabled = true; - const res = await cli(['import', sel.value, ...picked]); - out.replaceChildren(h('div', { class: 'term' + (res.ok ? '' : ' fail') }, res.output)); - go.disabled = false; refresh(); - if (res.ok) scan(); - } }, 'Import selected'); - list.replaceChildren(h('div', { class: 'card form' }, boxes, go)); - }; - return h('div', {}, head('Import', 'Clone repositories that exist on your forge but not on this machine.'), - h('div', { class: 'actions' }, sel, h('button', { class: 'btn', onclick: scan }, 'Scan remote')), list, out); -}; - -views.settings = () => { - const c = S.config; - if (!c || !c.exists) return onboarding(); - const cfg = c.config; - const kv = (rows) => h('dl', { class: 'kv card' }, rows.flatMap(([k, v]) => [h('dt', {}, k), h('dd', {}, v)])); - const provs = Object.entries(cfg.providers || {}); - const out = h('div'); - const prov = h('select', { id: 'tokprov', 'aria-label': 'Provider' }, provs.map(([id]) => h('option', { value: id }, id))); - const tok = h('input', { type: 'password', id: 'tok', autocomplete: 'off', placeholder: 'API token' }); - const act = async (args, stdin) => { const r = await cli(args, stdin); out.replaceChildren(h('div', { class: 'term' + (r.ok ? '' : ' fail') }, r.output)); refresh(); }; - return h('div', {}, head('Settings', 'Read from config.toml. Tokens live in the system keyring, never in the file.'), - h('h2', {}, 'This machine'), - kv([['Name', cfg.machine.name], ['Workspace root', cfg.root.path], ['Fetch interval', ((cfg.sync && cfg.sync.fetch_interval_s) || 60) + ' s'], ['Largest synced file', ((cfg.sync && cfg.sync.max_file_mb) ?? 50) + ' MiB']]), - h('h2', {}, 'Providers'), - kv(provs.map(([id, p]) => [id, p.kind + (p.url ? ' · ' + p.url : '')])), - h('h2', {}, 'Groups'), - kv((cfg.groups || []).map((g) => [g.name, 'primary ' + g.primary + (g.mirror_to && g.mirror_to.length ? ' · mirrors: ' + g.mirror_to.join(', ') : '') + (g.public ? ' · public: ' + g.public.primary + ((g.public.mirror_to || []).length ? ' → ' + g.public.mirror_to.join(', ') : '') : '') + ' · ' + (g.layout || 'bare-worktrees')])), - h('h2', {}, 'Config repository'), - kv([['Repository', cfg.config_repo ? cfg.config_repo.name + ' on ' + cfg.config_repo.provider : 'not configured']]), - h('div', { class: 'actions' }, - h('button', { class: 'btn', onclick: () => act(['config-repo-init']) }, 'Register repos on disk'), - h('button', { class: 'btn', onclick: () => act(['bootstrap']) }, 'Bootstrap from config repo')), - h('h2', {}, 'Sign in to a provider'), - h('form', { class: 'card form', onsubmit: (e) => { e.preventDefault(); if (tok.value) { act(['login', prov.value], tok.value + '\n'); tok.value = ''; } } }, - h('label', {}, 'Provider', prov), h('label', {}, 'Token', tok, h('span', { class: 'hint' }, 'Needs repository read/write scope. Sent to the forge only.')), - h('button', { class: 'btn btn-primary', type: 'submit' }, 'Verify and store')), - h('h2', {}, 'Encrypted files (.env)'), - h('div', { class: 'actions' }, - h('button', { class: 'btn', onclick: () => act(['secrets', 'init']) }, 'Create this machine’s key'), - h('button', { class: 'btn', onclick: () => act(['secrets', 'pull']) }, 'Pull secrets'), - h('button', { class: 'btn', onclick: () => act(['secrets', 'rekey']) }, 'Re-encrypt for all machines')), - out); -}; -function onboarding() { - const f = {}; - const field = (id, label, value, hint) => { f[id] = h('input', { type: 'text', id, value }); return h('label', {}, label, f[id], hint && h('span', { class: 'hint' }, hint)); }; - f.kind = h('select', { id: 'kind' }, ['gitea', 'forgejo', 'github'].map((k) => h('option', { value: k }, k))); - f.token = h('input', { type: 'password', id: 'token', autocomplete: 'off' }); - const out = h('div'); - const btn = h('button', { class: 'btn btn-primary', type: 'submit' }, 'Set up grove'); - const form = h('form', { class: 'card form', onsubmit: async (e) => { - e.preventDefault(); btn.disabled = true; - const lines = []; - const step = async (args, stdin) => { const r = await cli(args, stdin); lines.push('$ grove ' + args[0] + '\n' + r.output); out.replaceChildren(h('div', { class: 'term' + (r.ok ? '' : ' fail') }, lines.join('\n\n'))); return r.ok; }; - const a = ['init', '--machine', f.machine.value, '--root', f.root.value, '--provider', f.provider.value, '--kind', f.kind.value, '--group', f.group.value, '--config-repo', f.crepo.value]; - if (f.url.value) a.push('--url', f.url.value); - const existing = await getConfig(); // a previous attempt may already have written the config - if ((existing.exists || await step(a)) && await step(['login', f.provider.value], f.token.value + '\n') && await step(['bootstrap'])) { toast('All set'); S.config = undefined; await refresh(); location.hash = '#/repos'; } - btn.disabled = false; - } }, - field('machine', 'Machine name', 'my-laptop', 'Letters, digits, - and _. Unique per computer.'), - field('root', 'Workspace folder', '~/Workspace'), - h('label', {}, 'Forge type', f.kind), - field('provider', 'Provider id', 'main'), - field('url', 'Forge URL', 'https://git.example.com', 'Empty for github.com.'), - field('group', 'First group', 'work'), - field('crepo', 'Config repository', 'grove-config', 'Private repo holding the list of your repos, so a new machine only needs to sign in.'), - h('label', {}, 'API token', f.token), btn); - return h('div', {}, head('Welcome to Grove', 'Set up this machine. On a second computer this is all you do: sign in and your workspace appears.'), form, out); -} - -// ---- router / render ------------------------------------------------------------------------- -function route() { - const hash = location.hash.replace(/^#\/?/, '') || 'repos'; - const [name, ...rest] = hash.split('/'); - return { name, arg: rest.length ? decodeURIComponent(rest.join('/')) : null }; -} -let lastKey = ''; -function render(force) { - const { name, arg } = route(); - document.querySelectorAll('#nav a').forEach((a) => a.classList.toggle('active', a.dataset.route === (name === 'repo' ? 'repos' : name))); - renderTop(); - // Avoid clobbering forms while the user types: re-render form views only on navigation. - const formView = ['new', 'import', 'settings'].includes(name); - const key = name + '|' + arg; - if (!force && formView && key === lastKey) return; - lastKey = key; - // Never rebuild under the user's cursor on a background poll. - const ae = document.activeElement; - const typing = ae && $('#view').contains(ae) && /^(INPUT|SELECT|TEXTAREA)$/.test(ae.tagName); - if (!force && typing) return; - const keep = typing && ae.id ? { id: ae.id, pos: ae.selectionStart } : null; - const v = name === 'repo' ? views.repo(arg) : (views[name] || views.repos)(); - $('#view').replaceChildren(v); - if (keep) { const e = document.getElementById(keep.id); if (e) { e.focus(); try { e.setSelectionRange(keep.pos, keep.pos); } catch (_) { /* not a text input */ } } } -} - -// ---- actions & polling ----------------------------------------------------------------------- -async function syncRepo(path) { - const r = await ipc({ v: 1, cmd: 'sync', repo: path }); - toast(r.ok ? 'Sync queued' : r.error, !r.ok); -} -$('#btn-sync').addEventListener('click', async () => { const r = await ipc({ v: 1, cmd: 'sync' }); toast(r.ok ? 'Sync queued for all repositories' : r.error, !r.ok); }); -$('#btn-pause').addEventListener('click', async () => { - const paused = S.status && S.status.paused; - await ipc({ v: 1, cmd: paused ? 'resume' : 'pause' }); - refresh(); -}); -function watchTransitions() { - if (!S.status) return; - for (const r of S.status.repos) for (const w of r.worktrees) { - const key = w.path || r.path + w.branch, n = stateName(w.state), prev = S.lastStates.get(key); - if (prev && prev !== n && (n === 'diverged' || n === 'error')) notify(n === 'diverged' ? 'Diverged' : 'Sync error', short(r.path) + ' · ' + (w.branch || '')); - S.lastStates.set(key, n); - } -} -async function refresh() { - if (S.busy) return; - S.busy = true; - try { - const st = await ipc({ v: 1, cmd: 'status' }); - S.offline = !st.ok; S.status = st.ok ? st.data : null; - if (st.ok) { const lg = await ipc({ v: 1, cmd: 'log', limit: 200 }); if (lg.ok) S.log = lg.data; } - } catch (_) { S.offline = true; S.status = null; } - if (S.config === undefined) { try { S.config = await getConfig(); } catch (_) { S.config = { exists: false }; } } - try { watchTransitions(); } finally { S.busy = false; } - render(false); -} -window.addEventListener('hashchange', () => render(true)); -refresh().then(() => { if (!(S.config && S.config.exists) && !location.hash) location.hash = '#/settings'; }); -setInterval(refresh, 2000); // refresh() skips while a previous one is still in flight diff --git a/gui/ui/index.html b/gui/ui/index.html deleted file mode 100644 index fb31684..0000000 --- a/gui/ui/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -Grove - - - - -
- -
-
-
Connecting…
-
- - -
-
-
-
-
- - - diff --git a/gui/ui/logo.svg b/gui/ui/logo.svg deleted file mode 100644 index 0708609..0000000 --- a/gui/ui/logo.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/gui/ui/style.css b/gui/ui/style.css deleted file mode 100644 index 4679a3f..0000000 --- a/gui/ui/style.css +++ /dev/null @@ -1,98 +0,0 @@ -:root { - --bg: #f5f6f4; --panel: #ffffff; --text: #1b2420; --muted: #66726b; --line: #e1e5e1; - --accent: #1f7a4d; --accent-ink: #ffffff; --accent-soft: #e3f2ea; - --ok: #1f7a4d; --ok-bg: #e3f2ea; - --warn: #9a6200; --warn-bg: #fdf0d5; - --info: #1d5fa8; --info-bg: #e3eefa; - --bad: #b3261e; --bad-bg: #fbe4e1; - --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; - --radius: 10px; -} -@media (prefers-color-scheme: dark) { - :root { - --bg: #121714; --panel: #1a211d; --text: #e6ede8; --muted: #93a39a; --line: #2a342e; - --accent: #3fb27a; --accent-ink: #08140d; --accent-soft: #1d3a2b; - --ok: #5bd197; --ok-bg: #1d3a2b; --warn: #f0b64a; --warn-bg: #3a2e12; - --info: #7ab4f0; --info-bg: #17304d; --bad: #ff8a80; --bad-bg: #4a1f1b; - } -} -* { box-sizing: border-box; } -html, body { height: 100%; } -body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; } -.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; } -.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; } -.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: .2px; padding: 0 6px; } -nav { display: flex; flex-direction: column; gap: 2px; } -nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; } -nav a:hover { background: var(--bg); color: var(--text); } -nav a.active { background: var(--accent-soft); color: var(--accent); } -.machine { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 6px; word-break: break-all; } -.machine b { color: var(--text); font-weight: 600; } -.main { display: flex; flex-direction: column; min-width: 0; } -.top { display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; } -.spacer { flex: 1; } -.view { padding: 24px; max-width: 1100px; width: 100%; } -h1 { font-size: 20px; margin: 0 0 4px; } -h2 { font-size: 15px; margin: 22px 0 8px; } -.sub { color: var(--muted); margin: 0 0 18px; } -.btn { font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; font-weight: 500; } -.btn:hover { border-color: var(--muted); } -.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } -.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } -.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; } -.btn:disabled { opacity: .5; cursor: default; } -.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; } -.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; } -.pill-ok { background: var(--ok-bg); color: var(--ok); } -.pill-warn { background: var(--warn-bg); color: var(--warn); } -.pill-bad { background: var(--bad-bg); color: var(--bad); } -.pill-muted { background: var(--bg); color: var(--muted); } -.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); } -.table { width: 100%; border-collapse: collapse; } -.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 10px 16px; border-bottom: 1px solid var(--line); } -.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; } -.table tr:last-child td { border-bottom: 0; } -.row { cursor: pointer; } -.row:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); } -.repo-name { font-weight: 600; } -.path { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; } -.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 1px 4px 1px 0; } -.b-synced { background: var(--ok-bg); color: var(--ok); } -.b-dirty, .b-behinddirty { background: var(--warn-bg); color: var(--warn); } -.b-ahead, .b-behind { background: var(--info-bg); color: var(--info); } -.b-diverged, .b-error { background: var(--bad-bg); color: var(--bad); } -.muted { color: var(--muted); } -.err { color: var(--bad); font-size: 13px; margin-top: 4px; } -.empty { padding: 40px 20px; text-align: center; color: var(--muted); } -.form { display: grid; gap: 14px; max-width: 520px; padding: 20px; } -label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; } -label .hint { font-weight: 400; color: var(--muted); } -input[type=text], input[type=password], select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); } -.check { display: flex; align-items: center; gap: 8px; font-weight: 500; } -.term { font-family: var(--mono); font-size: 12.5px; background: #0f1512; color: #cfe8d9; border-radius: var(--radius); padding: 14px 16px; white-space: pre-wrap; word-break: break-word; margin-top: 14px; max-height: 320px; overflow: auto; } -.term.fail { color: #ffb4ab; } -.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; padding: 16px 20px; } -.kv dt { color: var(--muted); } -.kv dd { margin: 0; word-break: break-all; } -.kind { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); } -.k-error, .k-watch_error { color: var(--bad); border-color: var(--bad); } -.k-snapshot, .k-applied, .k-fast_forward, .k-materialized { color: var(--ok); } -.k-declined, .k-pause { color: var(--warn); } -.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; } -.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; } -.callout { border: 1px solid var(--bad); background: var(--bad-bg); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; } -.callout h3 { margin: 0 0 4px; font-size: 14px; color: var(--bad); } -.callout p { margin: 4px 0 10px; } -.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 10; } -.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: 0 6px 24px rgba(0,0,0,.25); } -.toast.bad { background: var(--bad); color: #fff; } -.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 18px; } -.stat { padding: 14px 16px; } -.stat b { display: block; font-size: 24px; line-height: 1.1; } -.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; } -@media (max-width: 760px) { - .app { grid-template-columns: 1fr; } - .side { flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; } - nav { flex-direction: row; } .machine { display: none; } - .view { padding: 16px; } .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; } -} From 67b4f9e5d4f3dca658652d07637a2d12d32c4e43 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:27:52 +0100 Subject: [PATCH 03/19] build: package grove-gui, desktop files and icon in the deb Co-Authored-By: Claude Sonnet 5.5 --- contrib/grove-autostart.desktop | 8 ++++++++ contrib/grove.desktop | 10 ++++++++++ crates/grove/Cargo.toml | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 contrib/grove-autostart.desktop create mode 100644 contrib/grove.desktop diff --git a/contrib/grove-autostart.desktop b/contrib/grove-autostart.desktop new file mode 100644 index 0000000..e57048a --- /dev/null +++ b/contrib/grove-autostart.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Grove +Comment=Grove tray icon (starts hidden) +Exec=grove-gui --hidden +Icon=grove +Terminal=false +X-GNOME-Autostart-enabled=true diff --git a/contrib/grove.desktop b/contrib/grove.desktop new file mode 100644 index 0000000..21022d0 --- /dev/null +++ b/contrib/grove.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=Grove +GenericName=Git sync +Comment=Keep your git repositories in sync across machines +Exec=grove-gui +Icon=grove +Terminal=false +Categories=Development;Utility; +StartupWMClass=grove diff --git a/crates/grove/Cargo.toml b/crates/grove/Cargo.toml index 3307b78..f2b86fb 100644 --- a/crates/grove/Cargo.toml +++ b/crates/grove/Cargo.toml @@ -14,7 +14,7 @@ grove-providers = { version = "0.1.0", path = "../grove-providers" } serde_json = "1.0.154" toml = "1.2.1" -# `cargo build --release --workspace && cargo deb -p grove --no-build` packages CLI + daemon + user unit. +# `cargo build --release --workspace && cargo deb -p grove --no-build` packages CLI + daemon + GUI + desktop files + user unit. [package.metadata.deb] name = "grove" section = "devel" @@ -23,5 +23,9 @@ extended-description = "Keeps chosen git repos continuously in sync across machi assets = [ ["../../target/release/grove", "usr/bin/", "755"], ["../../target/release/groved", "usr/bin/", "755"], + ["../../target/release/grove-gui", "usr/bin/", "755"], + ["../../contrib/grove.desktop", "usr/share/applications/", "644"], + ["../../contrib/grove-autostart.desktop", "etc/xdg/autostart/grove.desktop", "644"], + ["../../assets/grove.png", "usr/share/icons/hicolor/64x64/apps/grove.png", "644"], ["../../contrib/groved.deb.service", "usr/lib/systemd/user/groved.service", "644"], ] From 9b16e0b2cca1e60fdc28799c96bfa9d3b377bbbb Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:27:52 +0100 Subject: [PATCH 04/19] docs: phase 7 native GUI, mark phase 3 superseded, update CLAUDE.md and LESSONS.md Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 10 +++---- LESSONS.md | 2 ++ docs/phase3.md | 6 +++- docs/phase7.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 docs/phase7.md diff --git a/CLAUDE.md b/CLAUDE.md index 806b95d..736fb30 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,8 +4,7 @@ Linux tool that keeps chosen git repos continuously in sync across machines, including uncommitted work, via snapshot refs (`refs/sync//`) on a primary remote. Rust workspace: `grove-core`, `grove` (CLI), `grove-daemon` (`groved`), `grove-providers` (Gitea/Forgejo/GitHub), -`grove-bridge` (localhost HTTP bridge for the GUI), plus `gui/ui` (plain HTML/JS) and `gui/src-tauri` (Tauri shell, -outside the workspace, never compiled yet). Phases 0-5 are implemented; the real two-PC run is still pending. +`grove-gui` (native Slint desktop app with a ksni tray, `docs/phase7.md`). Phases 0-7 are implemented; the real two-PC run is still pending. Do not start new work before the previous results are written to `docs/`. ## Commands @@ -13,17 +12,17 @@ Do not start new work before the previous results are written to `docs/`. - Throwaway Forgejo (dev only, Podman): `spikes/forgejo-up.sh`, then `spikes/phase0.sh` - Rust: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo test` - Daemon: `cargo run -p grove-daemon --bin groved -- --config PATH`; client `grove daemon status` -- GUI in a browser: `cargo run -p grove-bridge -- --ui gui/ui`; Tauri shell: see `docs/phase3.md` +- GUI: `cargo run -p grove-gui` (`--hidden` starts in the tray; needs a Wayland/X11 session and a StatusNotifier host) - Package: `cargo build --release --workspace && cargo deb -p grove --no-build` - Throwaway e2e on a local Forgejo: `spikes/phase4-e2e.sh` ## Architecture -See `docs/` (`phase0-spike.md` ... `phase6.md`, `DECISIONS.md`). Git is the storage layer; shell out to +See `docs/` (`phase0-spike.md` ... `phase7.md`, `DECISIONS.md`). Git is the storage layer; shell out to system `git`; snapshots use a temp `GIT_INDEX_FILE` + `commit-tree`, never touching the user's branch or index. ## Conventions -- Dependencies: serde+toml, clap+anyhow, notify+serde_json, ureq, keyring, age, tauri v2 (GUI shell), approved. Ask before adding more. +- Dependencies: serde+toml, clap+anyhow, notify+serde_json, ureq, keyring, age, slint (GUI, `winit` + software renderer) and ksni (tray), approved. Ask before adding more. - Everything in the repo is English. Open questions go to `docs/DECISIONS.md`. - Never destroy local work; divergence is surfaced, never auto-merged. @@ -39,3 +38,4 @@ Native Linux app (systemd user service). Never Docker for deployment. ## Gotchas - Forgejo push mirrors to localhost need `migrations.ALLOW_LOCALNETWORKS` (test instances only). - Push-mirror exclusion of `refs/sync/*` is verified on Forgejo 11 only, not yet on the real Gitea. +- Slint on Wayland: a window shown from an idle (hidden) event loop is not mapped until another event arrives; `show_window` schedules a one-shot redraw. Keep it. diff --git a/LESSONS.md b/LESSONS.md index dadba6a..cb0811b 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -8,3 +8,5 @@ - Bare-layout clones must set upstream tracking per branch, or `status` silently reports Synced for Behind/Diverged. Assert tracking in tests of any clone path. - Unix socket paths are limited to ~100 bytes: use a short `XDG_RUNTIME_DIR` (e.g. `/tmp/gd`) when running a daemon from deep scratch dirs. - Mock-server tests must parse the JSON request body; pretty-printed JSON breaks string asserts. +- Slint (winit/Wayland): `show()` from an idle event loop leaves the window unmapped until another event arrives; follow it with a one-shot `request_redraw` timer. +- Slint has no top-level `function`; use a `global`. A wrapped `Text` under-reports its preferred height inside layouts, so elide long log/error text instead of wrapping it. diff --git a/docs/phase3.md b/docs/phase3.md index 6f66e75..f8d9bfe 100644 --- a/docs/phase3.md +++ b/docs/phase3.md @@ -1,4 +1,8 @@ -# Phase 3: GUI +# Phase 3: GUI (superseded) + +> **Superseded by [Phase 7](phase7.md).** The HTML/JS frontend, the localhost bridge and the Tauri +> shell described below were removed; the native `grove-gui` replaces them. Kept for history. + ## Layout diff --git a/docs/phase7.md b/docs/phase7.md new file mode 100644 index 0000000..6a485cd --- /dev/null +++ b/docs/phase7.md @@ -0,0 +1,77 @@ +# Phase 7: native GUI + +`grove-gui` (crate `crates/grove-gui`) replaces the web UI of Phase 3. It is a native desktop app +(Slint UI, StatusNotifierItem tray) that lives in the system tray. It contains no sync logic: state +comes from the daemon over its Unix socket and every action runs an allow-listed `grove` subcommand, +exactly as before. + +## Architecture + +| Part | Where | +|---|---| +| Daemon IPC + allow-listed CLI calls + config (formerly `grove-bridge`) | `src/bridge.rs` | +| Pure logic: status -> aggregate/tray state, formatting, `grove import` listing parser, settings summary | `src/model.rs` | +| Tray (ksni), icons drawn in code per state | `src/tray.rs` | +| Single instance (Unix socket) | `src/instance.rs` | +| Window, callbacks, worker threads | `src/main.rs`, `ui/app.slint` | + +Threads: the Slint event loop; a worker that fetches `status` (and `log`/config only while the window +is visible); a subscriber that holds a `subscribe` connection to the daemon and wakes the worker on +every event (reconnects every 5 s while the daemon is down); the tray service; the single-instance +listener; short-lived threads for CLI calls so the UI never blocks. Fallback poll: 5 s with the +window open, 30 s hidden. No Slint timers run while idle. + +Tray states: ok, syncing, attention (also sets the item to `NeedsAttention`), paused, daemon offline. +Menu: Open, Sync now, Pause/Resume, Quit; left click opens the window. Closing the window hides it; +Quit exits. If no StatusNotifier host exists, closing the window quits. A transition into +`Diverged`/`Error` shows a toast when the window is open and calls `notify-send` (best effort) when hidden. + +Single instance: `$XDG_RUNTIME_DIR/grove/gui.sock`. A second `grove-gui` asks the first to show +its window and exits; `grove-gui --hidden` (autostart) only checks and never raises the window. + +Screens (parity with Phase 3): repositories with per-worktree state, repository detail with the +resolve panel (confirmation first), activity with filter, new repository, import (scan, pick, +import), settings (machine, providers, groups incl. public route and `owners`, config repo, token +login, secrets), onboarding when there is no config, offline state with a hint. + +## Run + +```bash +cargo run --release -p grove-gui # window + tray +grove-gui --hidden # tray only +grove-gui --config PATH --socket PATH --grove-bin PATH # test against another daemon/config +grove-gui --view settings # start on a view (activity, new, import, repo:) +``` + +`grove` is looked up next to the `grove-gui` binary, then in `PATH`. Packaging: `.deb` installs +`grove-gui`, `contrib/grove.desktop`, `contrib/grove-autostart.desktop` (`/etc/xdg/autostart`) and +`assets/grove.png`. Dev builds need no system Qt: Slint is built with the `winit` backend (Wayland and +X11 loaded at runtime) and the software renderer. + +## Dependencies + +- `slint` / `slint-build` 1.18.1 (`std`, `backend-winit`, `renderer-software`, `compat-1-2`; no Qt, + no femtovg, no system-tray feature). Style `fluent` (pure Slint). Slint is licensed GPL-3.0 or its + royalty-free license (attribution required) or a commercial one; pick one before distributing. +- `ksni` 0.3.7 (`async-io` + `blocking`, no tokio). + +## Memory (release build, KDE Plasma 6 / Wayland, `ps -o rss`) + +| State | Software renderer (used) | femtovg (GL) | +|---|---|---| +| Started with `--hidden` | 24-25 MB | 94 MB | +| Window open | 33.5 MB | 105 MB | +| After closing the window (hidden again) | 28 MB | not measured | + +Idle CPU hidden: 0 ticks in 20 s. 9 threads. + +## Limits + +- Showing an already visible window does not raise it (no xdg-activation token is passed). +- Activity timestamps use the local UTC offset read via `date +%z` (no timezone crate). +- The activity list shows the first line of each message, repository errors are cut at 160 characters + in the list (full text in the detail view). +- Slint's wrapped text under-reports its height in layouts, so long text is elided, not wrapped. +- Side-by-side compare for `Diverged` stays in the CLI (`grove resolve --compare`). +- Only the layout and read-only views were checked visually; forms and CLI-driven flows were not + clicked through (no input injection available), only their parsing and logic are unit-tested. From e3a16a494c497d9ce6adb528ba4fb10f857b570b Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:36:06 +0100 Subject: [PATCH 05/19] feat(gui): show snapshot policy, withheld snapshots and not-migrated clones; raise visible window Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-gui/src/main.rs | 18 ++++++++++++++++++ crates/grove-gui/src/model.rs | 36 +++++++++++++++++++++++++++++++++-- crates/grove-gui/ui/app.slint | 33 +++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs index e99a2b7..ef1438d 100644 --- a/crates/grove-gui/src/main.rs +++ b/crates/grove-gui/src/main.rs @@ -199,6 +199,17 @@ fn render(ui: &MainWindow) { ui.set_wt_count(agg.worktrees as i32); ui.set_attention_count(agg.attention as i32); ui.set_has_config(snap.config.is_some()); + let nm: Vec = snap + .status + .as_ref() + .and_then(|s| s["not_migrated"].as_array()) + .map(|a| { + a.iter() + .filter_map(|p| p.as_str().map(SharedString::from)) + .collect() + }) + .unwrap_or_default(); + ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm)))); let empty = Vec::new(); let repos: Vec = snap @@ -243,6 +254,7 @@ fn render(ui: &MainWindow) { phase: s(r, "phase").into(), last_sync: model::ago(r["last_sync"].as_u64().unwrap_or(0), now).into(), error: r["last_error"].as_str().unwrap_or("").into(), + withheld: r["snapshots_withheld"].as_str().unwrap_or("").into(), path: path.into(), wts: ModelRc::from(Rc::new(VecModel::from(wts))), } @@ -286,6 +298,7 @@ fn render(ui: &MainWindow) { time: model::clock(e["ts"].as_u64().unwrap_or(0), off).into(), kind: s(e, "kind").into(), repo: e["repo"].as_str().unwrap_or("–").into(), + tone: model::log_tone(&s(e, "kind")).into(), msg: s(e, "msg").lines().next().unwrap_or("").into(), }) .collect(); @@ -350,6 +363,11 @@ fn toast(ui: &MainWindow, msg: &str, bad: bool) { } fn show_window(ui: &MainWindow, core: &Core) { + // Slint exposes no xdg-activation, so an already visible window is raised by re-mapping it: + // a fresh toplevel is what the compositor focuses. + if core.visible.load(Ordering::SeqCst) && ui.window().is_visible() { + let _ = ui.hide(); + } let _ = ui.show(); // On Wayland a window shown from an idle (hidden) loop is not mapped until another event // arrives; a one-shot redraw request provides it. diff --git a/crates/grove-gui/src/model.rs b/crates/grove-gui/src/model.rs index 5972187..deca4ea 100644 --- a/crates/grove-gui/src/model.rs +++ b/crates/grove-gui/src/model.rs @@ -112,6 +112,15 @@ pub fn aggregate(status: Option<&Value>) -> Aggregate { } } +/// Colour key of an activity event kind. +pub fn log_tone(kind: &str) -> &'static str { + match kind { + "error" | "watch_error" => "error", + "state" | "snapshots_withheld" | "snapshots_purged" | "declined" => "warn", + _ => "ok", + } +} + /// Last two path components, e.g. `work/api`. pub fn short(path: &str) -> String { let parts: Vec<&str> = path.split('/').filter(|p| !p.is_empty()).collect(); @@ -172,7 +181,7 @@ fn names(v: Option<&Value>) -> Vec { .unwrap_or_default() } -/// One line per group: routes (private + public), owners and layout. +/// One line per group: routes (private + public), snapshot policy, owners and layout. pub fn group_summary(g: &Value) -> String { let mut s = format!("primary {}", str_of(g, "primary")); let mirrors = names(g.get("mirror_to")); @@ -186,6 +195,9 @@ pub fn group_summary(g: &Value) -> String { s += &format!(" → {}", pm.join(", ")); } } + if let Some(p) = g.get("snapshots").and_then(Value::as_str) { + s += &format!(" · snapshots: {p}"); + } if let Some(o) = g .get("owners") .and_then(Value::as_object) @@ -231,6 +243,13 @@ pub fn settings_sections(cfg: &Value) -> Vec
{ "Largest synced file".into(), format!("{} MiB", num("max_file_mb", 50)), ), + ( + "Snapshots (default)".into(), + sync.and_then(|s| s.get("snapshots")) + .and_then(Value::as_str) + .unwrap_or("private-only") + .to_string(), + ), ]; let providers = cfg .get("providers") @@ -361,6 +380,14 @@ mod tests { assert!(parse_import_listing("nothing to import").is_empty()); } + #[test] + fn log_tones() { + assert_eq!(log_tone("snapshots_withheld"), "warn"); + assert_eq!(log_tone("snapshots_purged"), "warn"); + assert_eq!(log_tone("snapshots_enabled"), "ok"); + assert_eq!(log_tone("watch_error"), "error"); + } + #[test] fn formatting() { assert_eq!(short("/home/u/Workspace/work/api"), "work/api"); @@ -383,18 +410,23 @@ mod tests { "providers": {"gitea": {"kind": "gitea", "url": "https://g.example"}, "gh": {"kind": "github"}}, "groups": [{"name": "work", "primary": "gitea", "mirror_to": ["gh"], "owners": {"gitea": "Org", "gh": "org-gh"}, + "snapshots": "none", "public": {"primary": "gh", "mirror_to": ["gitea"]}}], "config_repo": {"name": "grove-config", "provider": "gitea"} }); let s = settings_sections(&cfg); assert_eq!(s[0].1[0], ("Name".into(), "pca".into())); assert_eq!(s[0].1[2].1, "60 s"); + assert_eq!( + s[0].1[4], + ("Snapshots (default)".into(), "private-only".into()) + ); // Providers come out sorted by id. assert_eq!(s[1].1[0].1, "github"); assert_eq!(s[1].1[1].1, "gitea · https://g.example"); assert_eq!( s[2].1[0].1, - "primary gitea · mirrors: gh · public: gh → gitea · owners: gh=org-gh, gitea=Org · bare-worktrees" + "primary gitea · mirrors: gh · public: gh → gitea · snapshots: none · owners: gh=org-gh, gitea=Org · bare-worktrees" ); assert_eq!(s[3].1[0].1, "grove-config on gitea"); assert_eq!(group_name("work → gitea"), "work"); diff --git a/crates/grove-gui/ui/app.slint b/crates/grove-gui/ui/app.slint index d5826d8..4dc00b7 100644 --- a/crates/grove-gui/ui/app.slint +++ b/crates/grove-gui/ui/app.slint @@ -16,6 +16,7 @@ export struct Repo { phase: string, last-sync: string, error: string, + withheld: string, wts: [Wt], } @@ -24,6 +25,7 @@ export struct LogRow { kind: string, repo: string, msg: string, + tone: string, } export struct Kv { @@ -176,6 +178,7 @@ export component MainWindow inherits Window { in property wt-count; in property attention-count; in property <[Repo]> repos; + in property <[string]> not-migrated; in property <[LogRow]> log; in property <[string]> groups; in property <[string]> providers; @@ -355,6 +358,22 @@ export component MainWindow inherits Window { text: "Start it with `systemctl --user start groved` (or run `groved` in a terminal)."; } } + if !root.offline && root.not-migrated.length > 0: Card { + Text { + text: "Not migrated clones"; + font-weight: 700; + } + + Muted { + text: "These clones are in your workspace but not managed by grove yet: run `grove add` for each one to bring it into a group."; + } + + for p in root.not-migrated: Muted { + text: p; + font-size: 12px; + overflow: elide; + } + } if !root.offline && root.loading: Muted { text: "Loading…"; } @@ -403,6 +422,13 @@ export component MainWindow inherits Window { font-size: 11px; } + if r.withheld != "": Text { + text: "snapshots withheld: " + r.withheld; + color: #d98e1f; + font-size: 12px; + overflow: elide; + } + if r.error != "": Text { text: r.error; color: #d9483b; @@ -496,6 +522,11 @@ export component MainWindow inherits Window { } } + if root.detail.withheld != "": Text { + text: "snapshots withheld: " + root.detail.withheld; + color: #d98e1f; + wrap: word-wrap; + } if root.detail.error != "": Text { text: root.detail.error; color: #d9483b; @@ -646,7 +677,7 @@ export component MainWindow inherits Window { Text { width: 90px; text: e.kind; - color: Tone.of(e.kind == "error" || e.kind == "watch_error" ? "error" : e.kind == "state" ? "warn" : "ok"); + color: Tone.of(e.tone); font-size: 12px; font-weight: 700; } From 053f5ef97e9dc662cad9533173e3895f3dafbc1e Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:36:06 +0100 Subject: [PATCH 06/19] docs: phase 7 daemon scope, snapshot policy and window raising Co-Authored-By: Claude Sonnet 5.5 --- docs/phase7.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/phase7.md b/docs/phase7.md index 6a485cd..f6fcf86 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -29,6 +29,11 @@ Quit exits. If no StatusNotifier host exists, closing the window quits. A transi Single instance: `$XDG_RUNTIME_DIR/grove/gui.sock`. A second `grove-gui` asks the first to show its window and exits; `grove-gui --hidden` (autostart) only checks and never raises the window. +Daemon scope and snapshot policy (Phase 6) in the GUI: each repo shows `snapshots withheld: ` +(list and detail), the repositories view lists the `not_migrated` clones with the hint to run +`grove add`, settings show the default snapshot policy and per-group overrides, and Activity colours +`snapshots_withheld`/`snapshots_purged` as warnings and `snapshots_enabled` as ok. + Screens (parity with Phase 3): repositories with per-worktree state, repository detail with the resolve panel (confirmation first), activity with filter, new repository, import (scan, pick, import), settings (machine, providers, groups incl. public route and `owners`, config repo, token @@ -59,15 +64,15 @@ X11 loaded at runtime) and the software renderer. | State | Software renderer (used) | femtovg (GL) | |---|---|---| -| Started with `--hidden` | 24-25 MB | 94 MB | -| Window open | 33.5 MB | 105 MB | -| After closing the window (hidden again) | 28 MB | not measured | +| Started with `--hidden` | 24 MB | 94 MB | +| Window open | 31 MB | 105 MB | +| After closing the window (hidden again) | 25 MB | not measured | Idle CPU hidden: 0 ticks in 20 s. 9 threads. ## Limits -- Showing an already visible window does not raise it (no xdg-activation token is passed). +- Slint does not expose xdg-activation, so launching again (or clicking the tray) on a visible window re-maps it (hide + show); the compositor focuses the fresh window (checked on KWin: keyboard focus arrives). The compositor picks the window position again. - Activity timestamps use the local UTC offset read via `date +%z` (no timezone crate). - The activity list shows the first line of each message, repository errors are cut at 160 characters in the list (full text in the detail view). From f8c191e9a09a54166c44b5c48bbcacf1db17f9a0 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:45:31 +0100 Subject: [PATCH 07/19] fix(gui): single-instance socket never evicts a live instance and lives in a private dir Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-gui/src/instance.rs | 100 +++++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 12 deletions(-) diff --git a/crates/grove-gui/src/instance.rs b/crates/grove-gui/src/instance.rs index d3a45c5..eec1aa4 100644 --- a/crates/grove-gui/src/instance.rs +++ b/crates/grove-gui/src/instance.rs @@ -2,16 +2,47 @@ //! its window and exits. use std::io::{BufRead, BufReader, Write}; +use std::os::unix::fs::{DirBuilderExt, MetadataExt}; use std::os::unix::net::{UnixListener, UnixStream}; use std::path::{Path, PathBuf}; use std::time::Duration; -/// `$XDG_RUNTIME_DIR/grove/gui.sock` (same private directory as the daemon socket). +/// `$XDG_RUNTIME_DIR/grove/gui.sock` (same private directory as the daemon socket); without a +/// runtime dir, a private per-user directory under the temp dir. pub fn default_socket_path() -> PathBuf { - let base = std::env::var_os("XDG_RUNTIME_DIR") - .map(PathBuf::from) - .unwrap_or_else(std::env::temp_dir); - base.join("grove").join("gui.sock") + match std::env::var_os("XDG_RUNTIME_DIR") { + Some(base) => PathBuf::from(base).join("grove").join("gui.sock"), + None => std::env::temp_dir() + .join(format!("grove-gui-{}", own_uid())) + .join("gui.sock"), + } +} + +fn own_uid() -> u32 { + std::fs::metadata("/proc/self") + .map(|m| m.uid()) + .unwrap_or(0) +} + +/// Creates `dir` with mode 0700, or checks that an existing one is ours and not accessible to +/// others (a pre-created directory in a shared /tmp must not be trusted). +pub fn ensure_private_dir(dir: &Path) -> std::io::Result<()> { + if let Some(parent) = dir.parent() { + std::fs::create_dir_all(parent)?; + } + match std::fs::DirBuilder::new().mode(0o700).create(dir) { + Ok(()) => return Ok(()), + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {} + Err(e) => return Err(e), + } + let m = std::fs::symlink_metadata(dir)?; + if !m.is_dir() || m.uid() != own_uid() || m.mode() & 0o077 != 0 { + return Err(std::io::Error::other(format!( + "{} is not a private directory owned by you", + dir.display() + ))); + } + Ok(()) } pub enum Role { @@ -23,15 +54,30 @@ pub enum Role { /// Tries to hand over to a running instance; otherwise becomes the primary one. pub fn acquire(path: &Path, show: bool) -> std::io::Result { + acquire_with(path, show, Duration::from_secs(2)) +} + +pub fn acquire_with(path: &Path, show: bool, timeout: Duration) -> std::io::Result { if let Some(dir) = path.parent() { - std::fs::create_dir_all(dir)?; + ensure_private_dir(dir)?; } for _ in 0..3 { - if notify(path, if show { "show" } else { "ping" }).is_ok() { - return Ok(Role::Secondary); + match notify(path, if show { "show" } else { "ping" }, timeout) { + Ok(()) => return Ok(Role::Secondary), + // Nobody listens: a stale socket file from a crash is replaced. + Err(e) + if matches!( + e.kind(), + std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::NotFound + ) => + { + if e.kind() == std::io::ErrorKind::ConnectionRefused { + let _ = std::fs::remove_file(path); + } + } + // A live instance that does not answer in time is never evicted. + Err(e) => return Err(e), } - // Nobody answers: a stale socket from a crash is replaced. - let _ = std::fs::remove_file(path); match UnixListener::bind(path) { Ok(l) => return Ok(Role::Primary(l)), Err(e) if e.kind() == std::io::ErrorKind::AddrInUse => continue, @@ -41,9 +87,9 @@ pub fn acquire(path: &Path, show: bool) -> std::io::Result { Err(std::io::Error::other("cannot acquire the instance socket")) } -fn notify(path: &Path, msg: &str) -> std::io::Result<()> { +fn notify(path: &Path, msg: &str, timeout: Duration) -> std::io::Result<()> { let mut c = UnixStream::connect(path)?; - c.set_read_timeout(Some(Duration::from_secs(2)))?; + c.set_read_timeout(Some(timeout))?; writeln!(c, "{msg}")?; let mut line = String::new(); BufReader::new(c).read_line(&mut line)?; @@ -73,11 +119,13 @@ pub fn serve(listener: UnixListener, on_show: impl Fn() + Send + 'static) { #[cfg(test)] mod tests { use super::*; + use std::os::unix::fs::PermissionsExt; use std::sync::mpsc; fn tmp_sock(tag: &str) -> PathBuf { let d = std::env::temp_dir().join(format!("gg-{tag}-{}", std::process::id())); std::fs::create_dir_all(&d).unwrap(); + std::fs::set_permissions(&d, std::fs::Permissions::from_mode(0o700)).unwrap(); d.join("gui.sock") } @@ -97,6 +145,34 @@ mod tests { assert!(rx.recv_timeout(Duration::from_millis(200)).is_err()); } + #[test] + fn unresponsive_instance_is_not_evicted() { + let p = tmp_sock("busy"); + let l = UnixListener::bind(&p).unwrap(); + // Accepts but never answers (a primary stuck in startup). + let t = std::thread::spawn(move || { + let c = l.accept().unwrap(); + std::thread::sleep(Duration::from_millis(600)); + drop(c); + }); + let r = acquire_with(&p, true, Duration::from_millis(200)); + assert!(r.is_err(), "must not become primary"); + assert!(p.exists(), "socket file must stay"); + t.join().unwrap(); + } + + #[test] + fn private_dir_is_enforced() { + let base = std::env::temp_dir().join(format!("gg-priv-{}", std::process::id())); + let d = base.join("x"); + ensure_private_dir(&d).unwrap(); + assert_eq!(std::fs::metadata(&d).unwrap().mode() & 0o777, 0o700); + ensure_private_dir(&d).unwrap(); // idempotent + std::fs::set_permissions(&d, std::fs::Permissions::from_mode(0o755)).unwrap(); + assert!(ensure_private_dir(&d).is_err()); + let _ = std::fs::remove_dir_all(&base); + } + #[test] fn stale_socket_is_replaced() { let p = tmp_sock("stale"); From 82c89cad1ff6291e4b0817c67f319c9a4cc5e66a Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:45:31 +0100 Subject: [PATCH 08/19] feat(gui): opt-in start at login; deb ships the autostart file under /usr/share/grove and recommends libnotify-bin Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-gui/src/autostart.rs | 55 +++++++++++++++++++++++++++++++ crates/grove/Cargo.toml | 3 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 crates/grove-gui/src/autostart.rs diff --git a/crates/grove-gui/src/autostart.rs b/crates/grove-gui/src/autostart.rs new file mode 100644 index 0000000..94082a4 --- /dev/null +++ b/crates/grove-gui/src/autostart.rs @@ -0,0 +1,55 @@ +//! "Start at login": a copy of the autostart desktop file in `~/.config/autostart`. + +use std::path::{Path, PathBuf}; + +const DESKTOP: &str = include_str!("../../../contrib/grove-autostart.desktop"); + +/// `$XDG_CONFIG_HOME` or `~/.config`. +pub fn config_home() -> Option { + std::env::var_os("XDG_CONFIG_HOME") + .map(PathBuf::from) + .filter(|p| p.is_absolute()) + .or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config"))) +} + +pub fn file(config_home: &Path) -> PathBuf { + config_home.join("autostart").join("grove.desktop") +} + +pub fn is_enabled(config_home: &Path) -> bool { + file(config_home).exists() +} + +pub fn set(config_home: &Path, on: bool) -> std::io::Result<()> { + let f = file(config_home); + if on { + if let Some(d) = f.parent() { + std::fs::create_dir_all(d)?; + } + std::fs::write(&f, DESKTOP) + } else { + match std::fs::remove_file(&f) { + Err(e) if e.kind() != std::io::ErrorKind::NotFound => Err(e), + _ => Ok(()), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn toggle_writes_and_removes_the_desktop_file() { + let d = std::env::temp_dir().join(format!("gg-auto-{}", std::process::id())); + assert!(!is_enabled(&d)); + set(&d, true).unwrap(); + assert!(is_enabled(&d)); + let text = std::fs::read_to_string(file(&d)).unwrap(); + assert!(text.contains("Exec=grove-gui --hidden")); + set(&d, false).unwrap(); + assert!(!is_enabled(&d)); + set(&d, false).unwrap(); // already off: fine + let _ = std::fs::remove_dir_all(&d); + } +} diff --git a/crates/grove/Cargo.toml b/crates/grove/Cargo.toml index f2b86fb..924b107 100644 --- a/crates/grove/Cargo.toml +++ b/crates/grove/Cargo.toml @@ -19,13 +19,14 @@ toml = "1.2.1" name = "grove" section = "devel" depends = "$auto, git" +recommends = "libnotify-bin" extended-description = "Keeps chosen git repos continuously in sync across machines, including uncommitted work." assets = [ ["../../target/release/grove", "usr/bin/", "755"], ["../../target/release/groved", "usr/bin/", "755"], ["../../target/release/grove-gui", "usr/bin/", "755"], ["../../contrib/grove.desktop", "usr/share/applications/", "644"], - ["../../contrib/grove-autostart.desktop", "etc/xdg/autostart/grove.desktop", "644"], + ["../../contrib/grove-autostart.desktop", "usr/share/grove/grove-autostart.desktop", "644"], ["../../assets/grove.png", "usr/share/icons/hicolor/64x64/apps/grove.png", "644"], ["../../contrib/groved.deb.service", "usr/lib/systemd/user/groved.service", "644"], ] From e65bd5c24e635bc9f7b141f0186672f413e9baad Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:45:31 +0100 Subject: [PATCH 09/19] fix(gui): keep branch name while typing, per-worktree busy state, onboarding that survives init, stale resolve output, ahead/behinddirty as attention Also: reject unknown resolve modes, compute the UTC offset once, notify-send --, serve the instance socket before the window exists. Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-gui/src/main.rs | 252 ++++++++++++++++++++++++++++------ crates/grove-gui/src/model.rs | 48 ++++++- crates/grove-gui/ui/app.slint | 31 ++++- 3 files changed, 279 insertions(+), 52 deletions(-) diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs index ef1438d..6e50d6f 100644 --- a/crates/grove-gui/src/main.rs +++ b/crates/grove-gui/src/main.rs @@ -4,6 +4,7 @@ //! the worker on daemon events, the tray service, the single-instance listener, and short-lived //! threads for CLI calls. Nothing runs on a timer while the daemon is quiet. +mod autostart; mod bridge; mod instance; mod model; @@ -15,14 +16,14 @@ use model::{Aggregate, TrayState}; use serde_json::{Value, json}; use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel, Weak}; use std::cell::RefCell; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::io::{BufRead, BufReader, Write}; use std::os::unix::net::UnixStream; use std::path::PathBuf; use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender}; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex, OnceLock}; use std::time::{Duration, Instant}; use tray::Action; @@ -114,7 +115,11 @@ struct Ctx { /// UI-thread state. struct UiState { snap: Option, - outputs: HashMap, + outputs: HashMap, + inflight: HashSet, + busy_count: u32, + branch_names: HashMap, + detail_fp: String, filter: String, pending: Option>, picks: Rc>, @@ -127,6 +132,10 @@ thread_local! { static ST: RefCell = RefCell::new(UiState { snap: None, outputs: HashMap::new(), + inflight: HashSet::new(), + busy_count: 0, + branch_names: HashMap::new(), + detail_fp: String::new(), filter: String::new(), pending: None, picks: Rc::new(VecModel::default()), @@ -140,7 +149,13 @@ fn s(v: &Value, k: &str) -> String { v.get(k).and_then(Value::as_str).unwrap_or("").to_string() } +/// Local UTC offset, computed once (one `date` process for the whole run). fn utc_offset_s() -> i64 { + static OFFSET: OnceLock = OnceLock::new(); + *OFFSET.get_or_init(read_utc_offset) +} + +fn read_utc_offset() -> i64 { let out = std::process::Command::new("date").arg("+%z").output().ok(); let z = out .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) @@ -199,6 +214,7 @@ fn render(ui: &MainWindow) { ui.set_wt_count(agg.worktrees as i32); ui.set_attention_count(agg.attention as i32); ui.set_has_config(snap.config.is_some()); + ui.set_autostart(autostart::config_home().is_some_and(|d| autostart::is_enabled(&d))); let nm: Vec = snap .status .as_ref() @@ -212,6 +228,18 @@ fn render(ui: &MainWindow) { ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm)))); let empty = Vec::new(); + let mut states: HashMap = HashMap::new(); + for r in snap + .status + .as_ref() + .and_then(|s| s["repos"].as_array()) + .unwrap_or(&empty) + { + for w in r["worktrees"].as_array().unwrap_or(&empty) { + states.insert(s(w, "path"), model::state_name(&s(w, "state")).to_string()); + } + } + model::reconcile_outputs(&mut st.outputs, &states); let repos: Vec = snap .status .as_ref() @@ -230,10 +258,17 @@ fn render(ui: &MainWindow) { let (out, out_ok) = st .outputs .get(&path) - .map(|(ok, t)| (t.clone(), *ok)) + .map(|r| (r.text.clone(), r.ok)) .unwrap_or_default(); let branch = s(w, "branch"); + let bname = st + .branch_names + .get(&path) + .cloned() + .unwrap_or_else(|| format!("{branch}-local")); Wt { + bname: bname.into(), + busy: st.inflight.contains(&path), branch: if branch.is_empty() { "(detached)".into() } else { @@ -262,10 +297,30 @@ fn render(ui: &MainWindow) { .collect(); let selected = ui.get_selected_path().to_string(); + // The detail model is replaced only when something it shows changed: rebuilding it + // would reset the focus and text of the branch-name field every few seconds. if let Some(r) = repos.iter().find(|r| r.path == selected) { - ui.set_detail(r.clone()); + let fp = format!( + "{}|{}|{}|{}", + r.path, + r.error, + r.withheld, + r.wts + .iter() + .map(|w| format!( + "{}|{}|{}|{}|{}|{}|{}", + w.branch, w.path, w.state, w.out, w.out_ok, w.busy, w.bname + )) + .collect::>() + .join(";") + ); + if fp != st.detail_fp { + st.detail_fp = fp; + ui.set_detail(r.clone()); + } ui.set_detail_found(true); } else { + st.detail_fp.clear(); ui.set_detail_found(false); } // Long errors are cut in the list; the detail view shows them in full. @@ -381,15 +436,44 @@ fn show_window(ui: &MainWindow, core: &Core) { render(ui); } +/// Marks an operation as running: a global counter, and `key` (a worktree path) when it targets one. +fn busy_begin(ui: &MainWindow, key: Option<&str>) { + ST.with(|st| { + let mut st = st.borrow_mut(); + st.busy_count += 1; + if let Some(k) = key { + st.inflight.insert(k.to_string()); + } + }); + ui.set_busy(true); + if key.is_some() { + render(ui); + } +} + +fn busy_end(ui: &MainWindow, key: Option<&str>) { + let n = ST.with(|st| { + let mut st = st.borrow_mut(); + st.busy_count = st.busy_count.saturating_sub(1); + if let Some(k) = key { + st.inflight.remove(k); + } + st.busy_count + }); + ui.set_busy(n > 0); +} + /// Runs an allow-listed `grove` subcommand off the UI thread; `done` runs on the UI thread. +/// `key` is the worktree path the command acts on, if any. fn run_cli( ctx: &Ctx, ui: &MainWindow, + key: Option, args: Vec, stdin: String, done: impl FnOnce(&MainWindow, bool, String) + Send + 'static, ) { - ui.set_busy(true); + busy_begin(ui, key.as_deref()); let (core, weak) = (ctx.core.clone(), ctx.weak.clone()); std::thread::spawn(move || { let r = core.bridge.cli(&args, &stdin); @@ -397,7 +481,7 @@ fn run_cli( let text = r["output"].as_str().unwrap_or("").to_string(); let _ = slint::invoke_from_event_loop(move || { if let Some(ui) = weak.upgrade() { - ui.set_busy(false); + busy_end(&ui, key.as_deref()); done(&ui, ok, text); } }); @@ -419,6 +503,7 @@ fn scan(ctx: &Ctx, ui: &MainWindow, group: String) { run_cli( ctx, ui, + None, vec!["import".into(), group], String::new(), |ui, ok, text| { @@ -505,7 +590,7 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { args.push("--public".into()); } ui.set_new_out(out(true, String::new())); - run_cli(&c, &ui, args, String::new(), |ui, ok, text| { + run_cli(&c, &ui, None, args, String::new(), |ui, ok, text| { ui.set_new_out(out(ok, text)); if ok { toast(ui, "Repository created", false); @@ -550,7 +635,7 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { let mut args = vec!["import".to_string(), group.clone()]; args.extend(picked); let c2 = c.clone(); - run_cli(&c, &ui, args, String::new(), move |ui, ok, text| { + run_cli(&c, &ui, None, args, String::new(), move |ui, ok, text| { ui.set_import_out(out(ok, text)); if ok { scan(&c2, ui, group); @@ -563,6 +648,10 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { let w = ui.as_weak(); move |path, mode, branch| { let Some(ui) = w.upgrade() else { return }; + if ST.with(|st| st.borrow().inflight.contains(path.as_str())) { + toast(&ui, "A resolve is already running for this worktree", true); + return; + } let (flags, label): (Vec, String) = match mode.as_str() { "save" => { let b = branch.trim().to_string(); @@ -576,7 +665,11 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { ) } "remote" => (vec!["--take-remote".into()], "Discard your local commits and take the remote tip.".into()), - _ => (vec!["--keep-local".into()], "Overwrite the remote branch with your local commits.".into()), + "local" => (vec!["--keep-local".into()], "Overwrite the remote branch with your local commits.".into()), + other => { + toast(&ui, &format!("Unknown resolve action {other:?}"), true); + return; + } }; let mut args = vec!["resolve".to_string(), path.to_string()]; args.extend(flags); @@ -584,6 +677,26 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { ui.set_confirm_text(label.into()); } }); + ui.on_branch_edited(|path, text| { + ST.with(|st| { + st.borrow_mut() + .branch_names + .insert(path.to_string(), text.to_string()) + }); + }); + ui.on_set_autostart({ + let w = ui.as_weak(); + move |on| { + let Some(ui) = w.upgrade() else { return }; + let res = autostart::config_home() + .ok_or_else(|| std::io::Error::other("no config directory")) + .and_then(|d| autostart::set(&d, on)); + if let Err(e) = res { + toast(&ui, &format!("Cannot change autostart: {e}"), true); + } + ui.set_autostart(autostart::config_home().is_some_and(|d| autostart::is_enabled(&d))); + } + }); ui.on_confirm_cancel({ let w = ui.as_weak(); move || { @@ -602,10 +715,40 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { return; }; let path = args[1].clone(); - run_cli(&c, &ui, args, String::new(), move |ui, ok, text| { - ST.with(|st| st.borrow_mut().outputs.insert(path, (ok, text))); - render(ui); - }); + if ST.with(|st| st.borrow().inflight.contains(&path)) { + return; + } + let key = path.clone(); + run_cli( + &c, + &ui, + Some(key), + args, + String::new(), + move |ui, ok, text| { + let first = text.lines().next().unwrap_or("").to_string(); + ST.with(|st| { + st.borrow_mut().outputs.insert( + path, + model::OutRec { + ok, + text, + baseline: None, + }, + ) + }); + toast( + ui, + &if ok { + format!("Resolved. {first}") + } else { + format!("Resolve failed: {first}") + }, + !ok, + ); + render(ui); + }, + ); } }); @@ -619,7 +762,7 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { } else { args }; - run_cli(&c, &ui, args, String::new(), |ui, ok, text| { + run_cli(&c, &ui, None, args, String::new(), |ui, ok, text| { ui.set_settings_out(out(ok, text)) }); } @@ -632,6 +775,7 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { run_cli( &c, &ui, + None, vec!["login".into(), provider], format!("{token}\n"), |ui, ok, text| { @@ -668,27 +812,31 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { init.push(url.to_string()); } let token = format!("{token}\n"); - ui.set_busy(true); + // The onboarding view stays up until the whole flow succeeded, even though `init` + // makes the config appear half way. + ui.set_onboarding_active(true); + busy_begin(&ui, None); ui.set_onboard_out(out(true, String::new())); let (core, weak) = (c.core.clone(), c.weak.clone()); std::thread::spawn(move || { let mut steps: Vec<(Vec, String)> = Vec::new(); - // A previous attempt may already have written the config. + let mut lines: Vec = Vec::new(); if core.bridge.config_json().is_none() { steps.push((init, String::new())); + } else { + lines.push( + "config.toml already exists and is kept as it is: `grove init` is skipped, so the fields above are ignored. Edit the file by hand to change them." + .into(), + ); } steps.push((vec!["login".into(), provider.to_string()], token)); steps.push((vec!["bootstrap".into()], String::new())); - let mut lines: Vec = Vec::new(); - let mut all_ok = true; + let mut failure: Option = None; for (args, stdin) in steps { let r = core.bridge.cli(&args, &stdin); let ok = r["ok"] == true; - lines.push(format!( - "$ grove {}\n{}", - args[0], - r["output"].as_str().unwrap_or("") - )); + let output = r["output"].as_str().unwrap_or("").to_string(); + lines.push(format!("$ grove {}\n{}", args[0], output)); let text = lines.join("\n\n"); let w = weak.clone(); let _ = slint::invoke_from_event_loop(move || { @@ -697,16 +845,24 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { } }); if !ok { - all_ok = false; + failure = Some(format!( + "`grove {}` failed: {}", + args[0], + output.lines().last().unwrap_or("see the output below") + )); break; } } let _ = slint::invoke_from_event_loop(move || { if let Some(ui) = weak.upgrade() { - ui.set_busy(false); - if all_ok { - toast(&ui, "All set", false); - ui.set_view("repos".into()); + busy_end(&ui, None); + match failure { + None => { + ui.set_onboarding_active(false); + toast(&ui, "All set", false); + ui.set_view("repos".into()); + } + Some(msg) => toast(&ui, &format!("Setup failed: {msg}"), true), } } }); @@ -781,7 +937,7 @@ fn worker( if !visible { for (t, b) in &alerts { let _ = std::process::Command::new("notify-send") - .args(["-a", "Grove", "-i", "grove", t, b]) + .args(["-a", "Grove", "-i", "grove", "--", t, b]) .spawn() .map(|mut c| std::thread::spawn(move || c.wait())); } @@ -885,6 +1041,26 @@ fn main() -> Result<()> { instance::Role::Primary(l) => l, }; + // Answer other launches right away; the window handle arrives later. + let late: Arc>> = Arc::new(Mutex::new(None)); + let pending_show = Arc::new(AtomicBool::new(false)); + { + let (late, pending) = (late.clone(), pending_show.clone()); + std::thread::spawn(move || { + instance::serve(listener, move || match late.lock().unwrap().clone() { + Some(c) => { + let _ = slint::invoke_from_event_loop(move || { + if let Some(ui) = c.weak.upgrade() { + show_window(&ui, &c.core); + } + }); + } + None => pending.store(true, Ordering::SeqCst), + }) + }); + } + let _ = utc_offset_s(); // one `date` call, before the UI runs + let bridge = Bridge { grove_bin: arg("--grove-bin") .map(PathBuf::from) @@ -972,21 +1148,9 @@ fn main() -> Result<()> { let c = core.clone(); std::thread::spawn(move || subscriber(c)); } - { - let c = ctx.clone(); - std::thread::spawn(move || { - instance::serve(listener, move || { - let c = c.clone(); - let _ = slint::invoke_from_event_loop(move || { - if let Some(ui) = c.weak.upgrade() { - show_window(&ui, &c.core); - } - }); - }) - }); - } + *late.lock().unwrap() = Some(ctx.clone()); - if !hidden || !core.tray_ok.load(Ordering::SeqCst) { + if !hidden || pending_show.load(Ordering::SeqCst) || !core.tray_ok.load(Ordering::SeqCst) { show_window(&ui, &core); } else { core.wake(); diff --git a/crates/grove-gui/src/model.rs b/crates/grove-gui/src/model.rs index deca4ea..06aa761 100644 --- a/crates/grove-gui/src/model.rs +++ b/crates/grove-gui/src/model.rs @@ -1,6 +1,7 @@ //! UI-independent logic: daemon status -> aggregate state, formatting, CLI output parsing. use serde_json::Value; +use std::collections::HashMap; /// What the tray icon and the status pill show. #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] @@ -84,7 +85,8 @@ pub fn aggregate(status: Option<&Value>) -> Aggregate { for w in wts { total += 1; match state_name(str_of(w, "state")) { - "diverged" | "error" => attention += 1, + // These need the user: nothing automatic will fix them. + "diverged" | "error" | "ahead" | "behinddirty" => attention += 1, "synced" => {} _ => dirty += 1, } @@ -112,6 +114,29 @@ pub fn aggregate(status: Option<&Value>) -> Aggregate { } } +/// Output of a CLI run shown under a worktree. It is dropped when the worktree's state changes +/// after the first render that followed the run. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct OutRec { + pub ok: bool, + pub text: String, + pub baseline: Option, +} + +/// `states`: worktree path -> current state key. +pub fn reconcile_outputs(outputs: &mut HashMap, states: &HashMap) { + outputs.retain(|path, rec| match states.get(path) { + None => true, + Some(now) => match &rec.baseline { + None => { + rec.baseline = Some(now.clone()); + true + } + Some(b) => b == now, + }, + }); +} + /// Colour key of an activity event kind. pub fn log_tone(kind: &str) -> &'static str { match kind { @@ -380,6 +405,27 @@ mod tests { assert!(parse_import_listing("nothing to import").is_empty()); } + #[test] + fn outputs_are_dropped_when_the_state_changes() { + let rec = |t: &str| OutRec { + ok: true, + text: t.into(), + baseline: None, + }; + let mut o = HashMap::from([ + ("/a".to_string(), rec("x")), + ("/gone".to_string(), rec("y")), + ]); + let st = |s: &str| HashMap::from([("/a".to_string(), s.to_string())]); + reconcile_outputs(&mut o, &st("diverged")); // first render sets the baseline + assert_eq!(o["/a"].baseline.as_deref(), Some("diverged")); + reconcile_outputs(&mut o, &st("diverged")); + assert!(o.contains_key("/a")); + reconcile_outputs(&mut o, &st("synced")); // state changed + assert!(!o.contains_key("/a")); + assert!(o.contains_key("/gone"), "unknown paths are kept"); + } + #[test] fn log_tones() { assert_eq!(log_tone("snapshots_withheld"), "warn"); diff --git a/crates/grove-gui/ui/app.slint b/crates/grove-gui/ui/app.slint index 4dc00b7..c3b4b54 100644 --- a/crates/grove-gui/ui/app.slint +++ b/crates/grove-gui/ui/app.slint @@ -8,6 +8,8 @@ export struct Wt { plan: string, out: string, out-ok: bool, + bname: string, + busy: bool, } export struct Repo { @@ -186,6 +188,8 @@ export component MainWindow inherits Window { in property <[Pick]> picks; in property import-note; in property busy; + in-out property onboarding-active: false; + in property autostart; in property toast-text; in property toast-bad; in property confirm-text; @@ -214,6 +218,8 @@ export component MainWindow inherits Window { callback login(string, string); callback onboard(string, string, string, string, string, string, string, string); callback view-changed(string); + callback branch-edited(string, string); + callback set-autostart(bool); function go(v: string) { root.view = v; @@ -568,7 +574,6 @@ export component MainWindow inherits Window { if w.state == "diverged": diverged := VerticalLayout { spacing: 8px; alignment: start; - property branch-name: w.branch + "-local"; Text { text: "Diverged: " + w.branch + " has commits here and on the remote"; font-weight: 700; @@ -589,18 +594,19 @@ export component MainWindow inherits Window { spacing: 8px; Button { text: "Save mine as a branch"; + enabled: !w.busy; clicked => { - root.resolve(w.path, "save", diverged.branch-name); + root.resolve(w.path, "save", bn.text); } } - LineEdit { + bn := LineEdit { horizontal-stretch: 1; - text: diverged.branch-name; + text: w.bname; placeholder-text: "branch name"; accessible-label: "New branch name"; edited(t) => { - diverged.branch-name = t; + root.branch-edited(w.path, t); } } } @@ -610,6 +616,7 @@ export component MainWindow inherits Window { alignment: start; Button { text: "Take remote"; + enabled: !w.busy; clicked => { root.resolve(w.path, "remote", ""); } @@ -617,6 +624,7 @@ export component MainWindow inherits Window { Button { text: "Keep mine (overwrite remote)"; + enabled: !w.busy; clicked => { root.resolve(w.path, "local", ""); } @@ -828,7 +836,7 @@ export component MainWindow inherits Window { } // ---------- settings ---------- - if root.view == "settings" && root.has-config: VerticalLayout { + if root.view == "settings" && root.has-config && !root.onboarding-active: VerticalLayout { spacing: 12px; alignment: start; H1 { @@ -926,6 +934,14 @@ export component MainWindow inherits Window { } } + CheckBox { + text: "Start Grove at login (tray only)"; + checked: root.autostart; + toggled => { + root.set-autostart(self.checked); + } + } + Text { text: "Encrypted files (.env)"; font-size: 16px; @@ -966,7 +982,7 @@ export component MainWindow inherits Window { } // ---------- onboarding ---------- - if root.view == "settings" && !root.has-config: VerticalLayout { + if root.view == "settings" && (!root.has-config || root.onboarding-active): VerticalLayout { spacing: 12px; alignment: start; H1 { @@ -1114,6 +1130,7 @@ export component MainWindow inherits Window { Button { text: "Continue"; primary: true; + enabled: !root.busy; clicked => { root.confirm-accept(); } From 7ccc8a497a9fb5042b969e8f49c1d17f52831ab3 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:45:31 +0100 Subject: [PATCH 10/19] docs: phase 7 autostart and onboarding notes, annotate Tauri line in phase 5 Co-Authored-By: Claude Sonnet 5.5 --- docs/phase5.md | 2 +- docs/phase7.md | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/phase5.md b/docs/phase5.md index 2b5f89d..5f494c1 100644 --- a/docs/phase5.md +++ b/docs/phase5.md @@ -20,7 +20,7 @@ ## Not done - AppImage (no `appimagetool`) and Flatpak: not attempted. The Tauri bundle config requests `deb` and - `appimage`, untested. + `appimage`, untested (Tauri was removed in [Phase 7](phase7.md); the `.deb` now ships `grove-gui`). - Daemon-side mirroring fallback for GitHub (GitHub has no push mirrors; `configure_mirror` returns `Unsupported`). - Syncing agent sessions (optional item in the plan): not implemented. - A real two-PC run, a real cross-forge mirror, Secret Service on a desktop, github.com: unverified. diff --git a/docs/phase7.md b/docs/phase7.md index f6fcf86..f508e2e 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -21,7 +21,7 @@ every event (reconnects every 5 s while the daemon is down); the tray service; t listener; short-lived threads for CLI calls so the UI never blocks. Fallback poll: 5 s with the window open, 30 s hidden. No Slint timers run while idle. -Tray states: ok, syncing, attention (also sets the item to `NeedsAttention`), paused, daemon offline. +Tray states: ok, syncing, attention (diverged, error, `ahead`, `behinddirty`; also sets the item to `NeedsAttention`), paused, daemon offline. Menu: Open, Sync now, Pause/Resume, Quit; left click opens the window. Closing the window hides it; Quit exits. If no StatusNotifier host exists, closing the window quits. A transition into `Diverged`/`Error` shows a toast when the window is open and calls `notify-send` (best effort) when hidden. @@ -49,8 +49,9 @@ grove-gui --view settings # start on a view (activity, new, im ``` `grove` is looked up next to the `grove-gui` binary, then in `PATH`. Packaging: `.deb` installs -`grove-gui`, `contrib/grove.desktop`, `contrib/grove-autostart.desktop` (`/etc/xdg/autostart`) and -`assets/grove.png`. Dev builds need no system Qt: Slint is built with the `winit` backend (Wayland and +`grove-gui`, `contrib/grove.desktop`, `assets/grove.png` and a copy of the autostart file under +`/usr/share/grove/`. Autostart is opt-in: Settings has a "Start Grove at login" toggle that writes or +removes `~/.config/autostart/grove.desktop`. The deb recommends `libnotify-bin` (`notify-send`). Dev builds need no system Qt: Slint is built with the `winit` backend (Wayland and X11 loaded at runtime) and the software renderer. ## Dependencies @@ -74,6 +75,8 @@ Idle CPU hidden: 0 ticks in 20 s. 9 threads. - Slint does not expose xdg-activation, so launching again (or clicking the tray) on a visible window re-maps it (hide + show); the compositor focuses the fresh window (checked on KWin: keyboard focus arrives). The compositor picks the window position again. - Activity timestamps use the local UTC offset read via `date +%z` (no timezone crate). +- Onboarding stays on screen until login and bootstrap succeed. If a config already exists it is kept and `grove init` is skipped (the form fields are then ignored, the output says so). +- Resolve output under a worktree disappears once that worktree's state changes after the run; a toast reports the result. - The activity list shows the first line of each message, repository errors are cut at 160 characters in the list (full text in the detail view). - Slint's wrapped text under-reports its height in layouts, so long text is elided, not wrapped. From 5aeb7b2077ba8e3744114ad09708e6faa26cabe6 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:54:57 +0100 Subject: [PATCH 11/19] perf(gui): cut hidden CPU with a busy daemon Coalesce daemon events to one status refresh per 10 s while hidden (1 s visible), skip log/config reads and the UI-thread hand-off while hidden, and render tray pixmaps once per state. Co-Authored-By: Claude Sonnet 5.5 --- 24380 | 1 + crates/grove-gui/src/main.rs | 42 ++++++++++++++++++++---------------- crates/grove-gui/src/tray.rs | 8 +++++-- docs/phase7.md | 8 +++++-- 4 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 24380 diff --git a/24380 b/24380 new file mode 100644 index 0000000..9b3f20d --- /dev/null +++ b/24380 @@ -0,0 +1 @@ +ticks30s 14 rss 24344 - diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs index 6e50d6f..c695608 100644 --- a/crates/grove-gui/src/main.rs +++ b/crates/grove-gui/src/main.rs @@ -32,7 +32,10 @@ slint::include_modules!(); /// Fallback poll interval; daemon events wake the worker earlier. const POLL_VISIBLE: Duration = Duration::from_secs(5); const POLL_HIDDEN: Duration = Duration::from_secs(30); -const MIN_GAP: Duration = Duration::from_millis(500); +/// Minimum time between two daemon refreshes: events arrive in bursts, and hidden there is +/// nobody to look at the result (the tray only changes when the aggregate does). +const MIN_GAP_VISIBLE: Duration = Duration::from_secs(1); +const MIN_GAP_HIDDEN: Duration = Duration::from_secs(10); const RECONNECT: Duration = Duration::from_secs(5); /// Everything the UI shows, taken from one refresh. @@ -882,7 +885,7 @@ fn worker( ) { let mut last_states: HashMap = HashMap::new(); let mut last_agg: Option = None; - let mut last_run = Instant::now() - MIN_GAP; + let mut last_run = Instant::now() - MIN_GAP_HIDDEN; loop { let interval = if core.visible.load(Ordering::SeqCst) { POLL_VISIBLE @@ -893,17 +896,29 @@ fn worker( Ok(_) | Err(RecvTimeoutError::Timeout) => {} Err(RecvTimeoutError::Disconnected) => return, } - // Coalesce bursts of events. - let gap = last_run.elapsed(); - if gap < MIN_GAP { - std::thread::sleep(MIN_GAP - gap); + // Coalesce bursts of events; opening the window shortens the wait. + loop { + let gap = if core.visible.load(Ordering::SeqCst) { + MIN_GAP_VISIBLE + } else { + MIN_GAP_HIDDEN + }; + let el = last_run.elapsed(); + if el >= gap { + break; + } + match rx.recv_timeout(gap - el) { + Ok(()) => {} + Err(RecvTimeoutError::Timeout) => break, + Err(RecvTimeoutError::Disconnected) => return, + } } while rx.try_recv().is_ok() {} last_run = Instant::now(); let visible = core.visible.load(Ordering::SeqCst); - let st = core.bridge.ipc(&json!({"v": 1, "cmd": "status"})); - let status = (st["ok"] == true).then(|| st["data"].clone()); + let mut st = core.bridge.ipc(&json!({"v": 1, "cmd": "status"})); + let status = (st["ok"] == true).then(|| st["data"].take()); let agg = model::aggregate(status.as_ref()); core.paused .store(agg.state == TrayState::Paused, Ordering::SeqCst); @@ -975,17 +990,6 @@ fn worker( render(&ui); } }); - } else { - // Keep the last status for the moment the window opens; drop the heavy parts. - let snap = Snapshot { - status, - log: Vec::new(), - config: core.bridge.config_json(), - alerts: Vec::new(), - }; - let _ = slint::invoke_from_event_loop(move || { - ST.with(|st| st.borrow_mut().snap = Some(snap)) - }); } } } diff --git a/crates/grove-gui/src/tray.rs b/crates/grove-gui/src/tray.rs index d493654..e300dd8 100644 --- a/crates/grove-gui/src/tray.rs +++ b/crates/grove-gui/src/tray.rs @@ -5,7 +5,7 @@ use crate::model::{Aggregate, TrayState}; use ksni::blocking::{Handle, TrayMethods}; use ksni::menu::StandardItem; use ksni::{Icon, MenuItem, Status, ToolTip}; -use std::sync::Arc; +use std::sync::{Arc, OnceLock}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Action { @@ -188,8 +188,12 @@ pub fn render(s: TrayState, size: u32) -> Icon { } } +/// Rendered once per state: the tray asks for the pixmaps on every property read. fn icons(s: TrayState) -> Vec { - vec![render(s, 22), render(s, 32), render(s, 64)] + static CACHE: [OnceLock>; 5] = [const { OnceLock::new() }; 5]; + CACHE[s as usize] + .get_or_init(|| vec![render(s, 22), render(s, 32), render(s, 64)]) + .clone() } #[cfg(test)] diff --git a/docs/phase7.md b/docs/phase7.md index f508e2e..7b07447 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -19,7 +19,10 @@ Threads: the Slint event loop; a worker that fetches `status` (and `log`/config is visible); a subscriber that holds a `subscribe` connection to the daemon and wakes the worker on every event (reconnects every 5 s while the daemon is down); the tray service; the single-instance listener; short-lived threads for CLI calls so the UI never blocks. Fallback poll: 5 s with the -window open, 30 s hidden. No Slint timers run while idle. +window open, 30 s hidden. Daemon events are coalesced (at most one status refresh per 1 s visible, +10 s hidden). Hidden, the worker only asks for `status`: it drives the tray (touched only when the +aggregate changes; pixmaps are rendered once per state) and notifications, and nothing is sent to +the UI thread. Log, config and models are fetched when the window opens. No Slint timers run while idle. Tray states: ok, syncing, attention (diverged, error, `ahead`, `behinddirty`; also sets the item to `NeedsAttention`), paused, daemon offline. Menu: Open, Sync now, Pause/Resume, Quit; left click opens the window. Closing the window hides it; @@ -69,7 +72,8 @@ X11 loaded at runtime) and the software renderer. | Window open | 31 MB | 105 MB | | After closing the window (hidden again) | 25 MB | not measured | -Idle CPU hidden: 0 ticks in 20 s. 9 threads. +Hidden CPU against a busy daemon (8 repos, 5 s fetch interval, ~4 events/s): about 4 ticks in 60 s +(0.07%), RSS flat. 9 threads. ## Limits From 28e07aab56e1678fba01d7a839d543712731f5c8 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 18:09:34 +0100 Subject: [PATCH 12/19] feat: owner-scoped import listing, ssh protocol, robust import - providers: list_owner_repos (org/user endpoints), ssh_url, Send+Sync - import: parallel sides, case-insensitive/origin-based presence check, continue after failed clones and report them - config: per-provider protocol (https|ssh); GUI settings, onboarding - gui: import scan on its own thread, per-group cache, Rescan, failures Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-core/src/config.rs | 38 ++++ crates/grove-gui/src/bridge.rs | 1 + crates/grove-gui/src/main.rs | 104 +++++++---- crates/grove-gui/src/model.rs | 29 ++- crates/grove-gui/ui/app.slint | 25 ++- crates/grove-providers/src/gitea.rs | 39 ++-- crates/grove-providers/src/github.rs | 43 +++-- crates/grove-providers/src/http.rs | 20 ++ crates/grove-providers/src/lib.rs | 22 ++- crates/grove-providers/src/token.rs | 1 + crates/grove-providers/tests/api.rs | 74 ++++++++ crates/grove/src/main.rs | 10 + crates/grove/src/workflow.rs | 267 ++++++++++++++++++++++----- docs/phase7.md | 26 +++ 14 files changed, 580 insertions(+), 119 deletions(-) diff --git a/crates/grove-core/src/config.rs b/crates/grove-core/src/config.rs index 2f827b6..4f7a58b 100644 --- a/crates/grove-core/src/config.rs +++ b/crates/grove-core/src/config.rs @@ -37,9 +37,35 @@ pub enum ProviderKind { Github, } +/// How local git talks to a forge: HTTPS with the API token, or SSH with the user's keys. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum Protocol { + #[default] + Https, + Ssh, +} + +fn is_https(p: &Protocol) -> bool { + *p == Protocol::Https +} + +impl Protocol { + pub fn as_str(self) -> &'static str { + match self { + Protocol::Https => "https", + Protocol::Ssh => "ssh", + } + } +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Provider { pub kind: ProviderKind, + /// Transport for clone/fetch/push (`https` by default). Mirrors are server-side and always + /// use HTTPS. + #[serde(default, skip_serializing_if = "is_https")] + pub protocol: Protocol, #[serde(skip_serializing_if = "Option::is_none")] pub url: Option, } @@ -485,4 +511,16 @@ mirror_to = ["gitea"] let t = "[machine]\nname=\"a\"\n[root]\npath=\"/x\"\n[providers.p]\nkind=\"gitlab\"\n"; assert!(matches!(Config::parse(t), Err(ConfigError::Parse(_)))); } + + #[test] + fn provider_protocol_defaults_to_https_and_is_validated() { + let t = |p: &str| { + format!("[machine]\nname=\"a\"\n[root]\npath=\"/x\"\n[providers.p]\nkind=\"gitea\"\n{p}") + }; + assert_eq!(Config::parse(&t("")).unwrap().providers["p"].protocol, Protocol::Https); + let c = Config::parse(&t("protocol=\"ssh\"\n")).unwrap(); + assert_eq!(c.providers["p"].protocol, Protocol::Ssh); + assert!(toml::to_string(&c).unwrap().contains("protocol = \"ssh\"")); + assert!(Config::parse(&t("protocol=\"git\"\n")).is_err()); + } } diff --git a/crates/grove-gui/src/bridge.rs b/crates/grove-gui/src/bridge.rs index 6d2b73c..dc32f9b 100644 --- a/crates/grove-gui/src/bridge.rs +++ b/crates/grove-gui/src/bridge.rs @@ -97,6 +97,7 @@ fn flag_spec(sub: &str) -> (&'static [&'static str], &'static [&'static str]) { "--root", "--provider", "--kind", + "--protocol", "--group", "--config-repo", "--url", diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs index c695608..e1e1e26 100644 --- a/crates/grove-gui/src/main.rs +++ b/crates/grove-gui/src/main.rs @@ -126,6 +126,10 @@ struct UiState { filter: String, pending: Option>, picks: Rc>, + /// Last successful scan per import group, for the session (names still to import). + import_cache: HashMap>, + /// The group whose scan the list on screen belongs to. + import_current: String, toast_gen: u32, last_groups: Vec, last_providers: Vec, @@ -142,6 +146,8 @@ thread_local! { filter: String::new(), pending: None, picks: Rc::new(VecModel::default()), + import_cache: HashMap::new(), + import_current: String::new(), toast_gen: 0, last_groups: Vec::new(), last_providers: Vec::new(), @@ -499,41 +505,67 @@ fn out(ok: bool, text: String) -> Out { } } -fn scan(ctx: &Ctx, ui: &MainWindow, group: String) { - ui.set_import_note("Scanning…".into()); +fn show_picks(ui: &MainWindow, names: Vec, note: Option) { + let empty = names.is_empty(); + ST.with(|st| { + st.borrow().picks.set_vec( + names + .into_iter() + .map(|n| Pick { + name: n.into(), + checked: false, + }) + .collect::>(), + ) + }); + ui.set_import_scanned(true); + ui.set_import_note(match note { + Some(n) => n.into(), + None if empty => { + "Nothing to import: every remote repository is already on this machine.".into() + } + None => "".into(), + }); +} + +/// Lists the group's remote repos still to import. The scan runs on its own thread (never queued +/// behind status polling) and its result is cached per group; `force` rescans. +fn scan(ctx: &Ctx, ui: &MainWindow, group: String, force: bool, note: Option) { + ST.with(|st| st.borrow_mut().import_current = group.clone()); ui.set_import_out(out(true, String::new())); + if !force && let Some(names) = ST.with(|st| st.borrow().import_cache.get(&group).cloned()) { + show_picks(ui, names, note); + return; + } + ui.set_import_scanning(true); + ui.set_import_note("Scanning…".into()); ST.with(|st| st.borrow().picks.set_vec(vec![])); - run_cli( - ctx, - ui, - None, - vec!["import".into(), group], - String::new(), - |ui, ok, text| { - ui.set_import_note("".into()); + let (core, weak) = (ctx.core.clone(), ctx.weak.clone()); + std::thread::spawn(move || { + let r = core.bridge.cli(&["import".to_string(), group.clone()], ""); + let ok = r["ok"] == true; + let text = r["output"].as_str().unwrap_or("").to_string(); + let _ = slint::invoke_from_event_loop(move || { + let Some(ui) = weak.upgrade() else { return }; + ui.set_import_scanning(false); if !ok { + ui.set_import_note("".into()); ui.set_import_out(out(false, text)); return; } let names = model::parse_import_listing(&text); - if names.is_empty() { - ui.set_import_note( - "Nothing to import: every remote repository is already on this machine.".into(), - ); - } ST.with(|st| { - st.borrow().picks.set_vec( - names - .into_iter() - .map(|n| Pick { - name: n.into(), - checked: false, - }) - .collect::>(), - ) + st.borrow_mut() + .import_cache + .insert(group.clone(), names.clone()) }); - }, - ); + if ST.with(|st| st.borrow().import_current == group) { + show_picks(&ui, names, note); + } else { + ui.set_import_note("".into()); + } + }); + }); } fn first_or(v: &str, list: &ModelRc) -> String { @@ -604,10 +636,10 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { ui.on_scan_import({ let c = ctx.clone(); - move |group| { + move |group, force| { let Some(ui) = c.weak.upgrade() else { return }; let group = model::group_name(&first_or(group.as_str(), &ui.get_groups())).to_string(); - scan(&c, &ui, group); + scan(&c, &ui, group, force, None); } }); ui.on_pick_toggled(|i, checked| { @@ -639,10 +671,14 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { args.extend(picked); let c2 = c.clone(); run_cli(&c, &ui, None, args, String::new(), move |ui, ok, text| { - ui.set_import_out(out(ok, text)); - if ok { - scan(&c2, ui, group); - } + ui.set_import_out(out(ok, text.clone())); + // Rescan either way: what was cloned must leave the list. + let failed = model::parse_import_failures(&text); + let note = (!failed.is_empty()).then(|| { + toast(ui, &format!("{} import(s) failed", failed.len()), true); + format!("Failed to import: {}", failed.join(", ")) + }); + scan(&c2, ui, group, true, note); }); } }); @@ -790,7 +826,7 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { ui.on_onboard({ let c = ctx.clone(); - move |machine, root, kind, provider, url, group, crepo, token| { + move |machine, root, kind, protocol, provider, url, group, crepo, token| { let Some(ui) = c.weak.upgrade() else { return }; let mut init: Vec = [ "init", @@ -802,6 +838,8 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { &provider, "--kind", &kind, + "--protocol", + &protocol, "--group", &group, "--config-repo", diff --git a/crates/grove-gui/src/model.rs b/crates/grove-gui/src/model.rs index 06aa761..6384c31 100644 --- a/crates/grove-gui/src/model.rs +++ b/crates/grove-gui/src/model.rs @@ -196,6 +196,15 @@ pub fn parse_import_listing(output: &str) -> Vec { names } +/// Repository names of the `FAILED : ` lines `grove import` prints per failed clone. +pub fn parse_import_failures(output: &str) -> Vec { + output + .lines() + .filter_map(|l| l.strip_prefix("FAILED ")) + .filter_map(|l| l.split_once(':').map(|(n, _)| n.trim().to_string())) + .collect() +} + fn names(v: Option<&Value>) -> Vec { v.and_then(Value::as_array) .map(|a| { @@ -288,7 +297,12 @@ pub fn settings_sections(cfg: &Value) -> Vec
{ } else { format!(" · {url}") }; - (id.clone(), format!("{}{url}", str_of(p, "kind"))) + // `protocol` is how git talks to the forge; https when the key is absent. + let proto = match str_of(p, "protocol") { + "" => "https", + p => p, + }; + (id.clone(), format!("{} · {proto}{url}", str_of(p, "kind"))) }) .collect() }) @@ -405,6 +419,13 @@ mod tests { assert!(parse_import_listing("nothing to import").is_empty()); } + #[test] + fn failed_imports_are_listed() { + let out = "imported a -> /x/a\nFAILED b: git clone failed: boom\nFAILED c: nope"; + assert_eq!(parse_import_failures(out), ["b", "c"]); + assert!(parse_import_failures("imported a").is_empty()); + } + #[test] fn outputs_are_dropped_when_the_state_changes() { let rec = |t: &str| OutRec { @@ -453,7 +474,7 @@ mod tests { fn settings_show_public_route_and_owners() { let cfg = json!({ "machine": {"name": "pca"}, "root": {"path": "/w"}, - "providers": {"gitea": {"kind": "gitea", "url": "https://g.example"}, "gh": {"kind": "github"}}, + "providers": {"gitea": {"kind": "gitea", "protocol": "ssh", "url": "https://g.example"}, "gh": {"kind": "github"}}, "groups": [{"name": "work", "primary": "gitea", "mirror_to": ["gh"], "owners": {"gitea": "Org", "gh": "org-gh"}, "snapshots": "none", @@ -468,8 +489,8 @@ mod tests { ("Snapshots (default)".into(), "private-only".into()) ); // Providers come out sorted by id. - assert_eq!(s[1].1[0].1, "github"); - assert_eq!(s[1].1[1].1, "gitea · https://g.example"); + assert_eq!(s[1].1[0].1, "github · https"); + assert_eq!(s[1].1[1].1, "gitea · ssh · https://g.example"); assert_eq!( s[2].1[0].1, "primary gitea · mirrors: gh · public: gh → gitea · snapshots: none · owners: gh=org-gh, gitea=Org · bare-worktrees" diff --git a/crates/grove-gui/ui/app.slint b/crates/grove-gui/ui/app.slint index c3b4b54..1ba09d2 100644 --- a/crates/grove-gui/ui/app.slint +++ b/crates/grove-gui/ui/app.slint @@ -187,6 +187,8 @@ export component MainWindow inherits Window { in property <[Section]> sections; in property <[Pick]> picks; in property import-note; + in property import-scanning; + in property import-scanned; in property busy; in-out property onboarding-active: false; in property autostart; @@ -208,7 +210,7 @@ export component MainWindow inherits Window { callback toggle-pause(); callback filter-changed(string); callback create-repo(string, string, bool); - callback scan-import(string); + callback scan-import(string, bool); callback import-selected(string); callback pick-toggled(int, bool); callback resolve(string, string, string); @@ -216,7 +218,7 @@ export component MainWindow inherits Window { callback confirm-cancel(); callback run-settings(string); callback login(string, string); - callback onboard(string, string, string, string, string, string, string, string); + callback onboard(string, string, string, string, string, string, string, string, string); callback view-changed(string); callback branch-edited(string, string); callback set-autostart(bool); @@ -794,13 +796,16 @@ export component MainWindow inherits Window { imp-group := ComboBox { model: root.groups; width: 260px; + selected(g) => { + root.scan-import(g, false); + } } Button { - text: "Scan remote"; - enabled: !root.busy; + text: root.import-scanning ? "Scanning…" : (root.import-scanned ? "Rescan" : "Scan remote"); + enabled: !root.import-scanning; clicked => { - root.scan-import(imp-group.current-value); + root.scan-import(imp-group.current-value, true); } } } @@ -1015,6 +1020,14 @@ export component MainWindow inherits Window { model: ["gitea", "forgejo", "github"]; } + Muted { + text: "Git transport (ssh uses your SSH keys; https uses the API token)"; + } + + ob-protocol := ComboBox { + model: ["https", "ssh"]; + } + Muted { text: "Provider id"; } @@ -1063,7 +1076,7 @@ export component MainWindow inherits Window { primary: true; enabled: !root.busy && ob-token.text != ""; clicked => { - root.onboard(ob-machine.text, ob-root.text, ob-kind.current-value, ob-provider.text, ob-url.text, ob-group.text, ob-crepo.text, ob-token.text); + root.onboard(ob-machine.text, ob-root.text, ob-kind.current-value, ob-protocol.current-value, ob-provider.text, ob-url.text, ob-group.text, ob-crepo.text, ob-token.text); ob-token.text = ""; } } diff --git a/crates/grove-providers/src/gitea.rs b/crates/grove-providers/src/gitea.rs index 8a70bda..c0a6d28 100644 --- a/crates/grove-providers/src/gitea.rs +++ b/crates/grove-providers/src/gitea.rs @@ -30,6 +30,7 @@ fn repo(v: &Value) -> RemoteRepo { name: s("name"), private: v["private"].as_bool().unwrap_or(false), clone_url: s("clone_url"), + ssh_url: s("ssh_url"), default_branch: v["default_branch"].as_str().unwrap_or("main").to_string(), } } @@ -67,19 +68,33 @@ impl Provider for Gitea { } fn list_repos(&self) -> Result> { - let mut out = Vec::new(); - for page in 1..=200 { - let v = self + Ok(self + .http + .pages("/user/repos", 50, "limit")? + .iter() + .map(repo) + .collect()) + } + + fn list_owner_repos(&self, owner: &str, login: &str) -> Result> { + let path = if owner.eq_ignore_ascii_case(login) { + "/user/repos".to_string() + } else { + format!("/orgs/{owner}/repos") + }; + let items = match self.http.pages(&path, 50, "limit") { + Ok(v) => v, + // Not an organisation: another user's public repos. + Err(Error::Api { status: 404, .. }) if !owner.eq_ignore_ascii_case(login) => self .http - .ok("GET", &format!("/user/repos?limit=50&page={page}"), None)?; - let items = v.as_array().cloned().unwrap_or_default(); - let n = items.len(); - out.extend(items.iter().map(repo)); - if n < 50 { - break; - } - } - Ok(out) + .pages(&format!("/users/{owner}/repos"), 50, "limit")?, + Err(e) => return Err(e), + }; + Ok(items + .iter() + .map(repo) + .filter(|r| r.owner.eq_ignore_ascii_case(owner)) + .collect()) } fn create_repo(&self, new: &NewRepo) -> Result { diff --git a/crates/grove-providers/src/github.rs b/crates/grove-providers/src/github.rs index 571691a..5e43edc 100644 --- a/crates/grove-providers/src/github.rs +++ b/crates/grove-providers/src/github.rs @@ -29,6 +29,7 @@ fn repo(v: &Value) -> RemoteRepo { name: v["name"].as_str().unwrap_or_default().to_string(), private: v["private"].as_bool().unwrap_or(false), clone_url: v["clone_url"].as_str().unwrap_or_default().to_string(), + ssh_url: v["ssh_url"].as_str().unwrap_or_default().to_string(), default_branch: v["default_branch"].as_str().unwrap_or("main").to_string(), } } @@ -74,21 +75,33 @@ impl Provider for GitHub { } fn list_repos(&self) -> Result> { - let mut out = Vec::new(); - for page in 1..=200 { - let v = self.http.ok( - "GET", - &format!("/user/repos?per_page=100&page={page}"), - None, - )?; - let items = v.as_array().cloned().unwrap_or_default(); - let n = items.len(); - out.extend(items.iter().map(repo)); - if n < 100 { - break; - } - } - Ok(out) + Ok(self + .http + .pages("/user/repos", 100, "per_page")? + .iter() + .map(repo) + .collect()) + } + + fn list_owner_repos(&self, owner: &str, login: &str) -> Result> { + let path = if owner.eq_ignore_ascii_case(login) { + "/user/repos?affiliation=owner".to_string() + } else { + format!("/orgs/{owner}/repos?type=all") + }; + let items = match self.http.pages(&path, 100, "per_page") { + Ok(v) => v, + // Not an organisation: another user's public repos. + Err(Error::Api { status: 404, .. }) if !owner.eq_ignore_ascii_case(login) => self + .http + .pages(&format!("/users/{owner}/repos"), 100, "per_page")?, + Err(e) => return Err(e), + }; + Ok(items + .iter() + .map(repo) + .filter(|r| r.owner.eq_ignore_ascii_case(owner)) + .collect()) } fn create_repo(&self, new: &NewRepo) -> Result { diff --git a/crates/grove-providers/src/http.rs b/crates/grove-providers/src/http.rs index 050f63d..909c468 100644 --- a/crates/grove-providers/src/http.rs +++ b/crates/grove-providers/src/http.rs @@ -60,4 +60,24 @@ impl Http { .to_string(); Err(Error::Api { status, message }) } + + /// Every item of a paginated list endpoint (`path` may already carry a query string). + pub fn pages(&self, path: &str, per_page: usize, size_param: &str) -> Result> { + let sep = if path.contains('?') { '&' } else { '?' }; + let mut out = Vec::new(); + for page in 1..=200 { + let v = self.ok( + "GET", + &format!("{path}{sep}{size_param}={per_page}&page={page}"), + None, + )?; + let items = v.as_array().cloned().unwrap_or_default(); + let n = items.len(); + out.extend(items); + if n < per_page { + break; + } + } + Ok(out) + } } diff --git a/crates/grove-providers/src/lib.rs b/crates/grove-providers/src/lib.rs index d5d1fe4..df84a88 100644 --- a/crates/grove-providers/src/lib.rs +++ b/crates/grove-providers/src/lib.rs @@ -53,9 +53,26 @@ pub struct RemoteRepo { pub name: String, pub private: bool, pub clone_url: String, + /// SSH clone URL (empty when the forge did not report one). + pub ssh_url: String, pub default_branch: String, } +impl RemoteRepo { + /// The URL local git should use for `protocol`. + pub fn git_url(&self, protocol: grove_core::config::Protocol) -> Result<&str> { + use grove_core::config::Protocol; + match protocol { + Protocol::Https => Ok(&self.clone_url), + Protocol::Ssh if self.ssh_url.is_empty() => Err(Error::Other(format!( + "the forge reported no SSH URL for {}/{}", + self.owner, self.name + ))), + Protocol::Ssh => Ok(&self.ssh_url), + } + } +} + #[derive(Debug, Clone)] pub struct NewRepo { pub name: String, @@ -99,7 +116,7 @@ pub struct PullMirrorSpec { pub interval: String, } -pub trait Provider { +pub trait Provider: Send + Sync { fn kind(&self) -> ProviderKind; fn capabilities(&self) -> Capabilities; /// Verifies the token and returns the authenticated login. @@ -107,6 +124,9 @@ pub trait Provider { /// One repo's metadata (notably its visibility): `GET /repos/{owner}/{repo}`. fn get_repo(&self, owner: &str, name: &str) -> Result; fn list_repos(&self) -> Result>; + /// The repos owned by `owner` (an organisation, or the authenticated user `login`), without + /// paging through everything else the token can see. + fn list_owner_repos(&self, owner: &str, login: &str) -> Result>; fn create_repo(&self, new: &NewRepo) -> Result; fn configure_mirror(&self, owner: &str, repo: &str, spec: &MirrorSpec) -> Result<()>; /// Creates a pull mirror (see [`Capabilities::pull_mirror`]). diff --git a/crates/grove-providers/src/token.rs b/crates/grove-providers/src/token.rs index de7ccc2..65b1072 100644 --- a/crates/grove-providers/src/token.rs +++ b/crates/grove-providers/src/token.rs @@ -161,6 +161,7 @@ mod tests { let h = |kind, url: &str| { host(&ProviderCfg { kind, + protocol: Default::default(), url: Some(url.into()), }) }; diff --git a/crates/grove-providers/tests/api.rs b/crates/grove-providers/tests/api.rs index 9d1847e..467cbf1 100644 --- a/crates/grove-providers/tests/api.rs +++ b/crates/grove-providers/tests/api.rs @@ -301,10 +301,12 @@ fn falls_back_to_tea_and_gh_logins() { let off = EnvGuard::set("GROVE_NO_CLI_TOKENS", "0"); let gitea = |url: &str| ProviderCfg { kind: ProviderKind::Gitea, + protocol: Default::default(), url: Some(url.into()), }; let github = ProviderCfg { kind: ProviderKind::Github, + protocol: Default::default(), url: None, }; let id = format!("clitok-{}", std::process::id()); @@ -368,3 +370,75 @@ fn get_repo_reports_visibility_on_both_forges() { .private ); } + +const REPO_A: &str = r#"{"name":"a","private":false,"clone_url":"https://h/o/a.git","ssh_url":"git@h:o/a.git","default_branch":"main","owner":{"login":"Org"}}"#; +const REPO_B: &str = r#"{"name":"b","private":true,"clone_url":"https://h/me/b.git","ssh_url":"ssh://gitea@h:2222/me/b.git","default_branch":"main","owner":{"login":"me"}}"#; +const REPO_C: &str = r#"{"name":"c","private":true,"clone_url":"https://h/x/c.git","ssh_url":"","default_branch":"main","owner":{"login":"x"}}"#; + +fn lines(req: &str) -> &str { + req.lines().next().unwrap() +} + +#[test] +fn gitea_owner_listing_uses_the_org_endpoint_or_the_users_own() { + let org = format!("[{REPO_A}]"); + let user = format!("[{REPO_B},{REPO_C}]"); + let (url, rx) = mock(vec![ + (200, Box::leak(org.into_boxed_str())), + (200, Box::leak(user.into_boxed_str())), + ]); + let g = Gitea::new(ProviderKind::Gitea, &url, "t".into()); + let r = g.list_owner_repos("Org", "me").unwrap(); + assert_eq!(r.len(), 1); + assert_eq!(r[0].ssh_url, "git@h:o/a.git"); + assert!(lines(&rx.recv().unwrap()).starts_with("GET /api/v1/orgs/Org/repos?limit=50&page=1 ")); + // The login itself: `/user/repos`, then only its own repos (org repos it can see are dropped). + let r = g.list_owner_repos("ME", "me").unwrap(); + assert_eq!(r.iter().map(|r| r.name.as_str()).collect::>(), ["b"]); + assert!(lines(&rx.recv().unwrap()).starts_with("GET /api/v1/user/repos?limit=50&page=1 ")); +} + +#[test] +fn github_owner_listing_scopes_the_query_and_falls_back_for_users() { + let org = format!("[{REPO_A}]"); + let mine = format!("[{REPO_B}]"); + let (url, rx) = mock(vec![ + (200, Box::leak(org.into_boxed_str())), + (200, Box::leak(mine.into_boxed_str())), + (404, r#"{"message":"Not Found"}"#), + (200, "[]"), + ]); + let g = GitHub::new(&url, "t".into()); + assert_eq!(g.list_owner_repos("Org", "me").unwrap().len(), 1); + assert!( + lines(&rx.recv().unwrap()).starts_with("GET /orgs/Org/repos?type=all&per_page=100&page=1 ") + ); + assert_eq!(g.list_owner_repos("me", "me").unwrap().len(), 1); + assert!( + lines(&rx.recv().unwrap()) + .starts_with("GET /user/repos?affiliation=owner&per_page=100&page=1 ") + ); + // Not an organisation (404): the other user's public repos. + assert!(g.list_owner_repos("someone", "me").unwrap().is_empty()); + rx.recv().unwrap(); + assert!( + lines(&rx.recv().unwrap()).starts_with("GET /users/someone/repos?per_page=100&page=1 ") + ); +} + +#[test] +fn git_url_follows_the_protocol_and_needs_an_ssh_url_for_ssh() { + use grove_core::config::Protocol; + let (url, _rx) = mock(vec![( + 200, + Box::leak(format!("[{REPO_B},{REPO_C}]").into_boxed_str()), + )]); + let g = Gitea::new(ProviderKind::Gitea, &url, "t".into()); + let r = g.list_repos().unwrap(); + assert_eq!(r[0].git_url(Protocol::Https).unwrap(), "https://h/me/b.git"); + assert_eq!( + r[0].git_url(Protocol::Ssh).unwrap(), + "ssh://gitea@h:2222/me/b.git" + ); + assert!(r[1].git_url(Protocol::Ssh).is_err()); +} diff --git a/crates/grove/src/main.rs b/crates/grove/src/main.rs index ebea929..b07c152 100644 --- a/crates/grove/src/main.rs +++ b/crates/grove/src/main.rs @@ -88,6 +88,9 @@ enum Cmd { kind: String, #[arg(long)] url: Option, + /// How git talks to the forge: https (API token) or ssh (your keys) + #[arg(long, default_value = "https")] + protocol: String, #[arg(long, default_value = "default")] group: String, /// Name of the private config repo to keep the repo registry in @@ -359,10 +362,16 @@ fn main() -> Result<()> { provider, kind, url, + protocol, group, config_repo, force, } => { + let protocol = match protocol.as_str() { + "https" => grove_core::config::Protocol::Https, + "ssh" => grove_core::config::Protocol::Ssh, + p => bail!("unknown protocol {p:?} (https, ssh)"), + }; let path = cli .config .clone() @@ -390,6 +399,7 @@ fn main() -> Result<()> { provider: provider.clone(), kind, url: url.clone(), + protocol, group: group.clone(), config_repo: config_repo.clone(), }, diff --git a/crates/grove/src/workflow.rs b/crates/grove/src/workflow.rs index aee26b3..f729077 100644 --- a/crates/grove/src/workflow.rs +++ b/crates/grove/src/workflow.rs @@ -2,7 +2,7 @@ use anyhow::{Context, Result, bail}; use grove_core::config::{ - Config, Group, Layout, Machine, Provider as ProviderCfg, ProviderKind, Root, + Config, Group, Layout, Machine, Protocol, Provider as ProviderCfg, ProviderKind, Root, }; use grove_core::git::Git; use grove_core::registry::{Entry, Registry, clone_bare_layout, init_bare_layout, push_initial}; @@ -17,6 +17,7 @@ pub struct Forge { pub token: String, /// Git environment that authenticates HTTPS operations with the stored token. pub git_env: Vec<(String, String)>, + pub protocol: Protocol, } pub fn connect(cfg: &Config, id: &str) -> Result { @@ -27,38 +28,60 @@ pub fn connect(cfg: &Config, id: &str) -> Result { let (tok, _) = token::resolve(id, pc)?; let api = build(pc, tok.clone()); let login = api.test_connection()?; - let git_env = match pc.kind { - ProviderKind::Gitea | ProviderKind::Forgejo => vec![ - ("GIT_CONFIG_COUNT".into(), "1".into()), - ("GIT_CONFIG_KEY_0".into(), "http.extraHeader".into()), - ( - "GIT_CONFIG_VALUE_0".into(), - format!("Authorization: token {tok}"), - ), - ("GIT_TERMINAL_PROMPT".into(), "0".into()), - ], - // GitHub git-over-HTTPS takes the token as Basic auth (any user name works). - ProviderKind::Github => vec![ - ("GIT_CONFIG_COUNT".into(), "1".into()), - ("GIT_CONFIG_KEY_0".into(), "http.extraHeader".into()), - ( - "GIT_CONFIG_VALUE_0".into(), - format!( - "Authorization: Basic {}", - base64(&format!("x-access-token:{tok}")) + let git_env = if pc.protocol == Protocol::Ssh { + // The user's SSH keys/agent authenticate; never prompt. + ssh_env() + } else { + match pc.kind { + ProviderKind::Gitea | ProviderKind::Forgejo => vec![ + ("GIT_CONFIG_COUNT".into(), "1".into()), + ("GIT_CONFIG_KEY_0".into(), "http.extraHeader".into()), + ( + "GIT_CONFIG_VALUE_0".into(), + format!("Authorization: token {tok}"), ), - ), - ("GIT_TERMINAL_PROMPT".into(), "0".into()), - ], + ("GIT_TERMINAL_PROMPT".into(), "0".into()), + ], + // GitHub git-over-HTTPS takes the token as Basic auth (any user name works). + ProviderKind::Github => vec![ + ("GIT_CONFIG_COUNT".into(), "1".into()), + ("GIT_CONFIG_KEY_0".into(), "http.extraHeader".into()), + ( + "GIT_CONFIG_VALUE_0".into(), + format!( + "Authorization: Basic {}", + base64(&format!("x-access-token:{tok}")) + ), + ), + ("GIT_TERMINAL_PROMPT".into(), "0".into()), + ], + } }; Ok(Forge { api, login, token: tok, git_env, + protocol: pc.protocol, }) } +/// Git environment for SSH remotes: the user's keys/agent authenticate and nothing prompts. +/// `BatchMode` is only forced when the user has no ssh command of their own. +fn ssh_env() -> Vec<(String, String)> { + let mut env = vec![("GIT_TERMINAL_PROMPT".to_string(), "0".to_string())]; + let custom = std::env::var_os("GIT_SSH_COMMAND").is_some() + || std::env::var_os("GIT_SSH").is_some() + || std::process::Command::new("git") + .args(["config", "--get", "core.sshCommand"]) + .output() + .is_ok_and(|o| o.status.success() && !o.stdout.is_empty()); + if !custom { + env.push(("GIT_SSH_COMMAND".into(), "ssh -o BatchMode=yes".into())); + } + env +} + /// The group's owner on `provider`, or `None` when that is the authenticated user itself /// (personal repos use `/user/repos`, not the org endpoint). fn org_owner(grp: &Group, provider: &str, login: &str) -> Option { @@ -103,6 +126,7 @@ pub struct InitArgs { pub provider: String, pub kind: ProviderKind, pub url: Option, + pub protocol: Protocol, pub group: String, pub config_repo: Option, } @@ -119,6 +143,7 @@ pub fn init(path: &Path, a: InitArgs, force: bool) -> Result { a.provider.clone(), ProviderCfg { kind: a.kind, + protocol: a.protocol, url: a.url, }, ); @@ -179,7 +204,8 @@ pub fn new_repo(cfg: &Config, group_name: &str, name: &str, private: bool) -> Re "created {}/{} on {}", remote.owner, remote.name, route.primary ); - let wt = init_bare_layout(&dir, &remote.clone_url)?; + let local_url = remote.git_url(primary.protocol)?.to_string(); + let wt = init_bare_layout(&dir, &local_url)?; push_initial(&dir, &primary.git_env)?; println!("pushed initial commit; worktree {}", wt.display()); @@ -194,7 +220,7 @@ pub fn new_repo(cfg: &Config, group_name: &str, name: &str, private: bool) -> Re &Entry { group: grp.name.clone(), name: name.into(), - url: remote.clone_url, + url: local_url, }, )?; Ok(wt) @@ -256,6 +282,67 @@ fn select(repos: Vec, owner: &str, private: Option) -> Vec Option { + let rest = url.split_once("://").map_or(url, |(_, r)| r); + let rest = rest.rsplit_once('@').map_or(rest, |(_, r)| r); + let (host, path) = match rest.split_once(['/', ':']) { + Some((h, p)) => (h, p), + None => return None, + }; + // `host:2222/owner/repo` (ssh with a port): drop the port. + let path = match path.split_once('/') { + Some((port, p)) if !port.is_empty() && port.bytes().all(|b| b.is_ascii_digit()) => p, + _ => path, + }; + let path = path.trim_matches('/').trim_end_matches(".git"); + let mut parts = path.rsplitn(2, '/'); + let name = parts.next()?; + let owner = parts.next()?; + Some(format!("{host}/{owner}/{name}").to_lowercase()) +} + +/// What is already in a group directory: bare-layout repos by lowercase directory name and by +/// the owner/name their `origin` points to. +struct Local { + names: std::collections::HashSet, + origins: std::collections::HashSet, +} + +impl Local { + fn scan(gdir: &Path) -> Local { + let mut l = Local { + names: Default::default(), + origins: Default::default(), + }; + let Ok(rd) = fs::read_dir(gdir) else { return l }; + for e in rd.filter_map(Result::ok) { + let bare = e.path().join(".bare"); + if !bare.exists() { + continue; + } + l.names + .insert(e.file_name().to_string_lossy().to_lowercase()); + if let Ok(Some(url)) = Git::new(&bare).probe(&["config", "--get", "remote.origin.url"]) + && let Some(k) = remote_key(&url) + { + l.origins.insert(k); + } + } + l + } + + /// Present when a repo of that name exists (case-insensitively: forge names are, and so are + /// many file systems) or an existing repo's origin is this very remote. + fn has(&self, r: &RemoteRepo) -> bool { + self.names.contains(&r.name.to_lowercase()) + || [&r.clone_url, &r.ssh_url] + .iter() + .filter_map(|u| remote_key(u)) + .any(|k| self.origins.contains(&k)) + } +} + /// Lists the group's remote repos that are not on disk; clones the named ones. pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { let grp = group(cfg, group_name)?; @@ -268,14 +355,34 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { None => vec![(grp.primary.clone(), None)], }; let gdir = cfg.root_path().join(&grp.name); + // Both routes of a split group are queried at the same time. + let scanned: Vec)>> = std::thread::scope(|sc| { + let hs: Vec<_> = sides + .iter() + .map(|(pid, vis)| { + let grp = &grp; + sc.spawn(move || { + let f = connect(cfg, pid)?; + let owner = grp.owner(pid).unwrap_or(&f.login).to_string(); + let repos = select(f.api.list_owner_repos(&owner, &f.login)?, &owner, *vis); + Ok((pid.clone(), f, repos)) + }) + }) + .collect(); + hs.into_iter() + .map(|h| { + h.join() + .unwrap_or_else(|_| Err(anyhow::anyhow!("provider scan panicked"))) + }) + .collect() + }); let mut forges = Vec::new(); let mut missing: Vec<(RemoteRepo, usize)> = Vec::new(); - for (pid, vis) in sides { - let f = connect(cfg, &pid)?; - let owner = grp.owner(&pid).unwrap_or(&f.login).to_string(); - for r in select(f.api.list_repos()?, &owner, vis) { - let here = gdir.join(&r.name).join(".bare").exists(); - if !here && !missing.iter().any(|(m, _)| m.name == r.name) { + let local = Local::scan(&gdir); + for res in scanned { + let (pid, f, repos) = res?; + for r in repos { + if !local.has(&r) && !missing.iter().any(|(m, _)| m.name == r.name) { missing.push((r, forges.len())); } } @@ -295,22 +402,45 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { println!("run `grove import {group_name} ...` to clone them"); return Ok(()); } + // One broken repo must not stop the others: collect failures and report them at the end. + let mut failed: Vec = Vec::new(); for w in wanted { - let (r, i) = missing - .iter() - .find(|(r, _)| &r.name == w) - .with_context(|| format!("{w:?} is not a remote repo missing locally"))?; - let dir = gdir.join(&r.name); - clone_bare_layout(&r.clone_url, &dir, &forges[*i].1.git_env)?; - println!("imported {} -> {}", r.name, dir.display()); - register( - cfg, - &Entry { - group: grp.name.clone(), - name: r.name.clone(), - url: r.clone_url.clone(), - }, - )?; + let Some((r, i)) = missing.iter().find(|(r, _)| &r.name == w) else { + println!("FAILED {w}: not a remote repo missing locally"); + failed.push(w.clone()); + continue; + }; + let forge = &forges[*i].1; + let res = (|| -> Result<()> { + let url = r.git_url(forge.protocol)?.to_string(); + let dir = gdir.join(&r.name); + if let Err(e) = clone_bare_layout(&url, &dir, &forge.git_env) { + // Leave no empty directory behind (it only goes away when nothing was cloned). + let _ = fs::remove_dir(&dir); + return Err(e.into()); + } + println!("imported {} -> {}", r.name, dir.display()); + register( + cfg, + &Entry { + group: grp.name.clone(), + name: r.name.clone(), + url, + }, + ) + })(); + if let Err(e) = res { + println!("FAILED {w}: {e:#}"); + failed.push(w.clone()); + } + } + if !failed.is_empty() { + bail!( + "{} of {} imports failed: {}", + failed.len(), + wanted.len(), + failed.join(", ") + ); } Ok(()) } @@ -338,7 +468,7 @@ pub(crate) fn config_repo_open(cfg: &Config, create: bool) -> Result<(PathBuf, F .into_iter() .find(|r| r.name == cr.name); let url = match exists { - Some(r) => r.clone_url, + Some(r) => r.git_url(forge.protocol)?.to_string(), None if create => { let r = forge.api.create_repo(&NewRepo { name: cr.name.clone(), @@ -346,7 +476,7 @@ pub(crate) fn config_repo_open(cfg: &Config, create: bool) -> Result<(PathBuf, F private: true, description: "grove configuration (managed repos, machines)".into(), })?; - r.clone_url + r.git_url(forge.protocol)?.to_string() } None => bail!( "config repo {:?} does not exist on {}", @@ -485,10 +615,51 @@ mod tests { name: name.into(), private, clone_url: format!("u/{name}.git"), + ssh_url: String::new(), default_branch: "main".into(), } } + #[test] + fn remote_key_normalises_every_url_form() { + let want = Some("github.com/dasemu/synapse".to_string()); + assert_eq!(remote_key("git@github.com:Dasemu/Synapse.git"), want); + assert_eq!(remote_key("https://github.com/Dasemu/Synapse.git"), want); + assert_eq!(remote_key("ssh://git@github.com/dasemu/synapse"), want); + assert_eq!( + remote_key("ssh://gitea@git.example.es:2222/dasemu/x.git").as_deref(), + Some("git.example.es/dasemu/x") + ); + assert_eq!(remote_key("nonsense"), None); + } + + #[test] + fn local_repos_match_by_name_or_origin_ignoring_case() { + let d = std::env::temp_dir().join(format!("grove-local-{}", std::process::id())); + let _ = fs::remove_dir_all(&d); + // `synapse` (lowercase dir) whose origin is Dasemu/Synapse; `other` with a renamed origin. + for (dir, origin) in [ + ("synapse", "git@github.com:Dasemu/Synapse.git"), + ("renamed", "git@github.com:me/old-name.git"), + ] { + let bare = d.join(dir).join(".bare"); + fs::create_dir_all(&bare).unwrap(); + let g = Git::new(&bare); + g.run(&["init", "-q", "--bare"]).unwrap(); + g.run(&["remote", "add", "origin", origin]).unwrap(); + } + let l = Local::scan(&d); + let mut syn = r("Dasemu", "Synapse", false); + syn.clone_url = "https://github.com/Dasemu/Synapse.git".into(); + assert!(l.has(&syn)); + // Different directory name, same origin. + let mut moved = r("me", "new-name", false); + moved.ssh_url = "git@github.com:me/old-name.git".into(); + assert!(l.has(&moved)); + assert!(!l.has(&r("me", "absent", false))); + let _ = fs::remove_dir_all(&d); + } + #[test] fn base64_matches_rfc4648_vectors() { for (i, o) in [ diff --git a/docs/phase7.md b/docs/phase7.md index 7b07447..82f6559 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -87,3 +87,29 @@ Hidden CPU against a busy daemon (8 repos, 5 s fetch interval, ~4 events/s): abo - Side-by-side compare for `Diverged` stays in the CLI (`grove resolve --compare`). - Only the layout and read-only views were checked visually; forms and CLI-driven flows were not clicked through (no input injection available), only their parsing and logic are unit-tested. + +## Import speed, git protocol, import robustness + +- `Provider::list_owner_repos(owner, login)` lists only the owner's repos: Gitea `/orgs/{org}/repos` + or `/user/repos` (filtered by owner) for the login; GitHub `/orgs/{org}/repos?type=all` or + `/user/repos?affiliation=owner`. A 404 on the org endpoint falls back to `/users/{owner}/repos`. + The two sides of a split group are scanned in parallel threads. `grove import Darío` on the + owner's real forges: 3.5 s -> 1.3 s. +- The GUI scan runs on its own thread (not the status worker), is cached per group for the session, + and has a Rescan button. Switching groups shows the cached list; an import drops the cache. +- "Already on this machine" is case-insensitive by directory name, or when an existing bare repo's + `origin` points to the same host/owner/name (https, `ssh://` and scp-like forms). +- A failing clone no longer aborts a multi-repo import: the others continue, failures are printed + as `FAILED : `, the exit status is non-zero and the GUI lists the failed names. +- Per-provider `protocol = "https" | "ssh"` (default `https`; also `grove init --protocol` and the + onboarding form). With `ssh`, `new`/`import`/`bootstrap` clone from the forge's `ssh_url`, registry + entries store that URL, and git gets no token header (only `GIT_TERMINAL_PROMPT=0`, plus + `GIT_SSH_COMMAND="ssh -o BatchMode=yes"` unless the user has their own ssh command). Mirrors stay + HTTPS with tokens (forge to forge). The Settings summary shows the protocol of each provider. + +```toml +[providers.gitea] +kind = "gitea" +url = "https://git.example.com" +protocol = "ssh" # optional, default "https" +``` From ec6a3a04f39451546e5ce3bebf26f495d2f13cce Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 18:15:36 +0100 Subject: [PATCH 13/19] feat(gui): migrate clones from the GUI; diagnostics log and tray restart - Migrate / Migrate all with confirmation, sequential runs, per-repo results - bridge: allow 'add' only for dirs directly under a group - log panics, exit reasons and daemon/tray events to /grove-gui.log - restart the tray service if its D-Bus connection ends Co-Authored-By: Claude Sonnet 5.5 --- Cargo.lock | 1 + crates/grove-core/src/config.rs | 9 +- crates/grove-gui/Cargo.toml | 1 + crates/grove-gui/src/bridge.rs | 121 +++++++++++++++++- crates/grove-gui/src/log.rs | 75 +++++++++++ crates/grove-gui/src/main.rs | 213 ++++++++++++++++++++++++++++++-- crates/grove-gui/src/tray.rs | 15 ++- crates/grove-gui/ui/app.slint | 98 ++++++++++++++- crates/grove/src/workflow.rs | 4 +- docs/phase7.md | 16 +++ 10 files changed, 528 insertions(+), 25 deletions(-) create mode 100644 crates/grove-gui/src/log.rs diff --git a/Cargo.lock b/Cargo.lock index f998eb5..849ddca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2096,6 +2096,7 @@ name = "grove-gui" version = "0.1.0" dependencies = [ "anyhow", + "grove-core", "grove-daemon", "ksni", "serde_json", diff --git a/crates/grove-core/src/config.rs b/crates/grove-core/src/config.rs index 4f7a58b..6178efd 100644 --- a/crates/grove-core/src/config.rs +++ b/crates/grove-core/src/config.rs @@ -515,9 +515,14 @@ mirror_to = ["gitea"] #[test] fn provider_protocol_defaults_to_https_and_is_validated() { let t = |p: &str| { - format!("[machine]\nname=\"a\"\n[root]\npath=\"/x\"\n[providers.p]\nkind=\"gitea\"\n{p}") + format!( + "[machine]\nname=\"a\"\n[root]\npath=\"/x\"\n[providers.p]\nkind=\"gitea\"\n{p}" + ) }; - assert_eq!(Config::parse(&t("")).unwrap().providers["p"].protocol, Protocol::Https); + assert_eq!( + Config::parse(&t("")).unwrap().providers["p"].protocol, + Protocol::Https + ); let c = Config::parse(&t("protocol=\"ssh\"\n")).unwrap(); assert_eq!(c.providers["p"].protocol, Protocol::Ssh); assert!(toml::to_string(&c).unwrap().contains("protocol = \"ssh\"")); diff --git a/crates/grove-gui/Cargo.toml b/crates/grove-gui/Cargo.toml index af5d492..8c4d57f 100644 --- a/crates/grove-gui/Cargo.toml +++ b/crates/grove-gui/Cargo.toml @@ -11,6 +11,7 @@ path = "src/main.rs" [dependencies] anyhow = "1.0.104" +grove-core = { version = "0.1.0", path = "../grove-core" } grove-daemon = { version = "0.1.0", path = "../grove-daemon" } # async-io instead of the default tokio: no second async runtime in a small tray app. ksni = { version = "0.3.7", default-features = false, features = ["async-io", "blocking"] } diff --git a/crates/grove-gui/src/bridge.rs b/crates/grove-gui/src/bridge.rs index dc32f9b..8abd278 100644 --- a/crates/grove-gui/src/bridge.rs +++ b/crates/grove-gui/src/bridge.rs @@ -2,7 +2,7 @@ use serde_json::{Value, json}; use std::io::Write; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; /// `grove` subcommands the GUI may run. Everything else is refused. @@ -11,6 +11,7 @@ const ALLOWED: &[&str] = &[ "login", "new", "import", + "add", "config-repo-init", "bootstrap", "resolve", @@ -44,6 +45,11 @@ impl Bridge { if let Err(e) = validate(args) { return json!({"ok": false, "output": format!("rejected: {e}")}); } + if sub == "add" + && let Err(e) = self.check_migrate_args(args) + { + return json!({"ok": false, "output": format!("rejected: {e}")}); + } let mut cmd = Command::new(&self.grove_bin); if let Some(c) = &self.config { cmd.arg("--config").arg(c); @@ -79,6 +85,28 @@ impl Bridge { } } + fn loaded_config(&self) -> Option { + let p = self + .config + .clone() + .or_else(grove_core::config::Config::default_path)?; + grove_core::config::Config::load(&p).ok() + } + + /// `add ` only for an existing directory directly under `//`. + fn check_migrate_args(&self, args: &[String]) -> Result<(), String> { + let [_, path] = args else { + return Err("add takes exactly one path".into()); + }; + let cfg = self.loaded_config().ok_or("no readable configuration")?; + check_migrate_path(&cfg, Path::new(path)).map(|_| ()) + } + + /// Where `grove add` writes its safety backup. + pub fn backup_dir() -> Option { + grove_core::config::Config::state_dir().map(|d| d.join("backups")) + } + /// `config.toml` as JSON (it holds no secrets), or `None` before onboarding. pub fn config_json(&self) -> Option { let p = self.config.clone().or_else(grove_core_default_config)?; @@ -135,6 +163,31 @@ pub fn validate(args: &[String]) -> Result<(), String> { Ok(()) } +/// A clone the GUI may migrate: an existing directory (not a symlink) whose parent is one of the +/// configured group directories. Returns its canonical path. +pub fn check_migrate_path( + cfg: &grove_core::config::Config, + path: &Path, +) -> Result { + let meta = std::fs::symlink_metadata(path).map_err(|e| format!("{}: {e}", path.display()))?; + if !meta.is_dir() { + return Err(format!("{} is not a directory", path.display())); + } + let canon = path.canonicalize().map_err(|e| e.to_string())?; + let parent = canon.parent().ok_or("path has no parent directory")?; + let root = cfg.root_path(); + let root = root.canonicalize().unwrap_or(root); + if cfg.groups.iter().any(|g| root.join(&g.name) == parent) { + Ok(canon) + } else { + Err(format!( + "{} is not directly inside a group directory under {}", + path.display(), + root.display() + )) + } +} + fn grove_core_default_config() -> Option { let base = std::env::var_os("XDG_CONFIG_HOME") .map(PathBuf::from) @@ -160,6 +213,72 @@ mod tests { assert!(v(&["secrets", "pull"]).is_ok()); } + #[test] + fn migrate_path_must_be_a_clone_directly_under_a_group() { + let base = std::env::temp_dir().join(format!("grove-mig-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&base); + std::fs::create_dir_all(base.join("work/proj/sub")).unwrap(); + std::fs::create_dir_all(base.join("other/proj")).unwrap(); + std::fs::write(base.join("work/file"), "x").unwrap(); + std::os::unix::fs::symlink(base.join("other/proj"), base.join("work/link")).unwrap(); + let cfg = grove_core::config::Config::parse(&format!( + "[machine]\nname=\"m\"\n[root]\npath=\"{}\"\n[providers.p]\nkind=\"gitea\"\n[[groups]]\nname=\"work\"\nprimary=\"p\"\n", + base.display() + )) + .unwrap(); + assert!(check_migrate_path(&cfg, &base.join("work/proj")).is_ok()); + for bad in [ + "work/proj/sub", + "other/proj", + "work/file", + "work/link", + "work/none", + "work", + "work/../other/proj", + ] { + assert!(check_migrate_path(&cfg, &base.join(bad)).is_err(), "{bad}"); + } + let _ = std::fs::remove_dir_all(&base); + } + + #[test] + fn add_runs_only_for_valid_clone_paths() { + use std::os::unix::fs::PermissionsExt; + let base = std::env::temp_dir().join(format!("grove-add-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&base); + std::fs::create_dir_all(base.join("work/proj")).unwrap(); + std::fs::create_dir_all(base.join("elsewhere")).unwrap(); + let cfg = base.join("config.toml"); + std::fs::write(&cfg, format!( + "[machine]\nname=\"m\"\n[root]\npath=\"{}\"\n[providers.p]\nkind=\"gitea\"\n[[groups]]\nname=\"work\"\nprimary=\"p\"\n", + base.display() + )).unwrap(); + // A stand-in `grove` that reports what it was asked to do. + let fake = base.join("grove"); + std::fs::write(&fake, "#!/bin/sh\necho \"migrated: $3/wt\"\n").unwrap(); + std::fs::set_permissions(&fake, std::fs::Permissions::from_mode(0o755)).unwrap(); + let b = Bridge { + grove_bin: fake, + config: Some(cfg), + socket: "/nonexistent".into(), + }; + let ok = b.cli( + &["add".into(), base.join("work/proj").display().to_string()], + "", + ); + assert_eq!(ok["ok"], true, "{ok}"); + assert!(ok["output"].as_str().unwrap().starts_with("migrated:")); + let bad = b.cli( + &["add".into(), base.join("elsewhere").display().to_string()], + "", + ); + assert_eq!(bad["ok"], false); + assert!(bad["output"].as_str().unwrap().contains("rejected")); + let flag = b.cli(&["add".into(), "--backup-dir".into(), "/x".into()], ""); + assert_eq!(flag["ok"], false); + let _ = std::fs::remove_dir_all(&base); + } + fn bridge() -> Bridge { Bridge { grove_bin: "/nonexistent/grove".into(), diff --git a/crates/grove-gui/src/log.rs b/crates/grove-gui/src/log.rs new file mode 100644 index 0000000..6a40a73 --- /dev/null +++ b/crates/grove-gui/src/log.rs @@ -0,0 +1,75 @@ +//! A small log file (`/grove-gui.log`) for things that would otherwise vanish when the +//! GUI runs from autostart with stdout/stderr closed: panics, fatal errors and why it exited. + +use std::io::Write; +use std::sync::OnceLock; +use std::sync::atomic::{AtomicBool, Ordering}; + +static PATH: OnceLock = OnceLock::new(); +/// Set when the process leaves on purpose (tray "Quit", window closed without a tray). +pub static EXPECTED_EXIT: AtomicBool = AtomicBool::new(false); + +const MAX_BYTES: u64 = 256 * 1024; + +/// Opens the log (truncating a file past 256 KiB) and installs the panic hook. +pub fn init() { + let Some(dir) = grove_core::config::Config::state_dir() else { + return; + }; + let _ = std::fs::create_dir_all(&dir); + let path = dir.join("grove-gui.log"); + if std::fs::metadata(&path).is_ok_and(|m| m.len() > MAX_BYTES) { + let _ = std::fs::rename(&path, dir.join("grove-gui.log.old")); + } + let _ = PATH.set(path); + let default = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |info| { + let t = std::thread::current(); + let bt = std::backtrace::Backtrace::force_capture(); + line(&format!( + "PANIC in thread {:?}: {info}\n{bt}", + t.name().unwrap_or("") + )); + default(info); + })); +} + +/// Appends one timestamped line; never fails and never panics. +pub fn line(msg: &str) { + let Some(p) = PATH.get() else { return }; + if let Ok(mut f) = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(p) + { + let _ = writeln!(f, "{} [{}] {msg}", stamp(), std::process::id()); + } +} + +pub fn expected_exit() { + EXPECTED_EXIT.store(true, Ordering::SeqCst); +} + +/// `YYYY-MM-DD HH:MM:SSZ` (UTC) from the system clock. +fn stamp() -> String { + let s = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| d.as_secs()); + let (days, rem) = (s / 86400, s % 86400); + // Civil-from-days (Howard Hinnant). + let z = days as i64 + 719_468; + let era = z.div_euclid(146_097); + let doe = z.rem_euclid(146_097); + let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let d = doy - (153 * mp + 2) / 5 + 1; + let m = if mp < 10 { mp + 3 } else { mp - 9 }; + let y = yoe + era * 400 + i64::from(m <= 2); + format!( + "{y:04}-{m:02}-{d:02} {:02}:{:02}:{:02}Z", + rem / 3600, + rem % 3600 / 60, + rem % 60 + ) +} diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs index e1e1e26..cf64fe0 100644 --- a/crates/grove-gui/src/main.rs +++ b/crates/grove-gui/src/main.rs @@ -7,6 +7,7 @@ mod autostart; mod bridge; mod instance; +mod log; mod model; mod tray; @@ -125,6 +126,10 @@ struct UiState { detail_fp: String, filter: String, pending: Option>, + /// Clones waiting for the migration confirmation, and what happened to each so far. + mig_pending: Option>, + mig: HashMap, + migrating: bool, picks: Rc>, /// Last successful scan per import group, for the session (names still to import). import_cache: HashMap>, @@ -145,6 +150,9 @@ thread_local! { detail_fp: String::new(), filter: String::new(), pending: None, + mig_pending: None, + mig: HashMap::new(), + migrating: false, picks: Rc::new(VecModel::default()), import_cache: HashMap::new(), import_current: String::new(), @@ -224,16 +232,25 @@ fn render(ui: &MainWindow) { ui.set_attention_count(agg.attention as i32); ui.set_has_config(snap.config.is_some()); ui.set_autostart(autostart::config_home().is_some_and(|d| autostart::is_enabled(&d))); - let nm: Vec = snap + let nm: Vec = snap .status .as_ref() .and_then(|s| s["not_migrated"].as_array()) .map(|a| { a.iter() - .filter_map(|p| p.as_str().map(SharedString::from)) + .filter_map(|p| p.as_str()) + .map(|p| { + let (state, msg) = st.mig.get(p).cloned().unwrap_or_default(); + MigRow { + path: p.into(), + state: state.into(), + msg: msg.into(), + } + }) .collect() }) .unwrap_or_default(); + ui.set_migrating(st.migrating); ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm)))); let empty = Vec::new(); @@ -568,6 +585,91 @@ fn scan(ctx: &Ctx, ui: &MainWindow, group: String, force: bool, note: Option) { + if paths.is_empty() || ST.with(|st| st.borrow().migrating) { + return; + } + let backup = Bridge::backup_dir() + .map(|d| d.display().to_string()) + .unwrap_or_else(|| "grove's state directory".into()); + let what = match paths.as_slice() { + [one] => one.clone(), + many => format!("{} clones", many.len()), + }; + ST.with(|st| st.borrow_mut().mig_pending = Some(paths)); + ui.set_migrate_confirm_text( + format!( + "Migrate {what} to grove's bare + worktrees layout?\n\nA full backup of each clone (a tar archive and a git ref) is taken first, in {backup}. A clone grove cannot migrate safely (linked worktrees, submodules, detached HEAD...) is refused and left untouched." + ) + .into(), + ); +} + +/// Migrates the clones one after the other on a worker thread, reporting each result as it comes. +fn run_migrations(ctx: &Ctx, ui: &MainWindow, paths: Vec) { + ST.with(|st| { + let mut st = st.borrow_mut(); + st.migrating = true; + for p in &paths { + st.mig.remove(p); + } + }); + render(ui); + let (core, weak) = (ctx.core.clone(), ctx.weak.clone()); + std::thread::spawn(move || { + let total = paths.len(); + let (mut done, mut failed) = (0, 0); + for p in paths { + let (w, p1) = (weak.clone(), p.clone()); + let _ = slint::invoke_from_event_loop(move || { + ST.with(|st| { + st.borrow_mut() + .mig + .insert(p1, ("running".into(), String::new())) + }); + if let Some(ui) = w.upgrade() { + render(&ui); + } + }); + let r = core.bridge.cli(&["add".to_string(), p.clone()], ""); + let ok = r["ok"] == true; + let text = r["output"].as_str().unwrap_or("").to_string(); + let msg = if ok { + done += 1; + text.lines() + .find_map(|l| l.strip_prefix("migrated:")) + .map(|m| format!("Migrated to {}", m.trim())) + .unwrap_or_else(|| "Migrated".into()) + } else { + failed += 1; + text.lines().next().unwrap_or("failed").to_string() + }; + let (w, p2) = (weak.clone(), p); + let _ = slint::invoke_from_event_loop(move || { + let state = if ok { "ok" } else { "failed" }; + ST.with(|st| st.borrow_mut().mig.insert(p2, (state.into(), msg))); + if let Some(ui) = w.upgrade() { + render(&ui); + } + }); + } + let w = weak.clone(); + let _ = slint::invoke_from_event_loop(move || { + ST.with(|st| st.borrow_mut().migrating = false); + if let Some(ui) = w.upgrade() { + render(&ui); + toast( + &ui, + &format!("Migration finished: {done} of {total} migrated, {failed} failed"), + failed > 0, + ); + } + }); + core.wake(); // refresh the status + }); +} + fn first_or(v: &str, list: &ModelRc) -> String { if v.is_empty() { list.row_data(0).map(|x| x.to_string()).unwrap_or_default() @@ -736,6 +838,47 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { ui.set_autostart(autostart::config_home().is_some_and(|d| autostart::is_enabled(&d))); } }); + ui.on_migrate_one({ + let w = ui.as_weak(); + move |path| { + if let Some(ui) = w.upgrade() { + ask_migrate(&ui, vec![path.to_string()]); + } + } + }); + ui.on_migrate_all({ + let w = ui.as_weak(); + move || { + let Some(ui) = w.upgrade() else { return }; + let todo: Vec = ui + .get_not_migrated() + .iter() + .filter(|r| r.state != "ok" && r.state != "running") + .map(|r| r.path.to_string()) + .collect(); + ask_migrate(&ui, todo); + } + }); + ui.on_migrate_confirm_cancel({ + let w = ui.as_weak(); + move || { + ST.with(|st| st.borrow_mut().mig_pending = None); + if let Some(ui) = w.upgrade() { + ui.set_migrate_confirm_text("".into()); + } + } + }); + ui.on_migrate_confirm_accept({ + let c = ctx.clone(); + move || { + let Some(ui) = c.weak.upgrade() else { return }; + ui.set_migrate_confirm_text("".into()); + let Some(paths) = ST.with(|st| st.borrow_mut().mig_pending.take()) else { + return; + }; + run_migrations(&c, &ui, paths); + } + }); ui.on_confirm_cancel({ let w = ui.as_weak(); move || { @@ -918,9 +1061,11 @@ fn wire(ui: &MainWindow, ctx: &Ctx) { fn worker( core: Arc, rx: Receiver<()>, - tray: Option, + mut tray: Option, + respawn_tray: impl Fn() -> Option, weak: Weak, ) { + let mut tray_lost = false; let mut last_states: HashMap = HashMap::new(); let mut last_agg: Option = None; let mut last_run = Instant::now() - MIN_GAP_HIDDEN; @@ -996,10 +1141,25 @@ fn worker( } } + // The tray service ends when its D-Bus connection is lost (e.g. the session bus or the + // desktop shell restarted): bring it back instead of leaving a running app with no icon. + if core.tray_ok.load(Ordering::SeqCst) && tray.as_ref().is_none_or(|t| t.is_closed()) { + if !tray_lost { + log::line("tray service ended; trying to restart it"); + tray_lost = true; + } + if let Some(h) = respawn_tray() { + log::line("tray service restarted"); + tray = Some(h); + tray_lost = false; + last_agg = None; + } + } if let Some(t) = &tray && last_agg.as_ref() != Some(&agg) + && !tray::set_state(t, &agg) { - tray::set_state(t, &agg); + log::line("tray update failed: service closed"); } last_agg = Some(agg); @@ -1034,17 +1194,27 @@ fn worker( /// Wakes the worker whenever the daemon emits an activity event. fn subscriber(core: Arc) { + let mut connected = false; loop { if let Ok(mut c) = UnixStream::connect(&core.bridge.socket) { + if !connected { + log::line("daemon: subscribed"); + connected = true; + } if writeln!(c, r#"{{"v":1,"cmd":"subscribe"}}"#).is_ok() { for line in BufReader::new(c).lines() { - if line.is_err() { + if let Err(e) = line { + log::line(&format!("daemon: event stream error: {e}")); break; } core.wake(); } } core.wake(); // connection ended: the daemon went away + if connected { + log::line("daemon: event stream ended"); + connected = false; + } } std::thread::sleep(RECONNECT); } @@ -1061,6 +1231,20 @@ fn default_grove_bin() -> PathBuf { } fn main() -> Result<()> { + log::init(); + log::line(&format!( + "start {}", + std::env::args().skip(1).collect::>().join(" ") + )); + let r = run(); + match &r { + Ok(()) => log::line("exit: ok"), + Err(e) => log::line(&format!("exit: error: {e:#}")), + } + r +} + +fn run() -> Result<()> { let args: Vec = std::env::args().skip(1).collect(); let arg = |name: &str| { args.iter() @@ -1154,18 +1338,21 @@ fn main() -> Result<()> { Action::SyncNow => ctx.core.sync(None, ctx.weak.clone()), Action::TogglePause => ctx.core.toggle_pause(), Action::Quit => { + log::line("quit requested from the tray menu"); + log::expected_exit(); let _ = slint::invoke_from_event_loop(|| { let _ = slint::quit_event_loop(); }); } }) }; - let tray = match tray::spawn(on_action) { + let tray = match tray::spawn(on_action.clone()) { Ok(h) => { core.tray_ok.store(true, Ordering::SeqCst); Some(h) } Err(e) => { + log::line(&format!("no system tray: {e}")); eprintln!("grove-gui: no system tray ({e}); closing the window will quit"); None } @@ -1176,6 +1363,8 @@ fn main() -> Result<()> { move || { c.core.set_visible(false); if !c.core.tray_ok.load(Ordering::SeqCst) { + log::line("window closed and no tray: quitting"); + log::expected_exit(); let _ = slint::quit_event_loop(); } slint::CloseRequestResponse::HideWindow @@ -1184,7 +1373,10 @@ fn main() -> Result<()> { { let (c, w) = (core.clone(), ui.as_weak()); - std::thread::spawn(move || worker(c, rx, tray, w)); + let respawn = on_action.clone(); + std::thread::spawn(move || { + worker(c, rx, tray, move || tray::spawn(respawn.clone()).ok(), w) + }); } { let c = core.clone(); @@ -1197,7 +1389,12 @@ fn main() -> Result<()> { } else { core.wake(); } - slint::run_event_loop_until_quit().context("event loop")?; + let r = slint::run_event_loop_until_quit(); + log::line(&format!( + "event loop ended: {r:?} (expected: {})", + log::EXPECTED_EXIT.load(Ordering::SeqCst) + )); + r.context("event loop")?; let _ = std::fs::remove_file(&inst_path); Ok(()) } diff --git a/crates/grove-gui/src/tray.rs b/crates/grove-gui/src/tray.rs index e300dd8..51752fa 100644 --- a/crates/grove-gui/src/tray.rs +++ b/crates/grove-gui/src/tray.rs @@ -31,13 +31,16 @@ pub fn spawn(on_action: Arc) -> Result bool { let agg = agg.clone(); - handle.update(move |t| { - if t.agg != agg { - t.agg = agg; - } - }); + handle + .update(move |t| { + if t.agg != agg { + t.agg = agg; + } + }) + .is_some() } impl ksni::Tray for GroveTray { diff --git a/crates/grove-gui/ui/app.slint b/crates/grove-gui/ui/app.slint index 1ba09d2..292dd3b 100644 --- a/crates/grove-gui/ui/app.slint +++ b/crates/grove-gui/ui/app.slint @@ -45,6 +45,13 @@ export struct Pick { checked: bool, } +export struct MigRow { + path: string, + // "" (not started), "running", "ok", "failed" + state: string, + msg: string, +} + export struct Out { text: string, ok: bool, @@ -180,7 +187,9 @@ export component MainWindow inherits Window { in property wt-count; in property attention-count; in property <[Repo]> repos; - in property <[string]> not-migrated; + in property <[MigRow]> not-migrated; + in property migrating; + in property migrate-confirm-text; in property <[LogRow]> log; in property <[string]> groups; in property <[string]> providers; @@ -214,6 +223,10 @@ export component MainWindow inherits Window { callback import-selected(string); callback pick-toggled(int, bool); callback resolve(string, string, string); + callback migrate-one(string); + callback migrate-all(); + callback migrate-confirm-accept(); + callback migrate-confirm-cancel(); callback confirm-accept(); callback confirm-cancel(); callback run-settings(string); @@ -376,10 +389,48 @@ export component MainWindow inherits Window { text: "These clones are in your workspace but not managed by grove yet: run `grove add` for each one to bring it into a group."; } - for p in root.not-migrated: Muted { - text: p; - font-size: 12px; - overflow: elide; + for p in root.not-migrated: VerticalLayout { + spacing: 2px; + HorizontalLayout { + spacing: 8px; + Muted { + text: p.path; + font-size: 12px; + overflow: elide; + horizontal-stretch: 1; + } + + if p.state == "running": Muted { + text: "Migrating…"; + } + if p.state == "ok": Muted { + text: "Migrated"; + } + if p.state == "" || p.state == "failed": Button { + text: p.state == "failed" ? "Retry" : "Migrate"; + enabled: !root.migrating; + clicked => { + root.migrate-one(p.path); + } + } + } + + if p.msg != "": Muted { + text: p.msg; + font-size: 12px; + overflow: elide; + } + } + + HorizontalLayout { + alignment: start; + Button { + text: root.migrating ? "Migrating…" : "Migrate all"; + enabled: !root.migrating; + clicked => { + root.migrate-all(); + } + } } } if !root.offline && root.loading: Muted { @@ -1110,6 +1161,43 @@ export component MainWindow inherits Window { } } + // ---- migration confirmation ---- + if root.migrate-confirm-text != "": Rectangle { + background: #00000088; + TouchArea { } + + Card { + width: min(500px, parent.width - 40px); + height: self.preferred-height; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + background: Palette.background; + Text { + text: root.migrate-confirm-text; + wrap: word-wrap; + } + + HorizontalLayout { + spacing: 8px; + alignment: end; + Button { + text: "Cancel"; + clicked => { + root.migrate-confirm-cancel(); + } + } + + Button { + text: "Migrate"; + primary: true; + clicked => { + root.migrate-confirm-accept(); + } + } + } + } + } + // ---- confirmation ---- if root.confirm-text != "": Rectangle { background: #00000088; diff --git a/crates/grove/src/workflow.rs b/crates/grove/src/workflow.rs index f729077..c8d75bc 100644 --- a/crates/grove/src/workflow.rs +++ b/crates/grove/src/workflow.rs @@ -296,9 +296,7 @@ fn remote_key(url: &str) -> Option { _ => path, }; let path = path.trim_matches('/').trim_end_matches(".git"); - let mut parts = path.rsplitn(2, '/'); - let name = parts.next()?; - let owner = parts.next()?; + let (owner, name) = path.rsplit_once('/')?; Some(format!("{host}/{owner}/{name}").to_lowercase()) } diff --git a/docs/phase7.md b/docs/phase7.md index 82f6559..b20a8d7 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -113,3 +113,19 @@ kind = "gitea" url = "https://git.example.com" protocol = "ssh" # optional, default "https" ``` + +## Migrating clones from the GUI + +The "Not migrated clones" card has a Migrate button per row and a Migrate all button. Each asks +for confirmation first (the dialog names the backup directory, `/backups`), then runs +`grove add ` one clone at a time off the UI thread, showing "Migrating…", then the migrated +path or the refusal message (linked worktrees, submodules, detached HEAD...). The bridge only runs +`add` for an existing, non-symlink directory directly under `//` and passes no flags +(so no custom backup directory). Afterwards the status is refreshed; the daemon computes its +not-migrated list at start (a daemon-side fix is separate), so finished rows stay on screen with +their result until the daemon list changes. + +## Diagnostics log + +`/grove-gui.log` (rotated at 256 KiB) records start-up, daemon subscribe/disconnect, +tray errors and restarts, panics with a backtrace (from any thread) and why the event loop ended. From b875a41b4deda3efcb17ce18b6eaeb1a5209fe80 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 18:47:38 +0100 Subject: [PATCH 14/19] feat(gui): stalled repos, runtime not-migrated rows, safer import cleanup - daemon status reports stalled repos; GUI shows them with the backup hint - activity: repo_stalled is a warning; repo_added/removed shown - migrate rows keep their result only until the next status refresh - import removes a failed clone's directory only if it created it Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-daemon/src/daemon.rs | 3 +++ crates/grove-daemon/src/ipc.rs | 3 ++- crates/grove-daemon/tests/daemon.rs | 4 ++++ crates/grove-gui/src/main.rs | 21 +++++++++++++++++++++ crates/grove-gui/src/model.rs | 5 ++++- crates/grove-gui/ui/app.slint | 17 +++++++++++++++++ crates/grove/src/workflow.rs | 8 ++++++-- docs/phase7.md | 8 ++++++-- 8 files changed, 63 insertions(+), 6 deletions(-) diff --git a/crates/grove-daemon/src/daemon.rs b/crates/grove-daemon/src/daemon.rs index 9febdba..994212d 100644 --- a/crates/grove-daemon/src/daemon.rs +++ b/crates/grove-daemon/src/daemon.rs @@ -86,6 +86,8 @@ pub struct Shared { pub repos: BTreeMap, /// Plain clones in configured groups: ignored until migrated with `grove add`. pub not_migrated: Vec, + /// Repos left alone because an interrupted `grove add`/clone left a marker behind. + pub stalled: Vec, } pub enum Msg { @@ -365,6 +367,7 @@ fn rescan( { let mut shared = ctx.shared.lock().unwrap(); shared.not_migrated = d.not_migrated; + shared.stalled = d.stalled.clone(); shared.repos.retain(|p, _| { let keep = found.contains(p); if !keep { diff --git a/crates/grove-daemon/src/ipc.rs b/crates/grove-daemon/src/ipc.rs index 4e7c419..df9af2a 100644 --- a/crates/grove-daemon/src/ipc.rs +++ b/crates/grove-daemon/src/ipc.rs @@ -169,7 +169,8 @@ fn handle(req: &Request, ctx: &Ctx) -> Value { .collect(); ok( json!({"machine": ctx.machine, "paused": s.paused, "now": now_secs(), "repos": repos, - "not_migrated": s.not_migrated.iter().map(|p| p.display().to_string()).collect::>()}), + "not_migrated": s.not_migrated.iter().map(|p| p.display().to_string()).collect::>(), + "stalled": s.stalled.iter().map(|p| p.display().to_string()).collect::>()}), ) } "pause" | "resume" => { diff --git a/crates/grove-daemon/tests/daemon.rs b/crates/grove-daemon/tests/daemon.rs index 8aabbde..9e8bd8b 100644 --- a/crates/grove-daemon/tests/daemon.rs +++ b/crates/grove-daemon/tests/daemon.rs @@ -712,6 +712,10 @@ fn stale_busy_marker_keeps_the_repo_out_and_warns_once() { assert_eq!(events(&sock, "repo_stalled").len(), 1); assert_eq!(repo_paths(&sock).len(), 1); assert!(stale.join(".grove-busy").exists()); + assert_eq!( + status(&sock)["stalled"], + json!([stale.display().to_string()]) + ); d.shutdown(); } diff --git a/crates/grove-gui/src/main.rs b/crates/grove-gui/src/main.rs index cf64fe0..5012adc 100644 --- a/crates/grove-gui/src/main.rs +++ b/crates/grove-gui/src/main.rs @@ -250,6 +250,27 @@ fn render(ui: &MainWindow) { .collect() }) .unwrap_or_default(); + // A result is shown until the daemon's list moves on, then it goes. + let listed: HashSet<&str> = snap + .status + .as_ref() + .and_then(|s| s["not_migrated"].as_array()) + .map(|a| a.iter().filter_map(Value::as_str).collect()) + .unwrap_or_default(); + if !st.migrating { + st.mig.retain(|p, _| listed.contains(p.as_str())); + } + let stalled: Vec = snap + .status + .as_ref() + .and_then(|s| s["stalled"].as_array()) + .map(|a| { + a.iter() + .filter_map(|p| p.as_str().map(SharedString::from)) + .collect() + }) + .unwrap_or_default(); + ui.set_stalled(ModelRc::from(Rc::new(VecModel::from(stalled)))); ui.set_migrating(st.migrating); ui.set_not_migrated(ModelRc::from(Rc::new(VecModel::from(nm)))); diff --git a/crates/grove-gui/src/model.rs b/crates/grove-gui/src/model.rs index 6384c31..82f1ef1 100644 --- a/crates/grove-gui/src/model.rs +++ b/crates/grove-gui/src/model.rs @@ -141,7 +141,7 @@ pub fn reconcile_outputs(outputs: &mut HashMap, states: &HashMap pub fn log_tone(kind: &str) -> &'static str { match kind { "error" | "watch_error" => "error", - "state" | "snapshots_withheld" | "snapshots_purged" | "declined" => "warn", + "state" | "snapshots_withheld" | "snapshots_purged" | "declined" | "repo_stalled" => "warn", _ => "ok", } } @@ -453,6 +453,9 @@ mod tests { assert_eq!(log_tone("snapshots_purged"), "warn"); assert_eq!(log_tone("snapshots_enabled"), "ok"); assert_eq!(log_tone("watch_error"), "error"); + assert_eq!(log_tone("repo_stalled"), "warn"); + assert_eq!(log_tone("repo_added"), "ok"); + assert_eq!(log_tone("repo_removed"), "ok"); } #[test] diff --git a/crates/grove-gui/ui/app.slint b/crates/grove-gui/ui/app.slint index 292dd3b..7e8c385 100644 --- a/crates/grove-gui/ui/app.slint +++ b/crates/grove-gui/ui/app.slint @@ -189,6 +189,7 @@ export component MainWindow inherits Window { in property <[Repo]> repos; in property <[MigRow]> not-migrated; in property migrating; + in property <[string]> stalled; in property migrate-confirm-text; in property <[LogRow]> log; in property <[string]> groups; @@ -379,6 +380,22 @@ export component MainWindow inherits Window { text: "Start it with `systemctl --user start groved` (or run `groved` in a terminal)."; } } + if !root.offline && root.stalled.length > 0: Card { + Text { + text: "Stalled repositories"; + font-weight: 700; + } + + Muted { + text: "An interrupted `grove add` or clone left a marker in these repositories, so grove leaves them alone. Check the repository and restore from the backups (see the Activity log), then remove the `.grove-busy` / `.grove-stage` marker by hand."; + } + + for p in root.stalled: Muted { + text: p; + font-size: 12px; + overflow: elide; + } + } if !root.offline && root.not-migrated.length > 0: Card { Text { text: "Not migrated clones"; diff --git a/crates/grove/src/workflow.rs b/crates/grove/src/workflow.rs index c8d75bc..baa38b1 100644 --- a/crates/grove/src/workflow.rs +++ b/crates/grove/src/workflow.rs @@ -412,9 +412,13 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { let res = (|| -> Result<()> { let url = r.git_url(forge.protocol)?.to_string(); let dir = gdir.join(&r.name); + let existed = dir.exists(); if let Err(e) = clone_bare_layout(&url, &dir, &forge.git_env) { - // Leave no empty directory behind (it only goes away when nothing was cloned). - let _ = fs::remove_dir(&dir); + // The busy marker is released by now. Remove only a directory this import + // created, and only while it is empty (`remove_dir` refuses anything else). + if !existed { + let _ = fs::remove_dir(&dir); + } return Err(e.into()); } println!("imported {} -> {}", r.name, dir.display()); diff --git a/docs/phase7.md b/docs/phase7.md index b20a8d7..c3ddabe 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -122,8 +122,12 @@ for confirmation first (the dialog names the backup directory, `/back path or the refusal message (linked worktrees, submodules, detached HEAD...). The bridge only runs `add` for an existing, non-symlink directory directly under `//` and passes no flags (so no custom backup directory). Afterwards the status is refreshed; the daemon computes its -not-migrated list at start (a daemon-side fix is separate), so finished rows stay on screen with -their result until the daemon list changes. +not-migrated list at runtime, so after a migration the row keeps its result on screen until the +next status refresh drops it. A second `grove add` is refused while a `.grove-busy` marker is held; +Migrate all runs strictly one clone at a time and shows that refusal text on the row. Repos the +daemon reports as `stalled` (interrupted operation, marker left behind) get their own card with +the hint to check the backups; `repo_added`, `repo_removed` and `repo_stalled` (warning) appear in +Activity. ## Diagnostics log From f1509c3d658b483544369f15672e6fb6a3a18a0d Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 18:53:10 +0100 Subject: [PATCH 15/19] fix(providers): pagination, owner listing fallback, URL and name validation - pages stop on total/Link/empty page, not on a short page - GitHub/Gitea owner listing falls back to /user/repos (collaborator repos) and says so - url module: plain repo names, https/ssh/scp URLs on the provider host, canonical https Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-providers/src/gitea.rs | 12 +- crates/grove-providers/src/github.rs | 16 ++- crates/grove-providers/src/http.rs | 63 +++++++-- crates/grove-providers/src/lib.rs | 1 + crates/grove-providers/src/url.rs | 191 +++++++++++++++++++++++++++ crates/grove-providers/tests/api.rs | 49 +++++-- 6 files changed, 303 insertions(+), 29 deletions(-) create mode 100644 crates/grove-providers/src/url.rs diff --git a/crates/grove-providers/src/gitea.rs b/crates/grove-providers/src/gitea.rs index c0a6d28..cbbfb19 100644 --- a/crates/grove-providers/src/gitea.rs +++ b/crates/grove-providers/src/gitea.rs @@ -84,10 +84,14 @@ impl Provider for Gitea { }; let items = match self.http.pages(&path, 50, "limit") { Ok(v) => v, - // Not an organisation: another user's public repos. - Err(Error::Api { status: 404, .. }) if !owner.eq_ignore_ascii_case(login) => self - .http - .pages(&format!("/users/{owner}/repos"), 50, "limit")?, + // Not an organisation (a user, or an org the token cannot see): say so, and take + // what the token can see under that name, private repos it collaborates on included. + Err(Error::Api { status: 404, .. }) if !owner.eq_ignore_ascii_case(login) => { + eprintln!( + "grove: /orgs/{owner} not found; listing the repositories you can see owned by {owner}" + ); + self.http.pages("/user/repos", 50, "limit")? + } Err(e) => return Err(e), }; Ok(items diff --git a/crates/grove-providers/src/github.rs b/crates/grove-providers/src/github.rs index 5e43edc..4ad8855 100644 --- a/crates/grove-providers/src/github.rs +++ b/crates/grove-providers/src/github.rs @@ -91,10 +91,18 @@ impl Provider for GitHub { }; let items = match self.http.pages(&path, 100, "per_page") { Ok(v) => v, - // Not an organisation: another user's public repos. - Err(Error::Api { status: 404, .. }) if !owner.eq_ignore_ascii_case(login) => self - .http - .pages(&format!("/users/{owner}/repos"), 100, "per_page")?, + // Not an organisation (a user, or an org the token cannot see): say so, and take + // what the token can see under that name, private repos it collaborates on included. + Err(Error::Api { status: 404, .. }) if !owner.eq_ignore_ascii_case(login) => { + eprintln!( + "grove: /orgs/{owner} not found; listing the repositories you can see owned by {owner}" + ); + self.http.pages( + "/user/repos?affiliation=owner,collaborator,organization_member", + 100, + "per_page", + )? + } Err(e) => return Err(e), }; Ok(items diff --git a/crates/grove-providers/src/http.rs b/crates/grove-providers/src/http.rs index 909c468..9959a5e 100644 --- a/crates/grove-providers/src/http.rs +++ b/crates/grove-providers/src/http.rs @@ -24,6 +24,17 @@ impl Http { /// Returns the status and the parsed JSON body (`Null` when empty or not JSON). pub fn send(&self, method: &str, path: &str, body: Option<&Value>) -> Result<(u16, Value)> { + self.send_h(method, path, body) + .map(|(status, json, _)| (status, json)) + } + + /// Like [`send`], also returning the pagination hints of the response headers. + fn send_h( + &self, + method: &str, + path: &str, + body: Option<&Value>, + ) -> Result<(u16, Value, PageHints)> { let url = format!("{}{}", self.base, path); let net = |e: ureq::Error| Error::Network(e.to_string()); let mut resp = match (method, body) { @@ -43,9 +54,19 @@ impl Http { } .map_err(net)?; let status = resp.status().as_u16(); + let header = |n: &str| { + resp.headers() + .get(n) + .and_then(|v| v.to_str().ok()) + .map(str::to_string) + }; + let hints = PageHints { + total: header("x-total-count").and_then(|v| v.trim().parse().ok()), + link: header("link"), + }; let text = resp.body_mut().read_to_string().map_err(net)?; let json = serde_json::from_str(&text).unwrap_or(Value::Null); - Ok((status, json)) + Ok((status, json, hints)) } /// Like [`send`], but maps non-2xx statuses to [`Error::Api`]. @@ -62,22 +83,42 @@ impl Http { } /// Every item of a paginated list endpoint (`path` may already carry a query string). + /// + /// A short page is not the end (a server may cap the page size below what was asked). It + /// ends on `X-Total-Count` being reached, on a `Link` header without `rel="next"`, or on an + /// empty or repeated page. pub fn pages(&self, path: &str, per_page: usize, size_param: &str) -> Result> { let sep = if path.contains('?') { '&' } else { '?' }; - let mut out = Vec::new(); - for page in 1..=200 { - let v = self.ok( - "GET", - &format!("{path}{sep}{size_param}={per_page}&page={page}"), - None, - )?; + let mut out: Vec = Vec::new(); + let mut prev: Option> = None; + for page in 1..=500 { + let url = format!("{path}{sep}{size_param}={per_page}&page={page}"); + let (status, v, hints) = self.send_h("GET", &url, None)?; + if !(200..300).contains(&status) { + let message = v["message"].as_str().unwrap_or("(no message)").to_string(); + return Err(Error::Api { status, message }); + } let items = v.as_array().cloned().unwrap_or_default(); - let n = items.len(); - out.extend(items); - if n < per_page { + if items.is_empty() || prev.as_ref() == Some(&items) { break; } + out.extend(items.iter().cloned()); + if hints.total.is_some_and(|t| out.len() >= t) + || hints + .link + .as_deref() + .is_some_and(|l| !l.contains("rel=\"next\"")) + { + break; + } + prev = Some(items); } Ok(out) } } + +/// What the response headers say about the rest of a paginated list. +struct PageHints { + total: Option, + link: Option, +} diff --git a/crates/grove-providers/src/lib.rs b/crates/grove-providers/src/lib.rs index df84a88..303bb20 100644 --- a/crates/grove-providers/src/lib.rs +++ b/crates/grove-providers/src/lib.rs @@ -6,6 +6,7 @@ mod gitea; mod github; mod http; pub mod token; +pub mod url; pub use gitea::Gitea; pub use github::GitHub; diff --git a/crates/grove-providers/src/url.rs b/crates/grove-providers/src/url.rs new file mode 100644 index 0000000..b70c769 --- /dev/null +++ b/crates/grove-providers/src/url.rs @@ -0,0 +1,191 @@ +//! Validation and normalisation of what a forge (or a registry entry) tells us to clone: repo +//! names become directory names, URLs go to `git clone` together with credentials. + +use crate::{Error, Result}; +use grove_core::config::{Provider as ProviderCfg, ProviderKind}; + +/// A repo name is used as a directory name under the group: a plain, harmless one. +pub fn valid_repo_name(name: &str) -> bool { + !name.is_empty() + && name != ".." + && !name.starts_with(['.', '-']) + && !name.contains(['/', '\\']) + && !name.chars().any(char::is_control) +} + +pub fn check_repo_name(name: &str) -> Result<()> { + if valid_repo_name(name) { + Ok(()) + } else { + Err(Error::Other(format!( + "refusing repository name {name:?}: not a plain directory name" + ))) + } +} + +/// Host (lowercase, no user info, no port) of an `https://`, `ssh://` or scp-like +/// (`user@host:path`) URL. `None` for anything else (`file://`, local paths, `ext::`...). +pub fn url_host(url: &str) -> Option { + if url.starts_with('-') || url.chars().any(char::is_control) { + return None; + } + let authority = if let Some((scheme, rest)) = url.split_once("://") { + if !["https", "ssh"].contains(&scheme) { + return None; + } + rest.split(['/', '?', '#']).next()? + } else { + // scp-like: user@host:path + let (head, _) = url.split_once(':')?; + if !head.contains('@') || head.contains('/') { + return None; + } + head + }; + let host = authority.rsplit_once('@').map_or(authority, |(_, h)| h); + let host = if host.starts_with('[') { + host + } else { + host.split(':').next()? + }; + (!host.is_empty()).then(|| host.to_lowercase()) +} + +/// Ok when `url` is a clonable https/ssh URL on the provider's own host. +pub fn check_git_url(url: &str, expected_host: &str) -> Result<()> { + match url_host(url) { + Some(h) if h.eq_ignore_ascii_case(expected_host) => Ok(()), + Some(h) => Err(Error::Other(format!( + "refusing URL {url:?}: host {h} is not the provider's host {expected_host}" + ))), + None => Err(Error::Other(format!( + "refusing URL {url:?}: only https://, ssh:// and user@host:path URLs are accepted" + ))), + } +} + +/// Host (no port) the provider's forge answers on; `github.com` for GitHub without a URL. +pub fn provider_host(cfg: &ProviderCfg) -> String { + let base = provider_base(cfg); + url_host(&base).unwrap_or_default() +} + +/// `https://host[:port]` of the provider's web/git endpoint (no trailing slash). +pub fn provider_base(cfg: &ProviderCfg) -> String { + let url = cfg.url.as_deref().map(str::trim).unwrap_or_default(); + let (scheme, rest) = url.split_once("://").unwrap_or(("https", url)); + let authority = rest.split(['/', '?', '#']).next().unwrap_or_default(); + let authority = authority.rsplit_once('@').map_or(authority, |(_, h)| h); + match cfg.kind { + ProviderKind::Github => { + let h = authority.strip_prefix("api.").unwrap_or(authority); + format!("https://{}", if h.is_empty() { "github.com" } else { h }) + } + _ if authority.is_empty() => String::new(), + _ => format!("{scheme}://{authority}"), + } +} + +/// `(owner, name)` of the path of a git URL (any accepted form), without a trailing `.git`. +pub fn owner_and_name(url: &str) -> Option<(String, String)> { + url_host(url)?; + let path = match url.split_once("://") { + Some((_, rest)) => rest.split_once('/')?.1, + None => url.split_once(':')?.1, + }; + let path = path.trim_matches('/'); + let path = path.strip_suffix(".git").unwrap_or(path); + let (owner, name) = path.rsplit_once('/')?; + // Only the last two segments matter (a forge may live under a sub-path). + let owner = owner.rsplit('/').next()?; + (!owner.is_empty() && !name.is_empty()).then(|| (owner.to_string(), name.to_string())) +} + +/// The canonical https clone URL of the repo a git URL points to, on the provider `cfg`. +/// `None` when the URL's host is not the provider's. +pub fn canonical_https(cfg: &ProviderCfg, url: &str) -> Option { + if !url_host(url)?.eq_ignore_ascii_case(&provider_host(cfg)) { + return None; + } + let (owner, name) = owner_and_name(url)?; + if !valid_repo_name(&name) || !valid_repo_name(&owner) { + return None; + } + Some(format!("{}/{owner}/{name}.git", provider_base(cfg))) +} + +#[cfg(test)] +mod tests { + use super::*; + use grove_core::config::Protocol; + + fn cfg(kind: ProviderKind, url: Option<&str>) -> ProviderCfg { + ProviderCfg { + kind, + protocol: Protocol::Https, + url: url.map(Into::into), + } + } + + #[test] + fn repo_names_must_be_plain() { + for ok in ["a", "my-repo", "x.y", "Synapse_2"] { + assert!(valid_repo_name(ok), "{ok}"); + } + for bad in [ + "", "..", ".", ".hidden", "-rf", "a/b", "a\\b", "a\nb", "a\u{7}", + ] { + assert!(!valid_repo_name(bad), "{bad:?}"); + } + } + + #[test] + fn only_https_ssh_and_scp_urls_on_the_right_host() { + let g = "git.example.es"; + for ok in [ + "https://git.example.es/o/r.git", + "https://tok@git.example.es:3000/o/r.git", + "ssh://gitea@git.example.es:2222/o/r.git", + "git@git.example.es:o/r.git", + ] { + assert!(check_git_url(ok, g).is_ok(), "{ok}"); + } + for bad in [ + "https://evil.example/o/r.git", + "git@evil.example:o/r.git", + "file:///etc/passwd", + "/local/path", + "ext::sh -c id", + "--upload-pack=x", + "http://git.example.es/o/r.git", + "git://git.example.es/o/r.git", + ] { + assert!(check_git_url(bad, g).is_err(), "{bad}"); + } + } + + #[test] + fn canonical_urls_follow_the_provider() { + let gitea = cfg(ProviderKind::Gitea, Some("https://git.example.es/")); + let want = Some("https://git.example.es/dasemu/x.git".to_string()); + assert_eq!( + canonical_https(&gitea, "ssh://gitea@git.example.es:2222/dasemu/x.git"), + want + ); + assert_eq!( + canonical_https(&gitea, "https://git.example.es/dasemu/x"), + want + ); + assert_eq!( + canonical_https(&gitea, "https://evil.example/dasemu/x.git"), + None + ); + let gh = cfg(ProviderKind::Github, None); + assert_eq!( + canonical_https(&gh, "git@github.com:Dasemu/Synapse.git").as_deref(), + Some("https://github.com/Dasemu/Synapse.git") + ); + let ghe = cfg(ProviderKind::Github, Some("https://api.ghe.example.com")); + assert_eq!(provider_host(&ghe), "ghe.example.com"); + } +} diff --git a/crates/grove-providers/tests/api.rs b/crates/grove-providers/tests/api.rs index 467cbf1..9c0beb3 100644 --- a/crates/grove-providers/tests/api.rs +++ b/crates/grove-providers/tests/api.rs @@ -87,6 +87,7 @@ fn gitea_connection_list_create_and_mirror() { 200, r#"[{"name":"a","private":true,"clone_url":"u/a.git","default_branch":"main","owner":{"login":"dasemu"}}]"#, ), + (200, "[]"), ( 201, r#"{"name":"n","private":true,"clone_url":"u/n.git","default_branch":"main","owner":{"login":"dasemu"}}"#, @@ -115,6 +116,7 @@ fn gitea_connection_list_create_and_mirror() { .unwrap(); assert_eq!(r.clone_url, "u/n.git"); rx.recv().unwrap(); + rx.recv().unwrap(); // the empty second page let create = rx.recv().unwrap(); assert!(create.starts_with("POST /api/v1/user/repos "), "{create}"); assert_eq!(body(&create)["private"], true); @@ -385,13 +387,16 @@ fn gitea_owner_listing_uses_the_org_endpoint_or_the_users_own() { let user = format!("[{REPO_B},{REPO_C}]"); let (url, rx) = mock(vec![ (200, Box::leak(org.into_boxed_str())), + (200, "[]"), (200, Box::leak(user.into_boxed_str())), + (200, "[]"), ]); let g = Gitea::new(ProviderKind::Gitea, &url, "t".into()); let r = g.list_owner_repos("Org", "me").unwrap(); assert_eq!(r.len(), 1); assert_eq!(r[0].ssh_url, "git@h:o/a.git"); assert!(lines(&rx.recv().unwrap()).starts_with("GET /api/v1/orgs/Org/repos?limit=50&page=1 ")); + assert!(lines(&rx.recv().unwrap()).contains("page=2 ")); // The login itself: `/user/repos`, then only its own repos (org repos it can see are dropped). let r = g.list_owner_repos("ME", "me").unwrap(); assert_eq!(r.iter().map(|r| r.name.as_str()).collect::>(), ["b"]); @@ -399,13 +404,17 @@ fn gitea_owner_listing_uses_the_org_endpoint_or_the_users_own() { } #[test] -fn github_owner_listing_scopes_the_query_and_falls_back_for_users() { +fn github_owner_listing_scopes_the_query_and_sees_collaborator_repos_of_users() { let org = format!("[{REPO_A}]"); let mine = format!("[{REPO_B}]"); + let collab = format!("[{REPO_C},{REPO_B}]"); let (url, rx) = mock(vec![ (200, Box::leak(org.into_boxed_str())), + (200, "[]"), (200, Box::leak(mine.into_boxed_str())), + (200, "[]"), (404, r#"{"message":"Not Found"}"#), + (200, Box::leak(collab.into_boxed_str())), (200, "[]"), ]); let g = GitHub::new(&url, "t".into()); @@ -413,26 +422,46 @@ fn github_owner_listing_scopes_the_query_and_falls_back_for_users() { assert!( lines(&rx.recv().unwrap()).starts_with("GET /orgs/Org/repos?type=all&per_page=100&page=1 ") ); + rx.recv().unwrap(); assert_eq!(g.list_owner_repos("me", "me").unwrap().len(), 1); assert!( lines(&rx.recv().unwrap()) .starts_with("GET /user/repos?affiliation=owner&per_page=100&page=1 ") ); - // Not an organisation (404): the other user's public repos. - assert!(g.list_owner_repos("someone", "me").unwrap().is_empty()); rx.recv().unwrap(); - assert!( - lines(&rx.recv().unwrap()).starts_with("GET /users/someone/repos?per_page=100&page=1 ") - ); + // Not an organisation (404): what the token sees under that name, private ones included. + let r = g.list_owner_repos("x", "me").unwrap(); + assert_eq!(r.iter().map(|r| r.name.as_str()).collect::>(), ["c"]); + rx.recv().unwrap(); + assert!(lines(&rx.recv().unwrap()).starts_with( + "GET /user/repos?affiliation=owner,collaborator,organization_member&per_page=100&page=1 " + )); +} + +#[test] +fn a_short_page_is_not_the_end_of_a_listing() { + // A server that caps the page size below the request: page 1 has 2 items, page 2 has 1. + let p1 = format!("[{REPO_A},{REPO_B}]"); + let p2 = format!("[{REPO_C}]"); + let (url, _rx) = mock(vec![ + (200, Box::leak(p1.into_boxed_str())), + (200, Box::leak(p2.into_boxed_str())), + (200, "[]"), + ]); + let g = GitHub::new(&url, "t".into()); + assert_eq!(g.list_repos().unwrap().len(), 3); } #[test] fn git_url_follows_the_protocol_and_needs_an_ssh_url_for_ssh() { use grove_core::config::Protocol; - let (url, _rx) = mock(vec![( - 200, - Box::leak(format!("[{REPO_B},{REPO_C}]").into_boxed_str()), - )]); + let (url, _rx) = mock(vec![ + ( + 200, + Box::leak(format!("[{REPO_B},{REPO_C}]").into_boxed_str()), + ), + (200, "[]"), + ]); let g = Gitea::new(ProviderKind::Gitea, &url, "t".into()); let r = g.list_repos().unwrap(); assert_eq!(r[0].git_url(Protocol::Https).unwrap(), "https://h/me/b.git"); From fdc5a8f5a640fe333392db4bbe0ceb71217aa0d4 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 18:54:12 +0100 Subject: [PATCH 16/19] fix(core): clone rolls back what it created and refuses a non-empty directory - failure after the clone step removes the .bare and worktree dirs it made - a directory it created is removed once the busy marker is gone - if cleanup fails, .grove-stage makes the daemon report the repo as stalled - git clone gets -- before url and path Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-core/src/registry.rs | 123 +++++++++++++++++++++++++++- crates/grove-core/tests/registry.rs | 55 +++++++++++++ 2 files changed, 176 insertions(+), 2 deletions(-) diff --git a/crates/grove-core/src/registry.rs b/crates/grove-core/src/registry.rs index 7ffa970..7da8120 100644 --- a/crates/grove-core/src/registry.rs +++ b/crates/grove-core/src/registry.rs @@ -5,6 +5,7 @@ use crate::git::{Git, GitError}; use crate::layout::dir_name; use crate::receive::{ensure_fetch_refspec, materialize}; use serde::{Deserialize, Serialize}; +use std::fs; use std::path::{Path, PathBuf}; #[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize, Serialize)] @@ -47,19 +48,104 @@ impl Registry { /// Creates `/.bare` as a clone of `url` and a worktree per remote branch. /// `envs` are extra git environment variables (credentials). +/// +/// `dir` must not exist or be empty. If anything fails, what this call created is removed again +/// (the `.bare`, the worktree directories, `dir` itself when it created it); if that is not +/// possible a `.grove-stage` marker is left so the daemon reports the repo as stalled instead of +/// adopting a half-built one. pub fn clone_bare_layout( url: &str, dir: &Path, envs: &[(String, String)], ) -> Result, GitError> { + clone_bare_layout_impl(url, dir, envs, false) +} + +#[doc(hidden)] +pub fn clone_bare_layout_failing_after_clone( + url: &str, + dir: &Path, + envs: &[(String, String)], +) -> Result, GitError> { + clone_bare_layout_impl(url, dir, envs, true) +} + +fn clone_bare_layout_impl( + url: &str, + dir: &Path, + envs: &[(String, String)], + fail_after_clone: bool, +) -> Result, GitError> { + let created_dir = !dir.exists(); + let non_empty = !created_dir + && fs::read_dir(dir) + .map_err(|e| GitError::Other(format!("{}: {e}", dir.display())))? + .next() + .is_some(); + if non_empty { + return Err(GitError::Other(format!( + "{} already exists and is not empty", + dir.display() + ))); + } // Released last: until then the daemon ignores the half-built repo. - let _busy = crate::busy::BusyGuard::acquire(dir)?; + let busy = crate::busy::BusyGuard::acquire(dir) + .map_err(|e| GitError::Other(format!("{}: {e}", dir.display())))?; + let res = clone_steps(url, dir, envs, fail_after_clone); + if res.is_err() { + rollback_clone(dir); + } + drop(busy); + if res.is_err() && created_dir { + // Only while empty: `remove_dir` refuses anything else. + let _ = fs::remove_dir(dir); + } + res +} + +/// Removes everything in `dir` except the busy marker (the caller guarantees `dir` was empty +/// before the clone started). On failure, leaves `.grove-stage` behind. +fn rollback_clone(dir: &Path) { + let mut failed = false; + if let Ok(rd) = fs::read_dir(dir) { + for e in rd.filter_map(Result::ok) { + if e.file_name() == crate::busy::BUSY { + continue; + } + let p = e.path(); + let r = if e.file_type().is_ok_and(|t| t.is_dir()) { + fs::remove_dir_all(&p) + } else { + fs::remove_file(&p) + }; + failed |= r.is_err(); + } + } else { + failed = true; + } + if failed { + let _ = fs::write( + dir.join(".grove-stage"), + "a failed clone could not be cleaned up; remove this directory's contents by hand\n", + ); + } +} + +fn clone_steps( + url: &str, + dir: &Path, + envs: &[(String, String)], + fail_after_clone: bool, +) -> Result, GitError> { let bare = dir.join(".bare"); let mut g = Git::new(dir); for (k, v) in envs { g = g.with_env(k, v); } - g.run(&["clone", "-q", "--bare", url, &bare.to_string_lossy()])?; + g.run(&["clone", "-q", "--bare", "--", url, &bare.to_string_lossy()])?; + if fail_after_clone { + return Err(GitError::Other("injected failure".into())); + } Git::new(&bare).run(&["config", "core.bare", "true"])?; ensure_fetch_refspec(&bare, "origin")?; let mut f = Git::new(&bare); @@ -124,3 +210,36 @@ pub fn push_initial(dir: &Path, envs: &[(String, String)]) -> Result<(), GitErro g.run(&["push", "-q", "-u", "origin", "main"])?; Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + use std::os::unix::fs::PermissionsExt; + + #[test] + fn rollback_that_cannot_remove_everything_leaves_a_stage_marker() { + let d = std::env::temp_dir().join(format!("grove-rb-{}", std::process::id())); + let _ = fs::remove_dir_all(&d); + let locked = d.join(".bare/locked"); + fs::create_dir_all(&locked).unwrap(); + fs::write(locked.join("f"), "x").unwrap(); + fs::write(d.join(crate::busy::BUSY), "1 1\n").unwrap(); + fs::set_permissions(&locked, fs::Permissions::from_mode(0o500)).unwrap(); + rollback_clone(&d); + assert!(d.join(".grove-stage").exists()); + assert!( + d.join(crate::busy::BUSY).exists(), + "the marker is the guard's to remove" + ); + fs::set_permissions(&locked, fs::Permissions::from_mode(0o700)).unwrap(); + let _ = fs::remove_dir_all(&d); + + // Everything removable: nothing left but the busy marker, no stage marker. + fs::create_dir_all(d.join(".bare")).unwrap(); + fs::create_dir_all(d.join("main")).unwrap(); + fs::write(d.join(crate::busy::BUSY), "1 1\n").unwrap(); + rollback_clone(&d); + assert!(!d.join(".grove-stage").exists() && !d.join(".bare").exists()); + let _ = fs::remove_dir_all(&d); + } +} diff --git a/crates/grove-core/tests/registry.rs b/crates/grove-core/tests/registry.rs index 0bf2d3c..833bb22 100644 --- a/crates/grove-core/tests/registry.rs +++ b/crates/grove-core/tests/registry.rs @@ -74,3 +74,58 @@ fn registry_roundtrip_and_upsert() { assert_eq!(r.repos[0].group, "a"); assert_eq!(Registry::parse(&r.to_text()).unwrap(), r); } + +fn remote_with_main(base: &std::path::Path) -> String { + let remote = base.join("r.git"); + Git::new(base) + .run(&[ + "init", + "-q", + "--bare", + "-b", + "main", + remote.to_str().unwrap(), + ]) + .unwrap(); + let a = base.join("A/g/proj"); + init_bare_layout(&a, remote.to_str().unwrap()).unwrap(); + push_initial(&a, &[]).unwrap(); + remote.to_str().unwrap().to_string() +} + +#[test] +fn clone_failing_after_the_clone_step_removes_what_it_created() { + let base = tmpdir("regfail"); + let url = remote_with_main(&base); + + // A directory the clone creates itself: gone afterwards, no marker left. + let fresh = base.join("B/g/fresh"); + assert!(clone_bare_layout_failing_after_clone(&url, &fresh, &[]).is_err()); + assert!(!fresh.exists()); + + // A pre-existing empty directory stays, empty and without markers. + let empty = base.join("B/g/empty"); + fs::create_dir_all(&empty).unwrap(); + assert!(clone_bare_layout_failing_after_clone(&url, &empty, &[]).is_err()); + assert_eq!(fs::read_dir(&empty).unwrap().count(), 0); + + // The retry works: nothing half-built is in the way. + clone_bare_layout(&url, &fresh, &[]).unwrap(); + assert!(fresh.join(".bare").is_dir() && !fresh.join(".grove-busy").exists()); + fs::remove_dir_all(&base).unwrap(); +} + +#[test] +fn clone_refuses_a_non_empty_directory_and_touches_nothing() { + let base = tmpdir("regkeep"); + let url = remote_with_main(&base); + let plain = base.join("B/g/plain"); + fs::create_dir_all(plain.join(".git")).unwrap(); + fs::write(plain.join("keep.txt"), "mine").unwrap(); + let e = clone_bare_layout(&url, &plain, &[]).unwrap_err(); + assert!(e.to_string().contains("not empty"), "{e}"); + assert_eq!(fs::read_to_string(plain.join("keep.txt")).unwrap(), "mine"); + assert!(plain.join(".git").is_dir() && !plain.join(".bare").exists()); + assert!(!plain.join(".grove-busy").exists()); + fs::remove_dir_all(&base).unwrap(); +} From 3cba9784a3cee1d4e60b903f94817e64be35ced6 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 18:58:28 +0100 Subject: [PATCH 17/19] fix: import/bootstrap hardening, canonical registry URLs, GUI canonical add path - plain clones count as present; import refuses non-empty targets - registry stores canonical https URLs; bootstrap matches provider by host - clone URLs and repo names validated; GitHub link-style pagination - bridge passes the canonical path to grove add; fix flaky instance test Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-gui/src/bridge.rs | 23 ++- crates/grove-gui/src/instance.rs | 1 + crates/grove-providers/src/gitea.rs | 6 +- crates/grove-providers/src/github.rs | 5 +- crates/grove-providers/src/http.rs | 24 ++- crates/grove-providers/tests/api.rs | 9 +- crates/grove/src/workflow.rs | 244 +++++++++++++++++++++++---- docs/phase7.md | 20 +++ 8 files changed, 273 insertions(+), 59 deletions(-) diff --git a/crates/grove-gui/src/bridge.rs b/crates/grove-gui/src/bridge.rs index 8abd278..b41bddd 100644 --- a/crates/grove-gui/src/bridge.rs +++ b/crates/grove-gui/src/bridge.rs @@ -45,11 +45,15 @@ impl Bridge { if let Err(e) = validate(args) { return json!({"ok": false, "output": format!("rejected: {e}")}); } - if sub == "add" - && let Err(e) = self.check_migrate_args(args) - { - return json!({"ok": false, "output": format!("rejected: {e}")}); + // `add` gets the canonical path the check validated, not the string it was given. + let mut checked: Vec = args.to_vec(); + if sub == "add" { + match self.check_migrate_args(args) { + Ok(canon) => checked[1] = canon.to_string_lossy().into_owned(), + Err(e) => return json!({"ok": false, "output": format!("rejected: {e}")}), + } } + let args = &checked[..]; let mut cmd = Command::new(&self.grove_bin); if let Some(c) = &self.config { cmd.arg("--config").arg(c); @@ -94,12 +98,12 @@ impl Bridge { } /// `add ` only for an existing directory directly under `//`. - fn check_migrate_args(&self, args: &[String]) -> Result<(), String> { + fn check_migrate_args(&self, args: &[String]) -> Result { let [_, path] = args else { return Err("add takes exactly one path".into()); }; let cfg = self.loaded_config().ok_or("no readable configuration")?; - check_migrate_path(&cfg, Path::new(path)).map(|_| ()) + check_migrate_path(&cfg, Path::new(path)) } /// Where `grove add` writes its safety backup. @@ -255,7 +259,7 @@ mod tests { )).unwrap(); // A stand-in `grove` that reports what it was asked to do. let fake = base.join("grove"); - std::fs::write(&fake, "#!/bin/sh\necho \"migrated: $3/wt\"\n").unwrap(); + std::fs::write(&fake, "#!/bin/sh\necho \"migrated: $4/wt\"\n").unwrap(); std::fs::set_permissions(&fake, std::fs::Permissions::from_mode(0o755)).unwrap(); let b = Bridge { grove_bin: fake, @@ -268,6 +272,11 @@ mod tests { ); assert_eq!(ok["ok"], true, "{ok}"); assert!(ok["output"].as_str().unwrap().starts_with("migrated:")); + // A path with `..`/symlink parts reaches `grove add` in canonical form. + let sneaky = format!("{}/work/../work/proj", base.display()); + let canon = base.join("work/proj").canonicalize().unwrap(); + let r = b.cli(&["add".into(), sneaky], ""); + assert_eq!(r["output"], format!("migrated: {}/wt", canon.display())); let bad = b.cli( &["add".into(), base.join("elsewhere").display().to_string()], "", diff --git a/crates/grove-gui/src/instance.rs b/crates/grove-gui/src/instance.rs index eec1aa4..c3b1fa4 100644 --- a/crates/grove-gui/src/instance.rs +++ b/crates/grove-gui/src/instance.rs @@ -124,6 +124,7 @@ mod tests { fn tmp_sock(tag: &str) -> PathBuf { let d = std::env::temp_dir().join(format!("gg-{tag}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&d); // leftovers of an earlier run with the same pid std::fs::create_dir_all(&d).unwrap(); std::fs::set_permissions(&d, std::fs::Permissions::from_mode(0o700)).unwrap(); d.join("gui.sock") diff --git a/crates/grove-providers/src/gitea.rs b/crates/grove-providers/src/gitea.rs index cbbfb19..a446351 100644 --- a/crates/grove-providers/src/gitea.rs +++ b/crates/grove-providers/src/gitea.rs @@ -70,7 +70,7 @@ impl Provider for Gitea { fn list_repos(&self) -> Result> { Ok(self .http - .pages("/user/repos", 50, "limit")? + .pages("/user/repos", 50, "limit", false)? .iter() .map(repo) .collect()) @@ -82,7 +82,7 @@ impl Provider for Gitea { } else { format!("/orgs/{owner}/repos") }; - let items = match self.http.pages(&path, 50, "limit") { + let items = match self.http.pages(&path, 50, "limit", false) { Ok(v) => v, // Not an organisation (a user, or an org the token cannot see): say so, and take // what the token can see under that name, private repos it collaborates on included. @@ -90,7 +90,7 @@ impl Provider for Gitea { eprintln!( "grove: /orgs/{owner} not found; listing the repositories you can see owned by {owner}" ); - self.http.pages("/user/repos", 50, "limit")? + self.http.pages("/user/repos", 50, "limit", false)? } Err(e) => return Err(e), }; diff --git a/crates/grove-providers/src/github.rs b/crates/grove-providers/src/github.rs index 4ad8855..6af2adf 100644 --- a/crates/grove-providers/src/github.rs +++ b/crates/grove-providers/src/github.rs @@ -77,7 +77,7 @@ impl Provider for GitHub { fn list_repos(&self) -> Result> { Ok(self .http - .pages("/user/repos", 100, "per_page")? + .pages("/user/repos", 100, "per_page", true)? .iter() .map(repo) .collect()) @@ -89,7 +89,7 @@ impl Provider for GitHub { } else { format!("/orgs/{owner}/repos?type=all") }; - let items = match self.http.pages(&path, 100, "per_page") { + let items = match self.http.pages(&path, 100, "per_page", true) { Ok(v) => v, // Not an organisation (a user, or an org the token cannot see): say so, and take // what the token can see under that name, private repos it collaborates on included. @@ -101,6 +101,7 @@ impl Provider for GitHub { "/user/repos?affiliation=owner,collaborator,organization_member", 100, "per_page", + true, )? } Err(e) => return Err(e), diff --git a/crates/grove-providers/src/http.rs b/crates/grove-providers/src/http.rs index 9959a5e..1e20c24 100644 --- a/crates/grove-providers/src/http.rs +++ b/crates/grove-providers/src/http.rs @@ -85,9 +85,15 @@ impl Http { /// Every item of a paginated list endpoint (`path` may already carry a query string). /// /// A short page is not the end (a server may cap the page size below what was asked). It - /// ends on `X-Total-Count` being reached, on a `Link` header without `rel="next"`, or on an - /// empty or repeated page. - pub fn pages(&self, path: &str, per_page: usize, size_param: &str) -> Result> { + /// ends on `X-Total-Count` being reached, on a `Link` header without `rel="next"` (also when + /// absent, for `link_style` servers such as GitHub), or on an empty or repeated page. + pub fn pages( + &self, + path: &str, + per_page: usize, + size_param: &str, + link_style: bool, + ) -> Result> { let sep = if path.contains('?') { '&' } else { '?' }; let mut out: Vec = Vec::new(); let mut prev: Option> = None; @@ -103,12 +109,12 @@ impl Http { break; } out.extend(items.iter().cloned()); - if hints.total.is_some_and(|t| out.len() >= t) - || hints - .link - .as_deref() - .is_some_and(|l| !l.contains("rel=\"next\"")) - { + // GitHub style: no `Link: rel="next"` means this was the last page. + let no_next = hints + .link + .as_deref() + .map_or(link_style, |l| !l.contains("rel=\"next\"")); + if hints.total.is_some_and(|t| out.len() >= t) || no_next { break; } prev = Some(items); diff --git a/crates/grove-providers/tests/api.rs b/crates/grove-providers/tests/api.rs index 9c0beb3..8ed6369 100644 --- a/crates/grove-providers/tests/api.rs +++ b/crates/grove-providers/tests/api.rs @@ -410,29 +410,24 @@ fn github_owner_listing_scopes_the_query_and_sees_collaborator_repos_of_users() let collab = format!("[{REPO_C},{REPO_B}]"); let (url, rx) = mock(vec![ (200, Box::leak(org.into_boxed_str())), - (200, "[]"), (200, Box::leak(mine.into_boxed_str())), - (200, "[]"), (404, r#"{"message":"Not Found"}"#), (200, Box::leak(collab.into_boxed_str())), - (200, "[]"), ]); let g = GitHub::new(&url, "t".into()); assert_eq!(g.list_owner_repos("Org", "me").unwrap().len(), 1); assert!( lines(&rx.recv().unwrap()).starts_with("GET /orgs/Org/repos?type=all&per_page=100&page=1 ") ); - rx.recv().unwrap(); assert_eq!(g.list_owner_repos("me", "me").unwrap().len(), 1); assert!( lines(&rx.recv().unwrap()) .starts_with("GET /user/repos?affiliation=owner&per_page=100&page=1 ") ); - rx.recv().unwrap(); // Not an organisation (404): what the token sees under that name, private ones included. let r = g.list_owner_repos("x", "me").unwrap(); assert_eq!(r.iter().map(|r| r.name.as_str()).collect::>(), ["c"]); - rx.recv().unwrap(); + rx.recv().unwrap(); // the 404 on /orgs/x assert!(lines(&rx.recv().unwrap()).starts_with( "GET /user/repos?affiliation=owner,collaborator,organization_member&per_page=100&page=1 " )); @@ -448,7 +443,7 @@ fn a_short_page_is_not_the_end_of_a_listing() { (200, Box::leak(p2.into_boxed_str())), (200, "[]"), ]); - let g = GitHub::new(&url, "t".into()); + let g = Gitea::new(ProviderKind::Gitea, &url, "t".into()); assert_eq!(g.list_repos().unwrap().len(), 3); } diff --git a/crates/grove/src/workflow.rs b/crates/grove/src/workflow.rs index baa38b1..c5a8259 100644 --- a/crates/grove/src/workflow.rs +++ b/crates/grove/src/workflow.rs @@ -6,7 +6,9 @@ use grove_core::config::{ }; use grove_core::git::Git; use grove_core::registry::{Entry, Registry, clone_bare_layout, init_bare_layout, push_initial}; -use grove_providers::{MirrorSpec, NewRepo, Provider, PullMirrorSpec, RemoteRepo, build, token}; +use grove_providers::{ + MirrorSpec, NewRepo, Provider, PullMirrorSpec, RemoteRepo, build, token, url, +}; use std::fs; use std::path::{Path, PathBuf}; @@ -18,6 +20,29 @@ pub struct Forge { /// Git environment that authenticates HTTPS operations with the stored token. pub git_env: Vec<(String, String)>, pub protocol: Protocol, + pub cfg: ProviderCfg, +} + +impl Forge { + /// The URL local git uses for `r` with this provider's protocol. The repo name must be a + /// plain directory name and both URLs the forge reports must be https/ssh URLs on the + /// provider's own host: credentials never go anywhere else. + pub fn clone_url(&self, r: &RemoteRepo) -> Result { + let host = url::provider_host(&self.cfg); + url::check_repo_name(&r.name)?; + for u in [&r.clone_url, &r.ssh_url] { + if !u.is_empty() { + url::check_git_url(u, &host)?; + } + } + Ok(r.git_url(self.protocol)?.to_string()) + } + + /// The canonical https URL stored in the registry for `r`. + pub fn registry_url(&self, r: &RemoteRepo) -> Result { + url::canonical_https(&self.cfg, &r.clone_url) + .with_context(|| format!("no canonical URL for {}/{}", r.owner, r.name)) + } } pub fn connect(cfg: &Config, id: &str) -> Result { @@ -63,6 +88,7 @@ pub fn connect(cfg: &Config, id: &str) -> Result { token: tok, git_env, protocol: pc.protocol, + cfg: pc.clone(), }) } @@ -204,7 +230,8 @@ pub fn new_repo(cfg: &Config, group_name: &str, name: &str, private: bool) -> Re "created {}/{} on {}", remote.owner, remote.name, route.primary ); - let local_url = remote.git_url(primary.protocol)?.to_string(); + let local_url = primary.clone_url(&remote)?; + let registry_url = primary.registry_url(&remote)?; let wt = init_bare_layout(&dir, &local_url)?; push_initial(&dir, &primary.git_env)?; println!("pushed initial commit; worktree {}", wt.display()); @@ -220,7 +247,7 @@ pub fn new_repo(cfg: &Config, group_name: &str, name: &str, private: bool) -> Re &Entry { group: grp.name.clone(), name: name.into(), - url: local_url, + url: registry_url, }, )?; Ok(wt) @@ -300,10 +327,12 @@ fn remote_key(url: &str) -> Option { Some(format!("{host}/{owner}/{name}").to_lowercase()) } -/// What is already in a group directory: bare-layout repos by lowercase directory name and by -/// the owner/name their `origin` points to. +/// What is already in a group directory: anything non-empty by lowercase directory name, plain +/// (not yet migrated) clones among them, and the owner/name the `origin` of bare-layout repos +/// points to. struct Local { names: std::collections::HashSet, + plain: std::collections::HashSet, origins: std::collections::HashSet, } @@ -311,16 +340,26 @@ impl Local { fn scan(gdir: &Path) -> Local { let mut l = Local { names: Default::default(), + plain: Default::default(), origins: Default::default(), }; let Ok(rd) = fs::read_dir(gdir) else { return l }; for e in rd.filter_map(Result::ok) { - let bare = e.path().join(".bare"); + let p = e.path(); + // An empty directory is free to import into; anything else is somebody's files. + let non_empty = fs::read_dir(&p).is_ok_and(|mut d| d.next().is_some()); + if !non_empty { + continue; + } + let name = e.file_name().to_string_lossy().to_lowercase(); + l.names.insert(name.clone()); + let bare = p.join(".bare"); if !bare.exists() { + if p.join(".git").exists() { + l.plain.insert(name); + } continue; } - l.names - .insert(e.file_name().to_string_lossy().to_lowercase()); if let Ok(Some(url)) = Git::new(&bare).probe(&["config", "--get", "remote.origin.url"]) && let Some(k) = remote_key(&url) { @@ -330,8 +369,8 @@ impl Local { l } - /// Present when a repo of that name exists (case-insensitively: forge names are, and so are - /// many file systems) or an existing repo's origin is this very remote. + /// Present when a non-empty directory of that name exists (case-insensitively: forge names + /// are, and so are many file systems) or an existing repo's origin is this very remote. fn has(&self, r: &RemoteRepo) -> bool { self.names.contains(&r.name.to_lowercase()) || [&r.clone_url, &r.ssh_url] @@ -339,6 +378,11 @@ impl Local { .filter_map(|u| remote_key(u)) .any(|k| self.origins.contains(&k)) } + + /// A plain, not yet migrated clone of that name. + fn is_plain(&self, r: &RemoteRepo) -> bool { + self.plain.contains(&r.name.to_lowercase()) + } } /// Lists the group's remote repos that are not on disk; clones the named ones. @@ -362,7 +406,17 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { sc.spawn(move || { let f = connect(cfg, pid)?; let owner = grp.owner(pid).unwrap_or(&f.login).to_string(); - let repos = select(f.api.list_owner_repos(&owner, &f.login)?, &owner, *vis); + let mut repos = select(f.api.list_owner_repos(&owner, &f.login)?, &owner, *vis); + repos.retain(|r| { + let ok = url::valid_repo_name(&r.name); + if !ok { + eprintln!( + "grove: skipping {}/{}: not a plain directory name", + r.owner, r.name + ); + } + ok + }); Ok((pid.clone(), f, repos)) }) }) @@ -376,11 +430,14 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { }); let mut forges = Vec::new(); let mut missing: Vec<(RemoteRepo, usize)> = Vec::new(); + let mut plain: Vec = Vec::new(); let local = Local::scan(&gdir); for res in scanned { let (pid, f, repos) = res?; for r in repos { - if !local.has(&r) && !missing.iter().any(|(m, _)| m.name == r.name) { + if local.is_plain(&r) { + plain.push(r); + } else if !local.has(&r) && !missing.iter().any(|(m, _)| m.name == r.name) { missing.push((r, forges.len())); } } @@ -397,6 +454,12 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { if r.private { " (private)" } else { "" } ); } + if !plain.is_empty() { + println!("already here as plain clones (not migrated: use `grove add `):"); + for r in &plain { + println!("- {}/{}", r.owner, r.name); + } + } println!("run `grove import {group_name} ...` to clone them"); return Ok(()); } @@ -404,30 +467,27 @@ pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { let mut failed: Vec = Vec::new(); for w in wanted { let Some((r, i)) = missing.iter().find(|(r, _)| &r.name == w) else { - println!("FAILED {w}: not a remote repo missing locally"); + if plain.iter().any(|r| &r.name == w) { + println!("FAILED {w}: local clone, not migrated; use `grove add`"); + } else { + println!("FAILED {w}: not a remote repo missing locally"); + } failed.push(w.clone()); continue; }; let forge = &forges[*i].1; let res = (|| -> Result<()> { - let url = r.git_url(forge.protocol)?.to_string(); + let url = forge.clone_url(r)?; let dir = gdir.join(&r.name); - let existed = dir.exists(); - if let Err(e) = clone_bare_layout(&url, &dir, &forge.git_env) { - // The busy marker is released by now. Remove only a directory this import - // created, and only while it is empty (`remove_dir` refuses anything else). - if !existed { - let _ = fs::remove_dir(&dir); - } - return Err(e.into()); - } + // Refuses a non-empty directory and cleans up after itself on failure. + clone_bare_layout(&url, &dir, &forge.git_env)?; println!("imported {} -> {}", r.name, dir.display()); register( cfg, &Entry { group: grp.name.clone(), name: r.name.clone(), - url, + url: forge.registry_url(r)?, }, ) })(); @@ -470,7 +530,7 @@ pub(crate) fn config_repo_open(cfg: &Config, create: bool) -> Result<(PathBuf, F .into_iter() .find(|r| r.name == cr.name); let url = match exists { - Some(r) => r.git_url(forge.protocol)?.to_string(), + Some(r) => forge.clone_url(&r)?, None if create => { let r = forge.api.create_repo(&NewRepo { name: cr.name.clone(), @@ -478,7 +538,7 @@ pub(crate) fn config_repo_open(cfg: &Config, create: bool) -> Result<(PathBuf, F private: true, description: "grove configuration (managed repos, machines)".into(), })?; - r.git_url(forge.protocol)?.to_string() + forge.clone_url(&r)? } None => bail!( "config repo {:?} does not exist on {}", @@ -552,7 +612,17 @@ pub fn register(cfg: &Config, e: &Entry) -> Result<()> { ) } +/// The configured provider whose host `url` is on (first by id when several share a host). +fn provider_for_url<'a>(cfg: &'a Config, url: &str) -> Option<(&'a String, &'a ProviderCfg)> { + let host = url::url_host(url)?; + cfg.providers + .iter() + .find(|(_, p)| url::provider_host(p).eq_ignore_ascii_case(&host)) +} + /// First machine: creates the config repo (if needed) and registers every repo already on disk. +/// Entries hold the canonical https URL; a repo whose origin is on no configured provider is +/// skipped with a warning. pub fn config_repo_init(cfg: &Config) -> Result { let (dir, forge) = config_repo_open(cfg, true)?; let mut reg = read_registry(&dir)?; @@ -566,14 +636,24 @@ pub fn config_repo_init(cfg: &Config) -> Result { if !bare.is_dir() { continue; } - let Some(url) = Git::new(&bare).probe(&["config", "--get", "remote.origin.url"])? + let Some(origin) = Git::new(&bare).probe(&["config", "--get", "remote.origin.url"])? else { continue; }; + let name = e.file_name().to_string_lossy().into_owned(); + let Some(canon) = + provider_for_url(cfg, &origin).and_then(|(_, p)| url::canonical_https(p, &origin)) + else { + println!( + "warning: {}/{name}: origin {origin:?} is on no configured provider; not registered", + grp.name + ); + continue; + }; reg.upsert(Entry { group: grp.name.clone(), - name: e.file_name().to_string_lossy().into_owned(), - url, + name, + url: canon, }); } } @@ -583,23 +663,69 @@ pub fn config_repo_init(cfg: &Config) -> Result { Ok(reg.repos.len()) } +/// Where and how to clone a registry entry on this machine: the provider is chosen by the +/// entry's host, the transport by that provider's local `protocol`, the credentials are that +/// provider's. An entry on a host no provider serves is refused (a token never leaves its host). +/// Entries written with ssh or https URLs are both understood. +fn plan_clone( + cfg: &Config, + forges: &mut std::collections::HashMap, + e: &Entry, +) -> Result<(String, String)> { + if !url::valid_repo_name(&e.name) || !url::valid_repo_name(&e.group) { + bail!( + "refusing entry {}/{}: not plain directory names", + e.group, + e.name + ); + } + let (pid, pc) = provider_for_url(cfg, &e.url) + .with_context(|| format!("no configured provider serves the host of {:?}", e.url))?; + let canon = url::canonical_https(pc, &e.url) + .with_context(|| format!("cannot read owner/name from {:?}", e.url))?; + if !forges.contains_key(pid) { + forges.insert(pid.clone(), connect(cfg, pid)?); + } + let forge = &forges[pid]; + let target = match forge.protocol { + Protocol::Https => { + url::check_git_url(&canon, &url::provider_host(pc))?; + canon + } + Protocol::Ssh => { + let (owner, name) = url::owner_and_name(&canon).context("bad registry URL")?; + forge.clone_url(&forge.api.get_repo(&owner, &name)?)? + } + }; + Ok((pid.clone(), target)) +} + /// Fresh machine: materializes every repo of the config repo under the root. pub fn bootstrap(cfg: &Config) -> Result<(usize, usize)> { let (dir, forge) = config_repo_open(cfg, false)?; let reg = read_registry(&dir)?; let (mut done, mut skipped) = (0, 0); + let mut forges = std::collections::HashMap::new(); for e in ®.repos { + // Names are checked before they are joined to a path. + if !url::valid_repo_name(&e.name) || !url::valid_repo_name(&e.group) { + println!("FAILED {}/{}: not plain directory names", e.group, e.name); + continue; + } let target = cfg.root_path().join(&e.group).join(&e.name); if target.join(".bare").exists() { skipped += 1; continue; } - match clone_bare_layout(&e.url, &target, &forge.git_env) { + let res = plan_clone(cfg, &mut forges, e).and_then(|(pid, u)| { + clone_bare_layout(&u, &target, &forges[&pid].git_env).map_err(Into::into) + }); + match res { Ok(_) => { println!("cloned {}/{}", e.group, e.name); done += 1; } - Err(err) => println!("FAILED {}/{}: {err}", e.group, e.name), + Err(err) => println!("FAILED {}/{}: {err:#}", e.group, e.name), } } write_heartbeat(cfg, &dir)?; @@ -650,7 +776,15 @@ mod tests { g.run(&["init", "-q", "--bare"]).unwrap(); g.run(&["remote", "add", "origin", origin]).unwrap(); } + // A plain clone and an unrelated non-empty dir count as present; an empty dir does not. + fs::create_dir_all(d.join("plainrepo/.git")).unwrap(); + fs::create_dir_all(d.join("notes")).unwrap(); + fs::write(d.join("notes/x.txt"), "x").unwrap(); + fs::create_dir_all(d.join("emptydir")).unwrap(); let l = Local::scan(&d); + assert!(l.has(&r("me", "PlainRepo", false)) && l.is_plain(&r("me", "plainrepo", false))); + assert!(l.has(&r("me", "notes", false)) && !l.is_plain(&r("me", "notes", false))); + assert!(!l.has(&r("me", "emptydir", false))); let mut syn = r("Dasemu", "Synapse", false); syn.clone_url = "https://github.com/Dasemu/Synapse.git".into(); assert!(l.has(&syn)); @@ -662,6 +796,54 @@ mod tests { let _ = fs::remove_dir_all(&d); } + fn two_provider_cfg() -> Config { + Config::parse( + "[machine]\nname=\"m\"\n[root]\npath=\"/x\"\n\ + [providers.gitea]\nkind=\"gitea\"\nurl=\"https://git.example.es\"\nprotocol=\"ssh\"\n\ + [providers.gh]\nkind=\"github\"\n", + ) + .unwrap() + } + + #[test] + fn registry_entries_pick_their_provider_by_host_in_any_url_form() { + let cfg = two_provider_cfg(); + let id = |u: &str| provider_for_url(&cfg, u).map(|(i, _)| i.as_str()); + assert_eq!(id("https://git.example.es/dasemu/x.git"), Some("gitea")); + assert_eq!( + id("ssh://gitea@git.example.es:2222/dasemu/x.git"), + Some("gitea") + ); + assert_eq!(id("git@github.com:Dasemu/Synapse.git"), Some("gh")); + assert_eq!(id("https://evil.example/dasemu/x.git"), None); + } + + #[test] + fn bootstrap_refuses_entries_on_hosts_no_provider_serves() { + let cfg = two_provider_cfg(); + let mut forges = std::collections::HashMap::new(); + let entry = |u: &str, n: &str| Entry { + group: "g".into(), + name: n.into(), + url: u.into(), + }; + let e = plan_clone( + &cfg, + &mut forges, + &entry("https://evil.example/o/r.git", "r"), + ) + .unwrap_err(); + assert!(e.to_string().contains("no configured provider"), "{e}"); + assert!(forges.is_empty(), "no token lookup for a foreign host"); + let e = plan_clone( + &cfg, + &mut forges, + &entry("https://git.example.es/o/r.git", "../x"), + ) + .unwrap_err(); + assert!(e.to_string().contains("plain directory names"), "{e}"); + } + #[test] fn base64_matches_rfc4648_vectors() { for (i, o) in [ diff --git a/docs/phase7.md b/docs/phase7.md index c3ddabe..6679f7f 100644 --- a/docs/phase7.md +++ b/docs/phase7.md @@ -133,3 +133,23 @@ Activity. `/grove-gui.log` (rotated at 256 KiB) records start-up, daemon subscribe/disconnect, tray errors and restarts, panics with a backtrace (from any thread) and why the event loop ended. + +## Hardening of import, clone and bootstrap + +- Any non-empty directory in the group counts as "already here". A plain clone is listed + separately ("use `grove add`") and `import` refuses it; `clone_bare_layout` refuses a non-empty + target itself. +- A clone that fails after `git clone` removes what it created (`.bare`, worktree directories, + and the directory when it created it). If that fails, `.grove-stage` is left so the daemon + reports the repo as stalled. +- The registry stores canonical https URLs (`https://host/owner/name.git`). `bootstrap` picks the + provider by the entry's host, the transport from that provider's `protocol`, and uses only that + provider's credentials; an entry on a host no provider serves is refused. Old entries with ssh + or https URLs are normalised when read. +- Repo names must be plain directory names (no `/`, `\`, leading `.` or `-`, control chars); + clone URLs must be `https://`, `ssh://` or `user@host:path` on the provider's host; `git clone` + gets `--`. +- Pagination stops on `X-Total-Count`, on a `Link` without `rel="next"` (GitHub), or an empty or + repeated page, not on a short page. For a user that is not the login, GitHub/Gitea listing uses + `/user/repos` (collaborator repos included) and says when `/orgs/{owner}` is a 404. +- The GUI hands `grove add` the canonical path it validated. From 04750532f293744d9ca09aea5eb646c97548c3da Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 19:04:24 +0100 Subject: [PATCH 18/19] fix(daemon): treat a repo whose directory vanishes mid-pass as removed, without error logs Co-Authored-By: Claude Sonnet 5.5 --- crates/grove-daemon/src/daemon.rs | 8 ++++++++ crates/grove-daemon/tests/daemon.rs | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/grove-daemon/src/daemon.rs b/crates/grove-daemon/src/daemon.rs index 994212d..6260fd8 100644 --- a/crates/grove-daemon/src/daemon.rs +++ b/crates/grove-daemon/src/daemon.rs @@ -666,6 +666,13 @@ fn pass( } } } + if !errors.is_empty() && !is_ready(repo) { + // The directory vanished (or stopped being a bare layout) mid-pass: the failure is a + // consequence of the removal, not a sync error. Rediscovery drops the repo and logs + // `repo_removed`. + status.phase = "idle"; + return 0; + } if offline { // A snapshot-only pass during backoff changes neither the failure count nor the phase. status.phase = if status.failures > 0 { "error" } else { "idle" }; @@ -726,6 +733,7 @@ fn purge_snapshots(ctx: &Ctx, repo: &Path, name: &str, cfg: &Config, st: &Settin done.join(", ") ), ), + Err(_) if !is_ready(repo) => {} // removed mid-pass: rediscovery reports it Err(e) => ctx.activity.log( "error", Some(name), diff --git a/crates/grove-daemon/tests/daemon.rs b/crates/grove-daemon/tests/daemon.rs index 9e8bd8b..1500b7d 100644 --- a/crates/grove-daemon/tests/daemon.rs +++ b/crates/grove-daemon/tests/daemon.rs @@ -610,7 +610,11 @@ fn managed_repo_removed_after_start_disappears_without_crash() { // Keep the first repo busy so a pass may be running when the other one vanishes. fs::write(root.join("g/repo/main/busy.txt"), "x\n").unwrap(); - fs::remove_dir_all(root.join("g/second")).unwrap(); + // The daemon may create files in the repo while it is being deleted (ENOTEMPTY): retry. + wait_until("repo directory removed", 5, || { + let _ = fs::remove_dir_all(root.join("g/second")); + !root.join("g/second").exists() + }); wait_until("removed repo dropped", 10, || { repo_paths(&sock) == vec![root.join("g/repo").display().to_string()] }); From 430e25c31d0d7c5525a0ac057266efa2b0d5f19c Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 19:18:24 +0100 Subject: [PATCH 19/19] fix(gui): treat a reset connection to the instance socket as stale Under load, connecting to a socket file whose listener is gone can fail with ECONNRESET instead of ECONNREFUSED; both mean no live instance. Co-Authored-By: Claude Opus 5.5 --- crates/grove-gui/src/instance.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/grove-gui/src/instance.rs b/crates/grove-gui/src/instance.rs index c3b1fa4..f699084 100644 --- a/crates/grove-gui/src/instance.rs +++ b/crates/grove-gui/src/instance.rs @@ -64,14 +64,17 @@ pub fn acquire_with(path: &Path, show: bool, timeout: Duration) -> std::io::Resu for _ in 0..3 { match notify(path, if show { "show" } else { "ping" }, timeout) { Ok(()) => return Ok(Role::Secondary), - // Nobody listens: a stale socket file from a crash is replaced. + // Nobody listens: a stale socket file from a crash is replaced. A reset + // (seen under load on a socket whose listener is gone) means the same. Err(e) if matches!( e.kind(), - std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::NotFound + std::io::ErrorKind::ConnectionRefused + | std::io::ErrorKind::ConnectionReset + | std::io::ErrorKind::NotFound ) => { - if e.kind() == std::io::ErrorKind::ConnectionRefused { + if e.kind() != std::io::ErrorKind::NotFound { let _ = std::fs::remove_file(path); } }