BlueGit

ict rusty-teams

feat(app): desktop notifications with toast windows, sound, taskbar badge and tray

Board 14: own toast window per message (bundling, stack of 3 with pill,
hover pause, inline reply), rules for DND, Focus Assist and mentions,
embedded MP3 via rodio, ITaskbarList3 badge, FlashWindowEx, tray icon with
close-to-tray, settings window opened from the title bar bell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-07 · 7 weeks ago

Hash
b7adb9bbf8ddd92e0ff753eed7f41a17f626ff44
Parent
396af7fa
30 files changed +4542 −27
Cargo.lock +826 −12
@@ -155,6 +155,28 @@ version = "0.2.21"
155 155 source = "registry+https://github.com/rust-lang/crates.io-index"
156 156 checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
157 157
158 [[package]]
159 name = "alsa"
160 version = "0.11.0"
161 source = "registry+https://github.com/rust-lang/crates.io-index"
162 checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d"
163 dependencies = [
164 "alsa-sys",
165 "bitflags 2.13.2",
166 "cfg-if",
167 "libc",
168 ]
169
170 [[package]]
171 name = "alsa-sys"
172 version = "0.4.0"
173 source = "registry+https://github.com/rust-lang/crates.io-index"
174 checksum = "ad7569085a265dd3f607ebecce7458eaab2132a84393534c95b18dcbc3f31e04"
175 dependencies = [
176 "libc",
177 "pkg-config",
178 ]
179
158 180 [[package]]
159 181 name = "android_system_properties"
160 182 version = "0.1.6"
@@ -242,12 +264,16 @@ dependencies = [
242 264 "gpui-kit",
243 265 "graph",
244 266 "image",
267 "raw-window-handle",
268 "rodio",
245 269 "session",
246 270 "store",
247 271 "teams-core",
248 272 "tempfile",
249 273 "tokio",
274 "tray-icon",
250 275 "webview",
276 "windows 0.62.2",
251 277 ]
252 278
253 279 [[package]]
@@ -315,7 +341,7 @@ version = "0.38.0+1.3.281"
315 341 source = "registry+https://github.com/rust-lang/crates.io-index"
316 342 checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
317 343 dependencies = [
318 "libloading",
344 "libloading 0.8.9",
319 345 ]
320 346
321 347 [[package]]
@@ -501,6 +527,29 @@ dependencies = [
501 527 "syn 3.0.6",
502 528 ]
503 529
530 [[package]]
531 name = "atk"
532 version = "0.18.2"
533 source = "registry+https://github.com/rust-lang/crates.io-index"
534 checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
535 dependencies = [
536 "atk-sys",
537 "glib",
538 "libc",
539 ]
540
541 [[package]]
542 name = "atk-sys"
543 version = "0.18.2"
544 source = "registry+https://github.com/rust-lang/crates.io-index"
545 checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
546 dependencies = [
547 "glib-sys",
548 "gobject-sys",
549 "libc",
550 "system-deps",
551 ]
552
504 553 [[package]]
505 554 name = "atomic"
506 555 version = "0.5.3"
@@ -684,6 +733,9 @@ name = "bitflags"
684 733 version = "2.13.2"
685 734 source = "registry+https://github.com/rust-lang/crates.io-index"
686 735 checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
736 dependencies = [
737 "serde_core",
738 ]
687 739
688 740 [[package]]
689 741 name = "bitstream-io"
@@ -842,6 +894,31 @@ dependencies = [
842 894 "libbz2-rs-sys",
843 895 ]
844 896
897 [[package]]
898 name = "cairo-rs"
899 version = "0.18.5"
900 source = "registry+https://github.com/rust-lang/crates.io-index"
901 checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
902 dependencies = [
903 "bitflags 2.13.2",
904 "cairo-sys-rs",
905 "glib",
906 "libc",
907 "once_cell",
908 "thiserror 1.0.69",
909 ]
910
911 [[package]]
912 name = "cairo-sys-rs"
913 version = "0.18.2"
914 source = "registry+https://github.com/rust-lang/crates.io-index"
915 checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
916 dependencies = [
917 "glib-sys",
918 "libc",
919 "system-deps",
920 ]
921
845 922 [[package]]
846 923 name = "calloop"
847 924 version = "0.14.5"
@@ -905,6 +982,12 @@ dependencies = [
905 982 "shlex 2.0.1",
906 983 ]
907 984
985 [[package]]
986 name = "cesu8"
987 version = "1.1.0"
988 source = "registry+https://github.com/rust-lang/crates.io-index"
989 checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
990
908 991 [[package]]
909 992 name = "cexpr"
910 993 version = "0.6.0"
@@ -914,6 +997,16 @@ dependencies = [
914 997 "nom 7.1.3",
915 998 ]
916 999
1000 [[package]]
1001 name = "cfg-expr"
1002 version = "0.15.8"
1003 source = "registry+https://github.com/rust-lang/crates.io-index"
1004 checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
1005 dependencies = [
1006 "smallvec",
1007 "target-lexicon",
1008 ]
1009
917 1010 [[package]]
918 1011 name = "cfg-if"
919 1012 version = "1.0.5"
@@ -994,7 +1087,7 @@ checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
994 1087 dependencies = [
995 1088 "glob",
996 1089 "libc",
997 "libloading",
1090 "libloading 0.8.9",
998 1091 ]
999 1092
1000 1093 [[package]]
@@ -1132,6 +1225,16 @@ version = "1.0.5"
1132 1225 source = "registry+https://github.com/rust-lang/crates.io-index"
1133 1226 checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
1134 1227
1228 [[package]]
1229 name = "combine"
1230 version = "4.6.8"
1231 source = "registry+https://github.com/rust-lang/crates.io-index"
1232 checksum = "cfc320937d09e6de266b31b9afb480f197d7a861be86be7cb2ea7e5d1bfffc5e"
1233 dependencies = [
1234 "bytes",
1235 "memchr",
1236 ]
1237
1135 1238 [[package]]
1136 1239 name = "compression-codecs"
1137 1240 version = "0.4.45"
@@ -1345,6 +1448,20 @@ dependencies = [
1345 1448 "libm",
1346 1449 ]
1347 1450
1451 [[package]]
1452 name = "coreaudio-rs"
1453 version = "0.14.2"
1454 source = "registry+https://github.com/rust-lang/crates.io-index"
1455 checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58"
1456 dependencies = [
1457 "bitflags 2.13.2",
1458 "libc",
1459 "objc2-audio-toolbox",
1460 "objc2-core-audio",
1461 "objc2-core-audio-types",
1462 "objc2-core-foundation",
1463 ]
1464
1348 1465 [[package]]
1349 1466 name = "cosmic-text"
1350 1467 version = "0.19.0"
@@ -1369,6 +1486,36 @@ dependencies = [
1369 1486 "unicode-segmentation",
1370 1487 ]
1371 1488
1489 [[package]]
1490 name = "cpal"
1491 version = "0.17.3"
1492 source = "registry+https://github.com/rust-lang/crates.io-index"
1493 checksum = "d8942da362c0f0d895d7cac616263f2f9424edc5687364dfd1d25ef7eba506d7"
1494 dependencies = [
1495 "alsa",
1496 "coreaudio-rs",
1497 "dasp_sample",
1498 "jni",
1499 "js-sys",
1500 "libc",
1501 "mach2",
1502 "ndk",
1503 "ndk-context",
1504 "num-derive",
1505 "num-traits",
1506 "objc2 0.6.5",
1507 "objc2-audio-toolbox",
1508 "objc2-avf-audio",
1509 "objc2-core-audio",
1510 "objc2-core-audio-types",
1511 "objc2-core-foundation",
1512 "objc2-foundation 0.3.2",
1513 "wasm-bindgen",
1514 "wasm-bindgen-futures",
1515 "web-sys",
1516 "windows 0.62.2",
1517 ]
1518
1372 1519 [[package]]
1373 1520 name = "cpufeatures"
1374 1521 version = "0.2.17"
@@ -1396,6 +1543,15 @@ dependencies = [
1396 1543 "cfg-if",
1397 1544 ]
1398 1545
1546 [[package]]
1547 name = "crossbeam-channel"
1548 version = "0.5.17"
1549 source = "registry+https://github.com/rust-lang/crates.io-index"
1550 checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"
1551 dependencies = [
1552 "crossbeam-utils",
1553 ]
1554
1399 1555 [[package]]
1400 1556 name = "crossbeam-deque"
1401 1557 version = "0.8.8"
@@ -1488,6 +1644,12 @@ dependencies = [
1488 1644 "linktime-proc-macro",
1489 1645 ]
1490 1646
1647 [[package]]
1648 name = "dasp_sample"
1649 version = "0.11.0"
1650 source = "registry+https://github.com/rust-lang/crates.io-index"
1651 checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
1652
1491 1653 [[package]]
1492 1654 name = "data-encoding"
1493 1655 version = "2.11.1"
@@ -1648,7 +1810,7 @@ version = "0.5.3"
1648 1810 source = "registry+https://github.com/rust-lang/crates.io-index"
1649 1811 checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
1650 1812 dependencies = [
1651 "libloading",
1813 "libloading 0.8.9",
1652 1814 ]
1653 1815
1654 1816 [[package]]
@@ -1666,6 +1828,12 @@ version = "1.2.1"
1666 1828 source = "registry+https://github.com/rust-lang/crates.io-index"
1667 1829 checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
1668 1830
1831 [[package]]
1832 name = "dpi"
1833 version = "0.1.2"
1834 source = "registry+https://github.com/rust-lang/crates.io-index"
1835 checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76"
1836
1669 1837 [[package]]
1670 1838 name = "dtoa"
1671 1839 version = "1.0.11"
@@ -1951,6 +2119,16 @@ dependencies = [
1951 2119 "simd-adler32",
1952 2120 ]
1953 2121
2122 [[package]]
2123 name = "field-offset"
2124 version = "0.3.6"
2125 source = "registry+https://github.com/rust-lang/crates.io-index"
2126 checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
2127 dependencies = [
2128 "memoffset",
2129 "rustc_version",
2130 ]
2131
1954 2132 [[package]]
1955 2133 name = "filedescriptor"
1956 2134 version = "0.8.3"
@@ -2272,6 +2450,64 @@ dependencies = [
2272 2450 "byteorder",
2273 2451 ]
2274 2452
2453 [[package]]
2454 name = "gdk"
2455 version = "0.18.2"
2456 source = "registry+https://github.com/rust-lang/crates.io-index"
2457 checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691"
2458 dependencies = [
2459 "cairo-rs",
2460 "gdk-pixbuf",
2461 "gdk-sys",
2462 "gio",
2463 "glib",
2464 "libc",
2465 "pango",
2466 ]
2467
2468 [[package]]
2469 name = "gdk-pixbuf"
2470 version = "0.18.5"
2471 source = "registry+https://github.com/rust-lang/crates.io-index"
2472 checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"
2473 dependencies = [
2474 "gdk-pixbuf-sys",
2475 "gio",
2476 "glib",
2477 "libc",
2478 "once_cell",
2479 ]
2480
2481 [[package]]
2482 name = "gdk-pixbuf-sys"
2483 version = "0.18.0"
2484 source = "registry+https://github.com/rust-lang/crates.io-index"
2485 checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
2486 dependencies = [
2487 "gio-sys",
2488 "glib-sys",
2489 "gobject-sys",
2490 "libc",
2491 "system-deps",
2492 ]
2493
2494 [[package]]
2495 name = "gdk-sys"
2496 version = "0.18.2"
2497 source = "registry+https://github.com/rust-lang/crates.io-index"
2498 checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"
2499 dependencies = [
2500 "cairo-sys-rs",
2501 "gdk-pixbuf-sys",
2502 "gio-sys",
2503 "glib-sys",
2504 "gobject-sys",
2505 "libc",
2506 "pango-sys",
2507 "pkg-config",
2508 "system-deps",
2509 ]
2510
2275 2511 [[package]]
2276 2512 name = "generic-array"
2277 2513 version = "0.14.7"
@@ -2368,6 +2604,38 @@ version = "0.32.3"
2368 2604 source = "registry+https://github.com/rust-lang/crates.io-index"
2369 2605 checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
2370 2606
2607 [[package]]
2608 name = "gio"
2609 version = "0.18.4"
2610 source = "registry+https://github.com/rust-lang/crates.io-index"
2611 checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73"
2612 dependencies = [
2613 "futures-channel",
2614 "futures-core",
2615 "futures-io",
2616 "futures-util",
2617 "gio-sys",
2618 "glib",
2619 "libc",
2620 "once_cell",
2621 "pin-project-lite",
2622 "smallvec",
2623 "thiserror 1.0.69",
2624 ]
2625
2626 [[package]]
2627 name = "gio-sys"
2628 version = "0.18.1"
2629 source = "registry+https://github.com/rust-lang/crates.io-index"
2630 checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
2631 dependencies = [
2632 "glib-sys",
2633 "gobject-sys",
2634 "libc",
2635 "system-deps",
2636 "winapi",
2637 ]
2638
2371 2639 [[package]]
2372 2640 name = "gl_generator"
2373 2641 version = "0.14.0"
@@ -2379,6 +2647,53 @@ dependencies = [
2379 2647 "xml-rs",
2380 2648 ]
2381 2649
2650 [[package]]
2651 name = "glib"
2652 version = "0.18.5"
2653 source = "registry+https://github.com/rust-lang/crates.io-index"
2654 checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5"
2655 dependencies = [
2656 "bitflags 2.13.2",
2657 "futures-channel",
2658 "futures-core",
2659 "futures-executor",
2660 "futures-task",
2661 "futures-util",
2662 "gio-sys",
2663 "glib-macros",
2664 "glib-sys",
2665 "gobject-sys",
2666 "libc",
2667 "memchr",
2668 "once_cell",
2669 "smallvec",
2670 "thiserror 1.0.69",
2671 ]
2672
2673 [[package]]
2674 name = "glib-macros"
2675 version = "0.18.5"
2676 source = "registry+https://github.com/rust-lang/crates.io-index"
2677 checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc"
2678 dependencies = [
2679 "heck 0.4.1",
2680 "proc-macro-crate 2.0.0",
2681 "proc-macro-error",
2682 "proc-macro2",
2683 "quote",
2684 "syn 2.0.119",
2685 ]
2686
2687 [[package]]
2688 name = "glib-sys"
2689 version = "0.18.1"
2690 source = "registry+https://github.com/rust-lang/crates.io-index"
2691 checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"
2692 dependencies = [
2693 "libc",
2694 "system-deps",
2695 ]
2696
2382 2697 [[package]]
2383 2698 name = "glob"
2384 2699 version = "0.3.4"
@@ -2430,6 +2745,17 @@ dependencies = [
2430 2745 "gl_generator",
2431 2746 ]
2432 2747
2748 [[package]]
2749 name = "gobject-sys"
2750 version = "0.18.0"
2751 source = "registry+https://github.com/rust-lang/crates.io-index"
2752 checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
2753 dependencies = [
2754 "glib-sys",
2755 "libc",
2756 "system-deps",
2757 ]
2758
2433 2759 [[package]]
2434 2760 name = "gpu-allocator"
2435 2761 version = "0.28.0"
@@ -2555,7 +2881,7 @@ version = "0.7.1"
2555 2881 source = "registry+https://github.com/rust-lang/crates.io-index"
2556 2882 checksum = "2968cc7f4a2bd8f51b09cfe4f1e77409951b48a0e2d48f372b010e69c3d7fb49"
2557 2883 dependencies = [
2558 "proc-macro-crate",
2884 "proc-macro-crate 3.5.0",
2559 2885 "proc-macro2",
2560 2886 "quote",
2561 2887 "syn 2.0.119",
@@ -2833,7 +3159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2833 3159 checksum = "d2ad26ca759364694cb55487bebff4c1b7dd6accab49990ff3cda6f7a818a9f4"
2834 3160 dependencies = [
2835 3161 "heck 0.5.0",
2836 "proc-macro-crate",
3162 "proc-macro-crate 3.5.0",
2837 3163 "proc-macro2",
2838 3164 "quote",
2839 3165 "syn 2.0.119",
@@ -3046,6 +3372,8 @@ dependencies = [
3046 3372 [[package]]
3047 3373 name = "gpui-pre-windows"
3048 3374 version = "0.3.8"
3375 source = "registry+https://github.com/rust-lang/crates.io-index"
3376 checksum = "371f9bb13f97e3bea2f8b8e5e81232bb74d735153c244ae67f7400e743925b1c"
3049 3377 dependencies = [
3050 3378 "accesskit",
3051 3379 "accesskit_windows",
@@ -3125,6 +3453,58 @@ dependencies = [
3125 3453 "tokio",
3126 3454 ]
3127 3455
3456 [[package]]
3457 name = "gtk"
3458 version = "0.18.2"
3459 source = "registry+https://github.com/rust-lang/crates.io-index"
3460 checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a"
3461 dependencies = [
3462 "atk",
3463 "cairo-rs",
3464 "field-offset",
3465 "futures-channel",
3466 "gdk",
3467 "gdk-pixbuf",
3468 "gio",
3469 "glib",
3470 "gtk-sys",
3471 "gtk3-macros",
3472 "libc",
3473 "pango",
3474 "pkg-config",
3475 ]
3476
3477 [[package]]
3478 name = "gtk-sys"
3479 version = "0.18.2"
3480 source = "registry+https://github.com/rust-lang/crates.io-index"
3481 checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414"
3482 dependencies = [
3483 "atk-sys",
3484 "cairo-sys-rs",
3485 "gdk-pixbuf-sys",
3486 "gdk-sys",
3487 "gio-sys",
3488 "glib-sys",
3489 "gobject-sys",
3490 "libc",
3491 "pango-sys",
3492 "system-deps",
3493 ]
3494
3495 [[package]]
3496 name = "gtk3-macros"
3497 version = "0.18.2"
3498 source = "registry+https://github.com/rust-lang/crates.io-index"
3499 checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d"
3500 dependencies = [
3501 "proc-macro-crate 1.3.1",
3502 "proc-macro-error",
3503 "proc-macro2",
3504 "quote",
3505 "syn 2.0.119",
3506 ]
3507
3128 3508 [[package]]
3129 3509 name = "h2"
3130 3510 version = "0.4.20"
@@ -3754,6 +4134,22 @@ version = "1.0.18"
3754 4134 source = "registry+https://github.com/rust-lang/crates.io-index"
3755 4135 checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
3756 4136
4137 [[package]]
4138 name = "jni"
4139 version = "0.21.1"
4140 source = "registry+https://github.com/rust-lang/crates.io-index"
4141 checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
4142 dependencies = [
4143 "cesu8",
4144 "cfg-if",
4145 "combine",
4146 "jni-sys 0.3.1",
4147 "log",
4148 "thiserror 1.0.69",
4149 "walkdir",
4150 "windows-sys 0.45.0",
4151 ]
4152
3757 4153 [[package]]
3758 4154 name = "jni-sys"
3759 4155 version = "0.3.1"
@@ -3803,6 +4199,17 @@ dependencies = [
3803 4199 "wasm-bindgen",
3804 4200 ]
3805 4201
4202 [[package]]
4203 name = "keyboard-types"
4204 version = "0.7.0"
4205 source = "registry+https://github.com/rust-lang/crates.io-index"
4206 checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a"
4207 dependencies = [
4208 "bitflags 2.13.2",
4209 "serde",
4210 "unicode-segmentation",
4211 ]
4212
3806 4213 [[package]]
3807 4214 name = "khronos-egl"
3808 4215 version = "6.0.0"
@@ -3810,7 +4217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3810 4217 checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
3811 4218 dependencies = [
3812 4219 "libc",
3813 "libloading",
4220 "libloading 0.8.9",
3814 4221 "pkg-config",
3815 4222 ]
3816 4223
@@ -3890,6 +4297,30 @@ version = "0.5.3"
3890 4297 source = "registry+https://github.com/rust-lang/crates.io-index"
3891 4298 checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
3892 4299
4300 [[package]]
4301 name = "libappindicator"
4302 version = "0.9.0"
4303 source = "registry+https://github.com/rust-lang/crates.io-index"
4304 checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
4305 dependencies = [
4306 "glib",
4307 "gtk",
4308 "gtk-sys",
4309 "libappindicator-sys",
4310 "log",
4311 ]
4312
4313 [[package]]
4314 name = "libappindicator-sys"
4315 version = "0.9.0"
4316 source = "registry+https://github.com/rust-lang/crates.io-index"
4317 checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf"
4318 dependencies = [
4319 "gtk-sys",
4320 "libloading 0.7.4",
4321 "once_cell",
4322 ]
4323
3893 4324 [[package]]
3894 4325 name = "libbz2-rs-sys"
3895 4326 version = "0.2.5"
@@ -3912,6 +4343,16 @@ dependencies = [
3912 4343 "cc",
3913 4344 ]
3914 4345
4346 [[package]]
4347 name = "libloading"
4348 version = "0.7.4"
4349 source = "registry+https://github.com/rust-lang/crates.io-index"
4350 checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
4351 dependencies = [
4352 "cfg-if",
4353 "winapi",
4354 ]
4355
3915 4356 [[package]]
3916 4357 name = "libloading"
3917 4358 version = "0.8.9"
@@ -4299,10 +4740,30 @@ dependencies = [
4299 4740 name = "moxcms"
4300 4741 version = "0.8.1"
4301 4742 source = "registry+https://github.com/rust-lang/crates.io-index"
4302 checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
4743 checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
4744 dependencies = [
4745 "num-traits",
4746 "pxfm",
4747 ]
4748
4749 [[package]]
4750 name = "muda"
4751 version = "0.17.2"
4752 source = "registry+https://github.com/rust-lang/crates.io-index"
4753 checksum = "7c9fec5a4e89860383d778d10563a605838f8f0b2f9303868937e5ff32e86177"
4303 4754 dependencies = [
4304 "num-traits",
4305 "pxfm",
4755 "crossbeam-channel",
4756 "dpi",
4757 "gtk",
4758 "keyboard-types",
4759 "objc2 0.6.5",
4760 "objc2-app-kit 0.3.2",
4761 "objc2-core-foundation",
4762 "objc2-foundation 0.3.2",
4763 "once_cell",
4764 "png 0.17.16",
4765 "thiserror 2.0.21",
4766 "windows-sys 0.60.2",
4306 4767 ]
4307 4768
4308 4769 [[package]]
@@ -4337,6 +4798,26 @@ dependencies = [
4337 4798 "unicode-ident",
4338 4799 ]
4339 4800
4801 [[package]]
4802 name = "ndk"
4803 version = "0.9.0"
4804 source = "registry+https://github.com/rust-lang/crates.io-index"
4805 checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4"
4806 dependencies = [
4807 "bitflags 2.13.2",
4808 "jni-sys 0.3.1",
4809 "log",
4810 "ndk-sys",
4811 "num_enum",
4812 "thiserror 1.0.69",
4813 ]
4814
4815 [[package]]
4816 name = "ndk-context"
4817 version = "0.1.1"
4818 source = "registry+https://github.com/rust-lang/crates.io-index"
4819 checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
4820
4340 4821 [[package]]
4341 4822 name = "ndk-sys"
4342 4823 version = "0.6.0+11769913"
@@ -4578,6 +5059,28 @@ dependencies = [
4578 5059 "libc",
4579 5060 ]
4580 5061
5062 [[package]]
5063 name = "num_enum"
5064 version = "0.7.6"
5065 source = "registry+https://github.com/rust-lang/crates.io-index"
5066 checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26"
5067 dependencies = [
5068 "num_enum_derive",
5069 "rustversion",
5070 ]
5071
5072 [[package]]
5073 name = "num_enum_derive"
5074 version = "0.7.6"
5075 source = "registry+https://github.com/rust-lang/crates.io-index"
5076 checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"
5077 dependencies = [
5078 "proc-macro-crate 3.5.0",
5079 "proc-macro2",
5080 "quote",
5081 "syn 2.0.119",
5082 ]
5083
4581 5084 [[package]]
4582 5085 name = "objc"
4583 5086 version = "0.2.7"
@@ -4661,6 +5164,31 @@ dependencies = [
4661 5164 "objc2-quartz-core 0.3.2",
4662 5165 ]
4663 5166
5167 [[package]]
5168 name = "objc2-audio-toolbox"
5169 version = "0.3.2"
5170 source = "registry+https://github.com/rust-lang/crates.io-index"
5171 checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08"
5172 dependencies = [
5173 "bitflags 2.13.2",
5174 "libc",
5175 "objc2 0.6.5",
5176 "objc2-core-audio",
5177 "objc2-core-audio-types",
5178 "objc2-core-foundation",
5179 "objc2-foundation 0.3.2",
5180 ]
5181
5182 [[package]]
5183 name = "objc2-avf-audio"
5184 version = "0.3.2"
5185 source = "registry+https://github.com/rust-lang/crates.io-index"
5186 checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be"
5187 dependencies = [
5188 "objc2 0.6.5",
5189 "objc2-foundation 0.3.2",
5190 ]
5191
4664 5192 [[package]]
4665 5193 name = "objc2-cloud-kit"
4666 5194 version = "0.3.2"
@@ -4682,6 +5210,7 @@ dependencies = [
4682 5210 "objc2 0.6.5",
4683 5211 "objc2-core-audio-types",
4684 5212 "objc2-core-foundation",
5213 "objc2-foundation 0.3.2",
4685 5214 ]
4686 5215
4687 5216 [[package]]
@@ -4724,7 +5253,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
4724 5253 checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
4725 5254 dependencies = [
4726 5255 "bitflags 2.13.2",
5256 "block2 0.6.2",
4727 5257 "dispatch2",
5258 "libc",
4728 5259 "objc2 0.6.5",
4729 5260 ]
4730 5261
@@ -5047,6 +5578,31 @@ dependencies = [
5047 5578 "pin-project-lite",
5048 5579 ]
5049 5580
5581 [[package]]
5582 name = "pango"
5583 version = "0.18.3"
5584 source = "registry+https://github.com/rust-lang/crates.io-index"
5585 checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
5586 dependencies = [
5587 "gio",
5588 "glib",
5589 "libc",
5590 "once_cell",
5591 "pango-sys",
5592 ]
5593
5594 [[package]]
5595 name = "pango-sys"
5596 version = "0.18.0"
5597 source = "registry+https://github.com/rust-lang/crates.io-index"
5598 checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
5599 dependencies = [
5600 "glib-sys",
5601 "gobject-sys",
5602 "libc",
5603 "system-deps",
5604 ]
5605
5050 5606 [[package]]
5051 5607 name = "parking"
5052 5608 version = "2.2.1"
@@ -5406,6 +5962,25 @@ dependencies = [
5406 5962 "syn 2.0.119",
5407 5963 ]
5408 5964
5965 [[package]]
5966 name = "proc-macro-crate"
5967 version = "1.3.1"
5968 source = "registry+https://github.com/rust-lang/crates.io-index"
5969 checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
5970 dependencies = [
5971 "once_cell",
5972 "toml_edit 0.19.15",
5973 ]
5974
5975 [[package]]
5976 name = "proc-macro-crate"
5977 version = "2.0.0"
5978 source = "registry+https://github.com/rust-lang/crates.io-index"
5979 checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
5980 dependencies = [
5981 "toml_edit 0.20.7",
5982 ]
5983
5409 5984 [[package]]
5410 5985 name = "proc-macro-crate"
5411 5986 version = "3.5.0"
@@ -5415,6 +5990,30 @@ dependencies = [
5415 5990 "toml_edit 0.25.15+spec-1.1.0",
5416 5991 ]
5417 5992
5993 [[package]]
5994 name = "proc-macro-error"
5995 version = "1.0.4"
5996 source = "registry+https://github.com/rust-lang/crates.io-index"
5997 checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
5998 dependencies = [
5999 "proc-macro-error-attr",
6000 "proc-macro2",
6001 "quote",
6002 "syn 1.0.109",
6003 "version_check",
6004 ]
6005
6006 [[package]]
6007 name = "proc-macro-error-attr"
6008 version = "1.0.4"
6009 source = "registry+https://github.com/rust-lang/crates.io-index"
6010 checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
6011 dependencies = [
6012 "proc-macro2",
6013 "quote",
6014 "version_check",
6015 ]
6016
5418 6017 [[package]]
5419 6018 name = "proc-macro2"
5420 6019 version = "1.0.107"
@@ -5937,6 +6536,19 @@ dependencies = [
5937 6536 "windows-sys 0.52.0",
5938 6537 ]
5939 6538
6539 [[package]]
6540 name = "rodio"
6541 version = "0.22.2"
6542 source = "registry+https://github.com/rust-lang/crates.io-index"
6543 checksum = "d0a536bb79db59098ef71a4dd4246c02eb87b316deceb1b68e0cde7167ec01eb"
6544 dependencies = [
6545 "cpal",
6546 "dasp_sample",
6547 "num-rational",
6548 "symphonia",
6549 "thiserror 2.0.21",
6550 ]
6551
5940 6552 [[package]]
5941 6553 name = "ropey"
5942 6554 version = "2.0.0-beta.1"
@@ -6931,6 +7543,65 @@ dependencies = [
6931 7543 "zeno",
6932 7544 ]
6933 7545
7546 [[package]]
7547 name = "symphonia"
7548 version = "0.5.5"
7549 source = "registry+https://github.com/rust-lang/crates.io-index"
7550 checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039"
7551 dependencies = [
7552 "lazy_static",
7553 "symphonia-bundle-mp3",
7554 "symphonia-core",
7555 "symphonia-metadata",
7556 ]
7557
7558 [[package]]
7559 name = "symphonia-bundle-mp3"
7560 version = "0.5.5"
7561 source = "registry+https://github.com/rust-lang/crates.io-index"
7562 checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed"
7563 dependencies = [
7564 "lazy_static",
7565 "log",
7566 "symphonia-core",
7567 "symphonia-metadata",
7568 ]
7569
7570 [[package]]
7571 name = "symphonia-core"
7572 version = "0.5.5"
7573 source = "registry+https://github.com/rust-lang/crates.io-index"
7574 checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af"
7575 dependencies = [
7576 "arrayvec",
7577 "bitflags 1.3.2",
7578 "bytemuck",
7579 "lazy_static",
7580 "log",
7581 ]
7582
7583 [[package]]
7584 name = "symphonia-metadata"
7585 version = "0.5.5"
7586 source = "registry+https://github.com/rust-lang/crates.io-index"
7587 checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16"
7588 dependencies = [
7589 "encoding_rs",
7590 "lazy_static",
7591 "log",
7592 "symphonia-core",
7593 ]
7594
7595 [[package]]
7596 name = "syn"
7597 version = "1.0.109"
7598 source = "registry+https://github.com/rust-lang/crates.io-index"
7599 checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
7600 dependencies = [
7601 "proc-macro2",
7602 "unicode-ident",
7603 ]
7604
6934 7605 [[package]]
6935 7606 name = "syn"
6936 7607 version = "2.0.119"
@@ -7017,6 +7688,19 @@ dependencies = [
7017 7688 "libc",
7018 7689 ]
7019 7690
7691 [[package]]
7692 name = "system-deps"
7693 version = "6.2.2"
7694 source = "registry+https://github.com/rust-lang/crates.io-index"
7695 checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
7696 dependencies = [
7697 "cfg-expr",
7698 "heck 0.5.0",
7699 "pkg-config",
7700 "toml 0.8.23",
7701 "version-compare",
7702 ]
7703
7020 7704 [[package]]
7021 7705 name = "taffy"
7022 7706 version = "0.13.0"
@@ -7041,6 +7725,12 @@ dependencies = [
7041 7725 "objc",
7042 7726 ]
7043 7727
7728 [[package]]
7729 name = "target-lexicon"
7730 version = "0.12.16"
7731 source = "registry+https://github.com/rust-lang/crates.io-index"
7732 checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
7733
7044 7734 [[package]]
7045 7735 name = "tauri-winrt-notification"
7046 7736 version = "0.8.1"
@@ -7356,6 +8046,28 @@ dependencies = [
7356 8046 "serde_core",
7357 8047 ]
7358 8048
8049 [[package]]
8050 name = "toml_edit"
8051 version = "0.19.15"
8052 source = "registry+https://github.com/rust-lang/crates.io-index"
8053 checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
8054 dependencies = [
8055 "indexmap",
8056 "toml_datetime 0.6.11",
8057 "winnow 0.5.40",
8058 ]
8059
8060 [[package]]
8061 name = "toml_edit"
8062 version = "0.20.7"
8063 source = "registry+https://github.com/rust-lang/crates.io-index"
8064 checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
8065 dependencies = [
8066 "indexmap",
8067 "toml_datetime 0.6.11",
8068 "winnow 0.5.40",
8069 ]
8070
7359 8071 [[package]]
7360 8072 name = "toml_edit"
7361 8073 version = "0.22.27"
@@ -7488,6 +8200,27 @@ dependencies = [
7488 8200 "tracing-log",
7489 8201 ]
7490 8202
8203 [[package]]
8204 name = "tray-icon"
8205 version = "0.21.3"
8206 source = "registry+https://github.com/rust-lang/crates.io-index"
8207 checksum = "a5e85aa143ceb072062fc4d6356c1b520a51d636e7bc8e77ec94be3608e5e80c"
8208 dependencies = [
8209 "crossbeam-channel",
8210 "dirs 6.0.0",
8211 "libappindicator",
8212 "muda",
8213 "objc2 0.6.5",
8214 "objc2-app-kit 0.3.2",
8215 "objc2-core-foundation",
8216 "objc2-core-graphics",
8217 "objc2-foundation 0.3.2",
8218 "once_cell",
8219 "png 0.17.16",
8220 "thiserror 2.0.21",
8221 "windows-sys 0.60.2",
8222 ]
8223
7491 8224 [[package]]
7492 8225 name = "triomphe"
7493 8226 version = "0.1.16"
@@ -7794,6 +8527,12 @@ version = "0.2.15"
7794 8527 source = "registry+https://github.com/rust-lang/crates.io-index"
7795 8528 checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
7796 8529
8530 [[package]]
8531 name = "version-compare"
8532 version = "0.2.1"
8533 source = "registry+https://github.com/rust-lang/crates.io-index"
8534 checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e"
8535
7797 8536 [[package]]
7798 8537 name = "version_check"
7799 8538 version = "0.9.5"
@@ -8235,7 +8974,7 @@ dependencies = [
8235 8974 "js-sys",
8236 8975 "khronos-egl",
8237 8976 "libc",
8238 "libloading",
8977 "libloading 0.8.9",
8239 8978 "log",
8240 8979 "naga",
8241 8980 "ndk-sys",
@@ -8672,6 +9411,15 @@ dependencies = [
8672 9411 "windows-link 0.2.1",
8673 9412 ]
8674 9413
9414 [[package]]
9415 name = "windows-sys"
9416 version = "0.45.0"
9417 source = "registry+https://github.com/rust-lang/crates.io-index"
9418 checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
9419 dependencies = [
9420 "windows-targets 0.42.2",
9421 ]
9422
8675 9423 [[package]]
8676 9424 name = "windows-sys"
8677 9425 version = "0.48.0"
@@ -8708,6 +9456,21 @@ dependencies = [
8708 9456 "windows-link 0.2.1",
8709 9457 ]
8710 9458
9459 [[package]]
9460 name = "windows-targets"
9461 version = "0.42.2"
9462 source = "registry+https://github.com/rust-lang/crates.io-index"
9463 checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
9464 dependencies = [
9465 "windows_aarch64_gnullvm 0.42.2",
9466 "windows_aarch64_msvc 0.42.2",
9467 "windows_i686_gnu 0.42.2",
9468 "windows_i686_msvc 0.42.2",
9469 "windows_x86_64_gnu 0.42.2",
9470 "windows_x86_64_gnullvm 0.42.2",
9471 "windows_x86_64_msvc 0.42.2",
9472 ]
9473
8711 9474 [[package]]
8712 9475 name = "windows-targets"
8713 9476 version = "0.48.5"
@@ -8783,6 +9546,12 @@ dependencies = [
8783 9546 "windows-link 0.2.1",
8784 9547 ]
8785 9548
9549 [[package]]
9550 name = "windows_aarch64_gnullvm"
9551 version = "0.42.2"
9552 source = "registry+https://github.com/rust-lang/crates.io-index"
9553 checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
9554
8786 9555 [[package]]
8787 9556 name = "windows_aarch64_gnullvm"
8788 9557 version = "0.48.5"
@@ -8801,6 +9570,12 @@ version = "0.53.1"
8801 9570 source = "registry+https://github.com/rust-lang/crates.io-index"
8802 9571 checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
8803 9572
9573 [[package]]
9574 name = "windows_aarch64_msvc"
9575 version = "0.42.2"
9576 source = "registry+https://github.com/rust-lang/crates.io-index"
9577 checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
9578
8804 9579 [[package]]
8805 9580 name = "windows_aarch64_msvc"
8806 9581 version = "0.48.5"
@@ -8819,6 +9594,12 @@ version = "0.53.1"
8819 9594 source = "registry+https://github.com/rust-lang/crates.io-index"
8820 9595 checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
8821 9596
9597 [[package]]
9598 name = "windows_i686_gnu"
9599 version = "0.42.2"
9600 source = "registry+https://github.com/rust-lang/crates.io-index"
9601 checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
9602
8822 9603 [[package]]
8823 9604 name = "windows_i686_gnu"
8824 9605 version = "0.48.5"
@@ -8849,6 +9630,12 @@ version = "0.53.1"
8849 9630 source = "registry+https://github.com/rust-lang/crates.io-index"
8850 9631 checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
8851 9632
9633 [[package]]
9634 name = "windows_i686_msvc"
9635 version = "0.42.2"
9636 source = "registry+https://github.com/rust-lang/crates.io-index"
9637 checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
9638
8852 9639 [[package]]
8853 9640 name = "windows_i686_msvc"
8854 9641 version = "0.48.5"
@@ -8867,6 +9654,12 @@ version = "0.53.1"
8867 9654 source = "registry+https://github.com/rust-lang/crates.io-index"
8868 9655 checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
8869 9656
9657 [[package]]
9658 name = "windows_x86_64_gnu"
9659 version = "0.42.2"
9660 source = "registry+https://github.com/rust-lang/crates.io-index"
9661 checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
9662
8870 9663 [[package]]
8871 9664 name = "windows_x86_64_gnu"
8872 9665 version = "0.48.5"
@@ -8885,6 +9678,12 @@ version = "0.53.1"
8885 9678 source = "registry+https://github.com/rust-lang/crates.io-index"
8886 9679 checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
8887 9680
9681 [[package]]
9682 name = "windows_x86_64_gnullvm"
9683 version = "0.42.2"
9684 source = "registry+https://github.com/rust-lang/crates.io-index"
9685 checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
9686
8888 9687 [[package]]
8889 9688 name = "windows_x86_64_gnullvm"
8890 9689 version = "0.48.5"
@@ -8903,6 +9702,12 @@ version = "0.53.1"
8903 9702 source = "registry+https://github.com/rust-lang/crates.io-index"
8904 9703 checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
8905 9704
9705 [[package]]
9706 name = "windows_x86_64_msvc"
9707 version = "0.42.2"
9708 source = "registry+https://github.com/rust-lang/crates.io-index"
9709 checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
9710
8906 9711 [[package]]
8907 9712 name = "windows_x86_64_msvc"
8908 9713 version = "0.48.5"
@@ -8921,6 +9726,15 @@ version = "0.53.1"
8921 9726 source = "registry+https://github.com/rust-lang/crates.io-index"
8922 9727 checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
8923 9728
9729 [[package]]
9730 name = "winnow"
9731 version = "0.5.40"
9732 source = "registry+https://github.com/rust-lang/crates.io-index"
9733 checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
9734 dependencies = [
9735 "memchr",
9736 ]
9737
8924 9738 [[package]]
8925 9739 name = "winnow"
8926 9740 version = "0.7.15"
@@ -9188,7 +10002,7 @@ version = "5.19.0"
9188 10002 source = "registry+https://github.com/rust-lang/crates.io-index"
9189 10003 checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
9190 10004 dependencies = [
9191 "proc-macro-crate",
10005 "proc-macro-crate 3.5.0",
9192 10006 "proc-macro2",
9193 10007 "quote",
9194 10008 "syn 3.0.6",
@@ -9463,7 +10277,7 @@ version = "5.15.0"
9463 10277 source = "registry+https://github.com/rust-lang/crates.io-index"
9464 10278 checksum = "864155e69b4352db0c7f374917bf45d1e0c8d17659c8b3dbf9795f3673f8c497"
9465 10279 dependencies = [
9466 "proc-macro-crate",
10280 "proc-macro-crate 3.5.0",
9467 10281 "proc-macro2",
9468 10282 "quote",
9469 10283 "syn 3.0.6",
@@ -155,6 +155,28 @@ version = "0.2.21"
155source = "registry+https://github.com/rust-lang/crates.io-index"
155source = "registry+https://github.com/rust-lang/crates.io-index"
156checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
156checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
157
157
158[[package]]
159name = "alsa"
160version = "0.11.0"
161source = "registry+https://github.com/rust-lang/crates.io-index"
162checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d"
163dependencies = [
164 "alsa-sys",
165 "bitflags 2.13.2",
166 "cfg-if",
167 "libc",
168]
169
170[[package]]
171name = "alsa-sys"
172version = "0.4.0"
173source = "registry+https://github.com/rust-lang/crates.io-index"
174checksum = "ad7569085a265dd3f607ebecce7458eaab2132a84393534c95b18dcbc3f31e04"
175dependencies = [
176 "libc",
177 "pkg-config",
178]
179
158[[package]]
180[[package]]
159name = "android_system_properties"
181name = "android_system_properties"
160version = "0.1.6"
182version = "0.1.6"
@@ -242,12 +264,16 @@ dependencies = [
242 "gpui-kit",
264 "gpui-kit",
243 "graph",
265 "graph",
244 "image",
266 "image",
267 "raw-window-handle",
268 "rodio",
245 "session",
269 "session",
246 "store",
270 "store",
247 "teams-core",
271 "teams-core",
248 "tempfile",
272 "tempfile",
249 "tokio",
273 "tokio",
274 "tray-icon",
250 "webview",
275 "webview",
276 "windows 0.62.2",
251]
277]
252
278
253[[package]]
279[[package]]
@@ -315,7 +341,7 @@ version = "0.38.0+1.3.281"
315source = "registry+https://github.com/rust-lang/crates.io-index"
341source = "registry+https://github.com/rust-lang/crates.io-index"
316checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
342checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
317dependencies = [
343dependencies = [
318 "libloading",
344 "libloading 0.8.9",
319]
345]
320
346
321[[package]]
347[[package]]
@@ -501,6 +527,29 @@ dependencies = [
501 "syn 3.0.6",
527 "syn 3.0.6",
502]
528]
503
529
530[[package]]
531name = "atk"
532version = "0.18.2"
533source = "registry+https://github.com/rust-lang/crates.io-index"
534checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
535dependencies = [
536 "atk-sys",
537 "glib",
538 "libc",
539]
540
541[[package]]
542name = "atk-sys"
543version = "0.18.2"
544source = "registry+https://github.com/rust-lang/crates.io-index"
545checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
546dependencies = [
547 "glib-sys",
548 "gobject-sys",
549 "libc",
550 "system-deps",
551]
552
504[[package]]
553[[package]]
505name = "atomic"
554name = "atomic"
506version = "0.5.3"
555version = "0.5.3"
@@ -684,6 +733,9 @@ name = "bitflags"
684version = "2.13.2"
733version = "2.13.2"
685source = "registry+https://github.com/rust-lang/crates.io-index"
734source = "registry+https://github.com/rust-lang/crates.io-index"
686checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
735checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
736dependencies = [
737 "serde_core",
738]
687
739
688[[package]]
740[[package]]
689name = "bitstream-io"
741name = "bitstream-io"
@@ -842,6 +894,31 @@ dependencies = [
842 "libbz2-rs-sys",
894 "libbz2-rs-sys",
843]
895]
844
896
897[[package]]
898name = "cairo-rs"
899version = "0.18.5"
900source = "registry+https://github.com/rust-lang/crates.io-index"
901checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
902dependencies = [
903 "bitflags 2.13.2",
904 "cairo-sys-rs",
905 "glib",
906 "libc",
907 "once_cell",
908 "thiserror 1.0.69",
909]
910
911[[package]]
912name = "cairo-sys-rs"
913version = "0.18.2"
914source = "registry+https://github.com/rust-lang/crates.io-index"
915checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
916dependencies = [
917 "glib-sys",
918 "libc",
919 "system-deps",
920]
921
845[[package]]
922[[package]]
846name = "calloop"
923name = "calloop"
847version = "0.14.5"
924version = "0.14.5"
@@ -905,6 +982,12 @@ dependencies = [
905 "shlex 2.0.1",
982 "shlex 2.0.1",
906]
983]
907
984
985[[package]]
986name = "cesu8"
987version = "1.1.0"
988source = "registry+https://github.com/rust-lang/crates.io-index"
989checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
990
908[[package]]
991[[package]]
909name = "cexpr"
992name = "cexpr"
910version = "0.6.0"
993version = "0.6.0"
@@ -914,6 +997,16 @@ dependencies = [
914 "nom 7.1.3",
997 "nom 7.1.3",
915]
998]
916
999
1000[[package]]
1001name = "cfg-expr"
1002version = "0.15.8"
1003source = "registry+https://github.com/rust-lang/crates.io-index"
1004checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
1005dependencies = [
1006 "smallvec",
1007 "target-lexicon",
1008]
1009
917[[package]]
1010[[package]]
918name = "cfg-if"
1011name = "cfg-if"
919version = "1.0.5"
1012version = "1.0.5"
@@ -994,7 +1087,7 @@ checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
994dependencies = [
1087dependencies = [
995 "glob",
1088 "glob",
996 "libc",
1089 "libc",
997 "libloading",
1090 "libloading 0.8.9",
998]
1091]
999
1092
1000[[package]]
1093[[package]]
@@ -1132,6 +1225,16 @@ version = "1.0.5"
1132source = "registry+https://github.com/rust-lang/crates.io-index"
1225source = "registry+https://github.com/rust-lang/crates.io-index"
1133checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
1226checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
1134
1227
1228[[package]]
1229name = "combine"
1230version = "4.6.8"
1231source = "registry+https://github.com/rust-lang/crates.io-index"
1232checksum = "cfc320937d09e6de266b31b9afb480f197d7a861be86be7cb2ea7e5d1bfffc5e"
1233dependencies = [
1234 "bytes",
1235 "memchr",
1236]
1237
1135[[package]]
1238[[package]]
1136name = "compression-codecs"
1239name = "compression-codecs"
1137version = "0.4.45"
1240version = "0.4.45"
@@ -1345,6 +1448,20 @@ dependencies = [
1345 "libm",
1448 "libm",
1346]
1449]
1347
1450
1451[[package]]
1452name = "coreaudio-rs"
1453version = "0.14.2"
1454source = "registry+https://github.com/rust-lang/crates.io-index"
1455checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58"
1456dependencies = [
1457 "bitflags 2.13.2",
1458 "libc",
1459 "objc2-audio-toolbox",
1460 "objc2-core-audio",
1461 "objc2-core-audio-types",
1462 "objc2-core-foundation",
1463]
1464
1348[[package]]
1465[[package]]
1349name = "cosmic-text"
1466name = "cosmic-text"
1350version = "0.19.0"
1467version = "0.19.0"
@@ -1369,6 +1486,36 @@ dependencies = [
1369 "unicode-segmentation",
1486 "unicode-segmentation",
1370]
1487]
1371
1488
1489[[package]]
1490name = "cpal"
1491version = "0.17.3"
1492source = "registry+https://github.com/rust-lang/crates.io-index"
1493checksum = "d8942da362c0f0d895d7cac616263f2f9424edc5687364dfd1d25ef7eba506d7"
1494dependencies = [
1495 "alsa",
1496 "coreaudio-rs",
1497 "dasp_sample",
1498 "jni",
1499 "js-sys",
1500 "libc",
1501 "mach2",
1502 "ndk",
1503 "ndk-context",
1504 "num-derive",
1505 "num-traits",
1506 "objc2 0.6.5",
1507 "objc2-audio-toolbox",
1508 "objc2-avf-audio",
1509 "objc2-core-audio",
1510 "objc2-core-audio-types",
1511 "objc2-core-foundation",
1512 "objc2-foundation 0.3.2",
1513 "wasm-bindgen",
1514 "wasm-bindgen-futures",
1515 "web-sys",
1516 "windows 0.62.2",
1517]
1518
1372[[package]]
1519[[package]]
1373name = "cpufeatures"
1520name = "cpufeatures"
1374version = "0.2.17"
1521version = "0.2.17"
@@ -1396,6 +1543,15 @@ dependencies = [
1396 "cfg-if",
1543 "cfg-if",
1397]
1544]
1398
1545
1546[[package]]
1547name = "crossbeam-channel"
1548version = "0.5.17"
1549source = "registry+https://github.com/rust-lang/crates.io-index"
1550checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"
1551dependencies = [
1552 "crossbeam-utils",
1553]
1554
1399[[package]]
1555[[package]]
1400name = "crossbeam-deque"
1556name = "crossbeam-deque"
1401version = "0.8.8"
1557version = "0.8.8"
@@ -1488,6 +1644,12 @@ dependencies = [
1488 "linktime-proc-macro",
1644 "linktime-proc-macro",
1489]
1645]
1490
1646
1647[[package]]
1648name = "dasp_sample"
1649version = "0.11.0"
1650source = "registry+https://github.com/rust-lang/crates.io-index"
1651checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
1652
1491[[package]]
1653[[package]]
1492name = "data-encoding"
1654name = "data-encoding"
1493version = "2.11.1"
1655version = "2.11.1"
@@ -1648,7 +1810,7 @@ version = "0.5.3"
1648source = "registry+https://github.com/rust-lang/crates.io-index"
1810source = "registry+https://github.com/rust-lang/crates.io-index"
1649checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
1811checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
1650dependencies = [
1812dependencies = [
1651 "libloading",
1813 "libloading 0.8.9",
1652]
1814]
1653
1815
1654[[package]]
1816[[package]]
@@ -1666,6 +1828,12 @@ version = "1.2.1"
1666source = "registry+https://github.com/rust-lang/crates.io-index"
1828source = "registry+https://github.com/rust-lang/crates.io-index"
1667checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
1829checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
1668
1830
1831[[package]]
1832name = "dpi"
1833version = "0.1.2"
1834source = "registry+https://github.com/rust-lang/crates.io-index"
1835checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76"
1836
1669[[package]]
1837[[package]]
1670name = "dtoa"
1838name = "dtoa"
1671version = "1.0.11"
1839version = "1.0.11"
@@ -1951,6 +2119,16 @@ dependencies = [
1951 "simd-adler32",
2119 "simd-adler32",
1952]
2120]
1953
2121
2122[[package]]
2123name = "field-offset"
2124version = "0.3.6"
2125source = "registry+https://github.com/rust-lang/crates.io-index"
2126checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
2127dependencies = [
2128 "memoffset",
2129 "rustc_version",
2130]
2131
1954[[package]]
2132[[package]]
1955name = "filedescriptor"
2133name = "filedescriptor"
1956version = "0.8.3"
2134version = "0.8.3"
@@ -2272,6 +2450,64 @@ dependencies = [
2272 "byteorder",
2450 "byteorder",
2273]
2451]
2274
2452
2453[[package]]
2454name = "gdk"
2455version = "0.18.2"
2456source = "registry+https://github.com/rust-lang/crates.io-index"
2457checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691"
2458dependencies = [
2459 "cairo-rs",
2460 "gdk-pixbuf",
2461 "gdk-sys",
2462 "gio",
2463 "glib",
2464 "libc",
2465 "pango",
2466]
2467
2468[[package]]
2469name = "gdk-pixbuf"
2470version = "0.18.5"
2471source = "registry+https://github.com/rust-lang/crates.io-index"
2472checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"
2473dependencies = [
2474 "gdk-pixbuf-sys",
2475 "gio",
2476 "glib",
2477 "libc",
2478 "once_cell",
2479]
2480
2481[[package]]
2482name = "gdk-pixbuf-sys"
2483version = "0.18.0"
2484source = "registry+https://github.com/rust-lang/crates.io-index"
2485checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
2486dependencies = [
2487 "gio-sys",
2488 "glib-sys",
2489 "gobject-sys",
2490 "libc",
2491 "system-deps",
2492]
2493
2494[[package]]
2495name = "gdk-sys"
2496version = "0.18.2"
2497source = "registry+https://github.com/rust-lang/crates.io-index"
2498checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"
2499dependencies = [
2500 "cairo-sys-rs",
2501 "gdk-pixbuf-sys",
2502 "gio-sys",
2503 "glib-sys",
2504 "gobject-sys",
2505 "libc",
2506 "pango-sys",
2507 "pkg-config",
2508 "system-deps",
2509]
2510
2275[[package]]
2511[[package]]
2276name = "generic-array"
2512name = "generic-array"
2277version = "0.14.7"
2513version = "0.14.7"
@@ -2368,6 +2604,38 @@ version = "0.32.3"
2368source = "registry+https://github.com/rust-lang/crates.io-index"
2604source = "registry+https://github.com/rust-lang/crates.io-index"
2369checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
2605checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
2370
2606
2607[[package]]
2608name = "gio"
2609version = "0.18.4"
2610source = "registry+https://github.com/rust-lang/crates.io-index"
2611checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73"
2612dependencies = [
2613 "futures-channel",
2614 "futures-core",
2615 "futures-io",
2616 "futures-util",
2617 "gio-sys",
2618 "glib",
2619 "libc",
2620 "once_cell",
2621 "pin-project-lite",
2622 "smallvec",
2623 "thiserror 1.0.69",
2624]
2625
2626[[package]]
2627name = "gio-sys"
2628version = "0.18.1"
2629source = "registry+https://github.com/rust-lang/crates.io-index"
2630checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
2631dependencies = [
2632 "glib-sys",
2633 "gobject-sys",
2634 "libc",
2635 "system-deps",
2636 "winapi",
2637]
2638
2371[[package]]
2639[[package]]
2372name = "gl_generator"
2640name = "gl_generator"
2373version = "0.14.0"
2641version = "0.14.0"
@@ -2379,6 +2647,53 @@ dependencies = [
2379 "xml-rs",
2647 "xml-rs",
2380]
2648]
2381
2649
2650[[package]]
2651name = "glib"
2652version = "0.18.5"
2653source = "registry+https://github.com/rust-lang/crates.io-index"
2654checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5"
2655dependencies = [
2656 "bitflags 2.13.2",
2657 "futures-channel",
2658 "futures-core",
2659 "futures-executor",
2660 "futures-task",
2661 "futures-util",
2662 "gio-sys",
2663 "glib-macros",
2664 "glib-sys",
2665 "gobject-sys",
2666 "libc",
2667 "memchr",
2668 "once_cell",
2669 "smallvec",
2670 "thiserror 1.0.69",
2671]
2672
2673[[package]]
2674name = "glib-macros"
2675version = "0.18.5"
2676source = "registry+https://github.com/rust-lang/crates.io-index"
2677checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc"
2678dependencies = [
2679 "heck 0.4.1",
2680 "proc-macro-crate 2.0.0",
2681 "proc-macro-error",
2682 "proc-macro2",
2683 "quote",
2684 "syn 2.0.119",
2685]
2686
2687[[package]]
2688name = "glib-sys"
2689version = "0.18.1"
2690source = "registry+https://github.com/rust-lang/crates.io-index"
2691checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"
2692dependencies = [
2693 "libc",
2694 "system-deps",
2695]
2696
2382[[package]]
2697[[package]]
2383name = "glob"
2698name = "glob"
2384version = "0.3.4"
2699version = "0.3.4"
@@ -2430,6 +2745,17 @@ dependencies = [
2430 "gl_generator",
2745 "gl_generator",
2431]
2746]
2432
2747
2748[[package]]
2749name = "gobject-sys"
2750version = "0.18.0"
2751source = "registry+https://github.com/rust-lang/crates.io-index"
2752checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
2753dependencies = [
2754 "glib-sys",
2755 "libc",
2756 "system-deps",
2757]
2758
2433[[package]]
2759[[package]]
2434name = "gpu-allocator"
2760name = "gpu-allocator"
2435version = "0.28.0"
2761version = "0.28.0"
@@ -2555,7 +2881,7 @@ version = "0.7.1"
2555source = "registry+https://github.com/rust-lang/crates.io-index"
2881source = "registry+https://github.com/rust-lang/crates.io-index"
2556checksum = "2968cc7f4a2bd8f51b09cfe4f1e77409951b48a0e2d48f372b010e69c3d7fb49"
2882checksum = "2968cc7f4a2bd8f51b09cfe4f1e77409951b48a0e2d48f372b010e69c3d7fb49"
2557dependencies = [
2883dependencies = [
2558 "proc-macro-crate",
2884 "proc-macro-crate 3.5.0",
2559 "proc-macro2",
2885 "proc-macro2",
2560 "quote",
2886 "quote",
2561 "syn 2.0.119",
2887 "syn 2.0.119",
@@ -2833,7 +3159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2833checksum = "d2ad26ca759364694cb55487bebff4c1b7dd6accab49990ff3cda6f7a818a9f4"
3159checksum = "d2ad26ca759364694cb55487bebff4c1b7dd6accab49990ff3cda6f7a818a9f4"
2834dependencies = [
3160dependencies = [
2835 "heck 0.5.0",
3161 "heck 0.5.0",
2836 "proc-macro-crate",
3162 "proc-macro-crate 3.5.0",
2837 "proc-macro2",
3163 "proc-macro2",
2838 "quote",
3164 "quote",
2839 "syn 2.0.119",
3165 "syn 2.0.119",
@@ -3046,6 +3372,8 @@ dependencies = [
3046[[package]]
3372[[package]]
3047name = "gpui-pre-windows"
3373name = "gpui-pre-windows"
3048version = "0.3.8"
3374version = "0.3.8"
3375source = "registry+https://github.com/rust-lang/crates.io-index"
3376checksum = "371f9bb13f97e3bea2f8b8e5e81232bb74d735153c244ae67f7400e743925b1c"
3049dependencies = [
3377dependencies = [
3050 "accesskit",
3378 "accesskit",
3051 "accesskit_windows",
3379 "accesskit_windows",
@@ -3125,6 +3453,58 @@ dependencies = [
3125 "tokio",
3453 "tokio",
3126]
3454]
3127
3455
3456[[package]]
3457name = "gtk"
3458version = "0.18.2"
3459source = "registry+https://github.com/rust-lang/crates.io-index"
3460checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a"
3461dependencies = [
3462 "atk",
3463 "cairo-rs",
3464 "field-offset",
3465 "futures-channel",
3466 "gdk",
3467 "gdk-pixbuf",
3468 "gio",
3469 "glib",
3470 "gtk-sys",
3471 "gtk3-macros",
3472 "libc",
3473 "pango",
3474 "pkg-config",
3475]
3476
3477[[package]]
3478name = "gtk-sys"
3479version = "0.18.2"
3480source = "registry+https://github.com/rust-lang/crates.io-index"
3481checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414"
3482dependencies = [
3483 "atk-sys",
3484 "cairo-sys-rs",
3485 "gdk-pixbuf-sys",
3486 "gdk-sys",
3487 "gio-sys",
3488 "glib-sys",
3489 "gobject-sys",
3490 "libc",
3491 "pango-sys",
3492 "system-deps",
3493]
3494
3495[[package]]
3496name = "gtk3-macros"
3497version = "0.18.2"
3498source = "registry+https://github.com/rust-lang/crates.io-index"
3499checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d"
3500dependencies = [
3501 "proc-macro-crate 1.3.1",
3502 "proc-macro-error",
3503 "proc-macro2",
3504 "quote",
3505 "syn 2.0.119",
3506]
3507
3128[[package]]
3508[[package]]
3129name = "h2"
3509name = "h2"
3130version = "0.4.20"
3510version = "0.4.20"
@@ -3754,6 +4134,22 @@ version = "1.0.18"
3754source = "registry+https://github.com/rust-lang/crates.io-index"
4134source = "registry+https://github.com/rust-lang/crates.io-index"
3755checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
4135checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
3756
4136
4137[[package]]
4138name = "jni"
4139version = "0.21.1"
4140source = "registry+https://github.com/rust-lang/crates.io-index"
4141checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
4142dependencies = [
4143 "cesu8",
4144 "cfg-if",
4145 "combine",
4146 "jni-sys 0.3.1",
4147 "log",
4148 "thiserror 1.0.69",
4149 "walkdir",
4150 "windows-sys 0.45.0",
4151]
4152
3757[[package]]
4153[[package]]
3758name = "jni-sys"
4154name = "jni-sys"
3759version = "0.3.1"
4155version = "0.3.1"
@@ -3803,6 +4199,17 @@ dependencies = [
3803 "wasm-bindgen",
4199 "wasm-bindgen",
3804]
4200]
3805
4201
4202[[package]]
4203name = "keyboard-types"
4204version = "0.7.0"
4205source = "registry+https://github.com/rust-lang/crates.io-index"
4206checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a"
4207dependencies = [
4208 "bitflags 2.13.2",
4209 "serde",
4210 "unicode-segmentation",
4211]
4212
3806[[package]]
4213[[package]]
3807name = "khronos-egl"
4214name = "khronos-egl"
3808version = "6.0.0"
4215version = "6.0.0"
@@ -3810,7 +4217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3810checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
4217checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
3811dependencies = [
4218dependencies = [
3812 "libc",
4219 "libc",
3813 "libloading",
4220 "libloading 0.8.9",
3814 "pkg-config",
4221 "pkg-config",
3815]
4222]
3816
4223
@@ -3890,6 +4297,30 @@ version = "0.5.3"
3890source = "registry+https://github.com/rust-lang/crates.io-index"
4297source = "registry+https://github.com/rust-lang/crates.io-index"
3891checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
4298checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
3892
4299
4300[[package]]
4301name = "libappindicator"
4302version = "0.9.0"
4303source = "registry+https://github.com/rust-lang/crates.io-index"
4304checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
4305dependencies = [
4306 "glib",
4307 "gtk",
4308 "gtk-sys",
4309 "libappindicator-sys",
4310 "log",
4311]
4312
4313[[package]]
4314name = "libappindicator-sys"
4315version = "0.9.0"
4316source = "registry+https://github.com/rust-lang/crates.io-index"
4317checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf"
4318dependencies = [
4319 "gtk-sys",
4320 "libloading 0.7.4",
4321 "once_cell",
4322]
4323
3893[[package]]
4324[[package]]
3894name = "libbz2-rs-sys"
4325name = "libbz2-rs-sys"
3895version = "0.2.5"
4326version = "0.2.5"
@@ -3912,6 +4343,16 @@ dependencies = [
3912 "cc",
4343 "cc",
3913]
4344]
3914
4345
4346[[package]]
4347name = "libloading"
4348version = "0.7.4"
4349source = "registry+https://github.com/rust-lang/crates.io-index"
4350checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
4351dependencies = [
4352 "cfg-if",
4353 "winapi",
4354]
4355
3915[[package]]
4356[[package]]
3916name = "libloading"
4357name = "libloading"
3917version = "0.8.9"
4358version = "0.8.9"
@@ -4299,10 +4740,30 @@ dependencies = [
4299name = "moxcms"
4740name = "moxcms"
4300version = "0.8.1"
4741version = "0.8.1"
4301source = "registry+https://github.com/rust-lang/crates.io-index"
4742source = "registry+https://github.com/rust-lang/crates.io-index"
4302checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
4743checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
4744dependencies = [
4745 "num-traits",
4746 "pxfm",
4747]
4748
4749[[package]]
4750name = "muda"
4751version = "0.17.2"
4752source = "registry+https://github.com/rust-lang/crates.io-index"
4753checksum = "7c9fec5a4e89860383d778d10563a605838f8f0b2f9303868937e5ff32e86177"
4303dependencies = [
4754dependencies = [
4304 "num-traits",
4755 "crossbeam-channel",
4305 "pxfm",
4756 "dpi",
4757 "gtk",
4758 "keyboard-types",
4759 "objc2 0.6.5",
4760 "objc2-app-kit 0.3.2",
4761 "objc2-core-foundation",
4762 "objc2-foundation 0.3.2",
4763 "once_cell",
4764 "png 0.17.16",
4765 "thiserror 2.0.21",
4766 "windows-sys 0.60.2",
4306]
4767]
4307
4768
4308[[package]]
4769[[package]]
@@ -4337,6 +4798,26 @@ dependencies = [
4337 "unicode-ident",
4798 "unicode-ident",
4338]
4799]
4339
4800
4801[[package]]
4802name = "ndk"
4803version = "0.9.0"
4804source = "registry+https://github.com/rust-lang/crates.io-index"
4805checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4"
4806dependencies = [
4807 "bitflags 2.13.2",
4808 "jni-sys 0.3.1",
4809 "log",
4810 "ndk-sys",
4811 "num_enum",
4812 "thiserror 1.0.69",
4813]
4814
4815[[package]]
4816name = "ndk-context"
4817version = "0.1.1"
4818source = "registry+https://github.com/rust-lang/crates.io-index"
4819checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
4820
4340[[package]]
4821[[package]]
4341name = "ndk-sys"
4822name = "ndk-sys"
4342version = "0.6.0+11769913"
4823version = "0.6.0+11769913"
@@ -4578,6 +5059,28 @@ dependencies = [
4578 "libc",
5059 "libc",
4579]
5060]
4580
5061
5062[[package]]
5063name = "num_enum"
5064version = "0.7.6"
5065source = "registry+https://github.com/rust-lang/crates.io-index"
5066checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26"
5067dependencies = [
5068 "num_enum_derive",
5069 "rustversion",
5070]
5071
5072[[package]]
5073name = "num_enum_derive"
5074version = "0.7.6"
5075source = "registry+https://github.com/rust-lang/crates.io-index"
5076checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"
5077dependencies = [
5078 "proc-macro-crate 3.5.0",
5079 "proc-macro2",
5080 "quote",
5081 "syn 2.0.119",
5082]
5083
4581[[package]]
5084[[package]]
4582name = "objc"
5085name = "objc"
4583version = "0.2.7"
5086version = "0.2.7"
@@ -4661,6 +5164,31 @@ dependencies = [
4661 "objc2-quartz-core 0.3.2",
5164 "objc2-quartz-core 0.3.2",
4662]
5165]
4663
5166
5167[[package]]
5168name = "objc2-audio-toolbox"
5169version = "0.3.2"
5170source = "registry+https://github.com/rust-lang/crates.io-index"
5171checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08"
5172dependencies = [
5173 "bitflags 2.13.2",
5174 "libc",
5175 "objc2 0.6.5",
5176 "objc2-core-audio",
5177 "objc2-core-audio-types",
5178 "objc2-core-foundation",
5179 "objc2-foundation 0.3.2",
5180]
5181
5182[[package]]
5183name = "objc2-avf-audio"
5184version = "0.3.2"
5185source = "registry+https://github.com/rust-lang/crates.io-index"
5186checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be"
5187dependencies = [
5188 "objc2 0.6.5",
5189 "objc2-foundation 0.3.2",
5190]
5191
4664[[package]]
5192[[package]]
4665name = "objc2-cloud-kit"
5193name = "objc2-cloud-kit"
4666version = "0.3.2"
5194version = "0.3.2"
@@ -4682,6 +5210,7 @@ dependencies = [
4682 "objc2 0.6.5",
5210 "objc2 0.6.5",
4683 "objc2-core-audio-types",
5211 "objc2-core-audio-types",
4684 "objc2-core-foundation",
5212 "objc2-core-foundation",
5213 "objc2-foundation 0.3.2",
4685]
5214]
4686
5215
4687[[package]]
5216[[package]]
@@ -4724,7 +5253,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
4724checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
5253checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
4725dependencies = [
5254dependencies = [
4726 "bitflags 2.13.2",
5255 "bitflags 2.13.2",
5256 "block2 0.6.2",
4727 "dispatch2",
5257 "dispatch2",
5258 "libc",
4728 "objc2 0.6.5",
5259 "objc2 0.6.5",
4729]
5260]
4730
5261
@@ -5047,6 +5578,31 @@ dependencies = [
5047 "pin-project-lite",
5578 "pin-project-lite",
5048]
5579]
5049
5580
5581[[package]]
5582name = "pango"
5583version = "0.18.3"
5584source = "registry+https://github.com/rust-lang/crates.io-index"
5585checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
5586dependencies = [
5587 "gio",
5588 "glib",
5589 "libc",
5590 "once_cell",
5591 "pango-sys",
5592]
5593
5594[[package]]
5595name = "pango-sys"
5596version = "0.18.0"
5597source = "registry+https://github.com/rust-lang/crates.io-index"
5598checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
5599dependencies = [
5600 "glib-sys",
5601 "gobject-sys",
5602 "libc",
5603 "system-deps",
5604]
5605
5050[[package]]
5606[[package]]
5051name = "parking"
5607name = "parking"
5052version = "2.2.1"
5608version = "2.2.1"
@@ -5406,6 +5962,25 @@ dependencies = [
5406 "syn 2.0.119",
5962 "syn 2.0.119",
5407]
5963]
5408
5964
5965[[package]]
5966name = "proc-macro-crate"
5967version = "1.3.1"
5968source = "registry+https://github.com/rust-lang/crates.io-index"
5969checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
5970dependencies = [
5971 "once_cell",
5972 "toml_edit 0.19.15",
5973]
5974
5975[[package]]
5976name = "proc-macro-crate"
5977version = "2.0.0"
5978source = "registry+https://github.com/rust-lang/crates.io-index"
5979checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
5980dependencies = [
5981 "toml_edit 0.20.7",
5982]
5983
5409[[package]]
5984[[package]]
5410name = "proc-macro-crate"
5985name = "proc-macro-crate"
5411version = "3.5.0"
5986version = "3.5.0"
@@ -5415,6 +5990,30 @@ dependencies = [
5415 "toml_edit 0.25.15+spec-1.1.0",
5990 "toml_edit 0.25.15+spec-1.1.0",
5416]
5991]
5417
5992
5993[[package]]
5994name = "proc-macro-error"
5995version = "1.0.4"
5996source = "registry+https://github.com/rust-lang/crates.io-index"
5997checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
5998dependencies = [
5999 "proc-macro-error-attr",
6000 "proc-macro2",
6001 "quote",
6002 "syn 1.0.109",
6003 "version_check",
6004]
6005
6006[[package]]
6007name = "proc-macro-error-attr"
6008version = "1.0.4"
6009source = "registry+https://github.com/rust-lang/crates.io-index"
6010checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
6011dependencies = [
6012 "proc-macro2",
6013 "quote",
6014 "version_check",
6015]
6016
5418[[package]]
6017[[package]]
5419name = "proc-macro2"
6018name = "proc-macro2"
5420version = "1.0.107"
6019version = "1.0.107"
@@ -5937,6 +6536,19 @@ dependencies = [
5937 "windows-sys 0.52.0",
6536 "windows-sys 0.52.0",
5938]
6537]
5939
6538
6539[[package]]
6540name = "rodio"
6541version = "0.22.2"
6542source = "registry+https://github.com/rust-lang/crates.io-index"
6543checksum = "d0a536bb79db59098ef71a4dd4246c02eb87b316deceb1b68e0cde7167ec01eb"
6544dependencies = [
6545 "cpal",
6546 "dasp_sample",
6547 "num-rational",
6548 "symphonia",
6549 "thiserror 2.0.21",
6550]
6551
5940[[package]]
6552[[package]]
5941name = "ropey"
6553name = "ropey"
5942version = "2.0.0-beta.1"
6554version = "2.0.0-beta.1"
@@ -6931,6 +7543,65 @@ dependencies = [
6931 "zeno",
7543 "zeno",
6932]
7544]
6933
7545
7546[[package]]
7547name = "symphonia"
7548version = "0.5.5"
7549source = "registry+https://github.com/rust-lang/crates.io-index"
7550checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039"
7551dependencies = [
7552 "lazy_static",
7553 "symphonia-bundle-mp3",
7554 "symphonia-core",
7555 "symphonia-metadata",
7556]
7557
7558[[package]]
7559name = "symphonia-bundle-mp3"
7560version = "0.5.5"
7561source = "registry+https://github.com/rust-lang/crates.io-index"
7562checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed"
7563dependencies = [
7564 "lazy_static",
7565 "log",
7566 "symphonia-core",
7567 "symphonia-metadata",
7568]
7569
7570[[package]]
7571name = "symphonia-core"
7572version = "0.5.5"
7573source = "registry+https://github.com/rust-lang/crates.io-index"
7574checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af"
7575dependencies = [
7576 "arrayvec",
7577 "bitflags 1.3.2",
7578 "bytemuck",
7579 "lazy_static",
7580 "log",
7581]
7582
7583[[package]]
7584name = "symphonia-metadata"
7585version = "0.5.5"
7586source = "registry+https://github.com/rust-lang/crates.io-index"
7587checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16"
7588dependencies = [
7589 "encoding_rs",
7590 "lazy_static",
7591 "log",
7592 "symphonia-core",
7593]
7594
7595[[package]]
7596name = "syn"
7597version = "1.0.109"
7598source = "registry+https://github.com/rust-lang/crates.io-index"
7599checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
7600dependencies = [
7601 "proc-macro2",
7602 "unicode-ident",
7603]
7604
6934[[package]]
7605[[package]]
6935name = "syn"
7606name = "syn"
6936version = "2.0.119"
7607version = "2.0.119"
@@ -7017,6 +7688,19 @@ dependencies = [
7017 "libc",
7688 "libc",
7018]
7689]
7019
7690
7691[[package]]
7692name = "system-deps"
7693version = "6.2.2"
7694source = "registry+https://github.com/rust-lang/crates.io-index"
7695checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
7696dependencies = [
7697 "cfg-expr",
7698 "heck 0.5.0",
7699 "pkg-config",
7700 "toml 0.8.23",
7701 "version-compare",
7702]
7703
7020[[package]]
7704[[package]]
7021name = "taffy"
7705name = "taffy"
7022version = "0.13.0"
7706version = "0.13.0"
@@ -7041,6 +7725,12 @@ dependencies = [
7041 "objc",
7725 "objc",
7042]
7726]
7043
7727
7728[[package]]
7729name = "target-lexicon"
7730version = "0.12.16"
7731source = "registry+https://github.com/rust-lang/crates.io-index"
7732checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
7733
7044[[package]]
7734[[package]]
7045name = "tauri-winrt-notification"
7735name = "tauri-winrt-notification"
7046version = "0.8.1"
7736version = "0.8.1"
@@ -7356,6 +8046,28 @@ dependencies = [
7356 "serde_core",
8046 "serde_core",
7357]
8047]
7358
8048
8049[[package]]
8050name = "toml_edit"
8051version = "0.19.15"
8052source = "registry+https://github.com/rust-lang/crates.io-index"
8053checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
8054dependencies = [
8055 "indexmap",
8056 "toml_datetime 0.6.11",
8057 "winnow 0.5.40",
8058]
8059
8060[[package]]
8061name = "toml_edit"
8062version = "0.20.7"
8063source = "registry+https://github.com/rust-lang/crates.io-index"
8064checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
8065dependencies = [
8066 "indexmap",
8067 "toml_datetime 0.6.11",
8068 "winnow 0.5.40",
8069]
8070
7359[[package]]
8071[[package]]
7360name = "toml_edit"
8072name = "toml_edit"
7361version = "0.22.27"
8073version = "0.22.27"
@@ -7488,6 +8200,27 @@ dependencies = [
7488 "tracing-log",
8200 "tracing-log",
7489]
8201]
7490
8202
8203[[package]]
8204name = "tray-icon"
8205version = "0.21.3"
8206source = "registry+https://github.com/rust-lang/crates.io-index"
8207checksum = "a5e85aa143ceb072062fc4d6356c1b520a51d636e7bc8e77ec94be3608e5e80c"
8208dependencies = [
8209 "crossbeam-channel",
8210 "dirs 6.0.0",
8211 "libappindicator",
8212 "muda",
8213 "objc2 0.6.5",
8214 "objc2-app-kit 0.3.2",
8215 "objc2-core-foundation",
8216 "objc2-core-graphics",
8217 "objc2-foundation 0.3.2",
8218 "once_cell",
8219 "png 0.17.16",
8220 "thiserror 2.0.21",
8221 "windows-sys 0.60.2",
8222]
8223
7491[[package]]
8224[[package]]
7492name = "triomphe"
8225name = "triomphe"
7493version = "0.1.16"
8226version = "0.1.16"
@@ -7794,6 +8527,12 @@ version = "0.2.15"
7794source = "registry+https://github.com/rust-lang/crates.io-index"
8527source = "registry+https://github.com/rust-lang/crates.io-index"
7795checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
8528checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
7796
8529
8530[[package]]
8531name = "version-compare"
8532version = "0.2.1"
8533source = "registry+https://github.com/rust-lang/crates.io-index"
8534checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e"
8535
7797[[package]]
8536[[package]]
7798name = "version_check"
8537name = "version_check"
7799version = "0.9.5"
8538version = "0.9.5"
@@ -8235,7 +8974,7 @@ dependencies = [
8235 "js-sys",
8974 "js-sys",
8236 "khronos-egl",
8975 "khronos-egl",
8237 "libc",
8976 "libc",
8238 "libloading",
8977 "libloading 0.8.9",
8239 "log",
8978 "log",
8240 "naga",
8979 "naga",
8241 "ndk-sys",
8980 "ndk-sys",
@@ -8672,6 +9411,15 @@ dependencies = [
8672 "windows-link 0.2.1",
9411 "windows-link 0.2.1",
8673]
9412]
8674
9413
9414[[package]]
9415name = "windows-sys"
9416version = "0.45.0"
9417source = "registry+https://github.com/rust-lang/crates.io-index"
9418checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
9419dependencies = [
9420 "windows-targets 0.42.2",
9421]
9422
8675[[package]]
9423[[package]]
8676name = "windows-sys"
9424name = "windows-sys"
8677version = "0.48.0"
9425version = "0.48.0"
@@ -8708,6 +9456,21 @@ dependencies = [
8708 "windows-link 0.2.1",
9456 "windows-link 0.2.1",
8709]
9457]
8710
9458
9459[[package]]
9460name = "windows-targets"
9461version = "0.42.2"
9462source = "registry+https://github.com/rust-lang/crates.io-index"
9463checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
9464dependencies = [
9465 "windows_aarch64_gnullvm 0.42.2",
9466 "windows_aarch64_msvc 0.42.2",
9467 "windows_i686_gnu 0.42.2",
9468 "windows_i686_msvc 0.42.2",
9469 "windows_x86_64_gnu 0.42.2",
9470 "windows_x86_64_gnullvm 0.42.2",
9471 "windows_x86_64_msvc 0.42.2",
9472]
9473
8711[[package]]
9474[[package]]
8712name = "windows-targets"
9475name = "windows-targets"
8713version = "0.48.5"
9476version = "0.48.5"
@@ -8783,6 +9546,12 @@ dependencies = [
8783 "windows-link 0.2.1",
9546 "windows-link 0.2.1",
8784]
9547]
8785
9548
9549[[package]]
9550name = "windows_aarch64_gnullvm"
9551version = "0.42.2"
9552source = "registry+https://github.com/rust-lang/crates.io-index"
9553checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
9554
8786[[package]]
9555[[package]]
8787name = "windows_aarch64_gnullvm"
9556name = "windows_aarch64_gnullvm"
8788version = "0.48.5"
9557version = "0.48.5"
@@ -8801,6 +9570,12 @@ version = "0.53.1"
8801source = "registry+https://github.com/rust-lang/crates.io-index"
9570source = "registry+https://github.com/rust-lang/crates.io-index"
8802checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
9571checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
8803
9572
9573[[package]]
9574name = "windows_aarch64_msvc"
9575version = "0.42.2"
9576source = "registry+https://github.com/rust-lang/crates.io-index"
9577checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
9578
8804[[package]]
9579[[package]]
8805name = "windows_aarch64_msvc"
9580name = "windows_aarch64_msvc"
8806version = "0.48.5"
9581version = "0.48.5"
@@ -8819,6 +9594,12 @@ version = "0.53.1"
8819source = "registry+https://github.com/rust-lang/crates.io-index"
9594source = "registry+https://github.com/rust-lang/crates.io-index"
8820checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
9595checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
8821
9596
9597[[package]]
9598name = "windows_i686_gnu"
9599version = "0.42.2"
9600source = "registry+https://github.com/rust-lang/crates.io-index"
9601checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
9602
8822[[package]]
9603[[package]]
8823name = "windows_i686_gnu"
9604name = "windows_i686_gnu"
8824version = "0.48.5"
9605version = "0.48.5"
@@ -8849,6 +9630,12 @@ version = "0.53.1"
8849source = "registry+https://github.com/rust-lang/crates.io-index"
9630source = "registry+https://github.com/rust-lang/crates.io-index"
8850checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
9631checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
8851
9632
9633[[package]]
9634name = "windows_i686_msvc"
9635version = "0.42.2"
9636source = "registry+https://github.com/rust-lang/crates.io-index"
9637checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
9638
8852[[package]]
9639[[package]]
8853name = "windows_i686_msvc"
9640name = "windows_i686_msvc"
8854version = "0.48.5"
9641version = "0.48.5"
@@ -8867,6 +9654,12 @@ version = "0.53.1"
8867source = "registry+https://github.com/rust-lang/crates.io-index"
9654source = "registry+https://github.com/rust-lang/crates.io-index"
8868checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
9655checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
8869
9656
9657[[package]]
9658name = "windows_x86_64_gnu"
9659version = "0.42.2"
9660source = "registry+https://github.com/rust-lang/crates.io-index"
9661checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
9662
8870[[package]]
9663[[package]]
8871name = "windows_x86_64_gnu"
9664name = "windows_x86_64_gnu"
8872version = "0.48.5"
9665version = "0.48.5"
@@ -8885,6 +9678,12 @@ version = "0.53.1"
8885source = "registry+https://github.com/rust-lang/crates.io-index"
9678source = "registry+https://github.com/rust-lang/crates.io-index"
8886checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
9679checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
8887
9680
9681[[package]]
9682name = "windows_x86_64_gnullvm"
9683version = "0.42.2"
9684source = "registry+https://github.com/rust-lang/crates.io-index"
9685checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
9686
8888[[package]]
9687[[package]]
8889name = "windows_x86_64_gnullvm"
9688name = "windows_x86_64_gnullvm"
8890version = "0.48.5"
9689version = "0.48.5"
@@ -8903,6 +9702,12 @@ version = "0.53.1"
8903source = "registry+https://github.com/rust-lang/crates.io-index"
9702source = "registry+https://github.com/rust-lang/crates.io-index"
8904checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
9703checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
8905
9704
9705[[package]]
9706name = "windows_x86_64_msvc"
9707version = "0.42.2"
9708source = "registry+https://github.com/rust-lang/crates.io-index"
9709checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
9710
8906[[package]]
9711[[package]]
8907name = "windows_x86_64_msvc"
9712name = "windows_x86_64_msvc"
8908version = "0.48.5"
9713version = "0.48.5"
@@ -8921,6 +9726,15 @@ version = "0.53.1"
8921source = "registry+https://github.com/rust-lang/crates.io-index"
9726source = "registry+https://github.com/rust-lang/crates.io-index"
8922checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
9727checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
8923
9728
9729[[package]]
9730name = "winnow"
9731version = "0.5.40"
9732source = "registry+https://github.com/rust-lang/crates.io-index"
9733checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
9734dependencies = [
9735 "memchr",
9736]
9737
8924[[package]]
9738[[package]]
8925name = "winnow"
9739name = "winnow"
8926version = "0.7.15"
9740version = "0.7.15"
@@ -9188,7 +10002,7 @@ version = "5.19.0"
9188source = "registry+https://github.com/rust-lang/crates.io-index"
10002source = "registry+https://github.com/rust-lang/crates.io-index"
9189checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
10003checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
9190dependencies = [
10004dependencies = [
9191 "proc-macro-crate",
10005 "proc-macro-crate 3.5.0",
9192 "proc-macro2",
10006 "proc-macro2",
9193 "quote",
10007 "quote",
9194 "syn 3.0.6",
10008 "syn 3.0.6",
@@ -9463,7 +10277,7 @@ version = "5.15.0"
9463source = "registry+https://github.com/rust-lang/crates.io-index"
10277source = "registry+https://github.com/rust-lang/crates.io-index"
9464checksum = "864155e69b4352db0c7f374917bf45d1e0c8d17659c8b3dbf9795f3673f8c497"
10278checksum = "864155e69b4352db0c7f374917bf45d1e0c8d17659c8b3dbf9795f3673f8c497"
9465dependencies = [
10279dependencies = [
9466 "proc-macro-crate",
10280 "proc-macro-crate 3.5.0",
9467 "proc-macro2",
10281 "proc-macro2",
9468 "quote",
10282 "quote",
9469 "syn 3.0.6",
10283 "syn 3.0.6",
crates/app/Cargo.toml +12 −0
@@ -30,3 +30,15 @@ image = { version = "0.25", default-features = false, features = ["jpeg", "png",
30 30
31 31 [target.'cfg(windows)'.dependencies]
32 32 webview.workspace = true
33 raw-window-handle = "0.6"
34 rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }
35 tray-icon = { version = "0.21", default-features = false }
36 windows = { version = "0.62", features = [
37 "Win32_Foundation",
38 "Win32_Graphics_Dwm",
39 "Win32_Graphics_Gdi",
40 "Win32_System_Com",
41 "Win32_UI_HiDpi",
42 "Win32_UI_Shell",
43 "Win32_UI_WindowsAndMessaging",
44 ] }
@@ -30,3 +30,15 @@ image = { version = "0.25", default-features = false, features = ["jpeg", "png",
30
30
31[target.'cfg(windows)'.dependencies]
31[target.'cfg(windows)'.dependencies]
32webview.workspace = true
32webview.workspace = true
33raw-window-handle = "0.6"
34rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }
35tray-icon = { version = "0.21", default-features = false }
36windows = { version = "0.62", features = [
37 "Win32_Foundation",
38 "Win32_Graphics_Dwm",
39 "Win32_Graphics_Gdi",
40 "Win32_System_Com",
41 "Win32_UI_HiDpi",
42 "Win32_UI_Shell",
43 "Win32_UI_WindowsAndMessaging",
44] }
crates/app/assets/symbols/check_circle.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m422.46-323.69 255.85-255.85L650-607.85 422.46-380.31l-114-114L280.15-466l142.31 142.31ZM480.13-120q-74.67 0-140.41-28.34-65.73-28.34-114.36-76.92-48.63-48.58-76.99-114.26Q120-405.19 120-479.87q0-74.67 28.34-140.41 28.34-65.73 76.92-114.36 48.58-48.63 114.26-76.99Q405.19-840 479.87-840q74.67 0 140.41 28.34 65.73 28.34 114.36 76.92 48.63 48.58 76.99 114.26Q840-554.81 840-480.13q0 74.67-28.34 140.41-28.34 65.73-76.92 114.36-48.58 48.63-114.26 76.99Q554.81-120 480.13-120Zm-.13-40q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m422.46-323.69 255.85-255.85L650-607.85 422.46-380.31l-114-114L280.15-466l142.31 142.31ZM480.13-120q-74.67 0-140.41-28.34-65.73-28.34-114.36-76.92-48.63-48.58-76.99-114.26Q120-405.19 120-479.87q0-74.67 28.34-140.41 28.34-65.73 76.92-114.36 48.58-48.63 114.26-76.99Q405.19-840 479.87-840q74.67 0 140.41 28.34 65.73 28.34 114.36 76.92 48.63 48.58 76.99 114.26Q840-554.81 840-480.13q0 74.67-28.34 140.41-28.34 65.73-76.92 114.36-48.58 48.63-114.26 76.99Q554.81-120 480.13-120Zm-.13-40q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
crates/app/assets/symbols/close.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M256-227.69 227.69-256l224-224-224-224L256-732.31l224 224 224-224L732.31-704l-224 224 224 224L704-227.69l-224-224-224 224Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M256-227.69 227.69-256l224-224-224-224L256-732.31l224 224 224-224L732.31-704l-224 224 224 224L704-227.69l-224-224-224 224Z"/></svg>
crates/app/assets/symbols/error.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M497.35-308.81q7.27-7.27 7.27-17.34 0-10.08-7.27-17.35-7.27-7.27-17.35-7.27-10.08 0-17.35 7.27-7.27 7.27-7.27 17.35 0 10.07 7.27 17.34t17.35 7.27q10.08 0 17.35-7.27ZM460-433.85h40v-240h-40v240ZM480.13-120q-74.67 0-140.41-28.34-65.73-28.34-114.36-76.92-48.63-48.58-76.99-114.26Q120-405.19 120-479.87q0-74.67 28.34-140.41 28.34-65.73 76.92-114.36 48.58-48.63 114.26-76.99Q405.19-840 479.87-840q74.67 0 140.41 28.34 65.73 28.34 114.36 76.92 48.63 48.58 76.99 114.26Q840-554.81 840-480.13q0 74.67-28.34 140.41-28.34 65.73-76.92 114.36-48.58 48.63-114.26 76.99Q554.81-120 480.13-120Zm-.13-40q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M497.35-308.81q7.27-7.27 7.27-17.34 0-10.08-7.27-17.35-7.27-7.27-17.35-7.27-10.08 0-17.35 7.27-7.27 7.27-7.27 17.35 0 10.07 7.27 17.34t17.35 7.27q10.08 0 17.35-7.27ZM460-433.85h40v-240h-40v240ZM480.13-120q-74.67 0-140.41-28.34-65.73-28.34-114.36-76.92-48.63-48.58-76.99-114.26Q120-405.19 120-479.87q0-74.67 28.34-140.41 28.34-65.73 76.92-114.36 48.58-48.63 114.26-76.99Q405.19-840 479.87-840q74.67 0 140.41 28.34 65.73 28.34 114.36 76.92 48.63 48.58 76.99 114.26Q840-554.81 840-480.13q0 74.67-28.34 140.41-28.34 65.73-76.92 114.36-48.58 48.63-114.26 76.99Q554.81-120 480.13-120Zm-.13-40q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
crates/app/assets/symbols/group.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M103.85-215.38v-65.85q0-27.85 14.42-47.89 14.42-20.03 38.76-32.02 52.05-24.78 103.35-39.51 51.31-14.73 123.47-14.73 72.15 0 123.46 14.73 51.31 14.73 103.35 39.51 24.34 11.99 38.76 32.02 14.43 20.04 14.43 47.89v65.85h-560Zm640 0v-67.7q0-34.77-14.08-65.64-14.07-30.87-39.92-52.97 29.46 6 56.77 16.65 27.3 10.66 54 23.96 26 13.08 40.77 33.47 14.76 20.4 14.76 44.53v67.7h-112.3ZM298.92-539.69q-35.07-35.08-35.07-84.93 0-49.84 35.07-84.92 35.08-35.08 84.93-35.08 49.84 0 84.92 35.08t35.08 84.92q0 49.85-35.08 84.93-35.08 35.07-84.92 35.07-49.85 0-84.93-35.07Zm340.45 0q-35.25 35.07-84.75 35.07-2.54 0-6.47-.57-3.92-.58-6.46-1.27 20.33-24.9 31.24-55.24 10.92-30.34 10.92-63.01t-11.43-62.44q-11.42-29.77-30.73-55.62 3.23-1.15 6.46-1.5 3.23-.35 6.47-.35 49.5 0 84.75 35.08t35.25 84.92q0 49.85-35.25 84.93ZM143.85-255.38h480v-25.85q0-14.08-7.04-24.62-7.04-10.53-25.27-20.15-44.77-23.92-94.39-36.65-49.61-12.73-113.3-12.73-63.7 0-113.31 12.73-49.62 12.73-94.39 36.65-18.23 9.62-25.27 20.15-7.03 10.54-7.03 24.62v25.85Zm296.5-312.74q23.5-23.5 23.5-56.5t-23.5-56.5q-23.5-23.5-56.5-23.5t-56.5 23.5q-23.5 23.5-23.5 56.5t23.5 56.5q23.5 23.5 56.5 23.5t56.5-23.5Zm-56.5 312.74Zm0-369.24Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M103.85-215.38v-65.85q0-27.85 14.42-47.89 14.42-20.03 38.76-32.02 52.05-24.78 103.35-39.51 51.31-14.73 123.47-14.73 72.15 0 123.46 14.73 51.31 14.73 103.35 39.51 24.34 11.99 38.76 32.02 14.43 20.04 14.43 47.89v65.85h-560Zm640 0v-67.7q0-34.77-14.08-65.64-14.07-30.87-39.92-52.97 29.46 6 56.77 16.65 27.3 10.66 54 23.96 26 13.08 40.77 33.47 14.76 20.4 14.76 44.53v67.7h-112.3ZM298.92-539.69q-35.07-35.08-35.07-84.93 0-49.84 35.07-84.92 35.08-35.08 84.93-35.08 49.84 0 84.92 35.08t35.08 84.92q0 49.85-35.08 84.93-35.08 35.07-84.92 35.07-49.85 0-84.93-35.07Zm340.45 0q-35.25 35.07-84.75 35.07-2.54 0-6.47-.57-3.92-.58-6.46-1.27 20.33-24.9 31.24-55.24 10.92-30.34 10.92-63.01t-11.43-62.44q-11.42-29.77-30.73-55.62 3.23-1.15 6.46-1.5 3.23-.35 6.47-.35 49.5 0 84.75 35.08t35.25 84.92q0 49.85-35.25 84.93ZM143.85-255.38h480v-25.85q0-14.08-7.04-24.62-7.04-10.53-25.27-20.15-44.77-23.92-94.39-36.65-49.61-12.73-113.3-12.73-63.7 0-113.31 12.73-49.62 12.73-94.39 36.65-18.23 9.62-25.27 20.15-7.03 10.54-7.03 24.62v25.85Zm296.5-312.74q23.5-23.5 23.5-56.5t-23.5-56.5q-23.5-23.5-56.5-23.5t-56.5 23.5q-23.5 23.5-23.5 56.5t23.5 56.5q23.5 23.5 56.5 23.5t56.5-23.5Zm-56.5 312.74Zm0-369.24Z"/></svg>
crates/app/assets/symbols/image.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M224.62-160q-27.62 0-46.12-18.5Q160-197 160-224.62v-510.76q0-27.62 18.5-46.12Q197-800 224.62-800h510.76q27.62 0 46.12 18.5Q800-763 800-735.38v510.76q0 27.62-18.5 46.12Q763-160 735.38-160H224.62Zm0-40h510.76q9.24 0 16.93-7.69 7.69-7.69 7.69-16.93v-510.76q0-9.24-7.69-16.93-7.69-7.69-16.93-7.69H224.62q-9.24 0-16.93 7.69-7.69 7.69-7.69 16.93v510.76q0 9.24 7.69 16.93 7.69 7.69 16.93 7.69ZM300-300h366.15L553.08-450.77 448.46-318.46l-70-84.62L300-300ZM200-200v-560 560Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M224.62-160q-27.62 0-46.12-18.5Q160-197 160-224.62v-510.76q0-27.62 18.5-46.12Q197-800 224.62-800h510.76q27.62 0 46.12 18.5Q800-763 800-735.38v510.76q0 27.62-18.5 46.12Q763-160 735.38-160H224.62Zm0-40h510.76q9.24 0 16.93-7.69 7.69-7.69 7.69-16.93v-510.76q0-9.24-7.69-16.93-7.69-7.69-16.93-7.69H224.62q-9.24 0-16.93 7.69-7.69 7.69-7.69 16.93v510.76q0 9.24 7.69 16.93 7.69 7.69 16.93 7.69ZM300-300h366.15L553.08-450.77 448.46-318.46l-70-84.62L300-300ZM200-200v-560 560Z"/></svg>
crates/app/assets/symbols/notifications.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M200-209.23v-40h64.62v-316.92q0-78.39 49.61-137.89 49.62-59.5 125.77-74.11V-800q0-16.67 11.64-28.33Q463.28-840 479.91-840t28.36 11.67Q520-816.67 520-800v21.85q76.15 14.61 125.77 74.11 49.61 59.5 49.61 137.89v316.92H760v40H200Zm280-286.15Zm-.14 390.76q-26.71 0-45.59-18.98-18.89-18.98-18.89-45.63h129.24q0 26.85-19.03 45.73-19.02 18.88-45.73 18.88ZM304.62-249.23h350.76v-316.92q0-72.93-51.23-124.16-51.23-51.23-124.15-51.23-72.92 0-124.15 51.23-51.23 51.23-51.23 124.16v316.92Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M200-209.23v-40h64.62v-316.92q0-78.39 49.61-137.89 49.62-59.5 125.77-74.11V-800q0-16.67 11.64-28.33Q463.28-840 479.91-840t28.36 11.67Q520-816.67 520-800v21.85q76.15 14.61 125.77 74.11 49.61 59.5 49.61 137.89v316.92H760v40H200Zm280-286.15Zm-.14 390.76q-26.71 0-45.59-18.98-18.89-18.98-18.89-45.63h129.24q0 26.85-19.03 45.73-19.02 18.88-45.73 18.88ZM304.62-249.23h350.76v-316.92q0-72.93-51.23-124.16-51.23-51.23-124.15-51.23-72.92 0-124.15 51.23-51.23 51.23-51.23 124.16v316.92Z"/></svg>
crates/app/assets/symbols/reply.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M760-240v-120q0-57.69-41.15-98.85Q677.69-500 620-500H236.85l164 164-28.54 28.31L160-520l212.31-212.31L400.85-704l-164 164H620q74.54 0 127.27 52.73Q800-434.54 800-360v120h-40Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M760-240v-120q0-57.69-41.15-98.85Q677.69-500 620-500H236.85l164 164-28.54 28.31L160-520l212.31-212.31L400.85-704l-164 164H620q74.54 0 127.27 52.73Q800-434.54 800-360v120h-40Z"/></svg>
crates/app/assets/symbols/tag.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m285.38-196.92 40-160H180.77l10-40h144.61l41.54-166.16H232.31l10-40h144.61l40-160h38.46l-40 160h170.77l40-160h38.47l-40 160h144.61l-10 40H624.62l-41.54 166.16h144.61l-10 40H573.08l-40 160h-38.46l40-160H363.85l-40 160h-38.47Zm88.47-200h170.77l41.53-166.16H415.38l-41.53 166.16Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m285.38-196.92 40-160H180.77l10-40h144.61l41.54-166.16H232.31l10-40h144.61l40-160h38.46l-40 160h170.77l40-160h38.47l-40 160h144.61l-10 40H624.62l-41.54 166.16h144.61l-10 40H573.08l-40 160h-38.46l40-160H363.85l-40 160h-38.47Zm88.47-200h170.77l41.53-166.16H415.38l-41.53 166.16Z"/></svg>
crates/app/src/assets.rs +19 −5
@@ -2,11 +2,25 @@ use std::borrow::Cow;
2 2
3 3 use gpui_kit::{AssetSource, Result, SharedString};
4 4
5 const SYMBOLS: [(&str, &[u8]); 4] = [
6 ("symbols/done.svg", include_bytes!("../assets/symbols/done.svg")),
7 ("symbols/done_all.svg", include_bytes!("../assets/symbols/done_all.svg")),
8 ("symbols/keyboard_return.svg", include_bytes!("../assets/symbols/keyboard_return.svg")),
9 ("symbols/schedule.svg", include_bytes!("../assets/symbols/schedule.svg")),
5 macro_rules! symbols {
6 ($($name:literal),* $(,)?) => {
7 [$((concat!("symbols/", $name, ".svg"), include_bytes!(concat!("../assets/symbols/", $name, ".svg")) as &[u8])),*]
8 };
9 }
10
11 const SYMBOLS: [(&str, &[u8]); 12] = symbols![
12 "done",
13 "done_all",
14 "keyboard_return",
15 "schedule",
16 "close",
17 "reply",
18 "group",
19 "tag",
20 "image",
21 "check_circle",
22 "error",
23 "notifications",
10 24 ];
11 25
12 26 pub struct AppAssets;
@@ -2,11 +2,25 @@ use std::borrow::Cow;
2
2
3use gpui_kit::{AssetSource, Result, SharedString};
3use gpui_kit::{AssetSource, Result, SharedString};
4
4
5const SYMBOLS: [(&str, &[u8]); 4] = [
5macro_rules! symbols {
6 ("symbols/done.svg", include_bytes!("../assets/symbols/done.svg")),
6 ($($name:literal),* $(,)?) => {
7 ("symbols/done_all.svg", include_bytes!("../assets/symbols/done_all.svg")),
7 [$((concat!("symbols/", $name, ".svg"), include_bytes!(concat!("../assets/symbols/", $name, ".svg")) as &[u8])),*]
8 ("symbols/keyboard_return.svg", include_bytes!("../assets/symbols/keyboard_return.svg")),
8 };
9 ("symbols/schedule.svg", include_bytes!("../assets/symbols/schedule.svg")),
9}
10
11const SYMBOLS: [(&str, &[u8]); 12] = symbols![
12 "done",
13 "done_all",
14 "keyboard_return",
15 "schedule",
16 "close",
17 "reply",
18 "group",
19 "tag",
20 "image",
21 "check_circle",
22 "error",
23 "notifications",
10];
24];
11
25
12pub struct AppAssets;
26pub struct AppAssets;
crates/app/src/main.rs +9 −8
@@ -13,6 +13,7 @@ mod format;
13 13 mod assets;
14 14 mod frame_log;
15 15 mod fuzzy;
16 mod notify;
16 17 mod render;
17 18 mod rows;
18 19 mod runtime;
@@ -141,13 +142,6 @@ fn main() {
141 142 theme::load_fonts(cx);
142 143 theme::apply(cx);
143 144 bind_keys(cx);
144 cx.on_window_closed(|cx, _| {
145 if cx.windows().is_empty() {
146 cx.quit();
147 }
148 })
149 .detach();
150
151 145 let state = cx.new(|_| {
152 146 let mut state = AppState::new(store, mode);
153 147 state.start_on_channels = arguments.channels_tab;
@@ -182,10 +176,17 @@ fn main() {
182 176 composer_text: arguments.composer_text,
183 177 reply_to_last: arguments.reply_to_last,
184 178 };
185 gpui_kit::open_window(options, cx, move |window, cx| {
179 let (main_window, _) = gpui_kit::open_window(options, cx, move |window, cx| {
186 180 cx.new(|cx| AppShell::new(state, open_target, startup, window, cx))
187 181 })
188 182 .expect("failed to open window");
183 let main_window_id = main_window.window_id();
184 cx.on_window_closed(move |cx, closed| {
185 if closed == main_window_id {
186 cx.quit();
187 }
188 })
189 .detach();
189 190 cx.activate(true);
190 191 });
191 192 }
@@ -13,6 +13,7 @@ mod format;
13mod assets;
13mod assets;
14mod frame_log;
14mod frame_log;
15mod fuzzy;
15mod fuzzy;
16mod notify;
16mod render;
17mod render;
17mod rows;
18mod rows;
18mod runtime;
19mod runtime;
@@ -141,13 +142,6 @@ fn main() {
141 theme::load_fonts(cx);
142 theme::load_fonts(cx);
142 theme::apply(cx);
143 theme::apply(cx);
143 bind_keys(cx);
144 bind_keys(cx);
144 cx.on_window_closed(|cx, _| {
145 if cx.windows().is_empty() {
146 cx.quit();
147 }
148 })
149 .detach();
150
151 let state = cx.new(|_| {
145 let state = cx.new(|_| {
152 let mut state = AppState::new(store, mode);
146 let mut state = AppState::new(store, mode);
153 state.start_on_channels = arguments.channels_tab;
147 state.start_on_channels = arguments.channels_tab;
@@ -182,10 +176,17 @@ fn main() {
182 composer_text: arguments.composer_text,
176 composer_text: arguments.composer_text,
183 reply_to_last: arguments.reply_to_last,
177 reply_to_last: arguments.reply_to_last,
184 };
178 };
185 gpui_kit::open_window(options, cx, move |window, cx| {
179 let (main_window, _) = gpui_kit::open_window(options, cx, move |window, cx| {
186 cx.new(|cx| AppShell::new(state, open_target, startup, window, cx))
180 cx.new(|cx| AppShell::new(state, open_target, startup, window, cx))
187 })
181 })
188 .expect("failed to open window");
182 .expect("failed to open window");
183 let main_window_id = main_window.window_id();
184 cx.on_window_closed(move |cx, closed| {
185 if closed == main_window_id {
186 cx.quit();
187 }
188 })
189 .detach();
189 cx.activate(true);
190 cx.activate(true);
190 });
191 });
191}
192}
crates/app/src/notify/badge.rs added +154 −0
@@ -0,0 +1,154 @@
1 pub const BADGE_SIZE: usize = 32;
2 const GLYPH_WIDTH: usize = 5;
3 const GLYPH_HEIGHT: usize = 7;
4 const GLYPH_SCALE: usize = 2;
5 const GLYPH_GAP: usize = 1;
6 const NEUTRAL: [u8; 3] = [0xf4, 0xf4, 0xf5];
7 const MENTION: [u8; 3] = [0xef, 0x44, 0x44];
8 const INK: [u8; 3] = [0x0a, 0x0a, 0x0a];
9
10 #[derive(Debug, Clone, PartialEq, Eq)]
11 pub struct Badge {
12 pub text: String,
13 pub mention: bool,
14 }
15
16 pub fn badge_for(unread_chats: usize, unread_mention: bool) -> Option<Badge> {
17 if unread_chats == 0 {
18 return None;
19 }
20 let text = if unread_chats >= 10 {
21 "9+".to_owned()
22 } else {
23 unread_chats.to_string()
24 };
25 Some(Badge {
26 text,
27 mention: unread_mention,
28 })
29 }
30
31 const GLYPHS: [[u8; GLYPH_HEIGHT]; 11] = [
32 [0b01110, 0b10001, 0b10011, 0b10101, 0b11001, 0b10001, 0b01110],
33 [0b00100, 0b01100, 0b00100, 0b00100, 0b00100, 0b00100, 0b01110],
34 [0b01110, 0b10001, 0b00001, 0b00010, 0b00100, 0b01000, 0b11111],
35 [0b11110, 0b00001, 0b00001, 0b01110, 0b00001, 0b00001, 0b11110],
36 [0b00010, 0b00110, 0b01010, 0b10010, 0b11111, 0b00010, 0b00010],
37 [0b11111, 0b10000, 0b11110, 0b00001, 0b00001, 0b10001, 0b01110],
38 [0b00110, 0b01000, 0b10000, 0b11110, 0b10001, 0b10001, 0b01110],
39 [0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b01000, 0b01000],
40 [0b01110, 0b10001, 0b10001, 0b01110, 0b10001, 0b10001, 0b01110],
41 [0b01110, 0b10001, 0b10001, 0b01111, 0b00001, 0b00010, 0b01100],
42 [0b00000, 0b00100, 0b00100, 0b11111, 0b00100, 0b00100, 0b00000],
43 ];
44
45 fn glyph_for(character: char) -> Option<&'static [u8; GLYPH_HEIGHT]> {
46 match character {
47 '0'..='9' => GLYPHS.get(character as usize - '0' as usize),
48 '+' => GLYPHS.get(10),
49 _ => None,
50 }
51 }
52
53 pub fn text_width(text: &str) -> usize {
54 let glyphs = text.chars().count();
55 if glyphs == 0 {
56 return 0;
57 }
58 glyphs * GLYPH_WIDTH * GLYPH_SCALE + (glyphs - 1) * GLYPH_GAP * GLYPH_SCALE
59 }
60
61 /// BGRA, premultiplied, top-down, `BADGE_SIZE` square.
62 pub fn render_badge(badge: &Badge) -> Vec<u8> {
63 let fill = if badge.mention { MENTION } else { NEUTRAL };
64 let mut pixels = vec![0u8; BADGE_SIZE * BADGE_SIZE * 4];
65 let center = (BADGE_SIZE as f32 - 1.) / 2.;
66 let radius = BADGE_SIZE as f32 / 2.;
67 for row in 0..BADGE_SIZE {
68 for column in 0..BADGE_SIZE {
69 let distance = ((column as f32 - center).powi(2) + (row as f32 - center).powi(2)).sqrt();
70 if distance <= radius - 0.5 {
71 put(&mut pixels, column, row, fill);
72 }
73 }
74 }
75 let width = text_width(&badge.text);
76 let left = (BADGE_SIZE - width.min(BADGE_SIZE)) / 2;
77 let top = (BADGE_SIZE - GLYPH_HEIGHT * GLYPH_SCALE) / 2;
78 for (index, character) in badge.text.chars().enumerate() {
79 let Some(glyph) = glyph_for(character) else {
80 continue;
81 };
82 let origin = left + index * (GLYPH_WIDTH + GLYPH_GAP) * GLYPH_SCALE;
83 for (glyph_row, bits) in glyph.iter().enumerate() {
84 for glyph_column in 0..GLYPH_WIDTH {
85 if bits & (1 << (GLYPH_WIDTH - 1 - glyph_column)) == 0 {
86 continue;
87 }
88 for dy in 0..GLYPH_SCALE {
89 for dx in 0..GLYPH_SCALE {
90 put(
91 &mut pixels,
92 origin + glyph_column * GLYPH_SCALE + dx,
93 top + glyph_row * GLYPH_SCALE + dy,
94 INK,
95 );
96 }
97 }
98 }
99 }
100 }
101 pixels
102 }
103
104 fn put(pixels: &mut [u8], column: usize, row: usize, rgb: [u8; 3]) {
105 if column >= BADGE_SIZE || row >= BADGE_SIZE {
106 return;
107 }
108 let offset = (row * BADGE_SIZE + column) * 4;
109 pixels[offset..offset + 4].copy_from_slice(&[rgb[2], rgb[1], rgb[0], 0xff]);
110 }
111
112 #[cfg(test)]
113 mod tests {
114 use super::*;
115
116 #[test]
117 fn no_unread_means_no_badge() {
118 assert_eq!(badge_for(0, true), None);
119 }
120
121 #[test]
122 fn counts_chats_and_caps_at_nine_plus() {
123 assert_eq!(badge_for(3, false).unwrap().text, "3");
124 assert_eq!(badge_for(9, false).unwrap().text, "9");
125 assert_eq!(badge_for(10, false).unwrap().text, "9+");
126 assert_eq!(badge_for(250, false).unwrap().text, "9+");
127 }
128
129 #[test]
130 fn mention_turns_badge_red() {
131 assert!(badge_for(1, true).unwrap().mention);
132 assert!(!badge_for(1, false).unwrap().mention);
133 }
134
135 #[test]
136 fn rendered_badge_has_fill_ink_and_transparent_corner() {
137 let badge = badge_for(3, true).unwrap();
138 let pixels = render_badge(&badge);
139 assert_eq!(pixels.len(), BADGE_SIZE * BADGE_SIZE * 4);
140 assert_eq!(pixels[3], 0);
141 let has = |blue: u8, green: u8, red: u8| {
142 pixels
143 .chunks(4)
144 .any(|pixel| pixel == [blue, green, red, 0xff])
145 };
146 assert!(has(0x44, 0x44, 0xef));
147 assert!(has(0x0a, 0x0a, 0x0a));
148 }
149
150 #[test]
151 fn two_glyphs_fit_the_badge() {
152 assert!(text_width("9+") < BADGE_SIZE);
153 }
154 }
@@ -0,0 +1,154 @@
1pub const BADGE_SIZE: usize = 32;
2const GLYPH_WIDTH: usize = 5;
3const GLYPH_HEIGHT: usize = 7;
4const GLYPH_SCALE: usize = 2;
5const GLYPH_GAP: usize = 1;
6const NEUTRAL: [u8; 3] = [0xf4, 0xf4, 0xf5];
7const MENTION: [u8; 3] = [0xef, 0x44, 0x44];
8const INK: [u8; 3] = [0x0a, 0x0a, 0x0a];
9
10#[derive(Debug, Clone, PartialEq, Eq)]
11pub struct Badge {
12 pub text: String,
13 pub mention: bool,
14}
15
16pub fn badge_for(unread_chats: usize, unread_mention: bool) -> Option<Badge> {
17 if unread_chats == 0 {
18 return None;
19 }
20 let text = if unread_chats >= 10 {
21 "9+".to_owned()
22 } else {
23 unread_chats.to_string()
24 };
25 Some(Badge {
26 text,
27 mention: unread_mention,
28 })
29}
30
31const GLYPHS: [[u8; GLYPH_HEIGHT]; 11] = [
32 [0b01110, 0b10001, 0b10011, 0b10101, 0b11001, 0b10001, 0b01110],
33 [0b00100, 0b01100, 0b00100, 0b00100, 0b00100, 0b00100, 0b01110],
34 [0b01110, 0b10001, 0b00001, 0b00010, 0b00100, 0b01000, 0b11111],
35 [0b11110, 0b00001, 0b00001, 0b01110, 0b00001, 0b00001, 0b11110],
36 [0b00010, 0b00110, 0b01010, 0b10010, 0b11111, 0b00010, 0b00010],
37 [0b11111, 0b10000, 0b11110, 0b00001, 0b00001, 0b10001, 0b01110],
38 [0b00110, 0b01000, 0b10000, 0b11110, 0b10001, 0b10001, 0b01110],
39 [0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b01000, 0b01000],
40 [0b01110, 0b10001, 0b10001, 0b01110, 0b10001, 0b10001, 0b01110],
41 [0b01110, 0b10001, 0b10001, 0b01111, 0b00001, 0b00010, 0b01100],
42 [0b00000, 0b00100, 0b00100, 0b11111, 0b00100, 0b00100, 0b00000],
43];
44
45fn glyph_for(character: char) -> Option<&'static [u8; GLYPH_HEIGHT]> {
46 match character {
47 '0'..='9' => GLYPHS.get(character as usize - '0' as usize),
48 '+' => GLYPHS.get(10),
49 _ => None,
50 }
51}
52
53pub fn text_width(text: &str) -> usize {
54 let glyphs = text.chars().count();
55 if glyphs == 0 {
56 return 0;
57 }
58 glyphs * GLYPH_WIDTH * GLYPH_SCALE + (glyphs - 1) * GLYPH_GAP * GLYPH_SCALE
59}
60
61/// BGRA, premultiplied, top-down, `BADGE_SIZE` square.
62pub fn render_badge(badge: &Badge) -> Vec<u8> {
63 let fill = if badge.mention { MENTION } else { NEUTRAL };
64 let mut pixels = vec![0u8; BADGE_SIZE * BADGE_SIZE * 4];
65 let center = (BADGE_SIZE as f32 - 1.) / 2.;
66 let radius = BADGE_SIZE as f32 / 2.;
67 for row in 0..BADGE_SIZE {
68 for column in 0..BADGE_SIZE {
69 let distance = ((column as f32 - center).powi(2) + (row as f32 - center).powi(2)).sqrt();
70 if distance <= radius - 0.5 {
71 put(&mut pixels, column, row, fill);
72 }
73 }
74 }
75 let width = text_width(&badge.text);
76 let left = (BADGE_SIZE - width.min(BADGE_SIZE)) / 2;
77 let top = (BADGE_SIZE - GLYPH_HEIGHT * GLYPH_SCALE) / 2;
78 for (index, character) in badge.text.chars().enumerate() {
79 let Some(glyph) = glyph_for(character) else {
80 continue;
81 };
82 let origin = left + index * (GLYPH_WIDTH + GLYPH_GAP) * GLYPH_SCALE;
83 for (glyph_row, bits) in glyph.iter().enumerate() {
84 for glyph_column in 0..GLYPH_WIDTH {
85 if bits & (1 << (GLYPH_WIDTH - 1 - glyph_column)) == 0 {
86 continue;
87 }
88 for dy in 0..GLYPH_SCALE {
89 for dx in 0..GLYPH_SCALE {
90 put(
91 &mut pixels,
92 origin + glyph_column * GLYPH_SCALE + dx,
93 top + glyph_row * GLYPH_SCALE + dy,
94 INK,
95 );
96 }
97 }
98 }
99 }
100 }
101 pixels
102}
103
104fn put(pixels: &mut [u8], column: usize, row: usize, rgb: [u8; 3]) {
105 if column >= BADGE_SIZE || row >= BADGE_SIZE {
106 return;
107 }
108 let offset = (row * BADGE_SIZE + column) * 4;
109 pixels[offset..offset + 4].copy_from_slice(&[rgb[2], rgb[1], rgb[0], 0xff]);
110}
111
112#[cfg(test)]
113mod tests {
114 use super::*;
115
116 #[test]
117 fn no_unread_means_no_badge() {
118 assert_eq!(badge_for(0, true), None);
119 }
120
121 #[test]
122 fn counts_chats_and_caps_at_nine_plus() {
123 assert_eq!(badge_for(3, false).unwrap().text, "3");
124 assert_eq!(badge_for(9, false).unwrap().text, "9");
125 assert_eq!(badge_for(10, false).unwrap().text, "9+");
126 assert_eq!(badge_for(250, false).unwrap().text, "9+");
127 }
128
129 #[test]
130 fn mention_turns_badge_red() {
131 assert!(badge_for(1, true).unwrap().mention);
132 assert!(!badge_for(1, false).unwrap().mention);
133 }
134
135 #[test]
136 fn rendered_badge_has_fill_ink_and_transparent_corner() {
137 let badge = badge_for(3, true).unwrap();
138 let pixels = render_badge(&badge);
139 assert_eq!(pixels.len(), BADGE_SIZE * BADGE_SIZE * 4);
140 assert_eq!(pixels[3], 0);
141 let has = |blue: u8, green: u8, red: u8| {
142 pixels
143 .chunks(4)
144 .any(|pixel| pixel == [blue, green, red, 0xff])
145 };
146 assert!(has(0x44, 0x44, 0xef));
147 assert!(has(0x0a, 0x0a, 0x0a));
148 }
149
150 #[test]
151 fn two_glyphs_fit_the_badge() {
152 assert!(text_width("9+") < BADGE_SIZE);
153 }
154}
crates/app/src/notify/center.rs added +835 −0
@@ -0,0 +1,835 @@
1 use std::collections::{HashMap, HashSet};
2 use std::time::{Duration, Instant};
3
4 use chrono::Utc;
5 use gpui_kit::*;
6 use store::Sidebar;
7
8 use super::badge::{Badge, badge_for};
9 use super::incoming::IncomingTracker;
10 use super::layout::{self, Slot};
11 use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};
12 use super::rules::{
13 ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide,
14 should_flash,
15 };
16 use super::settings;
17 use super::stack::{ReplyState, SENT_DURATION, ToastModel, ToastStack};
18 use super::toast::{PillView, ToastView};
19 use super::settings_view::SettingsView;
20 use crate::app_state::{AppEvent, AppState, Selection};
21 use crate::data::{Directory, PresenceKind};
22 use crate::runtime;
23
24 const TICK: Duration = Duration::from_millis(33);
25 const SLIDE_DURATION: Duration = Duration::from_millis(180);
26 const SLIDE_DISTANCE: f32 = 48.;
27 const DEMO_SPEC_DELAY: Duration = Duration::from_secs(3);
28 const FALLBACK_BORDER: u32 = 0x3f3f42;
29 const MENTION_BORDER: u32 = 0xce6a3b;
30
31 struct OpenWindow {
32 handle: AnyWindowHandle,
33 native: Option<NativeHandle>,
34 opened: Instant,
35 mention: bool,
36 }
37
38 pub struct NotificationCenter {
39 app: Entity<AppState>,
40 main_window: AnyWindowHandle,
41 main_native: Option<NativeHandle>,
42 settings: Settings,
43 stack: ToastStack,
44 tracker: IncomingTracker,
45 throttle: SoundThrottle,
46 windows: HashMap<u64, OpenWindow>,
47 pill: Option<OpenWindow>,
48 settings_window: Option<AnyWindowHandle>,
49 unread_mentions: HashSet<String>,
50 tray: Option<Tray>,
51 shown_badge: Option<Badge>,
52 animations: bool,
53 _subscription: Subscription,
54 }
55
56 impl NotificationCenter {
57 pub fn new(
58 app: Entity<AppState>,
59 window: &mut Window,
60 cx: &mut Context<Self>,
61 ) -> Self {
62 let settings = settings::load(&app.read(cx).store);
63 let tray = if app.read(cx).mode.demo {
64 None
65 } else {
66 Tray::new(settings.sound, settings.do_not_disturb)
67 };
68 let subscription = cx.subscribe(&app, |this, _, event: &AppEvent, cx| {
69 this.on_app_event(event, cx);
70 });
71 let center = NotificationCenter {
72 main_window: window.window_handle(),
73 main_native: platform::native_handle(window),
74 settings,
75 stack: ToastStack::default(),
76 tracker: IncomingTracker::new(Utc::now()),
77 throttle: SoundThrottle::default(),
78 windows: HashMap::new(),
79 pill: None,
80 settings_window: None,
81 unread_mentions: HashSet::new(),
82 tray,
83 shown_badge: None,
84 animations: platform::animations_enabled(),
85 app,
86 _subscription: subscription,
87 };
88 cx.spawn(async move |this, cx| {
89 loop {
90 cx.background_executor().timer(TICK).await;
91 if this.update(cx, |center, cx| center.tick(cx)).is_err() {
92 break;
93 }
94 }
95 })
96 .detach();
97 if center.app.read(cx).mode.demo {
98 cx.spawn(async move |this, cx| {
99 cx.background_executor().timer(DEMO_SPEC_DELAY).await;
100 this.update(cx, |center, cx| center.show_demo_toasts(cx)).ok();
101 })
102 .detach();
103 }
104 center
105 }
106
107 pub fn settings(&self) -> &Settings {
108 &self.settings
109 }
110
111 pub fn model(&self, id: u64) -> Option<&ToastModel> {
112 self.stack.get(id)
113 }
114
115 pub fn hidden_count(&self) -> usize {
116 self.stack.hidden_count()
117 }
118
119 pub fn directory<'a>(&self, cx: &'a App) -> &'a Directory {
120 &self.app.read(cx).directory
121 }
122
123 pub fn reply_text(&self, id: u64) -> Option<String> {
124 self.stack.get(id).map(|toast| toast.reply_text.clone())
125 }
126
127 pub fn intercept_close(&self, _cx: &App) -> bool {
128 match (self.settings.close_to_tray, &self.tray, self.main_native) {
129 (true, Some(_), Some(native)) => {
130 platform::hide_window(native);
131 true
132 }
133 _ => false,
134 }
135 }
136
137 pub fn update_settings(&mut self, cx: &mut Context<Self>, change: impl FnOnce(&mut Settings)) {
138 change(&mut self.settings);
139 settings::save(&self.app.read(cx).store, &self.settings);
140 self.sync_tray();
141 cx.notify();
142 }
143
144 fn on_app_event(&mut self, event: &AppEvent, cx: &mut Context<Self>) {
145 match event {
146 AppEvent::Messages(conversation_id) => self.on_messages(conversation_id, cx),
147 AppEvent::Selection => self.on_selection(cx),
148 AppEvent::Sidebar => self.refresh_badge(cx),
149 _ => {}
150 }
151 }
152
153 fn on_selection(&mut self, cx: &mut Context<Self>) {
154 let selected = self
155 .app
156 .read(cx)
157 .selection
158 .as_ref()
159 .map(|selection| selection.conversation_id().to_owned());
160 if let Some(conversation_id) = selected {
161 self.unread_mentions.remove(&conversation_id);
162 self.stack.remove_conversation(&conversation_id);
163 }
164 self.refresh_badge(cx);
165 }
166
167 fn on_messages(&mut self, conversation_id: &str, cx: &mut Context<Self>) {
168 let state = self.app.read(cx);
169 let my_user_id = state.directory.me.as_ref().map(|me| me.user_id.clone());
170 let found = self.tracker.collect(
171 &state.store,
172 &state.sidebar,
173 my_user_id.as_deref(),
174 conversation_id,
175 );
176 for incoming in found {
177 self.handle_incoming(incoming, cx);
178 }
179 self.refresh_badge(cx);
180 }
181
182 fn environment(&self, conversation_id: &str, cx: &mut Context<Self>) -> Environment {
183 let state = self.app.read(cx);
184 let selected = state
185 .selection
186 .as_ref()
187 .is_some_and(|selection| selection.conversation_id() == conversation_id);
188 let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {
189 state.directory.presence_of(&me.user_id) == PresenceKind::DoNotDisturb
190 });
191 Environment {
192 chat_in_foreground: selected && self.main_window_active(cx),
193 system_quiet: platform::system_quiet(),
194 own_do_not_disturb,
195 in_call: false,
196 }
197 }
198
199 fn main_window_active(&self, cx: &mut Context<Self>) -> bool {
200 self.main_window
201 .update(cx, |_, window, _| window.is_window_active())
202 .unwrap_or(false)
203 }
204
205 pub fn handle_incoming(&mut self, incoming: Incoming, cx: &mut Context<Self>) {
206 let environment = self.environment(&incoming.conversation_id, cx);
207 if !environment.chat_in_foreground && incoming.mentions_me {
208 self.unread_mentions
209 .insert(incoming.conversation_id.clone());
210 }
211 let decision = decide(&self.settings, &incoming, environment);
212 self.present(&incoming, decision, cx);
213 if should_flash(
214 &self.settings,
215 incoming.mentions_me && decision.toast,
216 self.main_window_active(cx),
217 ) && let Some(native) = self.main_native
218 {
219 platform::flash(native);
220 }
221 }
222
223 fn present(&mut self, incoming: &Incoming, decision: Decision, cx: &mut Context<Self>) {
224 if !decision.toast {
225 return;
226 }
227 let now = Instant::now();
228 let outcome = self.stack.push(incoming, now);
229 if let Some(model) = self.stack.get_mut(outcome.id) {
230 model.time = chrono::Local::now().format("%H:%M").to_string();
231 }
232 let throttle_allows = self.throttle.allow(&incoming.conversation_id, now);
233 if decision.sound && outcome.plays_sound(throttle_allows) && !self.app.read(cx).mode.demo {
234 platform::play_sound();
235 }
236 if let Some(user_id) = incoming.sender_id.clone() {
237 self.app
238 .update(cx, |state, cx| state.request_avatars(vec![user_id], cx));
239 }
240 self.sync_windows(cx);
241 }
242
243 fn visible_ids(&self) -> Vec<u64> {
244 self.stack.visible().iter().map(|toast| toast.id).collect()
245 }
246
247 fn work_area(&self, cx: &App) -> WorkArea {
248 if let Some(area) = self.main_native.and_then(platform::work_area) {
249 return area;
250 }
251 let bounds = cx
252 .primary_display()
253 .map(|display| display.bounds())
254 .unwrap_or_else(|| Bounds::new(point(px(0.), px(0.)), size(px(1280.), px(720.))));
255 WorkArea {
256 left: f32::from(bounds.origin.x) as i32,
257 top: f32::from(bounds.origin.y) as i32,
258 right: f32::from(bounds.origin.x + bounds.size.width) as i32,
259 bottom: f32::from(bounds.origin.y + bounds.size.height) as i32,
260 scale: 1.,
261 }
262 }
263
264 fn sync_windows(&mut self, cx: &mut Context<Self>) {
265 let visible = self.visible_ids();
266 let stale: Vec<u64> = self
267 .windows
268 .keys()
269 .filter(|id| !visible.contains(id))
270 .copied()
271 .collect();
272 for id in stale {
273 self.close_window(id, cx);
274 }
275 let area = self.work_area(cx);
276 let heights: Vec<f32> = self
277 .stack
278 .visible()
279 .iter()
280 .map(|toast| layout::toast_height(toast, toast.hovered, self.settings.preview))
281 .collect();
282 let hidden = self.stack.hidden_count();
283 let slots = layout::stack_slots(area, self.settings.corner, &heights, hidden > 0);
284 for (id, slot) in visible.iter().zip(slots.toasts.iter()) {
285 self.place_toast(*id, *slot, area, cx);
286 }
287 self.sync_pill(slots.pill, area, hidden, cx);
288 }
289
290 fn slide_offset(&self, opened: Instant, area: WorkArea) -> i32 {
291 if !self.animations {
292 return 0;
293 }
294 let progress = (opened.elapsed().as_secs_f32() / SLIDE_DURATION.as_secs_f32()).min(1.);
295 let eased = 1. - (1. - progress).powi(3);
296 let distance = ((1. - eased) * SLIDE_DISTANCE * area.scale) as i32;
297 if self.settings.corner.is_right() {
298 distance
299 } else {
300 -distance
301 }
302 }
303
304 fn place_toast(&mut self, id: u64, slot: Slot, area: WorkArea, cx: &mut Context<Self>) {
305 let mention = self.stack.get(id).is_some_and(|toast| toast.mentions_me);
306 if !self.windows.contains_key(&id) {
307 let Some(window) = self.open_toast_window(id, slot, area, cx) else {
308 return;
309 };
310 self.windows.insert(id, window);
311 }
312 let offset = self
313 .windows
314 .get(&id)
315 .map(|window| self.slide_offset(window.opened, area))
316 .unwrap_or(0);
317 if let Some(window) = self.windows.get_mut(&id)
318 && let Some(native) = window.native
319 {
320 platform::place(native, slot.x + offset, slot.y, slot.width, slot.height);
321 if window.mention != mention {
322 window.mention = mention;
323 platform::set_border_color(native, border_color(mention));
324 }
325 }
326 }
327
328 fn open_toast_window(
329 &mut self,
330 id: u64,
331 slot: Slot,
332 area: WorkArea,
333 cx: &mut Context<Self>,
334 ) -> Option<OpenWindow> {
335 let mention = self.stack.get(id).is_some_and(|toast| toast.mentions_me);
336 let options = popup_options(slot, area);
337 let center = cx.entity();
338 let (handle, _view) = gpui_kit::open_window(options, cx, move |window, cx| {
339 cx.new(|cx| ToastView::new(center, id, window, cx))
340 })
341 .ok()?;
342 let native = handle
343 .update(cx, |_, window, _| platform::native_handle(window))
344 .ok()
345 .flatten();
346 if let Some(native) = native {
347 platform::prepare_toast_window(native);
348 platform::set_border_color(native, border_color(mention));
349 }
350 Some(OpenWindow {
351 handle,
352 native,
353 opened: Instant::now(),
354 mention,
355 })
356 }
357
358 fn sync_pill(
359 &mut self,
360 slot: Option<Slot>,
361 area: WorkArea,
362 hidden: usize,
363 cx: &mut Context<Self>,
364 ) {
365 let Some(slot) = slot.filter(|_| hidden > 0) else {
366 if let Some(pill) = self.pill.take() {
367 pill.handle.update(cx, |_, window, _| window.remove_window()).ok();
368 }
369 return;
370 };
371 if self.pill.is_none() {
372 let options = popup_options(slot, area);
373 let center = cx.entity();
374 let opened = gpui_kit::open_window(options, cx, move |_, cx| {
375 cx.new(|cx| PillView::new(center, cx))
376 });
377 if let Ok((handle, _)) = opened {
378 let native = handle
379 .update(cx, |_, window, _| platform::native_handle(window))
380 .ok()
381 .flatten();
382 if let Some(native) = native {
383 platform::prepare_toast_window(native);
384 platform::set_border_color(native, border_color(false));
385 }
386 self.pill = Some(OpenWindow {
387 handle,
388 native,
389 opened: Instant::now(),
390 mention: false,
391 });
392 }
393 }
394 if let Some(native) = self.pill.as_ref().and_then(|pill| pill.native) {
395 platform::place(native, slot.x, slot.y, slot.width, slot.height);
396 }
397 }
398
399 fn close_window(&mut self, id: u64, cx: &mut Context<Self>) {
400 let closed = self.windows.get(&id).is_some_and(|window| {
401 window
402 .handle
403 .update(cx, |_, window, _| window.remove_window())
404 .is_ok()
405 });
406 if closed {
407 self.windows.remove(&id);
408 }
409 }
410
411 fn drop_toast(&mut self, id: u64, cx: &mut Context<Self>) {
412 self.stack.remove(id);
413 cx.notify();
414 }
415
416 fn tick(&mut self, cx: &mut Context<Self>) {
417 let now = Instant::now();
418 for id in self.stack.expired(now) {
419 self.stack.remove(id);
420 }
421 if !self.stack.is_empty() || !self.windows.is_empty() || self.pill.is_some() {
422 self.sync_windows(cx);
423 cx.notify();
424 }
425 self.poll_tray(cx);
426 }
427
428 fn poll_tray(&mut self, cx: &mut Context<Self>) {
429 let commands = self.tray.as_ref().map(Tray::poll).unwrap_or_default();
430 for command in commands {
431 match command {
432 TrayCommand::Toggle => self.toggle_main_window(cx),
433 TrayCommand::Open => self.raise_main_window(cx),
434 TrayCommand::ToggleSound => {
435 self.update_settings(cx, |settings| settings.sound = !settings.sound)
436 }
437 TrayCommand::ToggleDoNotDisturb => self.update_settings(cx, |settings| {
438 settings.do_not_disturb = !settings.do_not_disturb
439 }),
440 TrayCommand::Settings => self.open_settings(cx),
441 TrayCommand::Quit => cx.quit(),
442 }
443 }
444 }
445
446 fn toggle_main_window(&mut self, cx: &mut Context<Self>) {
447 if self.main_window_active(cx) {
448 if let Some(native) = self.main_native {
449 platform::hide_window(native);
450 }
451 } else {
452 self.raise_main_window(cx);
453 }
454 }
455
456 fn raise_main_window(&mut self, cx: &mut Context<Self>) {
457 if let Some(native) = self.main_native {
458 platform::restore_and_raise(native);
459 }
460 self.main_window
461 .update(cx, |_, window, _| window.activate_window())
462 .ok();
463 }
464
465 fn sync_tray(&self) {
466 if let Some(tray) = &self.tray {
467 tray.sync(
468 self.settings.sound,
469 self.settings.do_not_disturb,
470 !self.unread_mentions.is_empty(),
471 );
472 }
473 }
474
475 fn refresh_badge(&mut self, cx: &mut Context<Self>) {
476 let (count, still_unread) = unread_summary(&self.app.read(cx).sidebar);
477 self.unread_mentions
478 .retain(|conversation_id| still_unread.contains(conversation_id));
479 let badge = badge_for(count, !self.unread_mentions.is_empty());
480 if badge == self.shown_badge {
481 return;
482 }
483 if let Some(native) = self.main_native {
484 platform::set_badge(native, badge.as_ref());
485 }
486 self.shown_badge = badge;
487 self.sync_tray();
488 }
489
490 pub fn set_hover(&mut self, id: u64, hovered: bool, cx: &mut Context<Self>) {
491 let now = Instant::now();
492 let Some(toast) = self.stack.get_mut(id) else {
493 return;
494 };
495 if toast.hovered == hovered {
496 return;
497 }
498 toast.hovered = hovered;
499 if hovered {
500 toast.timer.pause(now);
501 } else if !toast.holds_open() {
502 toast.timer.resume(now);
503 }
504 cx.notify();
505 }
506
507 pub fn dismiss(&mut self, id: u64, cx: &mut Context<Self>) {
508 self.drop_toast(id, cx);
509 }
510
511 pub fn open_reply(&mut self, id: u64, cx: &mut Context<Self>) -> Option<String> {
512 let now = Instant::now();
513 let toast = self.stack.get_mut(id)?;
514 toast.reply = ReplyState::Open;
515 toast.timer.pause(now);
516 let draft = toast.reply_text.clone();
517 cx.notify();
518 Some(draft)
519 }
520
521 pub fn close_reply(&mut self, id: u64, cx: &mut Context<Self>) {
522 if let Some(toast) = self.stack.get_mut(id) {
523 toast.reply = ReplyState::Closed;
524 toast.reply_text.clear();
525 toast.hovered = false;
526 }
527 cx.notify();
528 }
529
530 pub fn submit_reply(&mut self, id: u64, text: String, cx: &mut Context<Self>) {
531 let Some(toast) = self.stack.get_mut(id) else {
532 return;
533 };
534 toast.reply_text = text.clone();
535 let conversation_id = toast.conversation_id.clone();
536 let message_id = toast.message_id.clone();
537 let is_channel = matches!(toast.kind, ChatKind::Channel { .. });
538 let state = self.app.read(cx);
539 let (mode, engine) = (state.mode, state.engine.clone());
540 let outcome: Result<(), ()> = if mode.demo {
541 Ok(())
542 } else if mode.read_only {
543 Err(())
544 } else if let Some(engine) = engine {
545 let receiver = runtime::spawn(async move {
546 if is_channel {
547 engine.reply_to(&conversation_id, &message_id, &text).await
548 } else {
549 engine.send_message(&conversation_id, &text, None).await
550 }
551 .map(|_| ())
552 });
553 cx.spawn(async move |this, cx| {
554 let sent = matches!(receiver.await, Ok(Ok(())));
555 this.update(cx, |center, cx| center.finish_reply(id, sent, cx)).ok();
556 })
557 .detach();
558 return;
559 } else {
560 Err(())
561 };
562 self.finish_reply(id, outcome.is_ok(), cx);
563 }
564
565 fn finish_reply(&mut self, id: u64, sent: bool, cx: &mut Context<Self>) {
566 let Some(toast) = self.stack.get_mut(id) else {
567 return;
568 };
569 toast.reply = if sent {
570 ReplyState::Sent
571 } else {
572 ReplyState::Failed
573 };
574 let conversation_id = toast.conversation_id.clone();
575 cx.notify();
576 if sent {
577 cx.spawn(async move |this, cx| {
578 cx.background_executor().timer(SENT_DURATION).await;
579 this.update(cx, |center, cx| {
580 center.mark_conversation_read(&conversation_id, cx);
581 center.drop_toast(id, cx);
582 })
583 .ok();
584 })
585 .detach();
586 }
587 }
588
589 fn mark_conversation_read(&mut self, conversation_id: &str, cx: &mut Context<Self>) {
590 self.unread_mentions.remove(conversation_id);
591 let conversation_id = conversation_id.to_owned();
592 self.app
593 .update(cx, |state, cx| state.mark_chat_read(&conversation_id, cx));
594 self.refresh_badge(cx);
595 }
596
597 pub fn mark_read(&mut self, id: u64, cx: &mut Context<Self>) {
598 let Some(conversation_id) = self.stack.get(id).map(|toast| toast.conversation_id.clone())
599 else {
600 return;
601 };
602 self.mark_conversation_read(&conversation_id, cx);
603 self.drop_toast(id, cx);
604 }
605
606 pub fn activate(&mut self, id: u64, cx: &mut Context<Self>) {
607 let Some((conversation_id, message_id)) = self
608 .stack
609 .get(id)
610 .map(|toast| (toast.conversation_id.clone(), toast.message_id.clone()))
611 else {
612 return;
613 };
614 self.drop_toast(id, cx);
615 self.raise_main_window(cx);
616 let selection = selection_for(&self.app.read(cx).sidebar, &conversation_id);
617 if let Some(selection) = selection {
618 self.app.update(cx, |state, cx| {
619 state.jump_to_message(selection, message_id, cx)
620 });
621 }
622 }
623
624 pub fn open_chat_list(&mut self, cx: &mut Context<Self>) {
625 self.raise_main_window(cx);
626 }
627
628 pub fn open_settings(&mut self, cx: &mut Context<Self>) {
629 if let Some(handle) = self.settings_window {
630 if handle.update(cx, |_, window, _| window.activate_window()).is_ok() {
631 return;
632 }
633 self.settings_window = None;
634 }
635 let center = cx.entity();
636 let options = WindowOptions {
637 window_bounds: Some(WindowBounds::Windowed(Bounds::centered(
638 None,
639 size(px(SettingsView::WIDTH), px(SettingsView::HEIGHT)),
640 cx,
641 ))),
642 titlebar: Some(TitlebarOptions {
643 title: Some("Benachrichtigungen".into()),
644 ..Default::default()
645 }),
646 is_resizable: false,
647 is_minimizable: false,
648 ..Default::default()
649 };
650 if let Ok((handle, _)) = gpui_kit::open_window(options, cx, move |_, cx| {
651 cx.new(|cx| SettingsView::new(center, cx))
652 }) {
653 self.settings_window = Some(handle);
654 }
655 }
656
657 pub fn send_test_notification(&mut self, cx: &mut Context<Self>) {
658 let incoming = Incoming {
659 conversation_id: "test-notification".to_owned(),
660 message_id: "test".to_owned(),
661 kind: ChatKind::Direct,
662 chat_title: "Mara Lindqvist".to_owned(),
663 sender_id: None,
664 sender_name: "Mara Lindqvist".to_owned(),
665 preview: Preview::Text("Das ist eine Testbenachrichtigung.".to_owned()),
666 mentions_me: false,
667 muted: false,
668 };
669 let decision = Decision {
670 toast: true,
671 sound: self.settings.sound,
672 };
673 self.throttle = SoundThrottle::default();
674 self.present(&incoming, decision, cx);
675 }
676
677 fn show_demo_toasts(&mut self, cx: &mut Context<Self>) {
678 for incoming in demo_incoming() {
679 let decision = Decision {
680 toast: true,
681 sound: false,
682 };
683 self.present(&incoming, decision, cx);
684 }
685 }
686 }
687
688 fn border_color(mention: bool) -> u32 {
689 if mention { MENTION_BORDER } else { FALLBACK_BORDER }
690 }
691
692 fn popup_options(slot: Slot, area: WorkArea) -> WindowOptions {
693 let scale = area.scale;
694 let bounds = Bounds::new(
695 point(px(slot.x as f32 / scale), px(slot.y as f32 / scale)),
696 size(px(slot.width as f32 / scale), px(slot.height as f32 / scale)),
697 );
698 WindowOptions {
699 window_bounds: Some(WindowBounds::Windowed(bounds)),
700 titlebar: None,
701 focus: false,
702 show: true,
703 kind: WindowKind::PopUp,
704 is_movable: false,
705 is_resizable: false,
706 is_minimizable: false,
707 window_background: WindowBackgroundAppearance::Opaque,
708 ..Default::default()
709 }
710 }
711
712 pub fn selection_for(sidebar: &Sidebar, conversation_id: &str) -> Option<Selection> {
713 if sidebar.chats.iter().any(|chat| chat.id == conversation_id) {
714 return Some(Selection::Chat(conversation_id.to_owned()));
715 }
716 sidebar
717 .teams
718 .iter()
719 .flat_map(|team| team.channels.iter())
720 .any(|channel| channel.id == conversation_id)
721 .then(|| Selection::Channel(conversation_id.to_owned()))
722 }
723
724 pub fn unread_summary(sidebar: &Sidebar) -> (usize, HashSet<String>) {
725 let chats = sidebar.chats.iter().filter(|chat| chat.unread);
726 let channels = sidebar
727 .teams
728 .iter()
729 .flat_map(|team| team.channels.iter())
730 .filter(|channel| channel.unread);
731 let ids: HashSet<String> = chats
732 .map(|chat| chat.id.clone())
733 .chain(channels.map(|channel| channel.id.clone()))
734 .collect();
735 (ids.len(), ids)
736 }
737
738 fn demo_incoming() -> Vec<Incoming> {
739 let item = |conversation: &str, kind: ChatKind, title: &str, sender: &str, text: &str, mention: bool| Incoming {
740 conversation_id: conversation.to_owned(),
741 message_id: format!("{conversation}-message"),
742 kind,
743 chat_title: title.to_owned(),
744 sender_id: None,
745 sender_name: sender.to_owned(),
746 preview: Preview::Text(text.to_owned()),
747 mentions_me: mention,
748 muted: false,
749 };
750 vec![
751 item(
752 "demo-toast-direct",
753 ChatKind::Direct,
754 "Tobias Klein",
755 "Tobias Klein",
756 "Passt, ich schaue morgen drauf.",
757 false,
758 ),
759 item(
760 "demo-toast-group",
761 ChatKind::Group { member_count: 5 },
762 "Retro-Team",
763 "Priya Nair",
764 "Themen bitte bis 17 Uhr eintragen.",
765 false,
766 ),
767 item(
768 "demo-toast-mention",
769 ChatKind::Channel {
770 team: "Plattform".to_owned(),
771 channel: "Releases".to_owned(),
772 },
773 "Releases",
774 "Mara Lindqvist",
775 "@Daniel kannst du den Merge freigeben? Pipeline wartet.",
776 true,
777 ),
778 ]
779 }
780
781 #[cfg(test)]
782 mod tests {
783 use store::{ChannelRecord, ChatRecord, SidebarTeam, TeamRecord};
784
785 use super::{selection_for, unread_summary};
786 use crate::app_state::Selection;
787 use store::Sidebar;
788
789 fn sidebar() -> Sidebar {
790 Sidebar {
791 chats: vec![
792 ChatRecord {
793 id: "a".into(),
794 unread: true,
795 ..Default::default()
796 },
797 ChatRecord {
798 id: "b".into(),
799 unread: false,
800 ..Default::default()
801 },
802 ],
803 teams: vec![SidebarTeam {
804 team: TeamRecord {
805 id: "t".into(),
806 name: "Team".into(),
807 },
808 channels: vec![ChannelRecord {
809 id: "ch".into(),
810 team_id: "t".into(),
811 name: "General".into(),
812 membership_type: None,
813 last_message_at: None,
814 unread: true,
815 }],
816 hidden: false,
817 hidden_channel_ids: Vec::new(),
818 }],
819 }
820 }
821
822 #[test]
823 fn unread_summary_counts_chats_and_channels() {
824 let (count, ids) = unread_summary(&sidebar());
825 assert_eq!(count, 2);
826 assert!(ids.contains("a") && ids.contains("ch"));
827 }
828
829 #[test]
830 fn selection_kind_follows_sidebar() {
831 assert_eq!(selection_for(&sidebar(), "a"), Some(Selection::Chat("a".into())));
832 assert_eq!(selection_for(&sidebar(), "ch"), Some(Selection::Channel("ch".into())));
833 assert_eq!(selection_for(&sidebar(), "x"), None);
834 }
835 }
@@ -0,0 +1,835 @@
1use std::collections::{HashMap, HashSet};
2use std::time::{Duration, Instant};
3
4use chrono::Utc;
5use gpui_kit::*;
6use store::Sidebar;
7
8use super::badge::{Badge, badge_for};
9use super::incoming::IncomingTracker;
10use super::layout::{self, Slot};
11use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};
12use super::rules::{
13 ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide,
14 should_flash,
15};
16use super::settings;
17use super::stack::{ReplyState, SENT_DURATION, ToastModel, ToastStack};
18use super::toast::{PillView, ToastView};
19use super::settings_view::SettingsView;
20use crate::app_state::{AppEvent, AppState, Selection};
21use crate::data::{Directory, PresenceKind};
22use crate::runtime;
23
24const TICK: Duration = Duration::from_millis(33);
25const SLIDE_DURATION: Duration = Duration::from_millis(180);
26const SLIDE_DISTANCE: f32 = 48.;
27const DEMO_SPEC_DELAY: Duration = Duration::from_secs(3);
28const FALLBACK_BORDER: u32 = 0x3f3f42;
29const MENTION_BORDER: u32 = 0xce6a3b;
30
31struct OpenWindow {
32 handle: AnyWindowHandle,
33 native: Option<NativeHandle>,
34 opened: Instant,
35 mention: bool,
36}
37
38pub struct NotificationCenter {
39 app: Entity<AppState>,
40 main_window: AnyWindowHandle,
41 main_native: Option<NativeHandle>,
42 settings: Settings,
43 stack: ToastStack,
44 tracker: IncomingTracker,
45 throttle: SoundThrottle,
46 windows: HashMap<u64, OpenWindow>,
47 pill: Option<OpenWindow>,
48 settings_window: Option<AnyWindowHandle>,
49 unread_mentions: HashSet<String>,
50 tray: Option<Tray>,
51 shown_badge: Option<Badge>,
52 animations: bool,
53 _subscription: Subscription,
54}
55
56impl NotificationCenter {
57 pub fn new(
58 app: Entity<AppState>,
59 window: &mut Window,
60 cx: &mut Context<Self>,
61 ) -> Self {
62 let settings = settings::load(&app.read(cx).store);
63 let tray = if app.read(cx).mode.demo {
64 None
65 } else {
66 Tray::new(settings.sound, settings.do_not_disturb)
67 };
68 let subscription = cx.subscribe(&app, |this, _, event: &AppEvent, cx| {
69 this.on_app_event(event, cx);
70 });
71 let center = NotificationCenter {
72 main_window: window.window_handle(),
73 main_native: platform::native_handle(window),
74 settings,
75 stack: ToastStack::default(),
76 tracker: IncomingTracker::new(Utc::now()),
77 throttle: SoundThrottle::default(),
78 windows: HashMap::new(),
79 pill: None,
80 settings_window: None,
81 unread_mentions: HashSet::new(),
82 tray,
83 shown_badge: None,
84 animations: platform::animations_enabled(),
85 app,
86 _subscription: subscription,
87 };
88 cx.spawn(async move |this, cx| {
89 loop {
90 cx.background_executor().timer(TICK).await;
91 if this.update(cx, |center, cx| center.tick(cx)).is_err() {
92 break;
93 }
94 }
95 })
96 .detach();
97 if center.app.read(cx).mode.demo {
98 cx.spawn(async move |this, cx| {
99 cx.background_executor().timer(DEMO_SPEC_DELAY).await;
100 this.update(cx, |center, cx| center.show_demo_toasts(cx)).ok();
101 })
102 .detach();
103 }
104 center
105 }
106
107 pub fn settings(&self) -> &Settings {
108 &self.settings
109 }
110
111 pub fn model(&self, id: u64) -> Option<&ToastModel> {
112 self.stack.get(id)
113 }
114
115 pub fn hidden_count(&self) -> usize {
116 self.stack.hidden_count()
117 }
118
119 pub fn directory<'a>(&self, cx: &'a App) -> &'a Directory {
120 &self.app.read(cx).directory
121 }
122
123 pub fn reply_text(&self, id: u64) -> Option<String> {
124 self.stack.get(id).map(|toast| toast.reply_text.clone())
125 }
126
127 pub fn intercept_close(&self, _cx: &App) -> bool {
128 match (self.settings.close_to_tray, &self.tray, self.main_native) {
129 (true, Some(_), Some(native)) => {
130 platform::hide_window(native);
131 true
132 }
133 _ => false,
134 }
135 }
136
137 pub fn update_settings(&mut self, cx: &mut Context<Self>, change: impl FnOnce(&mut Settings)) {
138 change(&mut self.settings);
139 settings::save(&self.app.read(cx).store, &self.settings);
140 self.sync_tray();
141 cx.notify();
142 }
143
144 fn on_app_event(&mut self, event: &AppEvent, cx: &mut Context<Self>) {
145 match event {
146 AppEvent::Messages(conversation_id) => self.on_messages(conversation_id, cx),
147 AppEvent::Selection => self.on_selection(cx),
148 AppEvent::Sidebar => self.refresh_badge(cx),
149 _ => {}
150 }
151 }
152
153 fn on_selection(&mut self, cx: &mut Context<Self>) {
154 let selected = self
155 .app
156 .read(cx)
157 .selection
158 .as_ref()
159 .map(|selection| selection.conversation_id().to_owned());
160 if let Some(conversation_id) = selected {
161 self.unread_mentions.remove(&conversation_id);
162 self.stack.remove_conversation(&conversation_id);
163 }
164 self.refresh_badge(cx);
165 }
166
167 fn on_messages(&mut self, conversation_id: &str, cx: &mut Context<Self>) {
168 let state = self.app.read(cx);
169 let my_user_id = state.directory.me.as_ref().map(|me| me.user_id.clone());
170 let found = self.tracker.collect(
171 &state.store,
172 &state.sidebar,
173 my_user_id.as_deref(),
174 conversation_id,
175 );
176 for incoming in found {
177 self.handle_incoming(incoming, cx);
178 }
179 self.refresh_badge(cx);
180 }
181
182 fn environment(&self, conversation_id: &str, cx: &mut Context<Self>) -> Environment {
183 let state = self.app.read(cx);
184 let selected = state
185 .selection
186 .as_ref()
187 .is_some_and(|selection| selection.conversation_id() == conversation_id);
188 let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {
189 state.directory.presence_of(&me.user_id) == PresenceKind::DoNotDisturb
190 });
191 Environment {
192 chat_in_foreground: selected && self.main_window_active(cx),
193 system_quiet: platform::system_quiet(),
194 own_do_not_disturb,
195 in_call: false,
196 }
197 }
198
199 fn main_window_active(&self, cx: &mut Context<Self>) -> bool {
200 self.main_window
201 .update(cx, |_, window, _| window.is_window_active())
202 .unwrap_or(false)
203 }
204
205 pub fn handle_incoming(&mut self, incoming: Incoming, cx: &mut Context<Self>) {
206 let environment = self.environment(&incoming.conversation_id, cx);
207 if !environment.chat_in_foreground && incoming.mentions_me {
208 self.unread_mentions
209 .insert(incoming.conversation_id.clone());
210 }
211 let decision = decide(&self.settings, &incoming, environment);
212 self.present(&incoming, decision, cx);
213 if should_flash(
214 &self.settings,
215 incoming.mentions_me && decision.toast,
216 self.main_window_active(cx),
217 ) && let Some(native) = self.main_native
218 {
219 platform::flash(native);
220 }
221 }
222
223 fn present(&mut self, incoming: &Incoming, decision: Decision, cx: &mut Context<Self>) {
224 if !decision.toast {
225 return;
226 }
227 let now = Instant::now();
228 let outcome = self.stack.push(incoming, now);
229 if let Some(model) = self.stack.get_mut(outcome.id) {
230 model.time = chrono::Local::now().format("%H:%M").to_string();
231 }
232 let throttle_allows = self.throttle.allow(&incoming.conversation_id, now);
233 if decision.sound && outcome.plays_sound(throttle_allows) && !self.app.read(cx).mode.demo {
234 platform::play_sound();
235 }
236 if let Some(user_id) = incoming.sender_id.clone() {
237 self.app
238 .update(cx, |state, cx| state.request_avatars(vec![user_id], cx));
239 }
240 self.sync_windows(cx);
241 }
242
243 fn visible_ids(&self) -> Vec<u64> {
244 self.stack.visible().iter().map(|toast| toast.id).collect()
245 }
246
247 fn work_area(&self, cx: &App) -> WorkArea {
248 if let Some(area) = self.main_native.and_then(platform::work_area) {
249 return area;
250 }
251 let bounds = cx
252 .primary_display()
253 .map(|display| display.bounds())
254 .unwrap_or_else(|| Bounds::new(point(px(0.), px(0.)), size(px(1280.), px(720.))));
255 WorkArea {
256 left: f32::from(bounds.origin.x) as i32,
257 top: f32::from(bounds.origin.y) as i32,
258 right: f32::from(bounds.origin.x + bounds.size.width) as i32,
259 bottom: f32::from(bounds.origin.y + bounds.size.height) as i32,
260 scale: 1.,
261 }
262 }
263
264 fn sync_windows(&mut self, cx: &mut Context<Self>) {
265 let visible = self.visible_ids();
266 let stale: Vec<u64> = self
267 .windows
268 .keys()
269 .filter(|id| !visible.contains(id))
270 .copied()
271 .collect();
272 for id in stale {
273 self.close_window(id, cx);
274 }
275 let area = self.work_area(cx);
276 let heights: Vec<f32> = self
277 .stack
278 .visible()
279 .iter()
280 .map(|toast| layout::toast_height(toast, toast.hovered, self.settings.preview))
281 .collect();
282 let hidden = self.stack.hidden_count();
283 let slots = layout::stack_slots(area, self.settings.corner, &heights, hidden > 0);
284 for (id, slot) in visible.iter().zip(slots.toasts.iter()) {
285 self.place_toast(*id, *slot, area, cx);
286 }
287 self.sync_pill(slots.pill, area, hidden, cx);
288 }
289
290 fn slide_offset(&self, opened: Instant, area: WorkArea) -> i32 {
291 if !self.animations {
292 return 0;
293 }
294 let progress = (opened.elapsed().as_secs_f32() / SLIDE_DURATION.as_secs_f32()).min(1.);
295 let eased = 1. - (1. - progress).powi(3);
296 let distance = ((1. - eased) * SLIDE_DISTANCE * area.scale) as i32;
297 if self.settings.corner.is_right() {
298 distance
299 } else {
300 -distance
301 }
302 }
303
304 fn place_toast(&mut self, id: u64, slot: Slot, area: WorkArea, cx: &mut Context<Self>) {
305 let mention = self.stack.get(id).is_some_and(|toast| toast.mentions_me);
306 if !self.windows.contains_key(&id) {
307 let Some(window) = self.open_toast_window(id, slot, area, cx) else {
308 return;
309 };
310 self.windows.insert(id, window);
311 }
312 let offset = self
313 .windows
314 .get(&id)
315 .map(|window| self.slide_offset(window.opened, area))
316 .unwrap_or(0);
317 if let Some(window) = self.windows.get_mut(&id)
318 && let Some(native) = window.native
319 {
320 platform::place(native, slot.x + offset, slot.y, slot.width, slot.height);
321 if window.mention != mention {
322 window.mention = mention;
323 platform::set_border_color(native, border_color(mention));
324 }
325 }
326 }
327
328 fn open_toast_window(
329 &mut self,
330 id: u64,
331 slot: Slot,
332 area: WorkArea,
333 cx: &mut Context<Self>,
334 ) -> Option<OpenWindow> {
335 let mention = self.stack.get(id).is_some_and(|toast| toast.mentions_me);
336 let options = popup_options(slot, area);
337 let center = cx.entity();
338 let (handle, _view) = gpui_kit::open_window(options, cx, move |window, cx| {
339 cx.new(|cx| ToastView::new(center, id, window, cx))
340 })
341 .ok()?;
342 let native = handle
343 .update(cx, |_, window, _| platform::native_handle(window))
344 .ok()
345 .flatten();
346 if let Some(native) = native {
347 platform::prepare_toast_window(native);
348 platform::set_border_color(native, border_color(mention));
349 }
350 Some(OpenWindow {
351 handle,
352 native,
353 opened: Instant::now(),
354 mention,
355 })
356 }
357
358 fn sync_pill(
359 &mut self,
360 slot: Option<Slot>,
361 area: WorkArea,
362 hidden: usize,
363 cx: &mut Context<Self>,
364 ) {
365 let Some(slot) = slot.filter(|_| hidden > 0) else {
366 if let Some(pill) = self.pill.take() {
367 pill.handle.update(cx, |_, window, _| window.remove_window()).ok();
368 }
369 return;
370 };
371 if self.pill.is_none() {
372 let options = popup_options(slot, area);
373 let center = cx.entity();
374 let opened = gpui_kit::open_window(options, cx, move |_, cx| {
375 cx.new(|cx| PillView::new(center, cx))
376 });
377 if let Ok((handle, _)) = opened {
378 let native = handle
379 .update(cx, |_, window, _| platform::native_handle(window))
380 .ok()
381 .flatten();
382 if let Some(native) = native {
383 platform::prepare_toast_window(native);
384 platform::set_border_color(native, border_color(false));
385 }
386 self.pill = Some(OpenWindow {
387 handle,
388 native,
389 opened: Instant::now(),
390 mention: false,
391 });
392 }
393 }
394 if let Some(native) = self.pill.as_ref().and_then(|pill| pill.native) {
395 platform::place(native, slot.x, slot.y, slot.width, slot.height);
396 }
397 }
398
399 fn close_window(&mut self, id: u64, cx: &mut Context<Self>) {
400 let closed = self.windows.get(&id).is_some_and(|window| {
401 window
402 .handle
403 .update(cx, |_, window, _| window.remove_window())
404 .is_ok()
405 });
406 if closed {
407 self.windows.remove(&id);
408 }
409 }
410
411 fn drop_toast(&mut self, id: u64, cx: &mut Context<Self>) {
412 self.stack.remove(id);
413 cx.notify();
414 }
415
416 fn tick(&mut self, cx: &mut Context<Self>) {
417 let now = Instant::now();
418 for id in self.stack.expired(now) {
419 self.stack.remove(id);
420 }
421 if !self.stack.is_empty() || !self.windows.is_empty() || self.pill.is_some() {
422 self.sync_windows(cx);
423 cx.notify();
424 }
425 self.poll_tray(cx);
426 }
427
428 fn poll_tray(&mut self, cx: &mut Context<Self>) {
429 let commands = self.tray.as_ref().map(Tray::poll).unwrap_or_default();
430 for command in commands {
431 match command {
432 TrayCommand::Toggle => self.toggle_main_window(cx),
433 TrayCommand::Open => self.raise_main_window(cx),
434 TrayCommand::ToggleSound => {
435 self.update_settings(cx, |settings| settings.sound = !settings.sound)
436 }
437 TrayCommand::ToggleDoNotDisturb => self.update_settings(cx, |settings| {
438 settings.do_not_disturb = !settings.do_not_disturb
439 }),
440 TrayCommand::Settings => self.open_settings(cx),
441 TrayCommand::Quit => cx.quit(),
442 }
443 }
444 }
445
446 fn toggle_main_window(&mut self, cx: &mut Context<Self>) {
447 if self.main_window_active(cx) {
448 if let Some(native) = self.main_native {
449 platform::hide_window(native);
450 }
451 } else {
452 self.raise_main_window(cx);
453 }
454 }
455
456 fn raise_main_window(&mut self, cx: &mut Context<Self>) {
457 if let Some(native) = self.main_native {
458 platform::restore_and_raise(native);
459 }
460 self.main_window
461 .update(cx, |_, window, _| window.activate_window())
462 .ok();
463 }
464
465 fn sync_tray(&self) {
466 if let Some(tray) = &self.tray {
467 tray.sync(
468 self.settings.sound,
469 self.settings.do_not_disturb,
470 !self.unread_mentions.is_empty(),
471 );
472 }
473 }
474
475 fn refresh_badge(&mut self, cx: &mut Context<Self>) {
476 let (count, still_unread) = unread_summary(&self.app.read(cx).sidebar);
477 self.unread_mentions
478 .retain(|conversation_id| still_unread.contains(conversation_id));
479 let badge = badge_for(count, !self.unread_mentions.is_empty());
480 if badge == self.shown_badge {
481 return;
482 }
483 if let Some(native) = self.main_native {
484 platform::set_badge(native, badge.as_ref());
485 }
486 self.shown_badge = badge;
487 self.sync_tray();
488 }
489
490 pub fn set_hover(&mut self, id: u64, hovered: bool, cx: &mut Context<Self>) {
491 let now = Instant::now();
492 let Some(toast) = self.stack.get_mut(id) else {
493 return;
494 };
495 if toast.hovered == hovered {
496 return;
497 }
498 toast.hovered = hovered;
499 if hovered {
500 toast.timer.pause(now);
501 } else if !toast.holds_open() {
502 toast.timer.resume(now);
503 }
504 cx.notify();
505 }
506
507 pub fn dismiss(&mut self, id: u64, cx: &mut Context<Self>) {
508 self.drop_toast(id, cx);
509 }
510
511 pub fn open_reply(&mut self, id: u64, cx: &mut Context<Self>) -> Option<String> {
512 let now = Instant::now();
513 let toast = self.stack.get_mut(id)?;
514 toast.reply = ReplyState::Open;
515 toast.timer.pause(now);
516 let draft = toast.reply_text.clone();
517 cx.notify();
518 Some(draft)
519 }
520
521 pub fn close_reply(&mut self, id: u64, cx: &mut Context<Self>) {
522 if let Some(toast) = self.stack.get_mut(id) {
523 toast.reply = ReplyState::Closed;
524 toast.reply_text.clear();
525 toast.hovered = false;
526 }
527 cx.notify();
528 }
529
530 pub fn submit_reply(&mut self, id: u64, text: String, cx: &mut Context<Self>) {
531 let Some(toast) = self.stack.get_mut(id) else {
532 return;
533 };
534 toast.reply_text = text.clone();
535 let conversation_id = toast.conversation_id.clone();
536 let message_id = toast.message_id.clone();
537 let is_channel = matches!(toast.kind, ChatKind::Channel { .. });
538 let state = self.app.read(cx);
539 let (mode, engine) = (state.mode, state.engine.clone());
540 let outcome: Result<(), ()> = if mode.demo {
541 Ok(())
542 } else if mode.read_only {
543 Err(())
544 } else if let Some(engine) = engine {
545 let receiver = runtime::spawn(async move {
546 if is_channel {
547 engine.reply_to(&conversation_id, &message_id, &text).await
548 } else {
549 engine.send_message(&conversation_id, &text, None).await
550 }
551 .map(|_| ())
552 });
553 cx.spawn(async move |this, cx| {
554 let sent = matches!(receiver.await, Ok(Ok(())));
555 this.update(cx, |center, cx| center.finish_reply(id, sent, cx)).ok();
556 })
557 .detach();
558 return;
559 } else {
560 Err(())
561 };
562 self.finish_reply(id, outcome.is_ok(), cx);
563 }
564
565 fn finish_reply(&mut self, id: u64, sent: bool, cx: &mut Context<Self>) {
566 let Some(toast) = self.stack.get_mut(id) else {
567 return;
568 };
569 toast.reply = if sent {
570 ReplyState::Sent
571 } else {
572 ReplyState::Failed
573 };
574 let conversation_id = toast.conversation_id.clone();
575 cx.notify();
576 if sent {
577 cx.spawn(async move |this, cx| {
578 cx.background_executor().timer(SENT_DURATION).await;
579 this.update(cx, |center, cx| {
580 center.mark_conversation_read(&conversation_id, cx);
581 center.drop_toast(id, cx);
582 })
583 .ok();
584 })
585 .detach();
586 }
587 }
588
589 fn mark_conversation_read(&mut self, conversation_id: &str, cx: &mut Context<Self>) {
590 self.unread_mentions.remove(conversation_id);
591 let conversation_id = conversation_id.to_owned();
592 self.app
593 .update(cx, |state, cx| state.mark_chat_read(&conversation_id, cx));
594 self.refresh_badge(cx);
595 }
596
597 pub fn mark_read(&mut self, id: u64, cx: &mut Context<Self>) {
598 let Some(conversation_id) = self.stack.get(id).map(|toast| toast.conversation_id.clone())
599 else {
600 return;
601 };
602 self.mark_conversation_read(&conversation_id, cx);
603 self.drop_toast(id, cx);
604 }
605
606 pub fn activate(&mut self, id: u64, cx: &mut Context<Self>) {
607 let Some((conversation_id, message_id)) = self
608 .stack
609 .get(id)
610 .map(|toast| (toast.conversation_id.clone(), toast.message_id.clone()))
611 else {
612 return;
613 };
614 self.drop_toast(id, cx);
615 self.raise_main_window(cx);
616 let selection = selection_for(&self.app.read(cx).sidebar, &conversation_id);
617 if let Some(selection) = selection {
618 self.app.update(cx, |state, cx| {
619 state.jump_to_message(selection, message_id, cx)
620 });
621 }
622 }
623
624 pub fn open_chat_list(&mut self, cx: &mut Context<Self>) {
625 self.raise_main_window(cx);
626 }
627
628 pub fn open_settings(&mut self, cx: &mut Context<Self>) {
629 if let Some(handle) = self.settings_window {
630 if handle.update(cx, |_, window, _| window.activate_window()).is_ok() {
631 return;
632 }
633 self.settings_window = None;
634 }
635 let center = cx.entity();
636 let options = WindowOptions {
637 window_bounds: Some(WindowBounds::Windowed(Bounds::centered(
638 None,
639 size(px(SettingsView::WIDTH), px(SettingsView::HEIGHT)),
640 cx,
641 ))),
642 titlebar: Some(TitlebarOptions {
643 title: Some("Benachrichtigungen".into()),
644 ..Default::default()
645 }),
646 is_resizable: false,
647 is_minimizable: false,
648 ..Default::default()
649 };
650 if let Ok((handle, _)) = gpui_kit::open_window(options, cx, move |_, cx| {
651 cx.new(|cx| SettingsView::new(center, cx))
652 }) {
653 self.settings_window = Some(handle);
654 }
655 }
656
657 pub fn send_test_notification(&mut self, cx: &mut Context<Self>) {
658 let incoming = Incoming {
659 conversation_id: "test-notification".to_owned(),
660 message_id: "test".to_owned(),
661 kind: ChatKind::Direct,
662 chat_title: "Mara Lindqvist".to_owned(),
663 sender_id: None,
664 sender_name: "Mara Lindqvist".to_owned(),
665 preview: Preview::Text("Das ist eine Testbenachrichtigung.".to_owned()),
666 mentions_me: false,
667 muted: false,
668 };
669 let decision = Decision {
670 toast: true,
671 sound: self.settings.sound,
672 };
673 self.throttle = SoundThrottle::default();
674 self.present(&incoming, decision, cx);
675 }
676
677 fn show_demo_toasts(&mut self, cx: &mut Context<Self>) {
678 for incoming in demo_incoming() {
679 let decision = Decision {
680 toast: true,
681 sound: false,
682 };
683 self.present(&incoming, decision, cx);
684 }
685 }
686}
687
688fn border_color(mention: bool) -> u32 {
689 if mention { MENTION_BORDER } else { FALLBACK_BORDER }
690}
691
692fn popup_options(slot: Slot, area: WorkArea) -> WindowOptions {
693 let scale = area.scale;
694 let bounds = Bounds::new(
695 point(px(slot.x as f32 / scale), px(slot.y as f32 / scale)),
696 size(px(slot.width as f32 / scale), px(slot.height as f32 / scale)),
697 );
698 WindowOptions {
699 window_bounds: Some(WindowBounds::Windowed(bounds)),
700 titlebar: None,
701 focus: false,
702 show: true,
703 kind: WindowKind::PopUp,
704 is_movable: false,
705 is_resizable: false,
706 is_minimizable: false,
707 window_background: WindowBackgroundAppearance::Opaque,
708 ..Default::default()
709 }
710}
711
712pub fn selection_for(sidebar: &Sidebar, conversation_id: &str) -> Option<Selection> {
713 if sidebar.chats.iter().any(|chat| chat.id == conversation_id) {
714 return Some(Selection::Chat(conversation_id.to_owned()));
715 }
716 sidebar
717 .teams
718 .iter()
719 .flat_map(|team| team.channels.iter())
720 .any(|channel| channel.id == conversation_id)
721 .then(|| Selection::Channel(conversation_id.to_owned()))
722}
723
724pub fn unread_summary(sidebar: &Sidebar) -> (usize, HashSet<String>) {
725 let chats = sidebar.chats.iter().filter(|chat| chat.unread);
726 let channels = sidebar
727 .teams
728 .iter()
729 .flat_map(|team| team.channels.iter())
730 .filter(|channel| channel.unread);
731 let ids: HashSet<String> = chats
732 .map(|chat| chat.id.clone())
733 .chain(channels.map(|channel| channel.id.clone()))
734 .collect();
735 (ids.len(), ids)
736}
737
738fn demo_incoming() -> Vec<Incoming> {
739 let item = |conversation: &str, kind: ChatKind, title: &str, sender: &str, text: &str, mention: bool| Incoming {
740 conversation_id: conversation.to_owned(),
741 message_id: format!("{conversation}-message"),
742 kind,
743 chat_title: title.to_owned(),
744 sender_id: None,
745 sender_name: sender.to_owned(),
746 preview: Preview::Text(text.to_owned()),
747 mentions_me: mention,
748 muted: false,
749 };
750 vec![
751 item(
752 "demo-toast-direct",
753 ChatKind::Direct,
754 "Tobias Klein",
755 "Tobias Klein",
756 "Passt, ich schaue morgen drauf.",
757 false,
758 ),
759 item(
760 "demo-toast-group",
761 ChatKind::Group { member_count: 5 },
762 "Retro-Team",
763 "Priya Nair",
764 "Themen bitte bis 17 Uhr eintragen.",
765 false,
766 ),
767 item(
768 "demo-toast-mention",
769 ChatKind::Channel {
770 team: "Plattform".to_owned(),
771 channel: "Releases".to_owned(),
772 },
773 "Releases",
774 "Mara Lindqvist",
775 "@Daniel kannst du den Merge freigeben? Pipeline wartet.",
776 true,
777 ),
778 ]
779}
780
781#[cfg(test)]
782mod tests {
783 use store::{ChannelRecord, ChatRecord, SidebarTeam, TeamRecord};
784
785 use super::{selection_for, unread_summary};
786 use crate::app_state::Selection;
787 use store::Sidebar;
788
789 fn sidebar() -> Sidebar {
790 Sidebar {
791 chats: vec![
792 ChatRecord {
793 id: "a".into(),
794 unread: true,
795 ..Default::default()
796 },
797 ChatRecord {
798 id: "b".into(),
799 unread: false,
800 ..Default::default()
801 },
802 ],
803 teams: vec![SidebarTeam {
804 team: TeamRecord {
805 id: "t".into(),
806 name: "Team".into(),
807 },
808 channels: vec![ChannelRecord {
809 id: "ch".into(),
810 team_id: "t".into(),
811 name: "General".into(),
812 membership_type: None,
813 last_message_at: None,
814 unread: true,
815 }],
816 hidden: false,
817 hidden_channel_ids: Vec::new(),
818 }],
819 }
820 }
821
822 #[test]
823 fn unread_summary_counts_chats_and_channels() {
824 let (count, ids) = unread_summary(&sidebar());
825 assert_eq!(count, 2);
826 assert!(ids.contains("a") && ids.contains("ch"));
827 }
828
829 #[test]
830 fn selection_kind_follows_sidebar() {
831 assert_eq!(selection_for(&sidebar(), "a"), Some(Selection::Chat("a".into())));
832 assert_eq!(selection_for(&sidebar(), "ch"), Some(Selection::Channel("ch".into())));
833 assert_eq!(selection_for(&sidebar(), "x"), None);
834 }
835}
crates/app/src/notify/incoming.rs added +236 −0
@@ -0,0 +1,236 @@
1 use std::collections::HashMap;
2
3 use chrono::{DateTime, Utc};
4 use store::{MessageRecord, Sidebar, Store};
5
6 use super::rules::{ChatKind, Incoming, Preview};
7 use crate::app_state::chat_title;
8
9 const RECENT_WINDOW: usize = 20;
10 const FILE_FALLBACK: &str = "Datei";
11
12 pub struct IncomingTracker {
13 started: DateTime<Utc>,
14 watermarks: HashMap<String, DateTime<Utc>>,
15 }
16
17 impl IncomingTracker {
18 pub fn new(started: DateTime<Utc>) -> Self {
19 IncomingTracker {
20 started,
21 watermarks: HashMap::new(),
22 }
23 }
24
25 pub fn collect(
26 &mut self,
27 store: &Store,
28 sidebar: &Sidebar,
29 my_user_id: Option<&str>,
30 conversation_id: &str,
31 ) -> Vec<Incoming> {
32 let Ok(records) = store.messages(conversation_id, None, RECENT_WINDOW) else {
33 return Vec::new();
34 };
35 self.fresh(records, sidebar, my_user_id)
36 }
37
38 fn fresh(
39 &mut self,
40 records: Vec<MessageRecord>,
41 sidebar: &Sidebar,
42 my_user_id: Option<&str>,
43 ) -> Vec<Incoming> {
44 let mut incoming = Vec::new();
45 for record in records {
46 let watermark = self
47 .watermarks
48 .get(&record.conversation_id)
49 .copied()
50 .unwrap_or(self.started)
51 .max(self.started);
52 if record.created_at <= watermark {
53 continue;
54 }
55 self.watermarks
56 .insert(record.conversation_id.clone(), record.created_at);
57 if record.deleted || is_own(&record, my_user_id) {
58 continue;
59 }
60 if let Some(entry) = build_incoming(&record, sidebar, my_user_id) {
61 incoming.push(entry);
62 }
63 }
64 incoming
65 }
66 }
67
68 fn is_own(record: &MessageRecord, my_user_id: Option<&str>) -> bool {
69 matches!((record.sender_id.as_deref(), my_user_id), (Some(sender), Some(me)) if sender == me)
70 }
71
72 pub fn build_incoming(
73 record: &MessageRecord,
74 sidebar: &Sidebar,
75 my_user_id: Option<&str>,
76 ) -> Option<Incoming> {
77 let (kind, chat_name) = chat_context(sidebar, &record.conversation_id)?;
78 Some(Incoming {
79 conversation_id: record.conversation_id.clone(),
80 message_id: record.message_id.clone(),
81 kind,
82 chat_title: chat_name,
83 sender_id: record.sender_id.clone(),
84 sender_name: record.sender_name.clone().unwrap_or_default(),
85 preview: preview_of(record),
86 mentions_me: mentions_me(record, my_user_id),
87 muted: false,
88 })
89 }
90
91 fn chat_context(sidebar: &Sidebar, conversation_id: &str) -> Option<(ChatKind, String)> {
92 if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {
93 let kind = if chat.kind.eq_ignore_ascii_case("oneOnOne") {
94 ChatKind::Direct
95 } else {
96 ChatKind::Group {
97 member_count: chat.members.len().max(2),
98 }
99 };
100 return Some((kind, chat_title(chat)));
101 }
102 sidebar.teams.iter().find_map(|team| {
103 team.channels
104 .iter()
105 .find(|channel| channel.id == conversation_id)
106 .map(|channel| {
107 (
108 ChatKind::Channel {
109 team: team.team.name.clone(),
110 channel: channel.name.clone(),
111 },
112 channel.name.clone(),
113 )
114 })
115 })
116 }
117
118 fn mentions_me(record: &MessageRecord, my_user_id: Option<&str>) -> bool {
119 let Some(me) = my_user_id else {
120 return false;
121 };
122 teams_core::mentions(record)
123 .iter()
124 .any(|mention| mention.user_id.as_deref() == Some(me))
125 }
126
127 fn preview_of(record: &MessageRecord) -> Preview {
128 if let Some(text) = teams_core::preview_text(&record.body_html) {
129 return Preview::Text(text);
130 }
131 if !teams_core::images(record).is_empty() {
132 return Preview::Image;
133 }
134 let file_name = teams_core::attachments(record)
135 .into_iter()
136 .find_map(|attachment| attachment.name);
137 Preview::Text(file_name.unwrap_or_else(|| FILE_FALLBACK.to_owned()))
138 }
139
140 #[cfg(test)]
141 mod tests {
142 use chrono::Duration;
143 use store::{ChatRecord, MemberRecord};
144
145 use super::*;
146
147 fn sidebar() -> Sidebar {
148 Sidebar {
149 chats: vec![
150 ChatRecord {
151 id: "direct".into(),
152 kind: "oneOnOne".into(),
153 title: "Mara".into(),
154 ..Default::default()
155 },
156 ChatRecord {
157 id: "group".into(),
158 kind: "group".into(),
159 title: "Team".into(),
160 members: vec![MemberRecord::default(); 5],
161 ..Default::default()
162 },
163 ],
164 teams: Vec::new(),
165 }
166 }
167
168 fn record(conversation: &str, sender: &str, at: DateTime<Utc>, html: &str) -> MessageRecord {
169 MessageRecord {
170 conversation_id: conversation.into(),
171 message_id: format!("{conversation}-{}", at.timestamp_millis()),
172 reply_to_id: None,
173 sender_id: Some(sender.into()),
174 sender_name: Some("Sender".into()),
175 created_at: at,
176 edited_at: None,
177 deleted: false,
178 body_html: html.into(),
179 attachments_json: "[]".into(),
180 reactions_json: "[]".into(),
181 mentions_json: "[]".into(),
182 }
183 }
184
185 #[test]
186 fn history_before_start_is_ignored() {
187 let start = Utc::now();
188 let mut tracker = IncomingTracker::new(start);
189 let old = record("direct", "u1", start - Duration::minutes(5), "alt");
190 let new = record("direct", "u1", start + Duration::seconds(5), "neu");
191 let found = tracker.fresh(vec![old, new], &sidebar(), Some("me"));
192 assert_eq!(found.len(), 1);
193 assert_eq!(found[0].preview, Preview::Text("neu".into()));
194 }
195
196 #[test]
197 fn same_message_is_not_reported_twice() {
198 let start = Utc::now();
199 let mut tracker = IncomingTracker::new(start);
200 let message = record("direct", "u1", start + Duration::seconds(5), "neu");
201 assert_eq!(tracker.fresh(vec![message.clone()], &sidebar(), None).len(), 1);
202 assert!(tracker.fresh(vec![message], &sidebar(), None).is_empty());
203 }
204
205 #[test]
206 fn own_messages_from_other_devices_are_skipped() {
207 let start = Utc::now();
208 let mut tracker = IncomingTracker::new(start);
209 let own = record("direct", "me", start + Duration::seconds(5), "ich");
210 assert!(tracker.fresh(vec![own], &sidebar(), Some("me")).is_empty());
211 }
212
213 #[test]
214 fn detects_mention_of_me_and_group_size() {
215 let start = Utc::now();
216 let mut message = record("group", "u1", start + Duration::seconds(5), "<at>Me</at> hi");
217 message.mentions_json = r#"[{"user_id":"me","name":"Me"}]"#.into();
218 let found = build_incoming(&message, &sidebar(), Some("me")).unwrap();
219 assert!(found.mentions_me);
220 assert_eq!(found.kind, ChatKind::Group { member_count: 5 });
221 assert!(!build_incoming(&message, &sidebar(), Some("other")).unwrap().mentions_me);
222 }
223
224 #[test]
225 fn unknown_conversation_yields_nothing() {
226 let message = record("nowhere", "u1", Utc::now(), "x");
227 assert!(build_incoming(&message, &sidebar(), None).is_none());
228 }
229
230 #[test]
231 fn empty_body_without_image_falls_back_to_file_label() {
232 let message = record("direct", "u1", Utc::now(), "");
233 let found = build_incoming(&message, &sidebar(), None).unwrap();
234 assert_eq!(found.preview, Preview::Text(FILE_FALLBACK.into()));
235 }
236 }
@@ -0,0 +1,236 @@
1use std::collections::HashMap;
2
3use chrono::{DateTime, Utc};
4use store::{MessageRecord, Sidebar, Store};
5
6use super::rules::{ChatKind, Incoming, Preview};
7use crate::app_state::chat_title;
8
9const RECENT_WINDOW: usize = 20;
10const FILE_FALLBACK: &str = "Datei";
11
12pub struct IncomingTracker {
13 started: DateTime<Utc>,
14 watermarks: HashMap<String, DateTime<Utc>>,
15}
16
17impl IncomingTracker {
18 pub fn new(started: DateTime<Utc>) -> Self {
19 IncomingTracker {
20 started,
21 watermarks: HashMap::new(),
22 }
23 }
24
25 pub fn collect(
26 &mut self,
27 store: &Store,
28 sidebar: &Sidebar,
29 my_user_id: Option<&str>,
30 conversation_id: &str,
31 ) -> Vec<Incoming> {
32 let Ok(records) = store.messages(conversation_id, None, RECENT_WINDOW) else {
33 return Vec::new();
34 };
35 self.fresh(records, sidebar, my_user_id)
36 }
37
38 fn fresh(
39 &mut self,
40 records: Vec<MessageRecord>,
41 sidebar: &Sidebar,
42 my_user_id: Option<&str>,
43 ) -> Vec<Incoming> {
44 let mut incoming = Vec::new();
45 for record in records {
46 let watermark = self
47 .watermarks
48 .get(&record.conversation_id)
49 .copied()
50 .unwrap_or(self.started)
51 .max(self.started);
52 if record.created_at <= watermark {
53 continue;
54 }
55 self.watermarks
56 .insert(record.conversation_id.clone(), record.created_at);
57 if record.deleted || is_own(&record, my_user_id) {
58 continue;
59 }
60 if let Some(entry) = build_incoming(&record, sidebar, my_user_id) {
61 incoming.push(entry);
62 }
63 }
64 incoming
65 }
66}
67
68fn is_own(record: &MessageRecord, my_user_id: Option<&str>) -> bool {
69 matches!((record.sender_id.as_deref(), my_user_id), (Some(sender), Some(me)) if sender == me)
70}
71
72pub fn build_incoming(
73 record: &MessageRecord,
74 sidebar: &Sidebar,
75 my_user_id: Option<&str>,
76) -> Option<Incoming> {
77 let (kind, chat_name) = chat_context(sidebar, &record.conversation_id)?;
78 Some(Incoming {
79 conversation_id: record.conversation_id.clone(),
80 message_id: record.message_id.clone(),
81 kind,
82 chat_title: chat_name,
83 sender_id: record.sender_id.clone(),
84 sender_name: record.sender_name.clone().unwrap_or_default(),
85 preview: preview_of(record),
86 mentions_me: mentions_me(record, my_user_id),
87 muted: false,
88 })
89}
90
91fn chat_context(sidebar: &Sidebar, conversation_id: &str) -> Option<(ChatKind, String)> {
92 if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {
93 let kind = if chat.kind.eq_ignore_ascii_case("oneOnOne") {
94 ChatKind::Direct
95 } else {
96 ChatKind::Group {
97 member_count: chat.members.len().max(2),
98 }
99 };
100 return Some((kind, chat_title(chat)));
101 }
102 sidebar.teams.iter().find_map(|team| {
103 team.channels
104 .iter()
105 .find(|channel| channel.id == conversation_id)
106 .map(|channel| {
107 (
108 ChatKind::Channel {
109 team: team.team.name.clone(),
110 channel: channel.name.clone(),
111 },
112 channel.name.clone(),
113 )
114 })
115 })
116}
117
118fn mentions_me(record: &MessageRecord, my_user_id: Option<&str>) -> bool {
119 let Some(me) = my_user_id else {
120 return false;
121 };
122 teams_core::mentions(record)
123 .iter()
124 .any(|mention| mention.user_id.as_deref() == Some(me))
125}
126
127fn preview_of(record: &MessageRecord) -> Preview {
128 if let Some(text) = teams_core::preview_text(&record.body_html) {
129 return Preview::Text(text);
130 }
131 if !teams_core::images(record).is_empty() {
132 return Preview::Image;
133 }
134 let file_name = teams_core::attachments(record)
135 .into_iter()
136 .find_map(|attachment| attachment.name);
137 Preview::Text(file_name.unwrap_or_else(|| FILE_FALLBACK.to_owned()))
138}
139
140#[cfg(test)]
141mod tests {
142 use chrono::Duration;
143 use store::{ChatRecord, MemberRecord};
144
145 use super::*;
146
147 fn sidebar() -> Sidebar {
148 Sidebar {
149 chats: vec![
150 ChatRecord {
151 id: "direct".into(),
152 kind: "oneOnOne".into(),
153 title: "Mara".into(),
154 ..Default::default()
155 },
156 ChatRecord {
157 id: "group".into(),
158 kind: "group".into(),
159 title: "Team".into(),
160 members: vec![MemberRecord::default(); 5],
161 ..Default::default()
162 },
163 ],
164 teams: Vec::new(),
165 }
166 }
167
168 fn record(conversation: &str, sender: &str, at: DateTime<Utc>, html: &str) -> MessageRecord {
169 MessageRecord {
170 conversation_id: conversation.into(),
171 message_id: format!("{conversation}-{}", at.timestamp_millis()),
172 reply_to_id: None,
173 sender_id: Some(sender.into()),
174 sender_name: Some("Sender".into()),
175 created_at: at,
176 edited_at: None,
177 deleted: false,
178 body_html: html.into(),
179 attachments_json: "[]".into(),
180 reactions_json: "[]".into(),
181 mentions_json: "[]".into(),
182 }
183 }
184
185 #[test]
186 fn history_before_start_is_ignored() {
187 let start = Utc::now();
188 let mut tracker = IncomingTracker::new(start);
189 let old = record("direct", "u1", start - Duration::minutes(5), "alt");
190 let new = record("direct", "u1", start + Duration::seconds(5), "neu");
191 let found = tracker.fresh(vec![old, new], &sidebar(), Some("me"));
192 assert_eq!(found.len(), 1);
193 assert_eq!(found[0].preview, Preview::Text("neu".into()));
194 }
195
196 #[test]
197 fn same_message_is_not_reported_twice() {
198 let start = Utc::now();
199 let mut tracker = IncomingTracker::new(start);
200 let message = record("direct", "u1", start + Duration::seconds(5), "neu");
201 assert_eq!(tracker.fresh(vec![message.clone()], &sidebar(), None).len(), 1);
202 assert!(tracker.fresh(vec![message], &sidebar(), None).is_empty());
203 }
204
205 #[test]
206 fn own_messages_from_other_devices_are_skipped() {
207 let start = Utc::now();
208 let mut tracker = IncomingTracker::new(start);
209 let own = record("direct", "me", start + Duration::seconds(5), "ich");
210 assert!(tracker.fresh(vec![own], &sidebar(), Some("me")).is_empty());
211 }
212
213 #[test]
214 fn detects_mention_of_me_and_group_size() {
215 let start = Utc::now();
216 let mut message = record("group", "u1", start + Duration::seconds(5), "<at>Me</at> hi");
217 message.mentions_json = r#"[{"user_id":"me","name":"Me"}]"#.into();
218 let found = build_incoming(&message, &sidebar(), Some("me")).unwrap();
219 assert!(found.mentions_me);
220 assert_eq!(found.kind, ChatKind::Group { member_count: 5 });
221 assert!(!build_incoming(&message, &sidebar(), Some("other")).unwrap().mentions_me);
222 }
223
224 #[test]
225 fn unknown_conversation_yields_nothing() {
226 let message = record("nowhere", "u1", Utc::now(), "x");
227 assert!(build_incoming(&message, &sidebar(), None).is_none());
228 }
229
230 #[test]
231 fn empty_body_without_image_falls_back_to_file_label() {
232 let message = record("direct", "u1", Utc::now(), "");
233 let found = build_incoming(&message, &sidebar(), None).unwrap();
234 assert_eq!(found.preview, Preview::Text(FILE_FALLBACK.into()));
235 }
236}
crates/app/src/notify/layout.rs added +188 −0
@@ -0,0 +1,188 @@
1 use super::platform::WorkArea;
2 use super::rules::{Corner, Preview};
3 use super::stack::{ReplyState, ToastModel};
4
5 pub const TOAST_WIDTH: f32 = 360.;
6 pub const PILL_WIDTH: f32 = 132.;
7 pub const PILL_HEIGHT: f32 = 32.;
8 pub const SIDE_MARGIN: f32 = 16.;
9 pub const EDGE_MARGIN: f32 = 12.;
10 pub const STACK_GAP: f32 = 8.;
11 pub const ACTION_ROW: f32 = 36.;
12 const BASE_HEIGHT: f32 = 62.;
13 const PREVIEW_LINE: f32 = 18.;
14 const CHARS_PER_LINE: usize = 40;
15 const ACTION_ROW_SPACING: f32 = 4.;
16 const REPLY_HINT_ROW: f32 = 20.;
17 const REPLY_SPACING: f32 = 8.;
18 const CONFIRM_HEIGHT: f32 = 56.;
19
20 #[derive(Debug, Clone, Copy, PartialEq)]
21 pub struct Slot {
22 pub x: i32,
23 pub y: i32,
24 pub width: i32,
25 pub height: i32,
26 }
27
28 fn preview_lines(model: &ToastModel, preview_on: bool) -> usize {
29 match (&model.preview, preview_on) {
30 (Preview::Text(text), true) => text.chars().count().div_ceil(CHARS_PER_LINE).clamp(1, 2),
31 _ => 1,
32 }
33 }
34
35 pub fn toast_height(model: &ToastModel, hovered: bool, preview_on: bool) -> f32 {
36 match model.reply {
37 ReplyState::Sent | ReplyState::Failed => CONFIRM_HEIGHT,
38 ReplyState::Open => {
39 let base = BASE_HEIGHT + preview_lines(model, preview_on) as f32 * PREVIEW_LINE;
40 base + REPLY_SPACING + ACTION_ROW + REPLY_HINT_ROW
41 }
42 ReplyState::Closed => {
43 let base = BASE_HEIGHT + preview_lines(model, preview_on) as f32 * PREVIEW_LINE;
44 if hovered {
45 base + ACTION_ROW + ACTION_ROW_SPACING
46 } else {
47 base
48 }
49 }
50 }
51 }
52
53 pub struct StackSlots {
54 pub toasts: Vec<Slot>,
55 pub pill: Option<Slot>,
56 }
57
58 pub fn stack_slots(
59 area: WorkArea,
60 corner: Corner,
61 heights: &[f32],
62 with_pill: bool,
63 ) -> StackSlots {
64 let scale = area.scale;
65 let physical = |value: f32| (value * scale).round() as i32;
66 let width = physical(TOAST_WIDTH);
67 let x = if corner.is_right() {
68 area.right - physical(SIDE_MARGIN) - width
69 } else {
70 area.left + physical(SIDE_MARGIN)
71 };
72 let gap = physical(STACK_GAP);
73 let mut rows: Vec<(i32, i32)> = Vec::new();
74 if with_pill {
75 rows.push((physical(PILL_WIDTH), physical(PILL_HEIGHT)));
76 }
77 rows.extend(heights.iter().map(|height| (width, physical(*height))));
78 let total: i32 = rows.iter().map(|(_, height)| height).sum::<i32>()
79 + gap * rows.len().saturating_sub(1) as i32;
80 let mut y = if corner.is_bottom() {
81 area.bottom - physical(EDGE_MARGIN) - total
82 } else {
83 area.top + physical(EDGE_MARGIN)
84 };
85 let mut slots = Vec::new();
86 for (row_width, height) in rows {
87 let row_x = if corner.is_right() {
88 x + width - row_width
89 } else {
90 x
91 };
92 slots.push(Slot {
93 x: row_x,
94 y,
95 width: row_width,
96 height,
97 });
98 y += height + gap;
99 }
100 let pill = if with_pill && !slots.is_empty() {
101 Some(slots.remove(0))
102 } else {
103 None
104 };
105 StackSlots {
106 toasts: slots,
107 pill,
108 }
109 }
110
111 #[cfg(test)]
112 mod tests {
113 use super::*;
114
115 fn area(scale: f32) -> WorkArea {
116 WorkArea {
117 left: 0,
118 top: 0,
119 right: 1920,
120 bottom: 1032,
121 scale,
122 }
123 }
124
125 #[test]
126 fn bottom_right_stack_hugs_corner_newest_at_bottom() {
127 let slots = stack_slots(area(1.), Corner::BottomRight, &[80., 98.], false);
128 assert_eq!(slots.toasts.len(), 2);
129 let newest = slots.toasts[1];
130 assert_eq!(newest.x, 1920 - 16 - 360);
131 assert_eq!(newest.y + newest.height, 1032 - 12);
132 let older = slots.toasts[0];
133 assert_eq!(older.y + older.height + 8, newest.y);
134 }
135
136 #[test]
137 fn pill_sits_above_oldest_toast() {
138 let slots = stack_slots(area(1.), Corner::BottomRight, &[80., 80., 80.], true);
139 let pill = slots.pill.unwrap();
140 assert_eq!(pill.height, 32);
141 assert_eq!(pill.y + pill.height + 8, slots.toasts[0].y);
142 assert_eq!(pill.x + pill.width, slots.toasts[0].x + slots.toasts[0].width);
143 }
144
145 #[test]
146 fn top_left_anchors_to_top_edge() {
147 let slots = stack_slots(area(1.), Corner::TopLeft, &[80.], false);
148 assert_eq!((slots.toasts[0].x, slots.toasts[0].y), (16, 12));
149 }
150
151 #[test]
152 fn scale_applies_to_all_distances() {
153 let slots = stack_slots(area(1.5), Corner::BottomRight, &[80.], false);
154 let toast = slots.toasts[0];
155 assert_eq!(toast.width, 540);
156 assert_eq!(toast.height, 120);
157 assert_eq!(toast.y + toast.height, 1032 - 18);
158 }
159
160 #[test]
161 fn heights_stay_in_board_range() {
162 use super::super::rules::ChatKind;
163 use super::super::stack::{ReplyState, ToastTimer};
164 let model = |text: &str| ToastModel {
165 id: 1,
166 conversation_id: "a".into(),
167 message_id: "m".into(),
168 kind: ChatKind::Direct,
169 chat_title: "T".into(),
170 sender_id: None,
171 sender_name: "S".into(),
172 preview: Preview::Text(text.into()),
173 mentions_me: false,
174 count: 1,
175 timer: ToastTimer::new(std::time::Instant::now(), false),
176 reply: ReplyState::Closed,
177 reply_text: String::new(),
178 hovered: false,
179 time: String::new(),
180 };
181 let short = toast_height(&model("Hi"), false, true);
182 let long = toast_height(&model(&"x".repeat(200)), false, true);
183 assert!((76. ..=104.).contains(&short));
184 assert!((76. ..=104.).contains(&long));
185 assert!(toast_height(&model("Hi"), true, true) > short);
186 assert_eq!(toast_height(&model(&"x".repeat(200)), false, false), short);
187 }
188 }
@@ -0,0 +1,188 @@
1use super::platform::WorkArea;
2use super::rules::{Corner, Preview};
3use super::stack::{ReplyState, ToastModel};
4
5pub const TOAST_WIDTH: f32 = 360.;
6pub const PILL_WIDTH: f32 = 132.;
7pub const PILL_HEIGHT: f32 = 32.;
8pub const SIDE_MARGIN: f32 = 16.;
9pub const EDGE_MARGIN: f32 = 12.;
10pub const STACK_GAP: f32 = 8.;
11pub const ACTION_ROW: f32 = 36.;
12const BASE_HEIGHT: f32 = 62.;
13const PREVIEW_LINE: f32 = 18.;
14const CHARS_PER_LINE: usize = 40;
15const ACTION_ROW_SPACING: f32 = 4.;
16const REPLY_HINT_ROW: f32 = 20.;
17const REPLY_SPACING: f32 = 8.;
18const CONFIRM_HEIGHT: f32 = 56.;
19
20#[derive(Debug, Clone, Copy, PartialEq)]
21pub struct Slot {
22 pub x: i32,
23 pub y: i32,
24 pub width: i32,
25 pub height: i32,
26}
27
28fn preview_lines(model: &ToastModel, preview_on: bool) -> usize {
29 match (&model.preview, preview_on) {
30 (Preview::Text(text), true) => text.chars().count().div_ceil(CHARS_PER_LINE).clamp(1, 2),
31 _ => 1,
32 }
33}
34
35pub fn toast_height(model: &ToastModel, hovered: bool, preview_on: bool) -> f32 {
36 match model.reply {
37 ReplyState::Sent | ReplyState::Failed => CONFIRM_HEIGHT,
38 ReplyState::Open => {
39 let base = BASE_HEIGHT + preview_lines(model, preview_on) as f32 * PREVIEW_LINE;
40 base + REPLY_SPACING + ACTION_ROW + REPLY_HINT_ROW
41 }
42 ReplyState::Closed => {
43 let base = BASE_HEIGHT + preview_lines(model, preview_on) as f32 * PREVIEW_LINE;
44 if hovered {
45 base + ACTION_ROW + ACTION_ROW_SPACING
46 } else {
47 base
48 }
49 }
50 }
51}
52
53pub struct StackSlots {
54 pub toasts: Vec<Slot>,
55 pub pill: Option<Slot>,
56}
57
58pub fn stack_slots(
59 area: WorkArea,
60 corner: Corner,
61 heights: &[f32],
62 with_pill: bool,
63) -> StackSlots {
64 let scale = area.scale;
65 let physical = |value: f32| (value * scale).round() as i32;
66 let width = physical(TOAST_WIDTH);
67 let x = if corner.is_right() {
68 area.right - physical(SIDE_MARGIN) - width
69 } else {
70 area.left + physical(SIDE_MARGIN)
71 };
72 let gap = physical(STACK_GAP);
73 let mut rows: Vec<(i32, i32)> = Vec::new();
74 if with_pill {
75 rows.push((physical(PILL_WIDTH), physical(PILL_HEIGHT)));
76 }
77 rows.extend(heights.iter().map(|height| (width, physical(*height))));
78 let total: i32 = rows.iter().map(|(_, height)| height).sum::<i32>()
79 + gap * rows.len().saturating_sub(1) as i32;
80 let mut y = if corner.is_bottom() {
81 area.bottom - physical(EDGE_MARGIN) - total
82 } else {
83 area.top + physical(EDGE_MARGIN)
84 };
85 let mut slots = Vec::new();
86 for (row_width, height) in rows {
87 let row_x = if corner.is_right() {
88 x + width - row_width
89 } else {
90 x
91 };
92 slots.push(Slot {
93 x: row_x,
94 y,
95 width: row_width,
96 height,
97 });
98 y += height + gap;
99 }
100 let pill = if with_pill && !slots.is_empty() {
101 Some(slots.remove(0))
102 } else {
103 None
104 };
105 StackSlots {
106 toasts: slots,
107 pill,
108 }
109}
110
111#[cfg(test)]
112mod tests {
113 use super::*;
114
115 fn area(scale: f32) -> WorkArea {
116 WorkArea {
117 left: 0,
118 top: 0,
119 right: 1920,
120 bottom: 1032,
121 scale,
122 }
123 }
124
125 #[test]
126 fn bottom_right_stack_hugs_corner_newest_at_bottom() {
127 let slots = stack_slots(area(1.), Corner::BottomRight, &[80., 98.], false);
128 assert_eq!(slots.toasts.len(), 2);
129 let newest = slots.toasts[1];
130 assert_eq!(newest.x, 1920 - 16 - 360);
131 assert_eq!(newest.y + newest.height, 1032 - 12);
132 let older = slots.toasts[0];
133 assert_eq!(older.y + older.height + 8, newest.y);
134 }
135
136 #[test]
137 fn pill_sits_above_oldest_toast() {
138 let slots = stack_slots(area(1.), Corner::BottomRight, &[80., 80., 80.], true);
139 let pill = slots.pill.unwrap();
140 assert_eq!(pill.height, 32);
141 assert_eq!(pill.y + pill.height + 8, slots.toasts[0].y);
142 assert_eq!(pill.x + pill.width, slots.toasts[0].x + slots.toasts[0].width);
143 }
144
145 #[test]
146 fn top_left_anchors_to_top_edge() {
147 let slots = stack_slots(area(1.), Corner::TopLeft, &[80.], false);
148 assert_eq!((slots.toasts[0].x, slots.toasts[0].y), (16, 12));
149 }
150
151 #[test]
152 fn scale_applies_to_all_distances() {
153 let slots = stack_slots(area(1.5), Corner::BottomRight, &[80.], false);
154 let toast = slots.toasts[0];
155 assert_eq!(toast.width, 540);
156 assert_eq!(toast.height, 120);
157 assert_eq!(toast.y + toast.height, 1032 - 18);
158 }
159
160 #[test]
161 fn heights_stay_in_board_range() {
162 use super::super::rules::ChatKind;
163 use super::super::stack::{ReplyState, ToastTimer};
164 let model = |text: &str| ToastModel {
165 id: 1,
166 conversation_id: "a".into(),
167 message_id: "m".into(),
168 kind: ChatKind::Direct,
169 chat_title: "T".into(),
170 sender_id: None,
171 sender_name: "S".into(),
172 preview: Preview::Text(text.into()),
173 mentions_me: false,
174 count: 1,
175 timer: ToastTimer::new(std::time::Instant::now(), false),
176 reply: ReplyState::Closed,
177 reply_text: String::new(),
178 hovered: false,
179 time: String::new(),
180 };
181 let short = toast_height(&model("Hi"), false, true);
182 let long = toast_height(&model(&"x".repeat(200)), false, true);
183 assert!((76. ..=104.).contains(&short));
184 assert!((76. ..=104.).contains(&long));
185 assert!(toast_height(&model("Hi"), true, true) > short);
186 assert_eq!(toast_height(&model(&"x".repeat(200)), false, false), short);
187 }
188}
crates/app/src/notify/mod.rs added +15 −0
@@ -0,0 +1,15 @@
1 #[cfg_attr(not(windows), allow(dead_code))]
2 mod badge;
3 mod center;
4 mod incoming;
5 mod layout;
6 #[cfg_attr(not(windows), allow(dead_code))]
7 mod platform;
8 mod rules;
9 mod settings;
10 mod settings_view;
11 mod stack;
12 mod text;
13 mod toast;
14
15 pub use center::NotificationCenter;
@@ -0,0 +1,15 @@
1#[cfg_attr(not(windows), allow(dead_code))]
2mod badge;
3mod center;
4mod incoming;
5mod layout;
6#[cfg_attr(not(windows), allow(dead_code))]
7mod platform;
8mod rules;
9mod settings;
10mod settings_view;
11mod stack;
12mod text;
13mod toast;
14
15pub use center::NotificationCenter;
crates/app/src/notify/platform/mod.rs added +30 −0
@@ -0,0 +1,30 @@
1 #[cfg(windows)]
2 mod windows_impl;
3 #[cfg(windows)]
4 pub use windows_impl::*;
5
6 #[cfg(not(windows))]
7 mod stub;
8 #[cfg(not(windows))]
9 pub use stub::*;
10
11 pub type NativeHandle = isize;
12
13 #[derive(Debug, Clone, Copy, PartialEq)]
14 pub struct WorkArea {
15 pub left: i32,
16 pub top: i32,
17 pub right: i32,
18 pub bottom: i32,
19 pub scale: f32,
20 }
21
22 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
23 pub enum TrayCommand {
24 Toggle,
25 Open,
26 ToggleSound,
27 ToggleDoNotDisturb,
28 Settings,
29 Quit,
30 }
@@ -0,0 +1,30 @@
1#[cfg(windows)]
2mod windows_impl;
3#[cfg(windows)]
4pub use windows_impl::*;
5
6#[cfg(not(windows))]
7mod stub;
8#[cfg(not(windows))]
9pub use stub::*;
10
11pub type NativeHandle = isize;
12
13#[derive(Debug, Clone, Copy, PartialEq)]
14pub struct WorkArea {
15 pub left: i32,
16 pub top: i32,
17 pub right: i32,
18 pub bottom: i32,
19 pub scale: f32,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub enum TrayCommand {
24 Toggle,
25 Open,
26 ToggleSound,
27 ToggleDoNotDisturb,
28 Settings,
29 Quit,
30}
crates/app/src/notify/platform/stub.rs added +52 −0
@@ -0,0 +1,52 @@
1 use gpui_kit::Window;
2
3 use super::{NativeHandle, TrayCommand, WorkArea};
4 use crate::notify::badge::Badge;
5
6 pub fn native_handle(_window: &Window) -> Option<NativeHandle> {
7 None
8 }
9
10 pub fn prepare_toast_window(_handle: NativeHandle) {}
11
12 pub fn set_activatable(_handle: NativeHandle, _activatable: bool) {}
13
14 pub fn work_area(_handle: NativeHandle) -> Option<WorkArea> {
15 None
16 }
17
18 pub fn place(_handle: NativeHandle, _x: i32, _y: i32, _width: i32, _height: i32) {}
19
20 pub fn system_quiet() -> bool {
21 false
22 }
23
24 pub fn restore_and_raise(_handle: NativeHandle) {}
25
26 pub fn hide_window(_handle: NativeHandle) {}
27
28 pub fn flash(_handle: NativeHandle) {}
29
30 pub fn set_badge(_handle: NativeHandle, _badge: Option<&Badge>) {}
31
32 pub fn play_sound() {}
33
34 pub struct Tray;
35
36 impl Tray {
37 pub fn new(_sound_on: bool, _do_not_disturb: bool) -> Option<Self> {
38 None
39 }
40
41 pub fn poll(&self) -> Vec<TrayCommand> {
42 Vec::new()
43 }
44
45 pub fn sync(&self, _sound_on: bool, _do_not_disturb: bool, _mention: bool) {}
46 }
47
48 pub fn set_border_color(_handle: NativeHandle, _rgb: u32) {}
49
50 pub fn animations_enabled() -> bool {
51 true
52 }
@@ -0,0 +1,52 @@
1use gpui_kit::Window;
2
3use super::{NativeHandle, TrayCommand, WorkArea};
4use crate::notify::badge::Badge;
5
6pub fn native_handle(_window: &Window) -> Option<NativeHandle> {
7 None
8}
9
10pub fn prepare_toast_window(_handle: NativeHandle) {}
11
12pub fn set_activatable(_handle: NativeHandle, _activatable: bool) {}
13
14pub fn work_area(_handle: NativeHandle) -> Option<WorkArea> {
15 None
16}
17
18pub fn place(_handle: NativeHandle, _x: i32, _y: i32, _width: i32, _height: i32) {}
19
20pub fn system_quiet() -> bool {
21 false
22}
23
24pub fn restore_and_raise(_handle: NativeHandle) {}
25
26pub fn hide_window(_handle: NativeHandle) {}
27
28pub fn flash(_handle: NativeHandle) {}
29
30pub fn set_badge(_handle: NativeHandle, _badge: Option<&Badge>) {}
31
32pub fn play_sound() {}
33
34pub struct Tray;
35
36impl Tray {
37 pub fn new(_sound_on: bool, _do_not_disturb: bool) -> Option<Self> {
38 None
39 }
40
41 pub fn poll(&self) -> Vec<TrayCommand> {
42 Vec::new()
43 }
44
45 pub fn sync(&self, _sound_on: bool, _do_not_disturb: bool, _mention: bool) {}
46}
47
48pub fn set_border_color(_handle: NativeHandle, _rgb: u32) {}
49
50pub fn animations_enabled() -> bool {
51 true
52}
crates/app/src/notify/platform/windows_impl.rs added +360 −0
@@ -0,0 +1,360 @@
1 use std::ffi::c_void;
2 use std::io::Cursor;
3
4 use gpui_kit::Window;
5 use raw_window_handle::{HasWindowHandle, RawWindowHandle};
6 use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem};
7 use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
8 use windows::Win32::Foundation::{HWND, RECT};
9 use windows::Win32::Graphics::Dwm::{
10 DWMWA_BORDER_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUND, DwmSetWindowAttribute,
11 };
12 use windows::Win32::Graphics::Gdi::{
13 CreateBitmap, DeleteObject, GetMonitorInfoW, HGDIOBJ, MONITOR_DEFAULTTONEAREST, MONITORINFO,
14 MonitorFromWindow,
15 };
16 use windows::Win32::System::Com::{CLSCTX_INPROC_SERVER, CoCreateInstance};
17 use windows::Win32::UI::HiDpi::GetDpiForWindow;
18 use windows::Win32::UI::Shell::{
19 ITaskbarList3, QUNS_BUSY, QUNS_PRESENTATION_MODE, QUNS_QUIET_TIME, QUNS_RUNNING_D3D_FULL_SCREEN,
20 SHQueryUserNotificationState, TaskbarList,
21 };
22 use windows::Win32::UI::WindowsAndMessaging::{
23 CreateIconIndirect, DestroyIcon, FLASHW_ALL, FLASHWINFO, FlashWindowEx, GWL_EXSTYLE,
24 GetWindowLongPtrW, HICON, HWND_TOPMOST, ICONINFO, IsIconic, SW_HIDE, SW_RESTORE, SW_SHOW, SWP_NOACTIVATE,
25 SPI_GETCLIENTAREAANIMATION, SWP_NOOWNERZORDER, SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS, SetForegroundWindow,
26 SetWindowLongPtrW, SetWindowPos, ShowWindow, SystemParametersInfoW,
27 WS_EX_NOACTIVATE,
28 };
29 use windows::core::{BOOL, w};
30
31 use super::{NativeHandle, TrayCommand, WorkArea};
32 use crate::notify::badge::{BADGE_SIZE, Badge, render_badge};
33
34 const SOUND_BYTES: &[u8] = include_bytes!("../../../assets/sounds/notification.mp3");
35 const TRAY_ICON_PNG: &[u8] = include_bytes!("../../../assets/icon/teams-fast-256.png");
36 const TRAY_ICON_SIZE: u32 = 32;
37 const TRAY_DOT_RADIUS: f32 = 6.;
38 const FLASH_COUNT: u32 = 3;
39 const BASE_DPI: f32 = 96.;
40
41 fn hwnd(handle: NativeHandle) -> HWND {
42 HWND(handle as *mut c_void)
43 }
44
45 pub fn native_handle(window: &Window) -> Option<NativeHandle> {
46 match HasWindowHandle::window_handle(window).ok()?.as_raw() {
47 RawWindowHandle::Win32(handle) => Some(handle.hwnd.get()),
48 _ => None,
49 }
50 }
51
52 pub fn prepare_toast_window(handle: NativeHandle) {
53 unsafe {
54 let style = GetWindowLongPtrW(hwnd(handle), GWL_EXSTYLE);
55 SetWindowLongPtrW(
56 hwnd(handle),
57 GWL_EXSTYLE,
58 style | WS_EX_NOACTIVATE.0 as isize,
59 );
60 let preference = DWMWCP_ROUND;
61 let _ = DwmSetWindowAttribute(
62 hwnd(handle),
63 DWMWA_WINDOW_CORNER_PREFERENCE,
64 &preference as *const _ as *const c_void,
65 size_of_val(&preference) as u32,
66 );
67 }
68 }
69
70 pub fn set_activatable(handle: NativeHandle, activatable: bool) {
71 unsafe {
72 let style = GetWindowLongPtrW(hwnd(handle), GWL_EXSTYLE);
73 let flag = WS_EX_NOACTIVATE.0 as isize;
74 let updated = if activatable { style & !flag } else { style | flag };
75 SetWindowLongPtrW(hwnd(handle), GWL_EXSTYLE, updated);
76 if activatable {
77 let _ = SetForegroundWindow(hwnd(handle));
78 }
79 }
80 }
81
82 pub fn work_area(handle: NativeHandle) -> Option<WorkArea> {
83 unsafe {
84 let monitor = MonitorFromWindow(hwnd(handle), MONITOR_DEFAULTTONEAREST);
85 let mut info = MONITORINFO {
86 cbSize: size_of::<MONITORINFO>() as u32,
87 ..Default::default()
88 };
89 if !GetMonitorInfoW(monitor, &mut info).as_bool() {
90 return None;
91 }
92 let RECT {
93 left,
94 top,
95 right,
96 bottom,
97 } = info.rcWork;
98 let dpi = GetDpiForWindow(hwnd(handle));
99 Some(WorkArea {
100 left,
101 top,
102 right,
103 bottom,
104 scale: if dpi == 0 { 1. } else { dpi as f32 / BASE_DPI },
105 })
106 }
107 }
108
109 pub fn place(handle: NativeHandle, x: i32, y: i32, width: i32, height: i32) {
110 unsafe {
111 let _ = SetWindowPos(
112 hwnd(handle),
113 Some(HWND_TOPMOST),
114 x,
115 y,
116 width,
117 height,
118 SWP_NOACTIVATE | SWP_NOOWNERZORDER,
119 );
120 }
121 }
122
123 pub fn system_quiet() -> bool {
124 let state = unsafe { SHQueryUserNotificationState() };
125 matches!(
126 state,
127 Ok(QUNS_BUSY | QUNS_RUNNING_D3D_FULL_SCREEN | QUNS_PRESENTATION_MODE | QUNS_QUIET_TIME)
128 )
129 }
130
131 pub fn restore_and_raise(handle: NativeHandle) {
132 unsafe {
133 let command = if IsIconic(hwnd(handle)).as_bool() {
134 SW_RESTORE
135 } else {
136 SW_SHOW
137 };
138 let _ = ShowWindow(hwnd(handle), command);
139 let _ = SetForegroundWindow(hwnd(handle));
140 }
141 }
142
143 pub fn hide_window(handle: NativeHandle) {
144 unsafe {
145 let _ = ShowWindow(hwnd(handle), SW_HIDE);
146 }
147 }
148
149 pub fn flash(handle: NativeHandle) {
150 let info = FLASHWINFO {
151 cbSize: size_of::<FLASHWINFO>() as u32,
152 hwnd: hwnd(handle),
153 dwFlags: FLASHW_ALL,
154 uCount: FLASH_COUNT,
155 dwTimeout: 0,
156 };
157 unsafe {
158 let _ = FlashWindowEx(&info);
159 }
160 }
161
162 pub fn set_badge(handle: NativeHandle, badge: Option<&Badge>) {
163 unsafe {
164 let Ok(taskbar) = CoCreateInstance::<_, ITaskbarList3>(&TaskbarList, None, CLSCTX_INPROC_SERVER)
165 else {
166 return;
167 };
168 if taskbar.HrInit().is_err() {
169 return;
170 }
171 match badge {
172 None => {
173 let _ = taskbar.SetOverlayIcon(hwnd(handle), HICON::default(), w!(""));
174 }
175 Some(badge) => {
176 let Some(icon) = icon_from_badge(badge) else {
177 return;
178 };
179 let _ = taskbar.SetOverlayIcon(hwnd(handle), icon, w!("Ungelesene Chats"));
180 let _ = DestroyIcon(icon);
181 }
182 }
183 }
184 }
185
186 unsafe fn icon_from_badge(badge: &Badge) -> Option<HICON> {
187 let pixels = render_badge(badge);
188 unsafe {
189 let color = CreateBitmap(
190 BADGE_SIZE as i32,
191 BADGE_SIZE as i32,
192 1,
193 32,
194 Some(pixels.as_ptr() as *const c_void),
195 );
196 let mask = CreateBitmap(BADGE_SIZE as i32, BADGE_SIZE as i32, 1, 1, None);
197 let info = ICONINFO {
198 fIcon: BOOL(1),
199 xHotspot: 0,
200 yHotspot: 0,
201 hbmMask: mask,
202 hbmColor: color,
203 };
204 let icon = CreateIconIndirect(&info).ok();
205 let _ = DeleteObject(HGDIOBJ(color.0));
206 let _ = DeleteObject(HGDIOBJ(mask.0));
207 icon
208 }
209 }
210
211 pub fn play_sound() {
212 std::thread::spawn(|| {
213 let Ok(mut sink) = rodio::DeviceSinkBuilder::open_default_sink() else {
214 return;
215 };
216 sink.log_on_drop(false);
217 if let Ok(player) = rodio::play(sink.mixer(), Cursor::new(SOUND_BYTES)) {
218 player.sleep_until_end();
219 }
220 });
221 }
222
223 const ID_OPEN: &str = "open";
224 const ID_SOUND: &str = "sound";
225 const ID_DO_NOT_DISTURB: &str = "do_not_disturb";
226 const ID_SETTINGS: &str = "settings";
227 const ID_QUIT: &str = "quit";
228
229 pub struct Tray {
230 icon: TrayIcon,
231 sound: CheckMenuItem,
232 do_not_disturb: CheckMenuItem,
233 plain: Icon,
234 with_dot: Icon,
235 }
236
237 impl Tray {
238 pub fn new(sound_on: bool, do_not_disturb: bool) -> Option<Self> {
239 let (plain, with_dot) = tray_icons()?;
240 let open = MenuItem::with_id(ID_OPEN, "Rusty Teams öffnen", true, None);
241 let sound = CheckMenuItem::with_id(ID_SOUND, "Ton aus", true, !sound_on, None);
242 let dnd = CheckMenuItem::with_id(
243 ID_DO_NOT_DISTURB,
244 "Nicht stören",
245 true,
246 do_not_disturb,
247 None,
248 );
249 let settings = MenuItem::with_id(ID_SETTINGS, "Benachrichtigungen", true, None);
250 let quit = MenuItem::with_id(ID_QUIT, "Beenden", true, None);
251 let menu = Menu::new();
252 menu.append_items(&[
253 &open,
254 &PredefinedMenuItem::separator(),
255 &sound,
256 &dnd,
257 &settings,
258 &PredefinedMenuItem::separator(),
259 &quit,
260 ])
261 .ok()?;
262 let icon = TrayIconBuilder::new()
263 .with_icon(plain.clone())
264 .with_tooltip(crate::APP_NAME)
265 .with_menu(Box::new(menu))
266 .with_menu_on_left_click(false)
267 .build()
268 .ok()?;
269 Some(Tray {
270 icon,
271 sound,
272 do_not_disturb: dnd,
273 plain,
274 with_dot,
275 })
276 }
277
278 pub fn poll(&self) -> Vec<TrayCommand> {
279 let mut commands = Vec::new();
280 while let Ok(event) = MenuEvent::receiver().try_recv() {
281 let command = match event.id.0.as_str() {
282 ID_OPEN => TrayCommand::Open,
283 ID_SOUND => TrayCommand::ToggleSound,
284 ID_DO_NOT_DISTURB => TrayCommand::ToggleDoNotDisturb,
285 ID_SETTINGS => TrayCommand::Settings,
286 ID_QUIT => TrayCommand::Quit,
287 _ => continue,
288 };
289 commands.push(command);
290 }
291 while let Ok(event) = TrayIconEvent::receiver().try_recv() {
292 if let TrayIconEvent::Click {
293 button: MouseButton::Left,
294 button_state: MouseButtonState::Up,
295 ..
296 } = event
297 {
298 commands.push(TrayCommand::Toggle);
299 }
300 }
301 commands
302 }
303
304 pub fn sync(&self, sound_on: bool, do_not_disturb: bool, mention: bool) {
305 self.sound.set_checked(!sound_on);
306 self.do_not_disturb.set_checked(do_not_disturb);
307 let icon = if mention { &self.with_dot } else { &self.plain };
308 let _ = self.icon.set_icon(Some(icon.clone()));
309 }
310 }
311
312 fn tray_icons() -> Option<(Icon, Icon)> {
313 let decoded = image::load_from_memory(TRAY_ICON_PNG).ok()?;
314 let resized = decoded
315 .resize_exact(
316 TRAY_ICON_SIZE,
317 TRAY_ICON_SIZE,
318 image::imageops::FilterType::Lanczos3,
319 )
320 .to_rgba8();
321 let plain = resized.clone().into_raw();
322 let mut dotted = resized;
323 let size = TRAY_ICON_SIZE as f32;
324 let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
325 for (column, row, pixel) in dotted.enumerate_pixels_mut() {
326 let distance = ((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
327 if distance <= TRAY_DOT_RADIUS {
328 *pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
329 }
330 }
331 Some((
332 Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
333 Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
334 ))
335 }
336
337 pub fn set_border_color(handle: NativeHandle, rgb: u32) {
338 let colorref: u32 = ((rgb & 0xff) << 16) | (rgb & 0xff00) | ((rgb >> 16) & 0xff);
339 unsafe {
340 let _ = DwmSetWindowAttribute(
341 hwnd(handle),
342 DWMWA_BORDER_COLOR,
343 &colorref as *const _ as *const c_void,
344 size_of::<u32>() as u32,
345 );
346 }
347 }
348
349 pub fn animations_enabled() -> bool {
350 let mut enabled = BOOL(1);
351 let read = unsafe {
352 SystemParametersInfoW(
353 SPI_GETCLIENTAREAANIMATION,
354 0,
355 Some(&mut enabled as *mut BOOL as *mut c_void),
356 SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS(0),
357 )
358 };
359 read.is_err() || enabled.as_bool()
360 }
@@ -0,0 +1,360 @@
1use std::ffi::c_void;
2use std::io::Cursor;
3
4use gpui_kit::Window;
5use raw_window_handle::{HasWindowHandle, RawWindowHandle};
6use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem};
7use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
8use windows::Win32::Foundation::{HWND, RECT};
9use windows::Win32::Graphics::Dwm::{
10 DWMWA_BORDER_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUND, DwmSetWindowAttribute,
11};
12use windows::Win32::Graphics::Gdi::{
13 CreateBitmap, DeleteObject, GetMonitorInfoW, HGDIOBJ, MONITOR_DEFAULTTONEAREST, MONITORINFO,
14 MonitorFromWindow,
15};
16use windows::Win32::System::Com::{CLSCTX_INPROC_SERVER, CoCreateInstance};
17use windows::Win32::UI::HiDpi::GetDpiForWindow;
18use windows::Win32::UI::Shell::{
19 ITaskbarList3, QUNS_BUSY, QUNS_PRESENTATION_MODE, QUNS_QUIET_TIME, QUNS_RUNNING_D3D_FULL_SCREEN,
20 SHQueryUserNotificationState, TaskbarList,
21};
22use windows::Win32::UI::WindowsAndMessaging::{
23 CreateIconIndirect, DestroyIcon, FLASHW_ALL, FLASHWINFO, FlashWindowEx, GWL_EXSTYLE,
24 GetWindowLongPtrW, HICON, HWND_TOPMOST, ICONINFO, IsIconic, SW_HIDE, SW_RESTORE, SW_SHOW, SWP_NOACTIVATE,
25 SPI_GETCLIENTAREAANIMATION, SWP_NOOWNERZORDER, SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS, SetForegroundWindow,
26 SetWindowLongPtrW, SetWindowPos, ShowWindow, SystemParametersInfoW,
27 WS_EX_NOACTIVATE,
28};
29use windows::core::{BOOL, w};
30
31use super::{NativeHandle, TrayCommand, WorkArea};
32use crate::notify::badge::{BADGE_SIZE, Badge, render_badge};
33
34const SOUND_BYTES: &[u8] = include_bytes!("../../../assets/sounds/notification.mp3");
35const TRAY_ICON_PNG: &[u8] = include_bytes!("../../../assets/icon/teams-fast-256.png");
36const TRAY_ICON_SIZE: u32 = 32;
37const TRAY_DOT_RADIUS: f32 = 6.;
38const FLASH_COUNT: u32 = 3;
39const BASE_DPI: f32 = 96.;
40
41fn hwnd(handle: NativeHandle) -> HWND {
42 HWND(handle as *mut c_void)
43}
44
45pub fn native_handle(window: &Window) -> Option<NativeHandle> {
46 match HasWindowHandle::window_handle(window).ok()?.as_raw() {
47 RawWindowHandle::Win32(handle) => Some(handle.hwnd.get()),
48 _ => None,
49 }
50}
51
52pub fn prepare_toast_window(handle: NativeHandle) {
53 unsafe {
54 let style = GetWindowLongPtrW(hwnd(handle), GWL_EXSTYLE);
55 SetWindowLongPtrW(
56 hwnd(handle),
57 GWL_EXSTYLE,
58 style | WS_EX_NOACTIVATE.0 as isize,
59 );
60 let preference = DWMWCP_ROUND;
61 let _ = DwmSetWindowAttribute(
62 hwnd(handle),
63 DWMWA_WINDOW_CORNER_PREFERENCE,
64 &preference as *const _ as *const c_void,
65 size_of_val(&preference) as u32,
66 );
67 }
68}
69
70pub fn set_activatable(handle: NativeHandle, activatable: bool) {
71 unsafe {
72 let style = GetWindowLongPtrW(hwnd(handle), GWL_EXSTYLE);
73 let flag = WS_EX_NOACTIVATE.0 as isize;
74 let updated = if activatable { style & !flag } else { style | flag };
75 SetWindowLongPtrW(hwnd(handle), GWL_EXSTYLE, updated);
76 if activatable {
77 let _ = SetForegroundWindow(hwnd(handle));
78 }
79 }
80}
81
82pub fn work_area(handle: NativeHandle) -> Option<WorkArea> {
83 unsafe {
84 let monitor = MonitorFromWindow(hwnd(handle), MONITOR_DEFAULTTONEAREST);
85 let mut info = MONITORINFO {
86 cbSize: size_of::<MONITORINFO>() as u32,
87 ..Default::default()
88 };
89 if !GetMonitorInfoW(monitor, &mut info).as_bool() {
90 return None;
91 }
92 let RECT {
93 left,
94 top,
95 right,
96 bottom,
97 } = info.rcWork;
98 let dpi = GetDpiForWindow(hwnd(handle));
99 Some(WorkArea {
100 left,
101 top,
102 right,
103 bottom,
104 scale: if dpi == 0 { 1. } else { dpi as f32 / BASE_DPI },
105 })
106 }
107}
108
109pub fn place(handle: NativeHandle, x: i32, y: i32, width: i32, height: i32) {
110 unsafe {
111 let _ = SetWindowPos(
112 hwnd(handle),
113 Some(HWND_TOPMOST),
114 x,
115 y,
116 width,
117 height,
118 SWP_NOACTIVATE | SWP_NOOWNERZORDER,
119 );
120 }
121}
122
123pub fn system_quiet() -> bool {
124 let state = unsafe { SHQueryUserNotificationState() };
125 matches!(
126 state,
127 Ok(QUNS_BUSY | QUNS_RUNNING_D3D_FULL_SCREEN | QUNS_PRESENTATION_MODE | QUNS_QUIET_TIME)
128 )
129}
130
131pub fn restore_and_raise(handle: NativeHandle) {
132 unsafe {
133 let command = if IsIconic(hwnd(handle)).as_bool() {
134 SW_RESTORE
135 } else {
136 SW_SHOW
137 };
138 let _ = ShowWindow(hwnd(handle), command);
139 let _ = SetForegroundWindow(hwnd(handle));
140 }
141}
142
143pub fn hide_window(handle: NativeHandle) {
144 unsafe {
145 let _ = ShowWindow(hwnd(handle), SW_HIDE);
146 }
147}
148
149pub fn flash(handle: NativeHandle) {
150 let info = FLASHWINFO {
151 cbSize: size_of::<FLASHWINFO>() as u32,
152 hwnd: hwnd(handle),
153 dwFlags: FLASHW_ALL,
154 uCount: FLASH_COUNT,
155 dwTimeout: 0,
156 };
157 unsafe {
158 let _ = FlashWindowEx(&info);
159 }
160}
161
162pub fn set_badge(handle: NativeHandle, badge: Option<&Badge>) {
163 unsafe {
164 let Ok(taskbar) = CoCreateInstance::<_, ITaskbarList3>(&TaskbarList, None, CLSCTX_INPROC_SERVER)
165 else {
166 return;
167 };
168 if taskbar.HrInit().is_err() {
169 return;
170 }
171 match badge {
172 None => {
173 let _ = taskbar.SetOverlayIcon(hwnd(handle), HICON::default(), w!(""));
174 }
175 Some(badge) => {
176 let Some(icon) = icon_from_badge(badge) else {
177 return;
178 };
179 let _ = taskbar.SetOverlayIcon(hwnd(handle), icon, w!("Ungelesene Chats"));
180 let _ = DestroyIcon(icon);
181 }
182 }
183 }
184}
185
186unsafe fn icon_from_badge(badge: &Badge) -> Option<HICON> {
187 let pixels = render_badge(badge);
188 unsafe {
189 let color = CreateBitmap(
190 BADGE_SIZE as i32,
191 BADGE_SIZE as i32,
192 1,
193 32,
194 Some(pixels.as_ptr() as *const c_void),
195 );
196 let mask = CreateBitmap(BADGE_SIZE as i32, BADGE_SIZE as i32, 1, 1, None);
197 let info = ICONINFO {
198 fIcon: BOOL(1),
199 xHotspot: 0,
200 yHotspot: 0,
201 hbmMask: mask,
202 hbmColor: color,
203 };
204 let icon = CreateIconIndirect(&info).ok();
205 let _ = DeleteObject(HGDIOBJ(color.0));
206 let _ = DeleteObject(HGDIOBJ(mask.0));
207 icon
208 }
209}
210
211pub fn play_sound() {
212 std::thread::spawn(|| {
213 let Ok(mut sink) = rodio::DeviceSinkBuilder::open_default_sink() else {
214 return;
215 };
216 sink.log_on_drop(false);
217 if let Ok(player) = rodio::play(sink.mixer(), Cursor::new(SOUND_BYTES)) {
218 player.sleep_until_end();
219 }
220 });
221}
222
223const ID_OPEN: &str = "open";
224const ID_SOUND: &str = "sound";
225const ID_DO_NOT_DISTURB: &str = "do_not_disturb";
226const ID_SETTINGS: &str = "settings";
227const ID_QUIT: &str = "quit";
228
229pub struct Tray {
230 icon: TrayIcon,
231 sound: CheckMenuItem,
232 do_not_disturb: CheckMenuItem,
233 plain: Icon,
234 with_dot: Icon,
235}
236
237impl Tray {
238 pub fn new(sound_on: bool, do_not_disturb: bool) -> Option<Self> {
239 let (plain, with_dot) = tray_icons()?;
240 let open = MenuItem::with_id(ID_OPEN, "Rusty Teams öffnen", true, None);
241 let sound = CheckMenuItem::with_id(ID_SOUND, "Ton aus", true, !sound_on, None);
242 let dnd = CheckMenuItem::with_id(
243 ID_DO_NOT_DISTURB,
244 "Nicht stören",
245 true,
246 do_not_disturb,
247 None,
248 );
249 let settings = MenuItem::with_id(ID_SETTINGS, "Benachrichtigungen", true, None);
250 let quit = MenuItem::with_id(ID_QUIT, "Beenden", true, None);
251 let menu = Menu::new();
252 menu.append_items(&[
253 &open,
254 &PredefinedMenuItem::separator(),
255 &sound,
256 &dnd,
257 &settings,
258 &PredefinedMenuItem::separator(),
259 &quit,
260 ])
261 .ok()?;
262 let icon = TrayIconBuilder::new()
263 .with_icon(plain.clone())
264 .with_tooltip(crate::APP_NAME)
265 .with_menu(Box::new(menu))
266 .with_menu_on_left_click(false)
267 .build()
268 .ok()?;
269 Some(Tray {
270 icon,
271 sound,
272 do_not_disturb: dnd,
273 plain,
274 with_dot,
275 })
276 }
277
278 pub fn poll(&self) -> Vec<TrayCommand> {
279 let mut commands = Vec::new();
280 while let Ok(event) = MenuEvent::receiver().try_recv() {
281 let command = match event.id.0.as_str() {
282 ID_OPEN => TrayCommand::Open,
283 ID_SOUND => TrayCommand::ToggleSound,
284 ID_DO_NOT_DISTURB => TrayCommand::ToggleDoNotDisturb,
285 ID_SETTINGS => TrayCommand::Settings,
286 ID_QUIT => TrayCommand::Quit,
287 _ => continue,
288 };
289 commands.push(command);
290 }
291 while let Ok(event) = TrayIconEvent::receiver().try_recv() {
292 if let TrayIconEvent::Click {
293 button: MouseButton::Left,
294 button_state: MouseButtonState::Up,
295 ..
296 } = event
297 {
298 commands.push(TrayCommand::Toggle);
299 }
300 }
301 commands
302 }
303
304 pub fn sync(&self, sound_on: bool, do_not_disturb: bool, mention: bool) {
305 self.sound.set_checked(!sound_on);
306 self.do_not_disturb.set_checked(do_not_disturb);
307 let icon = if mention { &self.with_dot } else { &self.plain };
308 let _ = self.icon.set_icon(Some(icon.clone()));
309 }
310}
311
312fn tray_icons() -> Option<(Icon, Icon)> {
313 let decoded = image::load_from_memory(TRAY_ICON_PNG).ok()?;
314 let resized = decoded
315 .resize_exact(
316 TRAY_ICON_SIZE,
317 TRAY_ICON_SIZE,
318 image::imageops::FilterType::Lanczos3,
319 )
320 .to_rgba8();
321 let plain = resized.clone().into_raw();
322 let mut dotted = resized;
323 let size = TRAY_ICON_SIZE as f32;
324 let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
325 for (column, row, pixel) in dotted.enumerate_pixels_mut() {
326 let distance = ((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
327 if distance <= TRAY_DOT_RADIUS {
328 *pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
329 }
330 }
331 Some((
332 Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
333 Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
334 ))
335}
336
337pub fn set_border_color(handle: NativeHandle, rgb: u32) {
338 let colorref: u32 = ((rgb & 0xff) << 16) | (rgb & 0xff00) | ((rgb >> 16) & 0xff);
339 unsafe {
340 let _ = DwmSetWindowAttribute(
341 hwnd(handle),
342 DWMWA_BORDER_COLOR,
343 &colorref as *const _ as *const c_void,
344 size_of::<u32>() as u32,
345 );
346 }
347}
348
349pub fn animations_enabled() -> bool {
350 let mut enabled = BOOL(1);
351 let read = unsafe {
352 SystemParametersInfoW(
353 SPI_GETCLIENTAREAANIMATION,
354 0,
355 Some(&mut enabled as *mut BOOL as *mut c_void),
356 SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS(0),
357 )
358 };
359 read.is_err() || enabled.as_bool()
360}
crates/app/src/notify/rules.rs added +327 −0
@@ -0,0 +1,327 @@
1 use std::collections::HashMap;
2 use std::time::{Duration, Instant};
3
4 pub const SOUND_THROTTLE: Duration = Duration::from_secs(10);
5
6 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
7 pub enum Corner {
8 TopLeft,
9 TopRight,
10 BottomLeft,
11 #[default]
12 BottomRight,
13 }
14
15 impl Corner {
16 pub const ALL: [Corner; 4] = [
17 Corner::TopLeft,
18 Corner::TopRight,
19 Corner::BottomLeft,
20 Corner::BottomRight,
21 ];
22
23 pub fn label(self) -> &'static str {
24 match self {
25 Corner::TopLeft => "Oben links",
26 Corner::TopRight => "Oben rechts",
27 Corner::BottomLeft => "Unten links",
28 Corner::BottomRight => "Unten rechts",
29 }
30 }
31
32 pub fn key(self) -> &'static str {
33 match self {
34 Corner::TopLeft => "top_left",
35 Corner::TopRight => "top_right",
36 Corner::BottomLeft => "bottom_left",
37 Corner::BottomRight => "bottom_right",
38 }
39 }
40
41 pub fn from_key(key: &str) -> Option<Corner> {
42 Corner::ALL.into_iter().find(|corner| corner.key() == key)
43 }
44
45 pub fn is_bottom(self) -> bool {
46 matches!(self, Corner::BottomLeft | Corner::BottomRight)
47 }
48
49 pub fn is_right(self) -> bool {
50 matches!(self, Corner::TopRight | Corner::BottomRight)
51 }
52
53 pub fn next(self) -> Corner {
54 let index = Corner::ALL
55 .iter()
56 .position(|corner| *corner == self)
57 .unwrap_or(0);
58 Corner::ALL[(index + 1) % Corner::ALL.len()]
59 }
60 }
61
62 #[derive(Debug, Clone, PartialEq, Eq)]
63 pub struct Settings {
64 pub sound: bool,
65 pub mentions_only: bool,
66 pub preview: bool,
67 pub corner: Corner,
68 pub flash: bool,
69 pub close_to_tray: bool,
70 pub do_not_disturb: bool,
71 }
72
73 impl Default for Settings {
74 fn default() -> Self {
75 Settings {
76 sound: true,
77 mentions_only: false,
78 preview: true,
79 corner: Corner::BottomRight,
80 flash: true,
81 close_to_tray: true,
82 do_not_disturb: false,
83 }
84 }
85 }
86
87 #[derive(Debug, Clone, PartialEq, Eq)]
88 pub enum ChatKind {
89 Direct,
90 Group { member_count: usize },
91 Channel { team: String, channel: String },
92 }
93
94 #[derive(Debug, Clone, PartialEq, Eq)]
95 pub enum Preview {
96 Text(String),
97 Image,
98 }
99
100 #[derive(Debug, Clone, PartialEq, Eq)]
101 pub struct Incoming {
102 pub conversation_id: String,
103 pub message_id: String,
104 pub kind: ChatKind,
105 pub chat_title: String,
106 pub sender_id: Option<String>,
107 pub sender_name: String,
108 pub preview: Preview,
109 pub mentions_me: bool,
110 pub muted: bool,
111 }
112
113 impl Incoming {
114 pub fn is_direct(&self) -> bool {
115 self.kind == ChatKind::Direct
116 }
117 }
118
119 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
120 pub struct Environment {
121 pub chat_in_foreground: bool,
122 pub system_quiet: bool,
123 pub own_do_not_disturb: bool,
124 pub in_call: bool,
125 }
126
127 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
128 pub struct Decision {
129 pub toast: bool,
130 pub sound: bool,
131 }
132
133 const SILENT: Decision = Decision {
134 toast: false,
135 sound: false,
136 };
137
138 pub fn decide(settings: &Settings, incoming: &Incoming, environment: Environment) -> Decision {
139 let suppressed = environment.chat_in_foreground
140 || environment.system_quiet
141 || environment.own_do_not_disturb
142 || settings.do_not_disturb
143 || (incoming.muted && !incoming.mentions_me)
144 || (settings.mentions_only && !incoming.mentions_me && !incoming.is_direct());
145 if suppressed {
146 return SILENT;
147 }
148 Decision {
149 toast: true,
150 sound: settings.sound && !environment.in_call,
151 }
152 }
153
154 #[derive(Default)]
155 pub struct SoundThrottle {
156 last_played: HashMap<String, Instant>,
157 }
158
159 impl SoundThrottle {
160 pub fn allow(&mut self, conversation_id: &str, now: Instant) -> bool {
161 let allowed = self
162 .last_played
163 .get(conversation_id)
164 .is_none_or(|last| now.duration_since(*last) >= SOUND_THROTTLE);
165 if allowed {
166 self.last_played.insert(conversation_id.to_owned(), now);
167 }
168 allowed
169 }
170 }
171
172 pub fn should_flash(settings: &Settings, mentions_me: bool, window_active: bool) -> bool {
173 settings.flash && mentions_me && !window_active
174 }
175
176 #[cfg(test)]
177 mod tests {
178 use super::*;
179
180 fn incoming(kind: ChatKind) -> Incoming {
181 Incoming {
182 conversation_id: "chat".into(),
183 message_id: "1".into(),
184 kind,
185 chat_title: "Chat".into(),
186 sender_id: Some("u1".into()),
187 sender_name: "Mara".into(),
188 preview: Preview::Text("Hallo".into()),
189 mentions_me: false,
190 muted: false,
191 }
192 }
193
194 fn group() -> Incoming {
195 incoming(ChatKind::Group { member_count: 5 })
196 }
197
198 #[test]
199 fn plain_message_gets_toast_and_sound() {
200 let decision = decide(&Settings::default(), &group(), Environment::default());
201 assert_eq!(
202 decision,
203 Decision {
204 toast: true,
205 sound: true
206 }
207 );
208 }
209
210 #[test]
211 fn foreground_chat_is_silent() {
212 let environment = Environment {
213 chat_in_foreground: true,
214 ..Default::default()
215 };
216 assert_eq!(decide(&Settings::default(), &group(), environment), SILENT);
217 }
218
219 #[test]
220 fn focus_assist_and_dnd_are_silent() {
221 for environment in [
222 Environment {
223 system_quiet: true,
224 ..Default::default()
225 },
226 Environment {
227 own_do_not_disturb: true,
228 ..Default::default()
229 },
230 ] {
231 assert_eq!(decide(&Settings::default(), &group(), environment), SILENT);
232 }
233 let settings = Settings {
234 do_not_disturb: true,
235 ..Default::default()
236 };
237 assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);
238 }
239
240 #[test]
241 fn call_keeps_toast_but_drops_sound() {
242 let environment = Environment {
243 in_call: true,
244 ..Default::default()
245 };
246 let decision = decide(&Settings::default(), &group(), environment);
247 assert_eq!(
248 decision,
249 Decision {
250 toast: true,
251 sound: false
252 }
253 );
254 }
255
256 #[test]
257 fn muted_chat_only_notifies_for_mentions() {
258 let mut muted = group();
259 muted.muted = true;
260 assert_eq!(
261 decide(&Settings::default(), &muted, Environment::default()),
262 SILENT
263 );
264 muted.mentions_me = true;
265 assert!(decide(&Settings::default(), &muted, Environment::default()).toast);
266 }
267
268 #[test]
269 fn mentions_only_keeps_direct_and_mentions() {
270 let settings = Settings {
271 mentions_only: true,
272 ..Default::default()
273 };
274 assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);
275 assert!(decide(&settings, &incoming(ChatKind::Direct), Environment::default()).toast);
276 let mut mention = group();
277 mention.mentions_me = true;
278 assert!(decide(&settings, &mention, Environment::default()).toast);
279 }
280
281 #[test]
282 fn sound_setting_off_keeps_toast() {
283 let settings = Settings {
284 sound: false,
285 ..Default::default()
286 };
287 let decision = decide(&settings, &group(), Environment::default());
288 assert_eq!(
289 decision,
290 Decision {
291 toast: true,
292 sound: false
293 }
294 );
295 }
296
297 #[test]
298 fn throttle_allows_once_per_window_per_chat() {
299 let mut throttle = SoundThrottle::default();
300 let start = Instant::now();
301 assert!(throttle.allow("a", start));
302 assert!(!throttle.allow("a", start + Duration::from_secs(9)));
303 assert!(throttle.allow("b", start + Duration::from_secs(9)));
304 assert!(throttle.allow("a", start + Duration::from_secs(10)));
305 }
306
307 #[test]
308 fn flash_needs_mention_inactive_window_and_setting() {
309 let settings = Settings::default();
310 assert!(should_flash(&settings, true, false));
311 assert!(!should_flash(&settings, true, true));
312 assert!(!should_flash(&settings, false, false));
313 let off = Settings {
314 flash: false,
315 ..Default::default()
316 };
317 assert!(!should_flash(&off, true, false));
318 }
319
320 #[test]
321 fn corner_keys_round_trip() {
322 for corner in Corner::ALL {
323 assert_eq!(Corner::from_key(corner.key()), Some(corner));
324 }
325 assert_eq!(Corner::BottomRight.next(), Corner::TopLeft);
326 }
327 }
@@ -0,0 +1,327 @@
1use std::collections::HashMap;
2use std::time::{Duration, Instant};
3
4pub const SOUND_THROTTLE: Duration = Duration::from_secs(10);
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
7pub enum Corner {
8 TopLeft,
9 TopRight,
10 BottomLeft,
11 #[default]
12 BottomRight,
13}
14
15impl Corner {
16 pub const ALL: [Corner; 4] = [
17 Corner::TopLeft,
18 Corner::TopRight,
19 Corner::BottomLeft,
20 Corner::BottomRight,
21 ];
22
23 pub fn label(self) -> &'static str {
24 match self {
25 Corner::TopLeft => "Oben links",
26 Corner::TopRight => "Oben rechts",
27 Corner::BottomLeft => "Unten links",
28 Corner::BottomRight => "Unten rechts",
29 }
30 }
31
32 pub fn key(self) -> &'static str {
33 match self {
34 Corner::TopLeft => "top_left",
35 Corner::TopRight => "top_right",
36 Corner::BottomLeft => "bottom_left",
37 Corner::BottomRight => "bottom_right",
38 }
39 }
40
41 pub fn from_key(key: &str) -> Option<Corner> {
42 Corner::ALL.into_iter().find(|corner| corner.key() == key)
43 }
44
45 pub fn is_bottom(self) -> bool {
46 matches!(self, Corner::BottomLeft | Corner::BottomRight)
47 }
48
49 pub fn is_right(self) -> bool {
50 matches!(self, Corner::TopRight | Corner::BottomRight)
51 }
52
53 pub fn next(self) -> Corner {
54 let index = Corner::ALL
55 .iter()
56 .position(|corner| *corner == self)
57 .unwrap_or(0);
58 Corner::ALL[(index + 1) % Corner::ALL.len()]
59 }
60}
61
62#[derive(Debug, Clone, PartialEq, Eq)]
63pub struct Settings {
64 pub sound: bool,
65 pub mentions_only: bool,
66 pub preview: bool,
67 pub corner: Corner,
68 pub flash: bool,
69 pub close_to_tray: bool,
70 pub do_not_disturb: bool,
71}
72
73impl Default for Settings {
74 fn default() -> Self {
75 Settings {
76 sound: true,
77 mentions_only: false,
78 preview: true,
79 corner: Corner::BottomRight,
80 flash: true,
81 close_to_tray: true,
82 do_not_disturb: false,
83 }
84 }
85}
86
87#[derive(Debug, Clone, PartialEq, Eq)]
88pub enum ChatKind {
89 Direct,
90 Group { member_count: usize },
91 Channel { team: String, channel: String },
92}
93
94#[derive(Debug, Clone, PartialEq, Eq)]
95pub enum Preview {
96 Text(String),
97 Image,
98}
99
100#[derive(Debug, Clone, PartialEq, Eq)]
101pub struct Incoming {
102 pub conversation_id: String,
103 pub message_id: String,
104 pub kind: ChatKind,
105 pub chat_title: String,
106 pub sender_id: Option<String>,
107 pub sender_name: String,
108 pub preview: Preview,
109 pub mentions_me: bool,
110 pub muted: bool,
111}
112
113impl Incoming {
114 pub fn is_direct(&self) -> bool {
115 self.kind == ChatKind::Direct
116 }
117}
118
119#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
120pub struct Environment {
121 pub chat_in_foreground: bool,
122 pub system_quiet: bool,
123 pub own_do_not_disturb: bool,
124 pub in_call: bool,
125}
126
127#[derive(Debug, Clone, Copy, PartialEq, Eq)]
128pub struct Decision {
129 pub toast: bool,
130 pub sound: bool,
131}
132
133const SILENT: Decision = Decision {
134 toast: false,
135 sound: false,
136};
137
138pub fn decide(settings: &Settings, incoming: &Incoming, environment: Environment) -> Decision {
139 let suppressed = environment.chat_in_foreground
140 || environment.system_quiet
141 || environment.own_do_not_disturb
142 || settings.do_not_disturb
143 || (incoming.muted && !incoming.mentions_me)
144 || (settings.mentions_only && !incoming.mentions_me && !incoming.is_direct());
145 if suppressed {
146 return SILENT;
147 }
148 Decision {
149 toast: true,
150 sound: settings.sound && !environment.in_call,
151 }
152}
153
154#[derive(Default)]
155pub struct SoundThrottle {
156 last_played: HashMap<String, Instant>,
157}
158
159impl SoundThrottle {
160 pub fn allow(&mut self, conversation_id: &str, now: Instant) -> bool {
161 let allowed = self
162 .last_played
163 .get(conversation_id)
164 .is_none_or(|last| now.duration_since(*last) >= SOUND_THROTTLE);
165 if allowed {
166 self.last_played.insert(conversation_id.to_owned(), now);
167 }
168 allowed
169 }
170}
171
172pub fn should_flash(settings: &Settings, mentions_me: bool, window_active: bool) -> bool {
173 settings.flash && mentions_me && !window_active
174}
175
176#[cfg(test)]
177mod tests {
178 use super::*;
179
180 fn incoming(kind: ChatKind) -> Incoming {
181 Incoming {
182 conversation_id: "chat".into(),
183 message_id: "1".into(),
184 kind,
185 chat_title: "Chat".into(),
186 sender_id: Some("u1".into()),
187 sender_name: "Mara".into(),
188 preview: Preview::Text("Hallo".into()),
189 mentions_me: false,
190 muted: false,
191 }
192 }
193
194 fn group() -> Incoming {
195 incoming(ChatKind::Group { member_count: 5 })
196 }
197
198 #[test]
199 fn plain_message_gets_toast_and_sound() {
200 let decision = decide(&Settings::default(), &group(), Environment::default());
201 assert_eq!(
202 decision,
203 Decision {
204 toast: true,
205 sound: true
206 }
207 );
208 }
209
210 #[test]
211 fn foreground_chat_is_silent() {
212 let environment = Environment {
213 chat_in_foreground: true,
214 ..Default::default()
215 };
216 assert_eq!(decide(&Settings::default(), &group(), environment), SILENT);
217 }
218
219 #[test]
220 fn focus_assist_and_dnd_are_silent() {
221 for environment in [
222 Environment {
223 system_quiet: true,
224 ..Default::default()
225 },
226 Environment {
227 own_do_not_disturb: true,
228 ..Default::default()
229 },
230 ] {
231 assert_eq!(decide(&Settings::default(), &group(), environment), SILENT);
232 }
233 let settings = Settings {
234 do_not_disturb: true,
235 ..Default::default()
236 };
237 assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);
238 }
239
240 #[test]
241 fn call_keeps_toast_but_drops_sound() {
242 let environment = Environment {
243 in_call: true,
244 ..Default::default()
245 };
246 let decision = decide(&Settings::default(), &group(), environment);
247 assert_eq!(
248 decision,
249 Decision {
250 toast: true,
251 sound: false
252 }
253 );
254 }
255
256 #[test]
257 fn muted_chat_only_notifies_for_mentions() {
258 let mut muted = group();
259 muted.muted = true;
260 assert_eq!(
261 decide(&Settings::default(), &muted, Environment::default()),
262 SILENT
263 );
264 muted.mentions_me = true;
265 assert!(decide(&Settings::default(), &muted, Environment::default()).toast);
266 }
267
268 #[test]
269 fn mentions_only_keeps_direct_and_mentions() {
270 let settings = Settings {
271 mentions_only: true,
272 ..Default::default()
273 };
274 assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);
275 assert!(decide(&settings, &incoming(ChatKind::Direct), Environment::default()).toast);
276 let mut mention = group();
277 mention.mentions_me = true;
278 assert!(decide(&settings, &mention, Environment::default()).toast);
279 }
280
281 #[test]
282 fn sound_setting_off_keeps_toast() {
283 let settings = Settings {
284 sound: false,
285 ..Default::default()
286 };
287 let decision = decide(&settings, &group(), Environment::default());
288 assert_eq!(
289 decision,
290 Decision {
291 toast: true,
292 sound: false
293 }
294 );
295 }
296
297 #[test]
298 fn throttle_allows_once_per_window_per_chat() {
299 let mut throttle = SoundThrottle::default();
300 let start = Instant::now();
301 assert!(throttle.allow("a", start));
302 assert!(!throttle.allow("a", start + Duration::from_secs(9)));
303 assert!(throttle.allow("b", start + Duration::from_secs(9)));
304 assert!(throttle.allow("a", start + Duration::from_secs(10)));
305 }
306
307 #[test]
308 fn flash_needs_mention_inactive_window_and_setting() {
309 let settings = Settings::default();
310 assert!(should_flash(&settings, true, false));
311 assert!(!should_flash(&settings, true, true));
312 assert!(!should_flash(&settings, false, false));
313 let off = Settings {
314 flash: false,
315 ..Default::default()
316 };
317 assert!(!should_flash(&off, true, false));
318 }
319
320 #[test]
321 fn corner_keys_round_trip() {
322 for corner in Corner::ALL {
323 assert_eq!(Corner::from_key(corner.key()), Some(corner));
324 }
325 assert_eq!(Corner::BottomRight.next(), Corner::TopLeft);
326 }
327}
crates/app/src/notify/settings.rs added +92 −0
@@ -0,0 +1,92 @@
1 use store::Store;
2
3 use super::rules::{Corner, Settings};
4
5 const META_KEY: &str = "notifications.settings";
6
7 pub fn load(store: &Store) -> Settings {
8 store
9 .meta(META_KEY)
10 .ok()
11 .flatten()
12 .map(|text| parse(&text))
13 .unwrap_or_default()
14 }
15
16 pub fn save(store: &Store, settings: &Settings) {
17 let _ = store.set_meta(META_KEY, &serialize(settings));
18 }
19
20 fn serialize(settings: &Settings) -> String {
21 [
22 ("sound", settings.sound.to_string()),
23 ("mentions_only", settings.mentions_only.to_string()),
24 ("preview", settings.preview.to_string()),
25 ("corner", settings.corner.key().to_owned()),
26 ("flash", settings.flash.to_string()),
27 ("close_to_tray", settings.close_to_tray.to_string()),
28 ("do_not_disturb", settings.do_not_disturb.to_string()),
29 ]
30 .iter()
31 .map(|(key, value)| format!("{key}={value}"))
32 .collect::<Vec<_>>()
33 .join("\n")
34 }
35
36 fn parse(text: &str) -> Settings {
37 let mut settings = Settings::default();
38 for line in text.lines() {
39 let Some((key, value)) = line.split_once('=') else {
40 continue;
41 };
42 let flag = value == "true";
43 match key {
44 "sound" => settings.sound = flag,
45 "mentions_only" => settings.mentions_only = flag,
46 "preview" => settings.preview = flag,
47 "corner" => settings.corner = Corner::from_key(value).unwrap_or_default(),
48 "flash" => settings.flash = flag,
49 "close_to_tray" => settings.close_to_tray = flag,
50 "do_not_disturb" => settings.do_not_disturb = flag,
51 _ => {}
52 }
53 }
54 settings
55 }
56
57 #[cfg(test)]
58 mod tests {
59 use super::*;
60
61 #[test]
62 fn round_trips_every_field() {
63 let settings = Settings {
64 sound: false,
65 mentions_only: true,
66 preview: false,
67 corner: Corner::TopLeft,
68 flash: false,
69 close_to_tray: false,
70 do_not_disturb: true,
71 };
72 assert_eq!(parse(&serialize(&settings)), settings);
73 }
74
75 #[test]
76 fn empty_or_garbage_gives_defaults() {
77 assert_eq!(parse(""), Settings::default());
78 assert_eq!(parse("junk\ncorner=nowhere"), Settings::default());
79 }
80
81 #[test]
82 fn persists_in_store() {
83 let store = Store::open_in_memory().unwrap();
84 assert_eq!(load(&store), Settings::default());
85 let changed = Settings {
86 sound: false,
87 ..Default::default()
88 };
89 save(&store, &changed);
90 assert_eq!(load(&store), changed);
91 }
92 }
@@ -0,0 +1,92 @@
1use store::Store;
2
3use super::rules::{Corner, Settings};
4
5const META_KEY: &str = "notifications.settings";
6
7pub fn load(store: &Store) -> Settings {
8 store
9 .meta(META_KEY)
10 .ok()
11 .flatten()
12 .map(|text| parse(&text))
13 .unwrap_or_default()
14}
15
16pub fn save(store: &Store, settings: &Settings) {
17 let _ = store.set_meta(META_KEY, &serialize(settings));
18}
19
20fn serialize(settings: &Settings) -> String {
21 [
22 ("sound", settings.sound.to_string()),
23 ("mentions_only", settings.mentions_only.to_string()),
24 ("preview", settings.preview.to_string()),
25 ("corner", settings.corner.key().to_owned()),
26 ("flash", settings.flash.to_string()),
27 ("close_to_tray", settings.close_to_tray.to_string()),
28 ("do_not_disturb", settings.do_not_disturb.to_string()),
29 ]
30 .iter()
31 .map(|(key, value)| format!("{key}={value}"))
32 .collect::<Vec<_>>()
33 .join("\n")
34}
35
36fn parse(text: &str) -> Settings {
37 let mut settings = Settings::default();
38 for line in text.lines() {
39 let Some((key, value)) = line.split_once('=') else {
40 continue;
41 };
42 let flag = value == "true";
43 match key {
44 "sound" => settings.sound = flag,
45 "mentions_only" => settings.mentions_only = flag,
46 "preview" => settings.preview = flag,
47 "corner" => settings.corner = Corner::from_key(value).unwrap_or_default(),
48 "flash" => settings.flash = flag,
49 "close_to_tray" => settings.close_to_tray = flag,
50 "do_not_disturb" => settings.do_not_disturb = flag,
51 _ => {}
52 }
53 }
54 settings
55}
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn round_trips_every_field() {
63 let settings = Settings {
64 sound: false,
65 mentions_only: true,
66 preview: false,
67 corner: Corner::TopLeft,
68 flash: false,
69 close_to_tray: false,
70 do_not_disturb: true,
71 };
72 assert_eq!(parse(&serialize(&settings)), settings);
73 }
74
75 #[test]
76 fn empty_or_garbage_gives_defaults() {
77 assert_eq!(parse(""), Settings::default());
78 assert_eq!(parse("junk\ncorner=nowhere"), Settings::default());
79 }
80
81 #[test]
82 fn persists_in_store() {
83 let store = Store::open_in_memory().unwrap();
84 assert_eq!(load(&store), Settings::default());
85 let changed = Settings {
86 sound: false,
87 ..Default::default()
88 };
89 save(&store, &changed);
90 assert_eq!(load(&store), changed);
91 }
92}
crates/app/src/notify/settings_view.rs added +196 −0
@@ -0,0 +1,196 @@
1 use gpui_kit::component::{h_flex, v_flex};
2 use gpui_kit::*;
3
4 use super::center::NotificationCenter;
5 use super::rules::Settings;
6 use crate::theme;
7
8 type Accessor = fn(&mut Settings) -> &mut bool;
9
10 struct Row {
11 title: &'static str,
12 detail: &'static str,
13 field: Accessor,
14 }
15
16 const ROWS: [Row; 5] = [
17 Row {
18 title: "Ton",
19 detail: "Nachricht und Erwähnung",
20 field: |settings| &mut settings.sound,
21 },
22 Row {
23 title: "Nur Erwähnungen",
24 detail: "Direktnachrichten und @Erwähnungen",
25 field: |settings| &mut settings.mentions_only,
26 },
27 Row {
28 title: "Vorschau anzeigen",
29 detail: "Aus: nur \"Neue Nachricht\"",
30 field: |settings| &mut settings.preview,
31 },
32 Row {
33 title: "Taskleiste blinken",
34 detail: "Bei Erwähnung, wenn das Fenster nicht aktiv ist",
35 field: |settings| &mut settings.flash,
36 },
37 Row {
38 title: "Beim Schließen in den Tray",
39 detail: "Das X im Titel versteckt das Fenster",
40 field: |settings| &mut settings.close_to_tray,
41 },
42 ];
43
44 pub struct SettingsView {
45 center: Entity<NotificationCenter>,
46 _subscription: Subscription,
47 }
48
49 impl SettingsView {
50 pub const WIDTH: f32 = 420.;
51 pub const HEIGHT: f32 = 460.;
52
53 pub fn new(center: Entity<NotificationCenter>, cx: &mut Context<Self>) -> Self {
54 let subscription = cx.observe(&center, |_, _, cx| cx.notify());
55 SettingsView {
56 center,
57 _subscription: subscription,
58 }
59 }
60 }
61
62 fn switch(on: bool) -> Div {
63 div()
64 .w(px(36.))
65 .h(px(20.))
66 .flex_none()
67 .rounded_full()
68 .relative()
69 .bg(if on {
70 theme::accent()
71 } else {
72 theme::border_strong()
73 })
74 .child(
75 div()
76 .absolute()
77 .top(px(2.))
78 .left(px(if on { 18. } else { 2. }))
79 .size(px(16.))
80 .rounded_full()
81 .bg(theme::text()),
82 )
83 }
84
85 fn button(label: &'static str) -> Stateful<Div> {
86 div()
87 .id(label)
88 .h(px(32.))
89 .px(px(14.))
90 .flex()
91 .items_center()
92 .rounded(px(8.))
93 .border_1()
94 .border_color(theme::border_strong())
95 .cursor_pointer()
96 .text_size(px(13.))
97 .font_weight(FontWeight::SEMIBOLD)
98 .text_color(theme::text())
99 .hover(|button| button.bg(theme::row_hover()))
100 .child(label)
101 }
102
103 impl Render for SettingsView {
104 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
105 let mut current = self.center.read(cx).settings().clone();
106 let corner = current.corner;
107 let rows = ROWS.iter().enumerate().map(|(index, row)| {
108 let on = *(row.field)(&mut current);
109 let center = self.center.clone();
110 let field = row.field;
111 h_flex()
112 .id(("setting", index))
113 .w_full()
114 .px(px(20.))
115 .py(px(10.))
116 .gap(px(12.))
117 .items_center()
118 .cursor_pointer()
119 .hover(|row| row.bg(theme::row_hover()))
120 .on_click(move |_, _, cx| {
121 center.update(cx, |center, cx| {
122 center.update_settings(cx, |settings| {
123 let value = field(settings);
124 *value = !*value;
125 })
126 });
127 })
128 .child(
129 v_flex()
130 .flex_1()
131 .child(
132 div()
133 .text_size(px(14.))
134 .font_weight(FontWeight::SEMIBOLD)
135 .text_color(theme::text())
136 .child(row.title),
137 )
138 .child(
139 div()
140 .text_size(px(12.))
141 .text_color(theme::text_muted())
142 .child(row.detail),
143 ),
144 )
145 .child(switch(on))
146 });
147 let position_center = self.center.clone();
148 let test_center = self.center.clone();
149 v_flex()
150 .size_full()
151 .bg(theme::background())
152 .pt(px(12.))
153 .children(rows)
154 .child(
155 h_flex()
156 .w_full()
157 .px(px(20.))
158 .py(px(10.))
159 .gap(px(12.))
160 .items_center()
161 .child(
162 v_flex()
163 .flex_1()
164 .child(
165 div()
166 .text_size(px(14.))
167 .font_weight(FontWeight::SEMIBOLD)
168 .text_color(theme::text())
169 .child("Position"),
170 )
171 .child(
172 div()
173 .text_size(px(12.))
174 .text_color(theme::text_muted())
175 .child("Ecke auf dem Hauptbildschirm"),
176 ),
177 )
178 .child(button(corner.label()).on_click(move |_, _, cx| {
179 position_center.update(cx, |center, cx| {
180 center.update_settings(cx, |settings| {
181 settings.corner = settings.corner.next()
182 })
183 });
184 })),
185 )
186 .child(
187 h_flex()
188 .w_full()
189 .px(px(20.))
190 .pt(px(12.))
191 .child(button("Testbenachrichtigung").on_click(move |_, _, cx| {
192 test_center.update(cx, |center, cx| center.send_test_notification(cx));
193 })),
194 )
195 }
196 }
@@ -0,0 +1,196 @@
1use gpui_kit::component::{h_flex, v_flex};
2use gpui_kit::*;
3
4use super::center::NotificationCenter;
5use super::rules::Settings;
6use crate::theme;
7
8type Accessor = fn(&mut Settings) -> &mut bool;
9
10struct Row {
11 title: &'static str,
12 detail: &'static str,
13 field: Accessor,
14}
15
16const ROWS: [Row; 5] = [
17 Row {
18 title: "Ton",
19 detail: "Nachricht und Erwähnung",
20 field: |settings| &mut settings.sound,
21 },
22 Row {
23 title: "Nur Erwähnungen",
24 detail: "Direktnachrichten und @Erwähnungen",
25 field: |settings| &mut settings.mentions_only,
26 },
27 Row {
28 title: "Vorschau anzeigen",
29 detail: "Aus: nur \"Neue Nachricht\"",
30 field: |settings| &mut settings.preview,
31 },
32 Row {
33 title: "Taskleiste blinken",
34 detail: "Bei Erwähnung, wenn das Fenster nicht aktiv ist",
35 field: |settings| &mut settings.flash,
36 },
37 Row {
38 title: "Beim Schließen in den Tray",
39 detail: "Das X im Titel versteckt das Fenster",
40 field: |settings| &mut settings.close_to_tray,
41 },
42];
43
44pub struct SettingsView {
45 center: Entity<NotificationCenter>,
46 _subscription: Subscription,
47}
48
49impl SettingsView {
50 pub const WIDTH: f32 = 420.;
51 pub const HEIGHT: f32 = 460.;
52
53 pub fn new(center: Entity<NotificationCenter>, cx: &mut Context<Self>) -> Self {
54 let subscription = cx.observe(&center, |_, _, cx| cx.notify());
55 SettingsView {
56 center,
57 _subscription: subscription,
58 }
59 }
60}
61
62fn switch(on: bool) -> Div {
63 div()
64 .w(px(36.))
65 .h(px(20.))
66 .flex_none()
67 .rounded_full()
68 .relative()
69 .bg(if on {
70 theme::accent()
71 } else {
72 theme::border_strong()
73 })
74 .child(
75 div()
76 .absolute()
77 .top(px(2.))
78 .left(px(if on { 18. } else { 2. }))
79 .size(px(16.))
80 .rounded_full()
81 .bg(theme::text()),
82 )
83}
84
85fn button(label: &'static str) -> Stateful<Div> {
86 div()
87 .id(label)
88 .h(px(32.))
89 .px(px(14.))
90 .flex()
91 .items_center()
92 .rounded(px(8.))
93 .border_1()
94 .border_color(theme::border_strong())
95 .cursor_pointer()
96 .text_size(px(13.))
97 .font_weight(FontWeight::SEMIBOLD)
98 .text_color(theme::text())
99 .hover(|button| button.bg(theme::row_hover()))
100 .child(label)
101}
102
103impl Render for SettingsView {
104 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
105 let mut current = self.center.read(cx).settings().clone();
106 let corner = current.corner;
107 let rows = ROWS.iter().enumerate().map(|(index, row)| {
108 let on = *(row.field)(&mut current);
109 let center = self.center.clone();
110 let field = row.field;
111 h_flex()
112 .id(("setting", index))
113 .w_full()
114 .px(px(20.))
115 .py(px(10.))
116 .gap(px(12.))
117 .items_center()
118 .cursor_pointer()
119 .hover(|row| row.bg(theme::row_hover()))
120 .on_click(move |_, _, cx| {
121 center.update(cx, |center, cx| {
122 center.update_settings(cx, |settings| {
123 let value = field(settings);
124 *value = !*value;
125 })
126 });
127 })
128 .child(
129 v_flex()
130 .flex_1()
131 .child(
132 div()
133 .text_size(px(14.))
134 .font_weight(FontWeight::SEMIBOLD)
135 .text_color(theme::text())
136 .child(row.title),
137 )
138 .child(
139 div()
140 .text_size(px(12.))
141 .text_color(theme::text_muted())
142 .child(row.detail),
143 ),
144 )
145 .child(switch(on))
146 });
147 let position_center = self.center.clone();
148 let test_center = self.center.clone();
149 v_flex()
150 .size_full()
151 .bg(theme::background())
152 .pt(px(12.))
153 .children(rows)
154 .child(
155 h_flex()
156 .w_full()
157 .px(px(20.))
158 .py(px(10.))
159 .gap(px(12.))
160 .items_center()
161 .child(
162 v_flex()
163 .flex_1()
164 .child(
165 div()
166 .text_size(px(14.))
167 .font_weight(FontWeight::SEMIBOLD)
168 .text_color(theme::text())
169 .child("Position"),
170 )
171 .child(
172 div()
173 .text_size(px(12.))
174 .text_color(theme::text_muted())
175 .child("Ecke auf dem Hauptbildschirm"),
176 ),
177 )
178 .child(button(corner.label()).on_click(move |_, _, cx| {
179 position_center.update(cx, |center, cx| {
180 center.update_settings(cx, |settings| {
181 settings.corner = settings.corner.next()
182 })
183 });
184 })),
185 )
186 .child(
187 h_flex()
188 .w_full()
189 .px(px(20.))
190 .pt(px(12.))
191 .child(button("Testbenachrichtigung").on_click(move |_, _, cx| {
192 test_center.update(cx, |center, cx| center.send_test_notification(cx));
193 })),
194 )
195 }
196}
crates/app/src/notify/stack.rs added +362 −0
@@ -0,0 +1,362 @@
1 use std::time::{Duration, Instant};
2
3 use super::rules::{ChatKind, Incoming, Preview};
4
5 pub const MAX_VISIBLE: usize = 3;
6 pub const MESSAGE_DURATION: Duration = Duration::from_secs(6);
7 pub const MENTION_DURATION: Duration = Duration::from_secs(10);
8 pub const MAX_TOTAL: Duration = Duration::from_secs(20);
9 pub const RESUME_REMAINING: Duration = Duration::from_secs(2);
10 pub const SENT_DURATION: Duration = Duration::from_millis(1500);
11
12 #[derive(Debug, Clone, Copy)]
13 pub struct ToastTimer {
14 first_shown: Instant,
15 started: Instant,
16 duration: Duration,
17 paused: Option<Instant>,
18 paused_total: Duration,
19 }
20
21 impl ToastTimer {
22 pub fn new(now: Instant, mention: bool) -> Self {
23 ToastTimer {
24 first_shown: now,
25 started: now,
26 duration: base_duration(mention),
27 paused: None,
28 paused_total: Duration::ZERO,
29 }
30 }
31
32 pub fn restart(&mut self, now: Instant, mention: bool) {
33 self.started = now;
34 self.duration = base_duration(mention);
35 if self.paused.is_some() {
36 self.paused = Some(now);
37 }
38 }
39
40 pub fn pause(&mut self, now: Instant) {
41 self.paused.get_or_insert(now);
42 }
43
44 pub fn resume(&mut self, now: Instant) {
45 if let Some(paused_at) = self.paused.take() {
46 self.paused_total += now.saturating_duration_since(paused_at);
47 self.started = now;
48 self.duration = RESUME_REMAINING;
49 }
50 }
51
52 pub fn is_paused(&self) -> bool {
53 self.paused.is_some()
54 }
55
56 fn elapsed(&self, now: Instant) -> Duration {
57 self.paused
58 .unwrap_or(now)
59 .saturating_duration_since(self.started)
60 }
61
62 pub fn fraction_left(&self, now: Instant) -> f32 {
63 let left = self.duration.saturating_sub(self.elapsed(now));
64 (left.as_secs_f32() / self.duration.as_secs_f32()).clamp(0., 1.)
65 }
66
67 pub fn expired(&self, now: Instant) -> bool {
68 if self.paused.is_some() {
69 return false;
70 }
71 self.elapsed(now) >= self.duration
72 || now
73 .saturating_duration_since(self.first_shown)
74 .saturating_sub(self.paused_total)
75 >= MAX_TOTAL
76 }
77 }
78
79 fn base_duration(mention: bool) -> Duration {
80 if mention {
81 MENTION_DURATION
82 } else {
83 MESSAGE_DURATION
84 }
85 }
86
87 #[derive(Debug, Clone, PartialEq, Eq)]
88 pub enum ReplyState {
89 Closed,
90 Open,
91 Sent,
92 Failed,
93 }
94
95 #[derive(Debug, Clone)]
96 pub struct ToastModel {
97 pub id: u64,
98 pub conversation_id: String,
99 pub message_id: String,
100 pub kind: ChatKind,
101 pub chat_title: String,
102 pub sender_id: Option<String>,
103 pub sender_name: String,
104 pub preview: Preview,
105 pub mentions_me: bool,
106 pub count: u32,
107 pub timer: ToastTimer,
108 pub reply: ReplyState,
109 pub reply_text: String,
110 pub hovered: bool,
111 pub time: String,
112 }
113
114 impl ToastModel {
115 pub fn holds_open(&self) -> bool {
116 self.reply != ReplyState::Closed
117 }
118 }
119
120 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
121 pub struct PushOutcome {
122 pub id: u64,
123 pub bundled: bool,
124 pub became_mention: bool,
125 }
126
127 impl PushOutcome {
128 pub fn plays_sound(self, throttle_allows: bool) -> bool {
129 self.became_mention || (!self.bundled && throttle_allows)
130 }
131 }
132
133 #[derive(Default)]
134 pub struct ToastStack {
135 toasts: Vec<ToastModel>,
136 next_id: u64,
137 }
138
139 impl ToastStack {
140 pub fn push(&mut self, incoming: &Incoming, now: Instant) -> PushOutcome {
141 if let Some(existing) = self
142 .toasts
143 .iter_mut()
144 .find(|toast| toast.conversation_id == incoming.conversation_id)
145 {
146 let became_mention = incoming.mentions_me && !existing.mentions_me;
147 existing.count += 1;
148 existing.mentions_me |= incoming.mentions_me;
149 existing.message_id = incoming.message_id.clone();
150 existing.sender_id = incoming.sender_id.clone();
151 existing.sender_name = incoming.sender_name.clone();
152 existing.preview = incoming.preview.clone();
153 let mention = existing.mentions_me;
154 existing.timer.restart(now, mention);
155 return PushOutcome {
156 id: existing.id,
157 bundled: true,
158 became_mention,
159 };
160 }
161 self.next_id += 1;
162 self.toasts.push(ToastModel {
163 id: self.next_id,
164 conversation_id: incoming.conversation_id.clone(),
165 message_id: incoming.message_id.clone(),
166 kind: incoming.kind.clone(),
167 chat_title: incoming.chat_title.clone(),
168 sender_id: incoming.sender_id.clone(),
169 sender_name: incoming.sender_name.clone(),
170 preview: incoming.preview.clone(),
171 mentions_me: incoming.mentions_me,
172 count: 1,
173 timer: ToastTimer::new(now, incoming.mentions_me),
174 reply: ReplyState::Closed,
175 reply_text: String::new(),
176 hovered: false,
177 time: String::new(),
178 });
179 PushOutcome {
180 id: self.next_id,
181 bundled: false,
182 became_mention: false,
183 }
184 }
185
186 pub fn get(&self, id: u64) -> Option<&ToastModel> {
187 self.toasts.iter().find(|toast| toast.id == id)
188 }
189
190 pub fn get_mut(&mut self, id: u64) -> Option<&mut ToastModel> {
191 self.toasts.iter_mut().find(|toast| toast.id == id)
192 }
193
194 pub fn remove(&mut self, id: u64) -> Option<ToastModel> {
195 let index = self.toasts.iter().position(|toast| toast.id == id)?;
196 Some(self.toasts.remove(index))
197 }
198
199 pub fn remove_conversation(&mut self, conversation_id: &str) -> Vec<u64> {
200 let ids: Vec<u64> = self
201 .toasts
202 .iter()
203 .filter(|toast| toast.conversation_id == conversation_id)
204 .map(|toast| toast.id)
205 .collect();
206 self.toasts
207 .retain(|toast| toast.conversation_id != conversation_id);
208 ids
209 }
210
211 pub fn visible(&self) -> &[ToastModel] {
212 let start = self.toasts.len().saturating_sub(MAX_VISIBLE);
213 &self.toasts[start..]
214 }
215
216 pub fn hidden_count(&self) -> usize {
217 self.toasts.len().saturating_sub(MAX_VISIBLE)
218 }
219
220 pub fn is_empty(&self) -> bool {
221 self.toasts.is_empty()
222 }
223
224 pub fn expired(&self, now: Instant) -> Vec<u64> {
225 self.toasts
226 .iter()
227 .filter(|toast| !toast.holds_open() && toast.timer.expired(now))
228 .map(|toast| toast.id)
229 .collect()
230 }
231 }
232
233 #[cfg(test)]
234 mod tests {
235 use super::*;
236
237 fn incoming(conversation: &str, mention: bool) -> Incoming {
238 Incoming {
239 conversation_id: conversation.into(),
240 message_id: "m".into(),
241 kind: ChatKind::Direct,
242 chat_title: "Chat".into(),
243 sender_id: None,
244 sender_name: "Mara".into(),
245 preview: Preview::Text("Hallo".into()),
246 mentions_me: mention,
247 muted: false,
248 }
249 }
250
251 #[test]
252 fn same_chat_bundles_into_one_toast_with_counter() {
253 let mut stack = ToastStack::default();
254 let now = Instant::now();
255 let first = stack.push(&incoming("a", false), now);
256 let second = stack.push(&incoming("a", false), now + Duration::from_secs(2));
257 assert!(!first.bundled);
258 assert!(second.bundled);
259 assert_eq!(first.id, second.id);
260 assert_eq!(stack.get(first.id).unwrap().count, 2);
261 assert_eq!(stack.visible().len(), 1);
262 }
263
264 #[test]
265 fn bundling_restarts_timer() {
266 let mut stack = ToastStack::default();
267 let now = Instant::now();
268 let id = stack.push(&incoming("a", false), now).id;
269 stack.push(&incoming("a", false), now + Duration::from_secs(5));
270 assert!(stack.expired(now + Duration::from_secs(7)).is_empty());
271 assert_eq!(stack.expired(now + Duration::from_secs(11)), vec![id]);
272 }
273
274 #[test]
275 fn mention_in_burst_upgrades_and_plays_sound() {
276 let mut stack = ToastStack::default();
277 let now = Instant::now();
278 stack.push(&incoming("a", false), now);
279 let outcome = stack.push(&incoming("a", true), now);
280 assert!(outcome.became_mention);
281 assert!(outcome.plays_sound(false));
282 assert!(stack.get(outcome.id).unwrap().mentions_me);
283 let again = stack.push(&incoming("a", true), now);
284 assert!(!again.plays_sound(true));
285 }
286
287 #[test]
288 fn only_first_of_burst_plays_sound() {
289 let mut stack = ToastStack::default();
290 let now = Instant::now();
291 assert!(stack.push(&incoming("a", false), now).plays_sound(true));
292 assert!(!stack.push(&incoming("a", false), now).plays_sound(true));
293 assert!(!stack.push(&incoming("b", false), now).plays_sound(false));
294 }
295
296 #[test]
297 fn shows_three_newest_and_counts_the_rest() {
298 let mut stack = ToastStack::default();
299 let now = Instant::now();
300 for chat in ["a", "b", "c", "d", "e"] {
301 stack.push(&incoming(chat, false), now);
302 }
303 let visible: Vec<&str> = stack
304 .visible()
305 .iter()
306 .map(|toast| toast.conversation_id.as_str())
307 .collect();
308 assert_eq!(visible, ["c", "d", "e"]);
309 assert_eq!(stack.hidden_count(), 2);
310 }
311
312 #[test]
313 fn mention_lasts_ten_seconds() {
314 let now = Instant::now();
315 let timer = ToastTimer::new(now, true);
316 assert!(!timer.expired(now + Duration::from_secs(9)));
317 assert!(timer.expired(now + Duration::from_secs(10)));
318 }
319
320 #[test]
321 fn hard_cap_beats_restarts() {
322 let mut stack = ToastStack::default();
323 let start = Instant::now();
324 let id = stack.push(&incoming("a", false), start).id;
325 for second in [5, 10, 15, 19] {
326 stack.push(&incoming("a", false), start + Duration::from_secs(second));
327 }
328 assert!(stack.expired(start + Duration::from_secs(19)).is_empty());
329 assert_eq!(stack.expired(start + Duration::from_secs(20)), vec![id]);
330 }
331
332 #[test]
333 fn pause_stops_expiry_and_resume_leaves_two_seconds() {
334 let now = Instant::now();
335 let mut timer = ToastTimer::new(now, false);
336 timer.pause(now + Duration::from_secs(1));
337 assert!(!timer.expired(now + Duration::from_secs(60)));
338 let resumed = now + Duration::from_secs(60);
339 timer.resume(resumed);
340 assert!(!timer.expired(resumed + Duration::from_millis(1900)));
341 assert!(timer.expired(resumed + Duration::from_secs(2)));
342 }
343
344 #[test]
345 fn open_reply_field_holds_toast() {
346 let mut stack = ToastStack::default();
347 let now = Instant::now();
348 let id = stack.push(&incoming("a", false), now).id;
349 stack.get_mut(id).unwrap().reply = ReplyState::Open;
350 assert!(stack.expired(now + Duration::from_secs(60)).is_empty());
351 }
352
353 #[test]
354 fn remove_conversation_returns_ids() {
355 let mut stack = ToastStack::default();
356 let now = Instant::now();
357 let id = stack.push(&incoming("a", false), now).id;
358 stack.push(&incoming("b", false), now);
359 assert_eq!(stack.remove_conversation("a"), vec![id]);
360 assert_eq!(stack.visible().len(), 1);
361 }
362 }
@@ -0,0 +1,362 @@
1use std::time::{Duration, Instant};
2
3use super::rules::{ChatKind, Incoming, Preview};
4
5pub const MAX_VISIBLE: usize = 3;
6pub const MESSAGE_DURATION: Duration = Duration::from_secs(6);
7pub const MENTION_DURATION: Duration = Duration::from_secs(10);
8pub const MAX_TOTAL: Duration = Duration::from_secs(20);
9pub const RESUME_REMAINING: Duration = Duration::from_secs(2);
10pub const SENT_DURATION: Duration = Duration::from_millis(1500);
11
12#[derive(Debug, Clone, Copy)]
13pub struct ToastTimer {
14 first_shown: Instant,
15 started: Instant,
16 duration: Duration,
17 paused: Option<Instant>,
18 paused_total: Duration,
19}
20
21impl ToastTimer {
22 pub fn new(now: Instant, mention: bool) -> Self {
23 ToastTimer {
24 first_shown: now,
25 started: now,
26 duration: base_duration(mention),
27 paused: None,
28 paused_total: Duration::ZERO,
29 }
30 }
31
32 pub fn restart(&mut self, now: Instant, mention: bool) {
33 self.started = now;
34 self.duration = base_duration(mention);
35 if self.paused.is_some() {
36 self.paused = Some(now);
37 }
38 }
39
40 pub fn pause(&mut self, now: Instant) {
41 self.paused.get_or_insert(now);
42 }
43
44 pub fn resume(&mut self, now: Instant) {
45 if let Some(paused_at) = self.paused.take() {
46 self.paused_total += now.saturating_duration_since(paused_at);
47 self.started = now;
48 self.duration = RESUME_REMAINING;
49 }
50 }
51
52 pub fn is_paused(&self) -> bool {
53 self.paused.is_some()
54 }
55
56 fn elapsed(&self, now: Instant) -> Duration {
57 self.paused
58 .unwrap_or(now)
59 .saturating_duration_since(self.started)
60 }
61
62 pub fn fraction_left(&self, now: Instant) -> f32 {
63 let left = self.duration.saturating_sub(self.elapsed(now));
64 (left.as_secs_f32() / self.duration.as_secs_f32()).clamp(0., 1.)
65 }
66
67 pub fn expired(&self, now: Instant) -> bool {
68 if self.paused.is_some() {
69 return false;
70 }
71 self.elapsed(now) >= self.duration
72 || now
73 .saturating_duration_since(self.first_shown)
74 .saturating_sub(self.paused_total)
75 >= MAX_TOTAL
76 }
77}
78
79fn base_duration(mention: bool) -> Duration {
80 if mention {
81 MENTION_DURATION
82 } else {
83 MESSAGE_DURATION
84 }
85}
86
87#[derive(Debug, Clone, PartialEq, Eq)]
88pub enum ReplyState {
89 Closed,
90 Open,
91 Sent,
92 Failed,
93}
94
95#[derive(Debug, Clone)]
96pub struct ToastModel {
97 pub id: u64,
98 pub conversation_id: String,
99 pub message_id: String,
100 pub kind: ChatKind,
101 pub chat_title: String,
102 pub sender_id: Option<String>,
103 pub sender_name: String,
104 pub preview: Preview,
105 pub mentions_me: bool,
106 pub count: u32,
107 pub timer: ToastTimer,
108 pub reply: ReplyState,
109 pub reply_text: String,
110 pub hovered: bool,
111 pub time: String,
112}
113
114impl ToastModel {
115 pub fn holds_open(&self) -> bool {
116 self.reply != ReplyState::Closed
117 }
118}
119
120#[derive(Debug, Clone, Copy, PartialEq, Eq)]
121pub struct PushOutcome {
122 pub id: u64,
123 pub bundled: bool,
124 pub became_mention: bool,
125}
126
127impl PushOutcome {
128 pub fn plays_sound(self, throttle_allows: bool) -> bool {
129 self.became_mention || (!self.bundled && throttle_allows)
130 }
131}
132
133#[derive(Default)]
134pub struct ToastStack {
135 toasts: Vec<ToastModel>,
136 next_id: u64,
137}
138
139impl ToastStack {
140 pub fn push(&mut self, incoming: &Incoming, now: Instant) -> PushOutcome {
141 if let Some(existing) = self
142 .toasts
143 .iter_mut()
144 .find(|toast| toast.conversation_id == incoming.conversation_id)
145 {
146 let became_mention = incoming.mentions_me && !existing.mentions_me;
147 existing.count += 1;
148 existing.mentions_me |= incoming.mentions_me;
149 existing.message_id = incoming.message_id.clone();
150 existing.sender_id = incoming.sender_id.clone();
151 existing.sender_name = incoming.sender_name.clone();
152 existing.preview = incoming.preview.clone();
153 let mention = existing.mentions_me;
154 existing.timer.restart(now, mention);
155 return PushOutcome {
156 id: existing.id,
157 bundled: true,
158 became_mention,
159 };
160 }
161 self.next_id += 1;
162 self.toasts.push(ToastModel {
163 id: self.next_id,
164 conversation_id: incoming.conversation_id.clone(),
165 message_id: incoming.message_id.clone(),
166 kind: incoming.kind.clone(),
167 chat_title: incoming.chat_title.clone(),
168 sender_id: incoming.sender_id.clone(),
169 sender_name: incoming.sender_name.clone(),
170 preview: incoming.preview.clone(),
171 mentions_me: incoming.mentions_me,
172 count: 1,
173 timer: ToastTimer::new(now, incoming.mentions_me),
174 reply: ReplyState::Closed,
175 reply_text: String::new(),
176 hovered: false,
177 time: String::new(),
178 });
179 PushOutcome {
180 id: self.next_id,
181 bundled: false,
182 became_mention: false,
183 }
184 }
185
186 pub fn get(&self, id: u64) -> Option<&ToastModel> {
187 self.toasts.iter().find(|toast| toast.id == id)
188 }
189
190 pub fn get_mut(&mut self, id: u64) -> Option<&mut ToastModel> {
191 self.toasts.iter_mut().find(|toast| toast.id == id)
192 }
193
194 pub fn remove(&mut self, id: u64) -> Option<ToastModel> {
195 let index = self.toasts.iter().position(|toast| toast.id == id)?;
196 Some(self.toasts.remove(index))
197 }
198
199 pub fn remove_conversation(&mut self, conversation_id: &str) -> Vec<u64> {
200 let ids: Vec<u64> = self
201 .toasts
202 .iter()
203 .filter(|toast| toast.conversation_id == conversation_id)
204 .map(|toast| toast.id)
205 .collect();
206 self.toasts
207 .retain(|toast| toast.conversation_id != conversation_id);
208 ids
209 }
210
211 pub fn visible(&self) -> &[ToastModel] {
212 let start = self.toasts.len().saturating_sub(MAX_VISIBLE);
213 &self.toasts[start..]
214 }
215
216 pub fn hidden_count(&self) -> usize {
217 self.toasts.len().saturating_sub(MAX_VISIBLE)
218 }
219
220 pub fn is_empty(&self) -> bool {
221 self.toasts.is_empty()
222 }
223
224 pub fn expired(&self, now: Instant) -> Vec<u64> {
225 self.toasts
226 .iter()
227 .filter(|toast| !toast.holds_open() && toast.timer.expired(now))
228 .map(|toast| toast.id)
229 .collect()
230 }
231}
232
233#[cfg(test)]
234mod tests {
235 use super::*;
236
237 fn incoming(conversation: &str, mention: bool) -> Incoming {
238 Incoming {
239 conversation_id: conversation.into(),
240 message_id: "m".into(),
241 kind: ChatKind::Direct,
242 chat_title: "Chat".into(),
243 sender_id: None,
244 sender_name: "Mara".into(),
245 preview: Preview::Text("Hallo".into()),
246 mentions_me: mention,
247 muted: false,
248 }
249 }
250
251 #[test]
252 fn same_chat_bundles_into_one_toast_with_counter() {
253 let mut stack = ToastStack::default();
254 let now = Instant::now();
255 let first = stack.push(&incoming("a", false), now);
256 let second = stack.push(&incoming("a", false), now + Duration::from_secs(2));
257 assert!(!first.bundled);
258 assert!(second.bundled);
259 assert_eq!(first.id, second.id);
260 assert_eq!(stack.get(first.id).unwrap().count, 2);
261 assert_eq!(stack.visible().len(), 1);
262 }
263
264 #[test]
265 fn bundling_restarts_timer() {
266 let mut stack = ToastStack::default();
267 let now = Instant::now();
268 let id = stack.push(&incoming("a", false), now).id;
269 stack.push(&incoming("a", false), now + Duration::from_secs(5));
270 assert!(stack.expired(now + Duration::from_secs(7)).is_empty());
271 assert_eq!(stack.expired(now + Duration::from_secs(11)), vec![id]);
272 }
273
274 #[test]
275 fn mention_in_burst_upgrades_and_plays_sound() {
276 let mut stack = ToastStack::default();
277 let now = Instant::now();
278 stack.push(&incoming("a", false), now);
279 let outcome = stack.push(&incoming("a", true), now);
280 assert!(outcome.became_mention);
281 assert!(outcome.plays_sound(false));
282 assert!(stack.get(outcome.id).unwrap().mentions_me);
283 let again = stack.push(&incoming("a", true), now);
284 assert!(!again.plays_sound(true));
285 }
286
287 #[test]
288 fn only_first_of_burst_plays_sound() {
289 let mut stack = ToastStack::default();
290 let now = Instant::now();
291 assert!(stack.push(&incoming("a", false), now).plays_sound(true));
292 assert!(!stack.push(&incoming("a", false), now).plays_sound(true));
293 assert!(!stack.push(&incoming("b", false), now).plays_sound(false));
294 }
295
296 #[test]
297 fn shows_three_newest_and_counts_the_rest() {
298 let mut stack = ToastStack::default();
299 let now = Instant::now();
300 for chat in ["a", "b", "c", "d", "e"] {
301 stack.push(&incoming(chat, false), now);
302 }
303 let visible: Vec<&str> = stack
304 .visible()
305 .iter()
306 .map(|toast| toast.conversation_id.as_str())
307 .collect();
308 assert_eq!(visible, ["c", "d", "e"]);
309 assert_eq!(stack.hidden_count(), 2);
310 }
311
312 #[test]
313 fn mention_lasts_ten_seconds() {
314 let now = Instant::now();
315 let timer = ToastTimer::new(now, true);
316 assert!(!timer.expired(now + Duration::from_secs(9)));
317 assert!(timer.expired(now + Duration::from_secs(10)));
318 }
319
320 #[test]
321 fn hard_cap_beats_restarts() {
322 let mut stack = ToastStack::default();
323 let start = Instant::now();
324 let id = stack.push(&incoming("a", false), start).id;
325 for second in [5, 10, 15, 19] {
326 stack.push(&incoming("a", false), start + Duration::from_secs(second));
327 }
328 assert!(stack.expired(start + Duration::from_secs(19)).is_empty());
329 assert_eq!(stack.expired(start + Duration::from_secs(20)), vec![id]);
330 }
331
332 #[test]
333 fn pause_stops_expiry_and_resume_leaves_two_seconds() {
334 let now = Instant::now();
335 let mut timer = ToastTimer::new(now, false);
336 timer.pause(now + Duration::from_secs(1));
337 assert!(!timer.expired(now + Duration::from_secs(60)));
338 let resumed = now + Duration::from_secs(60);
339 timer.resume(resumed);
340 assert!(!timer.expired(resumed + Duration::from_millis(1900)));
341 assert!(timer.expired(resumed + Duration::from_secs(2)));
342 }
343
344 #[test]
345 fn open_reply_field_holds_toast() {
346 let mut stack = ToastStack::default();
347 let now = Instant::now();
348 let id = stack.push(&incoming("a", false), now).id;
349 stack.get_mut(id).unwrap().reply = ReplyState::Open;
350 assert!(stack.expired(now + Duration::from_secs(60)).is_empty());
351 }
352
353 #[test]
354 fn remove_conversation_returns_ids() {
355 let mut stack = ToastStack::default();
356 let now = Instant::now();
357 let id = stack.push(&incoming("a", false), now).id;
358 stack.push(&incoming("b", false), now);
359 assert_eq!(stack.remove_conversation("a"), vec![id]);
360 assert_eq!(stack.visible().len(), 1);
361 }
362}
crates/app/src/notify/text.rs added +152 −0
@@ -0,0 +1,152 @@
1 use super::rules::{ChatKind, Preview};
2 use super::stack::ToastModel;
3 use crate::format;
4
5 const PREVIEW_OFF: &str = "Neue Nachricht";
6 const IMAGE_LABEL: &str = "Bild";
7 const UNKNOWN_SENDER: &str = "Unbekannt";
8
9 #[derive(Debug, Clone, PartialEq, Eq)]
10 pub struct ToastText {
11 pub title: String,
12 pub subtitle: String,
13 pub preview: String,
14 pub image_only: bool,
15 }
16
17 impl ToastText {
18 pub fn narration(&self) -> String {
19 format!("{}, {}, {}", self.title, self.subtitle, self.preview)
20 }
21 }
22
23 pub fn describe(model: &ToastModel, preview_on: bool) -> ToastText {
24 let sender = if model.sender_name.trim().is_empty() {
25 UNKNOWN_SENDER
26 } else {
27 model.sender_name.as_str()
28 };
29 let (title, subtitle) = match &model.kind {
30 ChatKind::Direct => (sender.to_owned(), "Direkt".to_owned()),
31 ChatKind::Group { member_count } => (
32 model.chat_title.clone(),
33 format!("Gruppe, {member_count} Personen"),
34 ),
35 ChatKind::Channel { team, channel } => (sender.to_owned(), format!("{team} > {channel}")),
36 };
37 let body = match (&model.preview, preview_on) {
38 (_, false) => PREVIEW_OFF.to_owned(),
39 (Preview::Text(text), true) => text.clone(),
40 (Preview::Image, true) => IMAGE_LABEL.to_owned(),
41 };
42 let prefixed = preview_on && model.kind != ChatKind::Direct;
43 let preview = if prefixed {
44 format!("{}: {body}", format::first_name(sender))
45 } else {
46 body
47 };
48 ToastText {
49 title,
50 subtitle,
51 preview,
52 image_only: preview_on && model.preview == Preview::Image,
53 }
54 }
55
56 /// Byte range of the first word after each `@`, for highlighting mentions.
57 pub fn mention_ranges(text: &str) -> Vec<std::ops::Range<usize>> {
58 let mut ranges = Vec::new();
59 let mut search_from = 0;
60 while let Some(offset) = text[search_from..].find('@') {
61 let start = search_from + offset;
62 let end = text[start + 1..]
63 .char_indices()
64 .find(|(_, character)| !character.is_alphanumeric())
65 .map_or(text.len(), |(index, _)| start + 1 + index);
66 if end > start + 1 {
67 ranges.push(start..end);
68 }
69 search_from = end.max(start + 1);
70 }
71 ranges
72 }
73
74 #[cfg(test)]
75 mod tests {
76 use std::time::Instant;
77
78 use super::*;
79 use crate::notify::stack::{ReplyState, ToastTimer};
80
81 fn model(kind: ChatKind, preview: Preview) -> ToastModel {
82 ToastModel {
83 id: 1,
84 conversation_id: "c".into(),
85 message_id: "m".into(),
86 kind,
87 chat_title: "Retro-Team".into(),
88 sender_id: None,
89 sender_name: "Priya Nair".into(),
90 preview,
91 mentions_me: false,
92 count: 1,
93 timer: ToastTimer::new(Instant::now(), false),
94 reply: ReplyState::Closed,
95 reply_text: String::new(),
96 hovered: false,
97 time: "14:30".into(),
98 }
99 }
100
101 #[test]
102 fn direct_shows_sender_and_plain_preview() {
103 let text = describe(&model(ChatKind::Direct, Preview::Text("Hallo".into())), true);
104 assert_eq!(text.title, "Priya Nair");
105 assert_eq!(text.subtitle, "Direkt");
106 assert_eq!(text.preview, "Hallo");
107 }
108
109 #[test]
110 fn group_shows_chat_title_and_prefixes_sender() {
111 let text = describe(
112 &model(ChatKind::Group { member_count: 5 }, Preview::Text("Hi".into())),
113 true,
114 );
115 assert_eq!(text.title, "Retro-Team");
116 assert_eq!(text.subtitle, "Gruppe, 5 Personen");
117 assert_eq!(text.preview, "Priya: Hi");
118 }
119
120 #[test]
121 fn channel_shows_path_and_prefixes_sender() {
122 let kind = ChatKind::Channel {
123 team: "Plattform".into(),
124 channel: "Releases".into(),
125 };
126 let text = describe(&model(kind, Preview::Text("Go".into())), true);
127 assert_eq!(text.title, "Priya Nair");
128 assert_eq!(text.subtitle, "Plattform > Releases");
129 assert_eq!(text.preview, "Priya: Go");
130 }
131
132 #[test]
133 fn preview_off_hides_content_but_keeps_name() {
134 let text = describe(&model(ChatKind::Direct, Preview::Text("geheim".into())), false);
135 assert_eq!(text.preview, "Neue Nachricht");
136 assert!(!text.narration().contains("geheim"));
137 }
138
139 #[test]
140 fn image_only_is_flagged() {
141 let text = describe(&model(ChatKind::Direct, Preview::Image), true);
142 assert_eq!(text.preview, "Bild");
143 assert!(text.image_only);
144 }
145
146 #[test]
147 fn mention_ranges_cover_first_word_after_at() {
148 let text = "Ping @Daniel kannst du @Mara fragen @";
149 let found: Vec<&str> = mention_ranges(text).into_iter().map(|range| &text[range]).collect();
150 assert_eq!(found, ["@Daniel", "@Mara"]);
151 }
152 }
@@ -0,0 +1,152 @@
1use super::rules::{ChatKind, Preview};
2use super::stack::ToastModel;
3use crate::format;
4
5const PREVIEW_OFF: &str = "Neue Nachricht";
6const IMAGE_LABEL: &str = "Bild";
7const UNKNOWN_SENDER: &str = "Unbekannt";
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct ToastText {
11 pub title: String,
12 pub subtitle: String,
13 pub preview: String,
14 pub image_only: bool,
15}
16
17impl ToastText {
18 pub fn narration(&self) -> String {
19 format!("{}, {}, {}", self.title, self.subtitle, self.preview)
20 }
21}
22
23pub fn describe(model: &ToastModel, preview_on: bool) -> ToastText {
24 let sender = if model.sender_name.trim().is_empty() {
25 UNKNOWN_SENDER
26 } else {
27 model.sender_name.as_str()
28 };
29 let (title, subtitle) = match &model.kind {
30 ChatKind::Direct => (sender.to_owned(), "Direkt".to_owned()),
31 ChatKind::Group { member_count } => (
32 model.chat_title.clone(),
33 format!("Gruppe, {member_count} Personen"),
34 ),
35 ChatKind::Channel { team, channel } => (sender.to_owned(), format!("{team} > {channel}")),
36 };
37 let body = match (&model.preview, preview_on) {
38 (_, false) => PREVIEW_OFF.to_owned(),
39 (Preview::Text(text), true) => text.clone(),
40 (Preview::Image, true) => IMAGE_LABEL.to_owned(),
41 };
42 let prefixed = preview_on && model.kind != ChatKind::Direct;
43 let preview = if prefixed {
44 format!("{}: {body}", format::first_name(sender))
45 } else {
46 body
47 };
48 ToastText {
49 title,
50 subtitle,
51 preview,
52 image_only: preview_on && model.preview == Preview::Image,
53 }
54}
55
56/// Byte range of the first word after each `@`, for highlighting mentions.
57pub fn mention_ranges(text: &str) -> Vec<std::ops::Range<usize>> {
58 let mut ranges = Vec::new();
59 let mut search_from = 0;
60 while let Some(offset) = text[search_from..].find('@') {
61 let start = search_from + offset;
62 let end = text[start + 1..]
63 .char_indices()
64 .find(|(_, character)| !character.is_alphanumeric())
65 .map_or(text.len(), |(index, _)| start + 1 + index);
66 if end > start + 1 {
67 ranges.push(start..end);
68 }
69 search_from = end.max(start + 1);
70 }
71 ranges
72}
73
74#[cfg(test)]
75mod tests {
76 use std::time::Instant;
77
78 use super::*;
79 use crate::notify::stack::{ReplyState, ToastTimer};
80
81 fn model(kind: ChatKind, preview: Preview) -> ToastModel {
82 ToastModel {
83 id: 1,
84 conversation_id: "c".into(),
85 message_id: "m".into(),
86 kind,
87 chat_title: "Retro-Team".into(),
88 sender_id: None,
89 sender_name: "Priya Nair".into(),
90 preview,
91 mentions_me: false,
92 count: 1,
93 timer: ToastTimer::new(Instant::now(), false),
94 reply: ReplyState::Closed,
95 reply_text: String::new(),
96 hovered: false,
97 time: "14:30".into(),
98 }
99 }
100
101 #[test]
102 fn direct_shows_sender_and_plain_preview() {
103 let text = describe(&model(ChatKind::Direct, Preview::Text("Hallo".into())), true);
104 assert_eq!(text.title, "Priya Nair");
105 assert_eq!(text.subtitle, "Direkt");
106 assert_eq!(text.preview, "Hallo");
107 }
108
109 #[test]
110 fn group_shows_chat_title_and_prefixes_sender() {
111 let text = describe(
112 &model(ChatKind::Group { member_count: 5 }, Preview::Text("Hi".into())),
113 true,
114 );
115 assert_eq!(text.title, "Retro-Team");
116 assert_eq!(text.subtitle, "Gruppe, 5 Personen");
117 assert_eq!(text.preview, "Priya: Hi");
118 }
119
120 #[test]
121 fn channel_shows_path_and_prefixes_sender() {
122 let kind = ChatKind::Channel {
123 team: "Plattform".into(),
124 channel: "Releases".into(),
125 };
126 let text = describe(&model(kind, Preview::Text("Go".into())), true);
127 assert_eq!(text.title, "Priya Nair");
128 assert_eq!(text.subtitle, "Plattform > Releases");
129 assert_eq!(text.preview, "Priya: Go");
130 }
131
132 #[test]
133 fn preview_off_hides_content_but_keeps_name() {
134 let text = describe(&model(ChatKind::Direct, Preview::Text("geheim".into())), false);
135 assert_eq!(text.preview, "Neue Nachricht");
136 assert!(!text.narration().contains("geheim"));
137 }
138
139 #[test]
140 fn image_only_is_flagged() {
141 let text = describe(&model(ChatKind::Direct, Preview::Image), true);
142 assert_eq!(text.preview, "Bild");
143 assert!(text.image_only);
144 }
145
146 #[test]
147 fn mention_ranges_cover_first_word_after_at() {
148 let text = "Ping @Daniel kannst du @Mara fragen @";
149 let found: Vec<&str> = mention_ranges(text).into_iter().map(|range| &text[range]).collect();
150 assert_eq!(found, ["@Daniel", "@Mara"]);
151 }
152}
crates/app/src/notify/toast.rs added +601 −0
@@ -0,0 +1,601 @@
1 use std::time::Instant;
2
3 use gpui_kit::component::{
4 h_flex,
5 input::{InputEvent, Textarea, TextareaState},
6 v_flex,
7 };
8 use gpui_kit::prelude::FluentBuilder as _;
9 use gpui_kit::*;
10
11 use super::center::NotificationCenter;
12 use super::layout::ACTION_ROW;
13 use super::platform;
14 use super::rules::ChatKind;
15 use super::stack::{ReplyState, ToastModel};
16 use super::text::{ToastText, describe, mention_ranges};
17 use crate::sidebar_model::{AvatarSpec, Face};
18 use crate::views::avatar::{spec_avatar, with_presence};
19 use crate::views::composer::submitted_text;
20 use crate::views::widgets::symbol;
21 use crate::theme;
22
23 const AVATAR_SIZE: f32 = 40.;
24 const CLOSE_SIZE: f32 = 24.;
25 const PROGRESS_HEIGHT: f32 = 3.;
26 const TOAST_BORDER_MENTION: f32 = 2.;
27
28 pub struct ToastView {
29 center: Entity<NotificationCenter>,
30 id: u64,
31 input: Entity<TextareaState>,
32 focus_handle: FocusHandle,
33 last_title: String,
34 _subscriptions: Vec<Subscription>,
35 }
36
37 impl ToastView {
38 pub fn new(
39 center: Entity<NotificationCenter>,
40 id: u64,
41 window: &mut Window,
42 cx: &mut Context<Self>,
43 ) -> Self {
44 let input = cx.new(|cx| {
45 TextareaState::new(window, cx)
46 .auto_grow(1, 4)
47 .submit_on_enter(true)
48 .placeholder("Antworten ...")
49 });
50 let subscriptions = vec![
51 cx.subscribe_in(&input, window, |this, input, event: &InputEvent, window, cx| {
52 let value = input.read(cx).value();
53 if submitted_text(event, &value).is_some() {
54 this.submit(window, cx);
55 }
56 }),
57 cx.observe(&center, |_, _, cx| cx.notify()),
58 ];
59 ToastView {
60 center,
61 id,
62 input,
63 focus_handle: cx.focus_handle(),
64 last_title: String::new(),
65 _subscriptions: subscriptions,
66 }
67 }
68
69 fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
70 let text = self.input.read(cx).value().trim().to_owned();
71 if text.is_empty() {
72 return;
73 }
74 self.input
75 .update(cx, |state, cx| state.set_value("", window, cx));
76 let id = self.id;
77 self.center
78 .update(cx, |center, cx| center.submit_reply(id, text, cx));
79 }
80
81 fn open_reply(&mut self, window: &mut Window, cx: &mut Context<Self>) {
82 let id = self.id;
83 let draft = self
84 .center
85 .update(cx, |center, cx| center.open_reply(id, cx));
86 if let Some(native) = platform::native_handle(window) {
87 platform::set_activatable(native, true);
88 }
89 let input = self.input.clone();
90 cx.defer_in(window, move |_, window, cx| {
91 input.update(cx, |state, cx| {
92 if let Some(draft) = draft.filter(|draft| !draft.is_empty()) {
93 state.set_value(&draft, window, cx);
94 }
95 state.focus(window, cx);
96 });
97 });
98 }
99
100 fn close_reply(&mut self, window: &mut Window, cx: &mut Context<Self>) {
101 self.input
102 .update(cx, |state, cx| state.set_value("", window, cx));
103 let id = self.id;
104 self.center
105 .update(cx, |center, cx| center.close_reply(id, cx));
106 window.focus(&self.focus_handle, cx);
107 }
108
109 fn retry(&mut self, cx: &mut Context<Self>) {
110 let id = self.id;
111 self.center.update(cx, |center, cx| {
112 if let Some(text) = center.reply_text(id) {
113 center.submit_reply(id, text, cx);
114 }
115 });
116 }
117 }
118
119 fn pill_button(label: &'static str, symbol_name: &'static str, accent: bool) -> Stateful<Div> {
120 let color = if accent {
121 theme::accent_text()
122 } else {
123 theme::text_soft()
124 };
125 h_flex()
126 .id(label)
127 .h(px(ACTION_ROW))
128 .px(px(14.))
129 .gap(px(6.))
130 .items_center()
131 .justify_center()
132 .rounded(px(8.))
133 .border_1()
134 .border_color(theme::border_strong())
135 .cursor_pointer()
136 .text_size(px(13.))
137 .font_weight(FontWeight::SEMIBOLD)
138 .text_color(color)
139 .hover(|button| button.bg(theme::row_hover()))
140 .child(symbol(symbol_name, 18., color))
141 .child(label)
142 }
143
144 fn highlighted_preview(text: &str, mention: bool) -> AnyElement {
145 let mut styled = StyledText::new(text.to_owned());
146 if mention {
147 let style = HighlightStyle {
148 color: Some(theme::accent_soft()),
149 font_weight: Some(FontWeight::SEMIBOLD),
150 ..Default::default()
151 };
152 let highlights: Vec<_> = mention_ranges(text)
153 .into_iter()
154 .map(|range| (range, style))
155 .collect();
156 styled = styled.with_highlights(highlights);
157 }
158 div()
159 .text_size(px(13.))
160 .line_height(px(18.))
161 .text_color(theme::text())
162 .line_clamp(2)
163 .child(styled)
164 .into_any_element()
165 }
166
167 fn side_chip(label: String, mention: bool) -> Div {
168 div()
169 .h(px(20.))
170 .px(px(8.))
171 .flex()
172 .items_center()
173 .rounded(px(10.))
174 .bg(if mention {
175 theme::bubble_own()
176 } else {
177 theme::border_strong()
178 })
179 .text_color(if mention {
180 theme::accent_soft()
181 } else {
182 theme::text()
183 })
184 .text_size(px(11.))
185 .line_height(px(20.))
186 .font_weight(FontWeight::SEMIBOLD)
187 .child(label)
188 }
189
190 impl ToastView {
191 fn avatar(&self, model: &ToastModel, fill: Hsla, cx: &App) -> AnyElement {
192 let center = self.center.read(cx);
193 let directory = center.directory(cx);
194 let sender = Face {
195 user_id: model.sender_id.clone(),
196 name: model.sender_name.clone(),
197 };
198 match &model.kind {
199 ChatKind::Group { .. } => {
200 let chat = Face {
201 user_id: None,
202 name: model.chat_title.clone(),
203 };
204 spec_avatar(directory, &AvatarSpec::Pair(sender, chat), AVATAR_SIZE, fill)
205 }
206 _ => {
207 let presence = model
208 .sender_id
209 .as_deref()
210 .map(|user_id| directory.presence_of(user_id))
211 .unwrap_or(crate::data::PresenceKind::Unknown);
212 let face = spec_avatar(directory, &AvatarSpec::Single(sender), AVATAR_SIZE, fill);
213 with_presence(face, presence, AVATAR_SIZE, fill).into_any_element()
214 }
215 }
216 }
217
218 fn side_slot(&self, model: &ToastModel, hovered: bool) -> AnyElement {
219 let id = self.id;
220 if hovered {
221 let center = self.center.clone();
222 return div()
223 .id("toast-close")
224 .size(px(CLOSE_SIZE))
225 .flex_none()
226 .flex()
227 .items_center()
228 .justify_center()
229 .rounded_full()
230 .bg(theme::border_strong())
231 .cursor_pointer()
232 .hover(|button| button.bg(theme::text_faint()))
233 .child(symbol("close", 16., theme::text()))
234 .on_click(move |_, _, cx| {
235 cx.stop_propagation();
236 center.update(cx, |center, cx| center.dismiss(id, cx));
237 })
238 .into_any_element();
239 }
240 if model.mentions_me {
241 return side_chip("Erwähnung".to_owned(), true).into_any_element();
242 }
243 if model.count > 1 {
244 return side_chip(format!("{} neue", model.count), false).into_any_element();
245 }
246 div()
247 .text_size(px(12.))
248 .text_color(theme::text_muted())
249 .child(model.time.clone())
250 .into_any_element()
251 }
252
253 fn body(&self, model: &ToastModel, text: &ToastText, hovered: bool) -> Div {
254 let subtitle_icon = match &model.kind {
255 ChatKind::Group { .. } => Some("group"),
256 ChatKind::Channel { .. } => Some("tag"),
257 ChatKind::Direct => None,
258 };
259 let preview = if text.image_only {
260 h_flex()
261 .gap(px(6.))
262 .items_center()
263 .child(symbol("image", 16., theme::text_muted()))
264 .child(
265 div()
266 .text_size(px(13.))
267 .text_color(theme::text())
268 .child(text.preview.clone()),
269 )
270 .into_any_element()
271 } else {
272 highlighted_preview(&text.preview, model.mentions_me)
273 };
274 v_flex()
275 .flex_1()
276 .min_w_0()
277 .gap(px(2.))
278 .child(
279 h_flex()
280 .w_full()
281 .gap(px(8.))
282 .items_center()
283 .justify_between()
284 .child(
285 div()
286 .flex_1()
287 .min_w_0()
288 .truncate()
289 .text_size(px(14.))
290 .line_height(px(20.))
291 .font_weight(FontWeight::SEMIBOLD)
292 .text_color(theme::text())
293 .child(text.title.clone()),
294 )
295 .child(div().flex_none().child(self.side_slot(model, hovered))),
296 )
297 .child(
298 h_flex()
299 .gap(px(4.))
300 .items_center()
301 .h(px(16.))
302 .text_size(px(12.))
303 .text_color(theme::text_muted())
304 .children(subtitle_icon.map(|name| symbol(name, 14., theme::text_muted())))
305 .child(div().truncate().child(text.subtitle.clone())),
306 )
307 .child(preview)
308 }
309
310 fn action_row(&self, cx: &mut Context<Self>) -> Div {
311 let id = self.id;
312 let center = self.center.clone();
313 h_flex()
314 .w_full()
315 .mt(px(4.))
316 .justify_between()
317 .child(pill_button("Gelesen", "done", false).on_click(move |_, _, cx| {
318 cx.stop_propagation();
319 center.update(cx, |center, cx| center.mark_read(id, cx));
320 }))
321 .child(
322 pill_button("Antworten", "reply", true).on_click(cx.listener(
323 |this, _, window, cx| {
324 cx.stop_propagation();
325 this.open_reply(window, cx);
326 },
327 )),
328 )
329 }
330
331 fn reply_field(&self, window: &Window, cx: &mut Context<Self>) -> Div {
332 let focused = self.input.focus_handle(cx).contains_focused(window, cx);
333 let empty = self.input.read(cx).value().trim().is_empty();
334 let send = div()
335 .id("toast-send")
336 .size(px(ACTION_ROW))
337 .flex_none()
338 .flex()
339 .items_center()
340 .justify_center()
341 .rounded(px(8.))
342 .bg(theme::accent())
343 .child(symbol("arrow_upward", 20., theme::on_accent()))
344 .when(empty, |button| button.opacity(0.4))
345 .when(!empty, |button| {
346 button
347 .cursor_pointer()
348 .hover(|button| button.bg(theme::accent_text()))
349 .on_click(cx.listener(|this, _, window, cx| {
350 cx.stop_propagation();
351 this.submit(window, cx);
352 }))
353 });
354 let hint = |keys: &'static str, action: &'static str| {
355 h_flex()
356 .gap(px(4.))
357 .child(div().text_color(theme::text_soft()).child(keys))
358 .child(action)
359 };
360 v_flex()
361 .w_full()
362 .mt(px(8.))
363 .gap(px(4.))
364 .child(
365 h_flex()
366 .w_full()
367 .h(px(ACTION_ROW))
368 .gap(px(6.))
369 .items_center()
370 .child(
371 div()
372 .flex_1()
373 .min_w_0()
374 .h(px(ACTION_ROW))
375 .px(px(10.))
376 .flex()
377 .items_center()
378 .rounded(px(8.))
379 .bg(theme::surface())
380 .border_1()
381 .border_color(if focused {
382 theme::accent()
383 } else {
384 theme::border_strong()
385 })
386 .child(
387 Textarea::new(&self.input)
388 .appearance(false)
389 .bordered(false),
390 ),
391 )
392 .child(send),
393 )
394 .child(
395 h_flex()
396 .h(px(16.))
397 .gap(px(12.))
398 .text_size(px(11.))
399 .text_color(theme::text_muted())
400 .child(hint("Enter", "senden"))
401 .child(hint("Umschalt+Enter", "Zeilenumbruch"))
402 .child(hint("Esc", "schließen")),
403 )
404 }
405
406 fn confirmation(&self, model: &ToastModel, cx: &mut Context<Self>) -> Div {
407 let sent = model.reply == ReplyState::Sent;
408 let label = if sent {
409 format!("Gesendet an {}", target_name(model))
410 } else {
411 "Senden fehlgeschlagen".to_owned()
412 };
413 let (icon_name, tone) = if sent {
414 ("check_circle", theme::green())
415 } else {
416 ("error", theme::red_soft())
417 };
418 h_flex()
419 .size_full()
420 .gap(px(10.))
421 .items_center()
422 .child(symbol(icon_name, 22., tone))
423 .child(
424 div()
425 .flex_1()
426 .min_w_0()
427 .truncate()
428 .text_size(px(14.))
429 .font_weight(FontWeight::SEMIBOLD)
430 .text_color(theme::text())
431 .child(label),
432 )
433 .when(sent, |row| {
434 row.child(
435 div()
436 .text_size(px(12.))
437 .text_color(theme::text_muted())
438 .child(model.time.clone()),
439 )
440 })
441 .when(!sent, |row| {
442 row.child(pill_button("Erneut", "reply", true).on_click(cx.listener(
443 |this, _, _, cx| {
444 cx.stop_propagation();
445 this.retry(cx);
446 },
447 )))
448 })
449 }
450 }
451
452 fn target_name(model: &ToastModel) -> String {
453 match &model.kind {
454 ChatKind::Group { .. } => model.chat_title.clone(),
455 _ => model.sender_name.clone(),
456 }
457 }
458
459 impl Render for ToastView {
460 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
461 let id = self.id;
462 let (model, preview_on) = {
463 let center = self.center.read(cx);
464 (center.model(id).cloned(), center.settings().preview)
465 };
466 let Some(model) = model else {
467 return div()
468 .size_full()
469 .bg(theme::surface_raised())
470 .into_any_element();
471 };
472 let text = describe(&model, preview_on);
473 let narration = text.narration();
474 if narration != self.last_title {
475 window.set_window_title(&narration);
476 self.last_title = narration;
477 }
478 let mention = model.mentions_me;
479 let fill = if mention {
480 theme::toast_mention_fill()
481 } else {
482 theme::surface_raised()
483 };
484 let border = if mention {
485 theme::accent()
486 } else {
487 theme::border_strong()
488 };
489 let border_width = if mention { TOAST_BORDER_MENTION } else { 1. };
490 let fraction = model.timer.fraction_left(Instant::now());
491 let bar_color = if model.timer.is_paused() {
492 theme::text_faint()
493 } else {
494 theme::accent()
495 };
496 let hovered = model.hovered;
497 let content = match model.reply {
498 ReplyState::Sent | ReplyState::Failed => self.confirmation(&model, cx),
499 ReplyState::Open => v_flex()
500 .w_full()
501 .child(
502 h_flex()
503 .w_full()
504 .gap(px(12.))
505 .items_start()
506 .child(self.avatar(&model, fill, cx))
507 .child(self.body(&model, &text, true)),
508 )
509 .child(self.reply_field(window, cx)),
510 ReplyState::Closed => v_flex()
511 .w_full()
512 .child(
513 h_flex()
514 .w_full()
515 .gap(px(12.))
516 .items_start()
517 .child(self.avatar(&model, fill, cx))
518 .child(self.body(&model, &text, hovered)),
519 )
520 .when(hovered, |column| column.child(self.action_row(cx))),
521 };
522 let center = self.center.clone();
523 let hover_center = self.center.clone();
524 div()
525 .id(("toast", id))
526 .track_focus(&self.focus_handle)
527 .relative()
528 .size_full()
529 .bg(fill)
530 .border(px(border_width))
531 .border_color(border)
532 .overflow_hidden()
533 .cursor_pointer()
534 .on_hover(move |is_hovered, _, cx| {
535 hover_center.update(cx, |center, cx| center.set_hover(id, *is_hovered, cx));
536 })
537 .on_click(move |_, _, cx| {
538 center.update(cx, |center, cx| center.activate(id, cx));
539 })
540 .capture_action(cx.listener(|this, _: &gpui_kit::component::input::Escape, window, cx| {
541 this.close_reply(window, cx);
542 cx.stop_propagation();
543 }))
544 .on_key_down(cx.listener(|this, event: &KeyDownEvent, _, cx| {
545 if event.keystroke.key == "escape" {
546 let id = this.id;
547 this.center.update(cx, |center, cx| center.dismiss(id, cx));
548 }
549 }))
550 .child(div().size_full().p(px(12.)).child(content))
551 .child(
552 div()
553 .absolute()
554 .left_0()
555 .bottom_0()
556 .h(px(PROGRESS_HEIGHT))
557 .w(relative(fraction))
558 .bg(bar_color),
559 )
560 .into_any_element()
561 }
562 }
563
564 pub struct PillView {
565 center: Entity<NotificationCenter>,
566 _subscription: Subscription,
567 }
568
569 impl PillView {
570 pub fn new(center: Entity<NotificationCenter>, cx: &mut Context<Self>) -> Self {
571 let subscription = cx.observe(&center, |_, _, cx| cx.notify());
572 PillView {
573 center,
574 _subscription: subscription,
575 }
576 }
577 }
578
579 impl Render for PillView {
580 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
581 let hidden = self.center.read(cx).hidden_count();
582 let center = self.center.clone();
583 div()
584 .id("toast-pill")
585 .size_full()
586 .flex()
587 .items_center()
588 .justify_center()
589 .bg(theme::surface_raised())
590 .border_1()
591 .border_color(theme::border_strong())
592 .cursor_pointer()
593 .text_size(px(13.))
594 .font_weight(FontWeight::SEMIBOLD)
595 .text_color(theme::text())
596 .child(format!("+{hidden} weitere"))
597 .on_click(move |_, _, cx| {
598 center.update(cx, |center, cx| center.open_chat_list(cx));
599 })
600 }
601 }
@@ -0,0 +1,601 @@
1use std::time::Instant;
2
3use gpui_kit::component::{
4 h_flex,
5 input::{InputEvent, Textarea, TextareaState},
6 v_flex,
7};
8use gpui_kit::prelude::FluentBuilder as _;
9use gpui_kit::*;
10
11use super::center::NotificationCenter;
12use super::layout::ACTION_ROW;
13use super::platform;
14use super::rules::ChatKind;
15use super::stack::{ReplyState, ToastModel};
16use super::text::{ToastText, describe, mention_ranges};
17use crate::sidebar_model::{AvatarSpec, Face};
18use crate::views::avatar::{spec_avatar, with_presence};
19use crate::views::composer::submitted_text;
20use crate::views::widgets::symbol;
21use crate::theme;
22
23const AVATAR_SIZE: f32 = 40.;
24const CLOSE_SIZE: f32 = 24.;
25const PROGRESS_HEIGHT: f32 = 3.;
26const TOAST_BORDER_MENTION: f32 = 2.;
27
28pub struct ToastView {
29 center: Entity<NotificationCenter>,
30 id: u64,
31 input: Entity<TextareaState>,
32 focus_handle: FocusHandle,
33 last_title: String,
34 _subscriptions: Vec<Subscription>,
35}
36
37impl ToastView {
38 pub fn new(
39 center: Entity<NotificationCenter>,
40 id: u64,
41 window: &mut Window,
42 cx: &mut Context<Self>,
43 ) -> Self {
44 let input = cx.new(|cx| {
45 TextareaState::new(window, cx)
46 .auto_grow(1, 4)
47 .submit_on_enter(true)
48 .placeholder("Antworten ...")
49 });
50 let subscriptions = vec![
51 cx.subscribe_in(&input, window, |this, input, event: &InputEvent, window, cx| {
52 let value = input.read(cx).value();
53 if submitted_text(event, &value).is_some() {
54 this.submit(window, cx);
55 }
56 }),
57 cx.observe(&center, |_, _, cx| cx.notify()),
58 ];
59 ToastView {
60 center,
61 id,
62 input,
63 focus_handle: cx.focus_handle(),
64 last_title: String::new(),
65 _subscriptions: subscriptions,
66 }
67 }
68
69 fn submit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
70 let text = self.input.read(cx).value().trim().to_owned();
71 if text.is_empty() {
72 return;
73 }
74 self.input
75 .update(cx, |state, cx| state.set_value("", window, cx));
76 let id = self.id;
77 self.center
78 .update(cx, |center, cx| center.submit_reply(id, text, cx));
79 }
80
81 fn open_reply(&mut self, window: &mut Window, cx: &mut Context<Self>) {
82 let id = self.id;
83 let draft = self
84 .center
85 .update(cx, |center, cx| center.open_reply(id, cx));
86 if let Some(native) = platform::native_handle(window) {
87 platform::set_activatable(native, true);
88 }
89 let input = self.input.clone();
90 cx.defer_in(window, move |_, window, cx| {
91 input.update(cx, |state, cx| {
92 if let Some(draft) = draft.filter(|draft| !draft.is_empty()) {
93 state.set_value(&draft, window, cx);
94 }
95 state.focus(window, cx);
96 });
97 });
98 }
99
100 fn close_reply(&mut self, window: &mut Window, cx: &mut Context<Self>) {
101 self.input
102 .update(cx, |state, cx| state.set_value("", window, cx));
103 let id = self.id;
104 self.center
105 .update(cx, |center, cx| center.close_reply(id, cx));
106 window.focus(&self.focus_handle, cx);
107 }
108
109 fn retry(&mut self, cx: &mut Context<Self>) {
110 let id = self.id;
111 self.center.update(cx, |center, cx| {
112 if let Some(text) = center.reply_text(id) {
113 center.submit_reply(id, text, cx);
114 }
115 });
116 }
117}
118
119fn pill_button(label: &'static str, symbol_name: &'static str, accent: bool) -> Stateful<Div> {
120 let color = if accent {
121 theme::accent_text()
122 } else {
123 theme::text_soft()
124 };
125 h_flex()
126 .id(label)
127 .h(px(ACTION_ROW))
128 .px(px(14.))
129 .gap(px(6.))
130 .items_center()
131 .justify_center()
132 .rounded(px(8.))
133 .border_1()
134 .border_color(theme::border_strong())
135 .cursor_pointer()
136 .text_size(px(13.))
137 .font_weight(FontWeight::SEMIBOLD)
138 .text_color(color)
139 .hover(|button| button.bg(theme::row_hover()))
140 .child(symbol(symbol_name, 18., color))
141 .child(label)
142}
143
144fn highlighted_preview(text: &str, mention: bool) -> AnyElement {
145 let mut styled = StyledText::new(text.to_owned());
146 if mention {
147 let style = HighlightStyle {
148 color: Some(theme::accent_soft()),
149 font_weight: Some(FontWeight::SEMIBOLD),
150 ..Default::default()
151 };
152 let highlights: Vec<_> = mention_ranges(text)
153 .into_iter()
154 .map(|range| (range, style))
155 .collect();
156 styled = styled.with_highlights(highlights);
157 }
158 div()
159 .text_size(px(13.))
160 .line_height(px(18.))
161 .text_color(theme::text())
162 .line_clamp(2)
163 .child(styled)
164 .into_any_element()
165}
166
167fn side_chip(label: String, mention: bool) -> Div {
168 div()
169 .h(px(20.))
170 .px(px(8.))
171 .flex()
172 .items_center()
173 .rounded(px(10.))
174 .bg(if mention {
175 theme::bubble_own()
176 } else {
177 theme::border_strong()
178 })
179 .text_color(if mention {
180 theme::accent_soft()
181 } else {
182 theme::text()
183 })
184 .text_size(px(11.))
185 .line_height(px(20.))
186 .font_weight(FontWeight::SEMIBOLD)
187 .child(label)
188}
189
190impl ToastView {
191 fn avatar(&self, model: &ToastModel, fill: Hsla, cx: &App) -> AnyElement {
192 let center = self.center.read(cx);
193 let directory = center.directory(cx);
194 let sender = Face {
195 user_id: model.sender_id.clone(),
196 name: model.sender_name.clone(),
197 };
198 match &model.kind {
199 ChatKind::Group { .. } => {
200 let chat = Face {
201 user_id: None,
202 name: model.chat_title.clone(),
203 };
204 spec_avatar(directory, &AvatarSpec::Pair(sender, chat), AVATAR_SIZE, fill)
205 }
206 _ => {
207 let presence = model
208 .sender_id
209 .as_deref()
210 .map(|user_id| directory.presence_of(user_id))
211 .unwrap_or(crate::data::PresenceKind::Unknown);
212 let face = spec_avatar(directory, &AvatarSpec::Single(sender), AVATAR_SIZE, fill);
213 with_presence(face, presence, AVATAR_SIZE, fill).into_any_element()
214 }
215 }
216 }
217
218 fn side_slot(&self, model: &ToastModel, hovered: bool) -> AnyElement {
219 let id = self.id;
220 if hovered {
221 let center = self.center.clone();
222 return div()
223 .id("toast-close")
224 .size(px(CLOSE_SIZE))
225 .flex_none()
226 .flex()
227 .items_center()
228 .justify_center()
229 .rounded_full()
230 .bg(theme::border_strong())
231 .cursor_pointer()
232 .hover(|button| button.bg(theme::text_faint()))
233 .child(symbol("close", 16., theme::text()))
234 .on_click(move |_, _, cx| {
235 cx.stop_propagation();
236 center.update(cx, |center, cx| center.dismiss(id, cx));
237 })
238 .into_any_element();
239 }
240 if model.mentions_me {
241 return side_chip("Erwähnung".to_owned(), true).into_any_element();
242 }
243 if model.count > 1 {
244 return side_chip(format!("{} neue", model.count), false).into_any_element();
245 }
246 div()
247 .text_size(px(12.))
248 .text_color(theme::text_muted())
249 .child(model.time.clone())
250 .into_any_element()
251 }
252
253 fn body(&self, model: &ToastModel, text: &ToastText, hovered: bool) -> Div {
254 let subtitle_icon = match &model.kind {
255 ChatKind::Group { .. } => Some("group"),
256 ChatKind::Channel { .. } => Some("tag"),
257 ChatKind::Direct => None,
258 };
259 let preview = if text.image_only {
260 h_flex()
261 .gap(px(6.))
262 .items_center()
263 .child(symbol("image", 16., theme::text_muted()))
264 .child(
265 div()
266 .text_size(px(13.))
267 .text_color(theme::text())
268 .child(text.preview.clone()),
269 )
270 .into_any_element()
271 } else {
272 highlighted_preview(&text.preview, model.mentions_me)
273 };
274 v_flex()
275 .flex_1()
276 .min_w_0()
277 .gap(px(2.))
278 .child(
279 h_flex()
280 .w_full()
281 .gap(px(8.))
282 .items_center()
283 .justify_between()
284 .child(
285 div()
286 .flex_1()
287 .min_w_0()
288 .truncate()
289 .text_size(px(14.))
290 .line_height(px(20.))
291 .font_weight(FontWeight::SEMIBOLD)
292 .text_color(theme::text())
293 .child(text.title.clone()),
294 )
295 .child(div().flex_none().child(self.side_slot(model, hovered))),
296 )
297 .child(
298 h_flex()
299 .gap(px(4.))
300 .items_center()
301 .h(px(16.))
302 .text_size(px(12.))
303 .text_color(theme::text_muted())
304 .children(subtitle_icon.map(|name| symbol(name, 14., theme::text_muted())))
305 .child(div().truncate().child(text.subtitle.clone())),
306 )
307 .child(preview)
308 }
309
310 fn action_row(&self, cx: &mut Context<Self>) -> Div {
311 let id = self.id;
312 let center = self.center.clone();
313 h_flex()
314 .w_full()
315 .mt(px(4.))
316 .justify_between()
317 .child(pill_button("Gelesen", "done", false).on_click(move |_, _, cx| {
318 cx.stop_propagation();
319 center.update(cx, |center, cx| center.mark_read(id, cx));
320 }))
321 .child(
322 pill_button("Antworten", "reply", true).on_click(cx.listener(
323 |this, _, window, cx| {
324 cx.stop_propagation();
325 this.open_reply(window, cx);
326 },
327 )),
328 )
329 }
330
331 fn reply_field(&self, window: &Window, cx: &mut Context<Self>) -> Div {
332 let focused = self.input.focus_handle(cx).contains_focused(window, cx);
333 let empty = self.input.read(cx).value().trim().is_empty();
334 let send = div()
335 .id("toast-send")
336 .size(px(ACTION_ROW))
337 .flex_none()
338 .flex()
339 .items_center()
340 .justify_center()
341 .rounded(px(8.))
342 .bg(theme::accent())
343 .child(symbol("arrow_upward", 20., theme::on_accent()))
344 .when(empty, |button| button.opacity(0.4))
345 .when(!empty, |button| {
346 button
347 .cursor_pointer()
348 .hover(|button| button.bg(theme::accent_text()))
349 .on_click(cx.listener(|this, _, window, cx| {
350 cx.stop_propagation();
351 this.submit(window, cx);
352 }))
353 });
354 let hint = |keys: &'static str, action: &'static str| {
355 h_flex()
356 .gap(px(4.))
357 .child(div().text_color(theme::text_soft()).child(keys))
358 .child(action)
359 };
360 v_flex()
361 .w_full()
362 .mt(px(8.))
363 .gap(px(4.))
364 .child(
365 h_flex()
366 .w_full()
367 .h(px(ACTION_ROW))
368 .gap(px(6.))
369 .items_center()
370 .child(
371 div()
372 .flex_1()
373 .min_w_0()
374 .h(px(ACTION_ROW))
375 .px(px(10.))
376 .flex()
377 .items_center()
378 .rounded(px(8.))
379 .bg(theme::surface())
380 .border_1()
381 .border_color(if focused {
382 theme::accent()
383 } else {
384 theme::border_strong()
385 })
386 .child(
387 Textarea::new(&self.input)
388 .appearance(false)
389 .bordered(false),
390 ),
391 )
392 .child(send),
393 )
394 .child(
395 h_flex()
396 .h(px(16.))
397 .gap(px(12.))
398 .text_size(px(11.))
399 .text_color(theme::text_muted())
400 .child(hint("Enter", "senden"))
401 .child(hint("Umschalt+Enter", "Zeilenumbruch"))
402 .child(hint("Esc", "schließen")),
403 )
404 }
405
406 fn confirmation(&self, model: &ToastModel, cx: &mut Context<Self>) -> Div {
407 let sent = model.reply == ReplyState::Sent;
408 let label = if sent {
409 format!("Gesendet an {}", target_name(model))
410 } else {
411 "Senden fehlgeschlagen".to_owned()
412 };
413 let (icon_name, tone) = if sent {
414 ("check_circle", theme::green())
415 } else {
416 ("error", theme::red_soft())
417 };
418 h_flex()
419 .size_full()
420 .gap(px(10.))
421 .items_center()
422 .child(symbol(icon_name, 22., tone))
423 .child(
424 div()
425 .flex_1()
426 .min_w_0()
427 .truncate()
428 .text_size(px(14.))
429 .font_weight(FontWeight::SEMIBOLD)
430 .text_color(theme::text())
431 .child(label),
432 )
433 .when(sent, |row| {
434 row.child(
435 div()
436 .text_size(px(12.))
437 .text_color(theme::text_muted())
438 .child(model.time.clone()),
439 )
440 })
441 .when(!sent, |row| {
442 row.child(pill_button("Erneut", "reply", true).on_click(cx.listener(
443 |this, _, _, cx| {
444 cx.stop_propagation();
445 this.retry(cx);
446 },
447 )))
448 })
449 }
450}
451
452fn target_name(model: &ToastModel) -> String {
453 match &model.kind {
454 ChatKind::Group { .. } => model.chat_title.clone(),
455 _ => model.sender_name.clone(),
456 }
457}
458
459impl Render for ToastView {
460 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
461 let id = self.id;
462 let (model, preview_on) = {
463 let center = self.center.read(cx);
464 (center.model(id).cloned(), center.settings().preview)
465 };
466 let Some(model) = model else {
467 return div()
468 .size_full()
469 .bg(theme::surface_raised())
470 .into_any_element();
471 };
472 let text = describe(&model, preview_on);
473 let narration = text.narration();
474 if narration != self.last_title {
475 window.set_window_title(&narration);
476 self.last_title = narration;
477 }
478 let mention = model.mentions_me;
479 let fill = if mention {
480 theme::toast_mention_fill()
481 } else {
482 theme::surface_raised()
483 };
484 let border = if mention {
485 theme::accent()
486 } else {
487 theme::border_strong()
488 };
489 let border_width = if mention { TOAST_BORDER_MENTION } else { 1. };
490 let fraction = model.timer.fraction_left(Instant::now());
491 let bar_color = if model.timer.is_paused() {
492 theme::text_faint()
493 } else {
494 theme::accent()
495 };
496 let hovered = model.hovered;
497 let content = match model.reply {
498 ReplyState::Sent | ReplyState::Failed => self.confirmation(&model, cx),
499 ReplyState::Open => v_flex()
500 .w_full()
501 .child(
502 h_flex()
503 .w_full()
504 .gap(px(12.))
505 .items_start()
506 .child(self.avatar(&model, fill, cx))
507 .child(self.body(&model, &text, true)),
508 )
509 .child(self.reply_field(window, cx)),
510 ReplyState::Closed => v_flex()
511 .w_full()
512 .child(
513 h_flex()
514 .w_full()
515 .gap(px(12.))
516 .items_start()
517 .child(self.avatar(&model, fill, cx))
518 .child(self.body(&model, &text, hovered)),
519 )
520 .when(hovered, |column| column.child(self.action_row(cx))),
521 };
522 let center = self.center.clone();
523 let hover_center = self.center.clone();
524 div()
525 .id(("toast", id))
526 .track_focus(&self.focus_handle)
527 .relative()
528 .size_full()
529 .bg(fill)
530 .border(px(border_width))
531 .border_color(border)
532 .overflow_hidden()
533 .cursor_pointer()
534 .on_hover(move |is_hovered, _, cx| {
535 hover_center.update(cx, |center, cx| center.set_hover(id, *is_hovered, cx));
536 })
537 .on_click(move |_, _, cx| {
538 center.update(cx, |center, cx| center.activate(id, cx));
539 })
540 .capture_action(cx.listener(|this, _: &gpui_kit::component::input::Escape, window, cx| {
541 this.close_reply(window, cx);
542 cx.stop_propagation();
543 }))
544 .on_key_down(cx.listener(|this, event: &KeyDownEvent, _, cx| {
545 if event.keystroke.key == "escape" {
546 let id = this.id;
547 this.center.update(cx, |center, cx| center.dismiss(id, cx));
548 }
549 }))
550 .child(div().size_full().p(px(12.)).child(content))
551 .child(
552 div()
553 .absolute()
554 .left_0()
555 .bottom_0()
556 .h(px(PROGRESS_HEIGHT))
557 .w(relative(fraction))
558 .bg(bar_color),
559 )
560 .into_any_element()
561 }
562}
563
564pub struct PillView {
565 center: Entity<NotificationCenter>,
566 _subscription: Subscription,
567}
568
569impl PillView {
570 pub fn new(center: Entity<NotificationCenter>, cx: &mut Context<Self>) -> Self {
571 let subscription = cx.observe(&center, |_, _, cx| cx.notify());
572 PillView {
573 center,
574 _subscription: subscription,
575 }
576 }
577}
578
579impl Render for PillView {
580 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
581 let hidden = self.center.read(cx).hidden_count();
582 let center = self.center.clone();
583 div()
584 .id("toast-pill")
585 .size_full()
586 .flex()
587 .items_center()
588 .justify_center()
589 .bg(theme::surface_raised())
590 .border_1()
591 .border_color(theme::border_strong())
592 .cursor_pointer()
593 .text_size(px(13.))
594 .font_weight(FontWeight::SEMIBOLD)
595 .text_color(theme::text())
596 .child(format!("+{hidden} weitere"))
597 .on_click(move |_, _, cx| {
598 center.update(cx, |center, cx| center.open_chat_list(cx));
599 })
600 }
601}
crates/app/src/theme.rs +5 −0
@@ -38,6 +38,7 @@ const OWN_READ: u32 = 0xf5c4a5;
38 38 const DROP_BACKGROUND: u32 = 0xce6a3b14;
39 39 const CODE_BACKGROUND: u32 = 0x0b0b0c;
40 40 const BADGE_MUTED: u32 = 0x3f3f42;
41 const TOAST_MENTION: u32 = 0x2e1d15;
41 42 const GREEN: u32 = 0x22c55e;
42 43 const RED: u32 = 0xef4444;
43 44 const CLOSE_BUTTON_HOVER: u32 = 0xc42b1c;
@@ -131,6 +132,10 @@ pub fn background() -> Hsla {
131 132 color(BACKGROUND)
132 133 }
133 134
135 pub fn toast_mention_fill() -> Hsla {
136 color(TOAST_MENTION)
137 }
138
134 139 pub fn surface() -> Hsla {
135 140 color(SURFACE)
136 141 }
@@ -38,6 +38,7 @@ const OWN_READ: u32 = 0xf5c4a5;
38const DROP_BACKGROUND: u32 = 0xce6a3b14;
38const DROP_BACKGROUND: u32 = 0xce6a3b14;
39const CODE_BACKGROUND: u32 = 0x0b0b0c;
39const CODE_BACKGROUND: u32 = 0x0b0b0c;
40const BADGE_MUTED: u32 = 0x3f3f42;
40const BADGE_MUTED: u32 = 0x3f3f42;
41const TOAST_MENTION: u32 = 0x2e1d15;
41const GREEN: u32 = 0x22c55e;
42const GREEN: u32 = 0x22c55e;
42const RED: u32 = 0xef4444;
43const RED: u32 = 0xef4444;
43const CLOSE_BUTTON_HOVER: u32 = 0xc42b1c;
44const CLOSE_BUTTON_HOVER: u32 = 0xc42b1c;
@@ -131,6 +132,10 @@ pub fn background() -> Hsla {
131 color(BACKGROUND)
132 color(BACKGROUND)
132}
133}
133
134
135pub fn toast_mention_fill() -> Hsla {
136 color(TOAST_MENTION)
137}
138
134pub fn surface() -> Hsla {
139pub fn surface() -> Hsla {
135 color(SURFACE)
140 color(SURFACE)
136}
141}
crates/app/src/views/shell.rs +10 −0
@@ -7,6 +7,7 @@ use super::status_bar::render_status_bar;
7 7 use super::switcher::{Switcher, SwitcherEvent, candidates_from};
8 8 use super::title_bar::render_title_bar;
9 9 use crate::app_state::{AppEvent, AppState, Selection};
10 use crate::notify::NotificationCenter;
10 11 use crate::theme;
11 12 use crate::updater::{self, IdleInputs, UpdateStatus};
12 13
@@ -39,6 +40,7 @@ pub struct AppShell {
39 40 sidebar: Entity<SidebarView>,
40 41 conversation: Entity<ConversationView>,
41 42 switcher: Option<Entity<Switcher>>,
43 notifications: Entity<NotificationCenter>,
42 44 focus_handle: FocusHandle,
43 45 open_target: Option<OpenTarget>,
44 46 update: UpdateStatus,
@@ -63,11 +65,15 @@ impl AppShell {
63 65 });
64 66 let focus_handle = cx.focus_handle();
65 67 window.focus(&focus_handle, cx);
68 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
69 let closing = notifications.clone();
70 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
66 71 let mut shell = AppShell {
67 72 state,
68 73 sidebar,
69 74 conversation,
70 75 switcher: None,
76 notifications,
71 77 focus_handle,
72 78 open_target,
73 79 update: UpdateStatus::UpToDate,
@@ -237,6 +243,10 @@ impl Render for AppShell {
237 243 let title_bar = render_title_bar(
238 244 &state.directory,
239 245 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
246 cx.listener(|this, _, _, cx| {
247 this.notifications
248 .update(cx, |center, cx| center.open_settings(cx));
249 }),
240 250 );
241 251 div()
242 252 .id("app-shell")
@@ -7,6 +7,7 @@ use super::status_bar::render_status_bar;
7use super::switcher::{Switcher, SwitcherEvent, candidates_from};
7use super::switcher::{Switcher, SwitcherEvent, candidates_from};
8use super::title_bar::render_title_bar;
8use super::title_bar::render_title_bar;
9use crate::app_state::{AppEvent, AppState, Selection};
9use crate::app_state::{AppEvent, AppState, Selection};
10use crate::notify::NotificationCenter;
10use crate::theme;
11use crate::theme;
11use crate::updater::{self, IdleInputs, UpdateStatus};
12use crate::updater::{self, IdleInputs, UpdateStatus};
12
13
@@ -39,6 +40,7 @@ pub struct AppShell {
39 sidebar: Entity<SidebarView>,
40 sidebar: Entity<SidebarView>,
40 conversation: Entity<ConversationView>,
41 conversation: Entity<ConversationView>,
41 switcher: Option<Entity<Switcher>>,
42 switcher: Option<Entity<Switcher>>,
43 notifications: Entity<NotificationCenter>,
42 focus_handle: FocusHandle,
44 focus_handle: FocusHandle,
43 open_target: Option<OpenTarget>,
45 open_target: Option<OpenTarget>,
44 update: UpdateStatus,
46 update: UpdateStatus,
@@ -63,11 +65,15 @@ impl AppShell {
63 });
65 });
64 let focus_handle = cx.focus_handle();
66 let focus_handle = cx.focus_handle();
65 window.focus(&focus_handle, cx);
67 window.focus(&focus_handle, cx);
68 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
69 let closing = notifications.clone();
70 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
66 let mut shell = AppShell {
71 let mut shell = AppShell {
67 state,
72 state,
68 sidebar,
73 sidebar,
69 conversation,
74 conversation,
70 switcher: None,
75 switcher: None,
76 notifications,
71 focus_handle,
77 focus_handle,
72 open_target,
78 open_target,
73 update: UpdateStatus::UpToDate,
79 update: UpdateStatus::UpToDate,
@@ -237,6 +243,10 @@ impl Render for AppShell {
237 let title_bar = render_title_bar(
243 let title_bar = render_title_bar(
238 &state.directory,
244 &state.directory,
239 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
245 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
246 cx.listener(|this, _, _, cx| {
247 this.notifications
248 .update(cx, |center, cx| center.open_settings(cx));
249 }),
240 );
250 );
241 div()
251 div()
242 .id("app-shell")
252 .id("app-shell")
crates/app/src/views/title_bar.rs +16 −1
@@ -5,7 +5,7 @@ use gpui_kit::component::{TitleBar, h_flex};
5 5 use gpui_kit::*;
6 6
7 7 use super::avatar::{person_avatar, with_presence};
8 use super::widgets::icon;
8 use super::widgets::{icon, symbol};
9 9 use crate::data::Directory;
10 10 use crate::theme;
11 11
@@ -26,7 +26,21 @@ fn app_icon() -> Arc<Image> {
26 26 pub fn render_title_bar(
27 27 directory: &Directory,
28 28 on_search: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
29 on_notifications: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
29 30 ) -> impl IntoElement {
31 let notifications = div()
32 .id("title-notifications")
33 .occlude()
34 .size(px(28.))
35 .flex()
36 .flex_none()
37 .items_center()
38 .justify_center()
39 .rounded(px(6.))
40 .cursor_pointer()
41 .hover(|button| button.bg(theme::surface()))
42 .child(symbol("notifications", 18., theme::text_muted()))
43 .on_click(on_notifications);
30 44 let search = h_flex()
31 45 .id("title-search")
32 46 .occlude()
@@ -88,6 +102,7 @@ pub fn render_title_bar(
88 102 .child(crate::APP_NAME),
89 103 )
90 104 .child(div().flex_1().flex().justify_center().child(search))
105 .child(notifications)
91 106 .children(own)
92 107 .child(div().w(px(4.))),
93 108 )
@@ -5,7 +5,7 @@ use gpui_kit::component::{TitleBar, h_flex};
5use gpui_kit::*;
5use gpui_kit::*;
6
6
7use super::avatar::{person_avatar, with_presence};
7use super::avatar::{person_avatar, with_presence};
8use super::widgets::icon;
8use super::widgets::{icon, symbol};
9use crate::data::Directory;
9use crate::data::Directory;
10use crate::theme;
10use crate::theme;
11
11
@@ -26,7 +26,21 @@ fn app_icon() -> Arc<Image> {
26pub fn render_title_bar(
26pub fn render_title_bar(
27 directory: &Directory,
27 directory: &Directory,
28 on_search: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
28 on_search: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
29 on_notifications: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
29) -> impl IntoElement {
30) -> impl IntoElement {
31 let notifications = div()
32 .id("title-notifications")
33 .occlude()
34 .size(px(28.))
35 .flex()
36 .flex_none()
37 .items_center()
38 .justify_center()
39 .rounded(px(6.))
40 .cursor_pointer()
41 .hover(|button| button.bg(theme::surface()))
42 .child(symbol("notifications", 18., theme::text_muted()))
43 .on_click(on_notifications);
30 let search = h_flex()
44 let search = h_flex()
31 .id("title-search")
45 .id("title-search")
32 .occlude()
46 .occlude()
@@ -88,6 +102,7 @@ pub fn render_title_bar(
88 .child(crate::APP_NAME),
102 .child(crate::APP_NAME),
89 )
103 )
90 .child(div().flex_1().flex().justify_center().child(search))
104 .child(div().flex_1().flex().justify_center().child(search))
105 .child(notifications)
91 .children(own)
106 .children(own)
92 .child(div().w(px(4.))),
107 .child(div().w(px(4.))),
93 )
108 )
scripts/window-shot.ps1 +37 −1
@@ -1,6 +1,7 @@
1 1 # Starts an exe, waits for its main window, saves it as PNG with PrintWindow flag 2 (CopyFromScreen is black for GPUI), stops it.
2 2 # Usage: powershell -ExecutionPolicy Bypass -File window-shot.ps1 -Exe C:\x\teams.exe -Out C:\x\shot.png [-Arguments "--demo"] [-WaitSeconds 6] [-Width 720 -Height 640] [-Keys "^k","plat"] [-PostKeys DOWN,ENTER]
3 3 # -Keys are SendKeys strings sent to the focused window before the shot.
4 # -AllWindows composes every visible top-level window of the process (toasts, pill) onto a primary-screen canvas.
4 5 # -PostKeys (UP, DOWN, ENTER, TAB, ESC, BACK or characters) go straight to the window as messages, no foreground needed.
5 6 param(
6 7 [Parameter(Mandatory = $true)][string]$Exe,
@@ -11,7 +12,8 @@ param(
11 12 [int]$Height = 0,
12 13 [string[]]$Keys = @(),
13 14 [string[]]$PostKeys = @(),
14 [switch]$KeepRunning
15 [switch]$KeepRunning,
16 [switch]$AllWindows
15 17 )
16 18 Add-Type -AssemblyName System.Drawing
17 19 Add-Type -AssemblyName System.Windows.Forms
@@ -23,6 +25,15 @@ public static class Shot {
23 25 [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr window, uint message, IntPtr wParam, IntPtr lParam);
24 26 [DllImport("user32.dll")] public static extern bool MoveWindow(IntPtr window, int x, int y, int width, int height, bool repaint);
25 27 [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr window, out RECT rect);
28 [DllImport("user32.dll")] static extern bool EnumWindows(EnumProc callback, IntPtr parameter);
29 [DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(IntPtr window, out uint processId);
30 [DllImport("user32.dll")] static extern bool IsWindowVisible(IntPtr window);
31 public delegate bool EnumProc(IntPtr window, IntPtr parameter);
32 public static System.Collections.Generic.List<IntPtr> VisibleWindowsOf(uint processId) {
33 var found = new System.Collections.Generic.List<IntPtr>();
34 EnumWindows((window, parameter) => { uint owner; GetWindowThreadProcessId(window, out owner); if (owner == processId && IsWindowVisible(window)) found.Add(window); return true; }, IntPtr.Zero);
35 return found;
36 }
26 37 [StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
27 38 }
28 39 '@
@@ -54,6 +65,31 @@ foreach ($key in ($PostKeys | ForEach-Object { $_ -split ',' })) {
54 65 Start-Sleep -Milliseconds 400
55 66 }
56 67 if ($PostKeys.Count -gt 0) { Start-Sleep -Seconds 1 }
68 if ($AllWindows) {
69 $screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
70 $canvas = New-Object System.Drawing.Bitmap $screen.Width, $screen.Height
71 $canvasGraphics = [System.Drawing.Graphics]::FromImage($canvas)
72 $canvasGraphics.Clear([System.Drawing.Color]::FromArgb(15, 15, 16))
73 $handles = [Shot]::VisibleWindowsOf([uint32]$process.Id) | Sort-Object { $_ -eq $process.MainWindowHandle } -Descending
74 foreach ($handle in $handles) {
75 $windowRect = New-Object Shot+RECT
76 [void][Shot]::GetWindowRect($handle, [ref]$windowRect)
77 $windowWidth = $windowRect.Right - $windowRect.Left; $windowHeight = $windowRect.Bottom - $windowRect.Top
78 if ($windowWidth -le 0 -or $windowHeight -le 0) { continue }
79 $part = New-Object System.Drawing.Bitmap $windowWidth, $windowHeight
80 $partGraphics = [System.Drawing.Graphics]::FromImage($part)
81 $partContext = $partGraphics.GetHdc()
82 [void][Shot]::PrintWindow($handle, $partContext, 2)
83 $partGraphics.ReleaseHdc($partContext)
84 $canvasGraphics.DrawImage($part, $windowRect.Left - $screen.Left, $windowRect.Top - $screen.Top)
85 $partGraphics.Dispose(); $part.Dispose()
86 }
87 $canvas.Save($Out, [System.Drawing.Imaging.ImageFormat]::Png)
88 $canvasGraphics.Dispose(); $canvas.Dispose()
89 Write-Output "saved $($screen.Width)x$($screen.Height) with $($handles.Count) windows"
90 if (-not $KeepRunning) { Stop-Process -Id $process.Id -Force }
91 exit 0
92 }
57 93 $rect = New-Object Shot+RECT
58 94 [void][Shot]::GetWindowRect($process.MainWindowHandle, [ref]$rect)
59 95 $width = $rect.Right - $rect.Left; $height = $rect.Bottom - $rect.Top
@@ -1,6 +1,7 @@
1# Starts an exe, waits for its main window, saves it as PNG with PrintWindow flag 2 (CopyFromScreen is black for GPUI), stops it.
1# Starts an exe, waits for its main window, saves it as PNG with PrintWindow flag 2 (CopyFromScreen is black for GPUI), stops it.
2# Usage: powershell -ExecutionPolicy Bypass -File window-shot.ps1 -Exe C:\x\teams.exe -Out C:\x\shot.png [-Arguments "--demo"] [-WaitSeconds 6] [-Width 720 -Height 640] [-Keys "^k","plat"] [-PostKeys DOWN,ENTER]
2# Usage: powershell -ExecutionPolicy Bypass -File window-shot.ps1 -Exe C:\x\teams.exe -Out C:\x\shot.png [-Arguments "--demo"] [-WaitSeconds 6] [-Width 720 -Height 640] [-Keys "^k","plat"] [-PostKeys DOWN,ENTER]
3# -Keys are SendKeys strings sent to the focused window before the shot.
3# -Keys are SendKeys strings sent to the focused window before the shot.
4# -AllWindows composes every visible top-level window of the process (toasts, pill) onto a primary-screen canvas.
4# -PostKeys (UP, DOWN, ENTER, TAB, ESC, BACK or characters) go straight to the window as messages, no foreground needed.
5# -PostKeys (UP, DOWN, ENTER, TAB, ESC, BACK or characters) go straight to the window as messages, no foreground needed.
5param(
6param(
6 [Parameter(Mandatory = $true)][string]$Exe,
7 [Parameter(Mandatory = $true)][string]$Exe,
@@ -11,7 +12,8 @@ param(
11 [int]$Height = 0,
12 [int]$Height = 0,
12 [string[]]$Keys = @(),
13 [string[]]$Keys = @(),
13 [string[]]$PostKeys = @(),
14 [string[]]$PostKeys = @(),
14 [switch]$KeepRunning
15 [switch]$KeepRunning,
16 [switch]$AllWindows
15)
17)
16Add-Type -AssemblyName System.Drawing
18Add-Type -AssemblyName System.Drawing
17Add-Type -AssemblyName System.Windows.Forms
19Add-Type -AssemblyName System.Windows.Forms
@@ -23,6 +25,15 @@ public static class Shot {
23 [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr window, uint message, IntPtr wParam, IntPtr lParam);
25 [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr window, uint message, IntPtr wParam, IntPtr lParam);
24 [DllImport("user32.dll")] public static extern bool MoveWindow(IntPtr window, int x, int y, int width, int height, bool repaint);
26 [DllImport("user32.dll")] public static extern bool MoveWindow(IntPtr window, int x, int y, int width, int height, bool repaint);
25 [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr window, out RECT rect);
27 [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr window, out RECT rect);
28 [DllImport("user32.dll")] static extern bool EnumWindows(EnumProc callback, IntPtr parameter);
29 [DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(IntPtr window, out uint processId);
30 [DllImport("user32.dll")] static extern bool IsWindowVisible(IntPtr window);
31 public delegate bool EnumProc(IntPtr window, IntPtr parameter);
32 public static System.Collections.Generic.List<IntPtr> VisibleWindowsOf(uint processId) {
33 var found = new System.Collections.Generic.List<IntPtr>();
34 EnumWindows((window, parameter) => { uint owner; GetWindowThreadProcessId(window, out owner); if (owner == processId && IsWindowVisible(window)) found.Add(window); return true; }, IntPtr.Zero);
35 return found;
36 }
26 [StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
37 [StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
27}
38}
28'@
39'@
@@ -54,6 +65,31 @@ foreach ($key in ($PostKeys | ForEach-Object { $_ -split ',' })) {
54 Start-Sleep -Milliseconds 400
65 Start-Sleep -Milliseconds 400
55}
66}
56if ($PostKeys.Count -gt 0) { Start-Sleep -Seconds 1 }
67if ($PostKeys.Count -gt 0) { Start-Sleep -Seconds 1 }
68if ($AllWindows) {
69 $screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
70 $canvas = New-Object System.Drawing.Bitmap $screen.Width, $screen.Height
71 $canvasGraphics = [System.Drawing.Graphics]::FromImage($canvas)
72 $canvasGraphics.Clear([System.Drawing.Color]::FromArgb(15, 15, 16))
73 $handles = [Shot]::VisibleWindowsOf([uint32]$process.Id) | Sort-Object { $_ -eq $process.MainWindowHandle } -Descending
74 foreach ($handle in $handles) {
75 $windowRect = New-Object Shot+RECT
76 [void][Shot]::GetWindowRect($handle, [ref]$windowRect)
77 $windowWidth = $windowRect.Right - $windowRect.Left; $windowHeight = $windowRect.Bottom - $windowRect.Top
78 if ($windowWidth -le 0 -or $windowHeight -le 0) { continue }
79 $part = New-Object System.Drawing.Bitmap $windowWidth, $windowHeight
80 $partGraphics = [System.Drawing.Graphics]::FromImage($part)
81 $partContext = $partGraphics.GetHdc()
82 [void][Shot]::PrintWindow($handle, $partContext, 2)
83 $partGraphics.ReleaseHdc($partContext)
84 $canvasGraphics.DrawImage($part, $windowRect.Left - $screen.Left, $windowRect.Top - $screen.Top)
85 $partGraphics.Dispose(); $part.Dispose()
86 }
87 $canvas.Save($Out, [System.Drawing.Imaging.ImageFormat]::Png)
88 $canvasGraphics.Dispose(); $canvas.Dispose()
89 Write-Output "saved $($screen.Width)x$($screen.Height) with $($handles.Count) windows"
90 if (-not $KeepRunning) { Stop-Process -Id $process.Id -Force }
91 exit 0
92}
57$rect = New-Object Shot+RECT
93$rect = New-Object Shot+RECT
58[void][Shot]::GetWindowRect($process.MainWindowHandle, [ref]$rect)
94[void][Shot]::GetWindowRect($process.MainWindowHandle, [ref]$rect)
59$width = $rect.Right - $rect.Left; $height = $rect.Bottom - $rect.Top
95$width = $rect.Right - $rect.Left; $height = $rect.Bottom - $rect.Top