From 7d2c3fd0c52d9cd0a3080d1558cb44bddee57a53 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Mon, 14 Sep 2026 10:41:30 +0700 Subject: [PATCH] update nav item --- Cargo.lock | 154 ++++++++++++---------- crates/signed_state/src/local_repos.rs | 36 ++++- crates/signed_ui/src/pixel_avatar.rs | 43 +++--- crates/workspace/src/views/sidebar/mod.rs | 91 ++++++++----- 4 files changed, 201 insertions(+), 123 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a364b65..8a40acd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -913,9 +913,9 @@ dependencies = [ [[package]] name = "bytemuck_derive" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0e56a716f1e132ff6bf4bdac1c944a3fcdc1cae65f70a4a2a1ac3b401d2d1f" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" dependencies = [ "proc-macro2", "quote", @@ -1222,7 +1222,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "gpui_util", "indexmap", @@ -1511,9 +1511,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8498c871161e1742aaa9d52551b2d6ebdd4c3d45a3be423e3728f33b955be550" +checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78" dependencies = [ "cfg-if", ] @@ -1694,7 +1694,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "proc-macro2", "quote", @@ -1865,7 +1865,7 @@ dependencies = [ "cc", "memchr", "rustc_version", - "toml 1.1.5+spec-1.1.0", + "toml 1.1.6+spec-1.1.0", "vswhom", "winreg", ] @@ -3539,7 +3539,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.2.2" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "accesskit", "anyhow", @@ -3747,7 +3747,7 @@ dependencies = [ [[package]] name = "gpui_apple" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "block", @@ -3764,13 +3764,14 @@ dependencies = [ "log", "metal", "objc", + "objc2 0.6.4", "parking_lot", ] [[package]] name = "gpui_linux" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "accesskit", "accesskit_unix", @@ -3816,7 +3817,7 @@ dependencies = [ [[package]] name = "gpui_macos" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "accesskit", "accesskit_macos", @@ -3848,6 +3849,7 @@ dependencies = [ "objc2 0.6.4", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", + "objc2-screen-capture-kit", "objc2-user-notifications", "parking_lot", "pathfinder_geometry", @@ -3862,7 +3864,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3873,7 +3875,7 @@ dependencies = [ [[package]] name = "gpui_platform" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "console_error_panic_hook", "gpui", @@ -3886,7 +3888,7 @@ dependencies = [ [[package]] name = "gpui_shared_string" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "schemars", "serde", @@ -3896,7 +3898,7 @@ dependencies = [ [[package]] name = "gpui_util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "log", @@ -3906,7 +3908,7 @@ dependencies = [ [[package]] name = "gpui_web" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "console_error_panic_hook", @@ -3919,6 +3921,10 @@ dependencies = [ "parking_lot", "raw-window-handle", "scheduler", + "smallvec", + "unicode-properties", + "unicode-script", + "unicode-segmentation", "uuid", "wasm-bindgen", "wasm-bindgen-futures", @@ -3930,7 +3936,7 @@ dependencies = [ [[package]] name = "gpui_wgpu" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "bytemuck", @@ -3956,7 +3962,7 @@ dependencies = [ [[package]] name = "gpui_windows" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "accesskit", "accesskit_windows", @@ -3983,9 +3989,9 @@ dependencies = [ [[package]] name = "granit-parser" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ec0d45986cd51c847c75c5b69a00852c4fc84d0e5e79f041173f73437d0cdf" +checksum = "48aa83cc6ac4dc610adf5501a5392b4bcc543b2c1f24eaf77469a96e31ec9abe" dependencies = [ "arraydeque", "smallvec", @@ -4260,7 +4266,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "async-compression", @@ -4280,7 +4286,7 @@ dependencies = [ [[package]] name = "http_client_tls" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "log", "rustls", @@ -4723,9 +4729,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" -version = "0.2.35" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" +checksum = "0ab1baf72f08796de0260609515130699b890ac25f30e610ad894bc5856cafdb" dependencies = [ "defmt", "jiff-core", @@ -4740,18 +4746,19 @@ dependencies = [ [[package]] name = "jiff-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09" +checksum = "5e52fe76043ccecc9005d2305ebaadf7d7fc0cc89ca6baa10a94d6bc68c7128c" dependencies = [ "defmt", + "log", ] [[package]] name = "jiff-static" -version = "0.2.35" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" +checksum = "378268a1116ad67ae6228701118ac9f491d78fda38a40a1f1a9e1348de6f7212" dependencies = [ "jiff-core", "proc-macro2", @@ -4980,9 +4987,9 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d8f1ea3f21fd3405dcaf6c9b5c1630af9afc422d9073ea39c5f6d6c772e08ed" +checksum = "6480ccc157a1389bb2e4891b24751b0f798ba640d22386f23143fbcc89da195a" dependencies = [ "libc", ] @@ -5070,9 +5077,9 @@ checksum = "ff9840bcc50b71349309900da0ce7279aa336ae71d73250b07998932c7d97c25" [[package]] name = "lru-slab" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" [[package]] name = "lsp-types" @@ -5236,7 +5243,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "bindgen", @@ -5488,7 +5495,7 @@ dependencies = [ [[package]] name = "nostr" version = "0.45.4" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "aes", "base64 0.22.1", @@ -5514,7 +5521,7 @@ dependencies = [ [[package]] name = "nostr-connect" version = "0.45.1" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "async-utility", "futures-core", @@ -5528,7 +5535,7 @@ dependencies = [ [[package]] name = "nostr-database" version = "0.45.1" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "nostr", "opaquerr", @@ -5537,7 +5544,7 @@ dependencies = [ [[package]] name = "nostr-gossip" version = "0.45.0" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "nostr", "opaquerr", @@ -5546,7 +5553,7 @@ dependencies = [ [[package]] name = "nostr-gossip-memory" version = "0.45.0" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "indexmap", "lru", @@ -5558,7 +5565,7 @@ dependencies = [ [[package]] name = "nostr-lmdb" version = "0.45.2" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "async-utility", "flatbuffers", @@ -5573,7 +5580,7 @@ dependencies = [ [[package]] name = "nostr-memory" version = "0.45.1" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "btreecap", "nostr", @@ -5584,7 +5591,7 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.45.2" -source = "git+https://github.com/rust-nostr/nostr#5c669a498e5f8dd1ec5713b11fdb92bcd858ad73" +source = "git+https://github.com/rust-nostr/nostr#b230cecf9dbb38e0228e6fff4544ed9d261326fc" dependencies = [ "async-utility", "async-wsocket", @@ -6071,6 +6078,18 @@ dependencies = [ "objc2-metal 0.3.2", ] +[[package]] +name = "objc2-screen-capture-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b7c5390f477482f001bc354d6571a70db7e4f8d5288e860c45521fbce11394" +dependencies = [ + "block2 0.6.2", + "objc2 0.6.4", + "objc2-core-graphics", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-user-notifications" version = "0.3.2" @@ -6311,7 +6330,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "perf" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "collections", "serde", @@ -6618,7 +6637,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ - "toml_edit 0.25.13+spec-1.1.0", + "toml_edit 0.25.15+spec-1.1.0", ] [[package]] @@ -7099,7 +7118,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "derive_refineable", ] @@ -7182,7 +7201,7 @@ dependencies = [ [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "bytes", @@ -7560,7 +7579,7 @@ dependencies = [ [[package]] name = "scheduler" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "async-task", "backtrace", @@ -8120,9 +8139,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f" +checksum = "ba467056f1b547ed52077911161fc86985becbc60e8e1857c8a144dab0def891" [[package]] name = "smol" @@ -8276,7 +8295,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "heapless 0.9.3", "log", @@ -8722,18 +8741,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf0ded5c4e56918d8f8a339e1bb67d038d3bc6d144ac407904015ba2e4cde9b" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" [[package]] name = "tokio" @@ -8848,9 +8858,9 @@ dependencies = [ [[package]] name = "toml" -version = "1.1.5+spec-1.1.0" +version = "1.1.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785" +checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a" dependencies = [ "indexmap", "serde_core", @@ -8895,9 +8905,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.13+spec-1.1.0" +version = "0.25.15+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" +checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614" dependencies = [ "indexmap", "toml_datetime 1.1.1+spec-1.1.0", @@ -9085,9 +9095,9 @@ dependencies = [ [[package]] name = "tree-sitter-cmake" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164e0c4f4236ec5ceff14824a5528615cf462e100467e49826442ff57d327061" +checksum = "d22893fac54133fdb93497efc45713d53a96d93b035288c7a8ab0c2af77c0ddd" dependencies = [ "cc", "tree-sitter-language", @@ -9522,9 +9532,9 @@ dependencies = [ [[package]] name = "unicode-properties" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" [[package]] name = "unicode-script" @@ -9660,7 +9670,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "util_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "perf", "quote", @@ -11427,7 +11437,7 @@ checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12" [[package]] name = "zlog" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "anyhow", "chrono", @@ -11444,7 +11454,7 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" [[package]] name = "ztracing" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" dependencies = [ "tracing", "tracing-subscriber", @@ -11455,7 +11465,7 @@ dependencies = [ [[package]] name = "ztracing_macro" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#6ad3c7f278e513875e0bbde5ee935f6c9a342b9c" +source = "git+https://github.com/zed-industries/zed#7960b2a7c9568e90fbe0727332149e5b2a5fd57a" [[package]] name = "zune-core" diff --git a/crates/signed_state/src/local_repos.rs b/crates/signed_state/src/local_repos.rs index ac2607d..2a072e3 100644 --- a/crates/signed_state/src/local_repos.rs +++ b/crates/signed_state/src/local_repos.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use anyhow::Error; -use gpui::{App, AppContext, Context, Entity, Global, Task}; +use gpui::{App, AppContext, Context, Entity, Global, SharedString, Task}; use signed_core::{Announcement, RepoAddr, repo_addr}; use signed_git::{LocalRepo, Nip34Binding, find_git_repos}; @@ -126,6 +126,16 @@ pub struct ResolvedLocalRepo { pub announcement: Option, } +impl ResolvedLocalRepo { + /// The repository's directory name, or `Untitled` when the path has none. + pub fn name(&self) -> SharedString { + self.path + .file_name() + .map(|name| SharedString::from(name.to_string_lossy().into_owned())) + .unwrap_or_else(|| SharedString::from("Untitled")) + } +} + /// Resolve the scanned repositories against the known announcements. pub fn resolve_local_repos( repos: &[LocalRepo], @@ -253,4 +263,28 @@ mod tests { assert!(resolved[0].nip34.is_none()); assert!(resolved[0].announcement.is_none()); } + + #[test] + fn the_name_is_the_directory_name() { + let repo = LocalRepo { + path: PathBuf::from("/tmp/my-repo"), + nip34: None, + }; + + let resolved = resolve_local_repos(&[repo], &[], &[]); + + assert_eq!(resolved[0].name(), SharedString::from("my-repo")); + } + + #[test] + fn a_path_without_a_directory_name_is_untitled() { + let repo = LocalRepo { + path: PathBuf::from("/"), + nip34: None, + }; + + let resolved = resolve_local_repos(&[repo], &[], &[]); + + assert_eq!(resolved[0].name(), SharedString::from("Untitled")); + } } diff --git a/crates/signed_ui/src/pixel_avatar.rs b/crates/signed_ui/src/pixel_avatar.rs index f39a529..18a56f0 100644 --- a/crates/signed_ui/src/pixel_avatar.rs +++ b/crates/signed_ui/src/pixel_avatar.rs @@ -1,7 +1,7 @@ use gpui::prelude::*; use gpui::{App, Pixels, StyleRefinement, Window, div, px}; use gpui_base::StyledExt; -use gpui_component::{ActiveTheme, Colorize}; +use gpui_component::{ActiveTheme, Colorize, Sizable, Size}; /// Number of rows and columns in the pixel grid. const GRID_SIZE: usize = 8; @@ -10,34 +10,36 @@ const FILL_PROBABILITY: f32 = 0.42; /// Probability that a filled cell uses the accent shade instead of the main color. const ACCENT_PROBABILITY: f32 = 0.25; /// Minimum number of filled left-half cells. -/// A sparse roll still yields a recognizable shape. -/// Each left-half cell is mirrored to a right-half one. const MIN_FILLED: usize = 5; -/// Side length of the avatar in pixels, no setter. -const AVATAR_SIZE: Pixels = px(16.); - /// A deterministic, offline pixel-art avatar. -/// An 8×8 grid with horizontal mirror symmetry. -/// Seeded from a stable string such as the repository id and owner public key. -/// The same seed always renders the same avatar. #[derive(IntoElement)] pub struct PixelAvatar { seed: u64, + size: Size, style: StyleRefinement, } impl PixelAvatar { /// Create an avatar seeded from `seed`. + /// /// The seed should be a stable string unique to the entity the avatar represents. pub fn new(seed: impl AsRef) -> Self { Self { seed: fnv1a(seed.as_ref().as_bytes()), + size: Size::XSmall, style: StyleRefinement::default(), } } } +impl Sizable for PixelAvatar { + fn with_size(mut self, size: impl Into) -> Self { + self.size = size.into(); + self + } +} + impl Styled for PixelAvatar { fn style(&mut self) -> &mut StyleRefinement { &mut self.style @@ -48,16 +50,17 @@ impl RenderOnce for PixelAvatar { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { let theme = cx.theme(); let pattern = pattern(self.seed); + let mut cells = Vec::new(); let hue = self.seed as f32 / u64::MAX as f32; let main = theme.blue.hue(hue); + let shade = if theme.is_dark() { main.lightness((main.l * 1.6).min(0.95)) } else { main.lightness((main.l * 0.45).max(0.18)) }; - let mut cells = Vec::new(); for row in 0..GRID_SIZE { for col in 0..GRID_SIZE { let value = pattern[row * GRID_SIZE + col]; @@ -80,7 +83,7 @@ impl RenderOnce for PixelAvatar { .grid() .grid_cols(GRID_SIZE as u16) .grid_rows(GRID_SIZE as u16) - .size(AVATAR_SIZE) + .size(side_length(self.size)) .flex_shrink_0() .overflow_hidden() .bg(main.opacity(0.16)) @@ -88,9 +91,16 @@ impl RenderOnce for PixelAvatar { } } -/// Generate the 8×8 cell pattern for `seed`. -/// Cells are `0` for empty, `1` for main color and `2` for accent shade. -/// The right half mirrors the left half. +fn side_length(size: Size) -> Pixels { + match size { + Size::XSmall => px(16.), + Size::Small => px(24.), + Size::Medium => px(48.), + Size::Large => px(80.), + Size::Size(size) => size, + } +} + fn pattern(seed: u64) -> [u8; GRID_SIZE * GRID_SIZE] { let mut rng = PixelRng::new(seed); let mut pattern = [0u8; GRID_SIZE * GRID_SIZE]; @@ -106,18 +116,19 @@ fn pattern(seed: u64) -> [u8; GRID_SIZE * GRID_SIZE] { } } - // Sparse rolls can come out nearly empty. - // Top the pattern up to the minimum fill, scanning from a seeded starting cell. if filled < MIN_FILLED { let half = GRID_SIZE * GRID_SIZE / 2; let start = (rng.next() % half as u64) as usize; + for offset in 0..half { if filled >= MIN_FILLED { break; } + let ix = (start + offset) % half; let row = ix / (GRID_SIZE / 2); let col = ix % (GRID_SIZE / 2); + if pattern[row * GRID_SIZE + col] == 0 { set_cell(&mut pattern, row, col, 1); filled += 1; diff --git a/crates/workspace/src/views/sidebar/mod.rs b/crates/workspace/src/views/sidebar/mod.rs index 5f2df34..4f0804d 100644 --- a/crates/workspace/src/views/sidebar/mod.rs +++ b/crates/workspace/src/views/sidebar/mod.rs @@ -10,9 +10,8 @@ use dock::{ }; use gpui::prelude::*; use gpui::{ - AnyElement, App, Context, Div, Entity, EventEmitter, FocusHandle, Focusable, Hsla, ObjectFit, - Render, SharedString, Subscription, WeakEntity, Window, div, img, px, relative, uniform_list, - white, + AnyElement, App, Context, Div, Entity, EventEmitter, FocusHandle, Focusable, ObjectFit, Render, + SharedString, Subscription, WeakEntity, Window, div, img, px, relative, uniform_list, white, }; use gpui_base::Button as BaseButton; use gpui_component::button::{Button, ButtonVariants}; @@ -37,8 +36,8 @@ mod settings_dialog; use self::onboarding_dialog::OnboardingState; -/// The tool that bound a repository, `"nak"` or `"ngit"`. -fn local_tool(binding: &Nip34Binding) -> Option<&'static str> { +/// The platform that bound a repository, `"nak"` or `"ngit"`. +fn local_platform(binding: &Nip34Binding) -> Option<&'static str> { let signals = &binding.signals; if signals.nip34_json || signals.nip34_grasp_remote || signals.nip34_state_refs { @@ -485,34 +484,43 @@ impl SidebarPanel { entry: &ResolvedLocalRepo, cx: &mut Context, ) -> impl IntoElement { - let name = entry - .path - .file_name() - .map(|name| name.to_string_lossy().into_owned()) - .unwrap_or("Untitled".into()); - let avatar = PixelAvatar::new(entry.path.to_string_lossy()); - - let suffix: AnyElement = match entry.nip34.as_ref().map(|binding| binding.kind) { - Some(Nip34Kind::Initialized) => { - let label = match entry.nip34.as_ref().and_then(local_tool) { - Some(tool) => format!("NIP-34 · {tool}"), - None => "NIP-34".to_owned(), - }; - local_badge(&label, cx.theme().muted_foreground) - } - Some(Nip34Kind::Cloned) => local_badge("NIP-34 clone", cx.theme().muted_foreground), - Some(Nip34Kind::ToolingOnly) => { - local_badge("Nostr tooling", cx.theme().muted_foreground) - } - None => Icon::new(IconName::TriangleAlert) - .small() - .text_color(cx.theme().warning) - .into_any_element(), - }; + let name = entry.name(); + let avatar = local_avatar(entry, cx); let id = format!("local-repo:{}", entry.path.display()); let entry = entry.clone(); + let suffix: AnyElement = match entry.nip34.as_ref() { + Some(binding) => { + let (label, tooltip) = match binding.kind { + Nip34Kind::Initialized => { + let platform = local_platform(binding).unwrap_or("Grasp"); + let tooltip = match platform { + "nak" => "Initialized with nak", + "ngit" => "Initialized with ngit", + _ => "Initialized for NIP-34", + }; + (platform, tooltip) + } + Nip34Kind::Cloned => ("Cloned", "Cloned buts not initialized"), + Nip34Kind::ToolingOnly => ("Tooling", "Grasp tooling only"), + }; + + Button::new(id.clone()) + .xsmall() + .child(div().text_size(px(10.)).child(label)) + .tooltip(tooltip) + .secondary() + .into_any_element() + } + None => Button::new(id.clone()) + .xsmall() + .icon(IconName::TriangleAlert) + .tooltip("Not published yet") + .ghost() + .into_any_element(), + }; + NavItem::new(id, name, avatar) .suffix(suffix) .on_click(cx.listener(move |this, _ev, window, cx| { @@ -644,12 +652,27 @@ pub(super) fn server_host(relay: &RelayUrl) -> SharedString { .unwrap_or_else(|| SharedString::from(relay.to_string())) } -fn local_badge(label: &str, color: Hsla) -> AnyElement { +/// The repository's pixel avatar, with the bound owner's avatar at its bottom right. +fn local_avatar(entry: &ResolvedLocalRepo, cx: &App) -> AnyElement { + let avatar = PixelAvatar::new(entry.path.to_string_lossy()); + + let Some(owner) = entry.nip34.as_ref().and_then(|binding| binding.owner) else { + return avatar.into_any_element(); + }; + + let store = ProfileStore::global(cx); + let profile = store.read(cx).get(&owner); + div() - .flex_shrink_0() - .text_xs() - .text_color(color) - .child(SharedString::from(label.to_owned())) + .relative() + .child(avatar) + .child( + div().absolute().bottom_neg_0p5().right_neg_0p5().child( + UserAvatar::new(profile.name()) + .picture(profile.picture()) + .size(px(14.)), + ), + ) .into_any_element() }