Compare commits
12 Commits
16ab8e4207
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| dc85276567 | |||
| b7f9ac043d | |||
| a91949a2fd | |||
| 6364fdf1cd | |||
| edc425e28f | |||
| cafec90019 | |||
| d88501a872 | |||
| 2717dde5af | |||
| 9920bfcdee | |||
| 3ce2fa3841 | |||
| e63fd76d2f | |||
| e878b8120b |
651
Cargo.lock
generated
651
Cargo.lock
generated
@@ -21,6 +21,7 @@ dependencies = [
|
||||
name = "ai-desktop-app"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"feshared",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shared",
|
||||
@@ -47,6 +48,12 @@ dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
@@ -58,9 +65,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.100"
|
||||
version = "1.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
||||
checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea"
|
||||
|
||||
[[package]]
|
||||
name = "async-broadcast"
|
||||
@@ -216,6 +223,15 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atoi"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-waker"
|
||||
version = "1.1.2"
|
||||
@@ -305,6 +321,12 @@ version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@@ -557,6 +579,12 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.4.0"
|
||||
@@ -641,6 +669,21 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d"
|
||||
dependencies = [
|
||||
"crc-catalog",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc-catalog"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.0"
|
||||
@@ -659,6 +702,15 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
@@ -716,8 +768,11 @@ dependencies = [
|
||||
name = "daemon"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"directories",
|
||||
"genai",
|
||||
"shared",
|
||||
"sqlx",
|
||||
"tokio",
|
||||
"tonic",
|
||||
"tonic-reflection",
|
||||
@@ -758,6 +813,17 @@ dependencies = [
|
||||
"syn 2.0.114",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"pem-rfc7468",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.5.5"
|
||||
@@ -831,7 +897,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "directories"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -905,6 +982,12 @@ dependencies = [
|
||||
"syn 2.0.114",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dotenvy"
|
||||
version = "0.15.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||
|
||||
[[package]]
|
||||
name = "dpi"
|
||||
version = "0.1.2"
|
||||
@@ -946,6 +1029,9 @@ name = "either"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embed-resource"
|
||||
@@ -1030,6 +1116,17 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "etcetera"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"home",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "5.4.1"
|
||||
@@ -1077,6 +1174,13 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "feshared"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.6"
|
||||
@@ -1109,6 +1213,17 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"spin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
@@ -1215,6 +1330,17 @@ dependencies = [
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-intrusive"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"lock_api",
|
||||
"parking_lot",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.31"
|
||||
@@ -1660,6 +1786,8 @@ version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
@@ -1669,6 +1797,15 @@ version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
||||
|
||||
[[package]]
|
||||
name = "hashlink"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
@@ -1693,6 +1830,33 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "hkdf"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "html5ever"
|
||||
version = "0.29.1"
|
||||
@@ -2167,6 +2331,9 @@ name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
dependencies = [
|
||||
"spin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libappindicator"
|
||||
@@ -2208,6 +2375,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.12"
|
||||
@@ -2216,6 +2389,18 @@ checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"libc",
|
||||
"redox_syscall 0.7.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.30.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2294,6 +2479,16 @@ version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
||||
|
||||
[[package]]
|
||||
name = "md-5"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
@@ -2431,12 +2626,48 @@ dependencies = [
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint-dig"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libm",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-traits",
|
||||
"rand 0.8.5",
|
||||
"smallvec",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -2444,6 +2675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2769,7 +3001,7 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"redox_syscall 0.5.18",
|
||||
"smallvec",
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
@@ -2780,6 +3012,15 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.2"
|
||||
@@ -2974,6 +3215,27 @@ dependencies = [
|
||||
"futures-io",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs1"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"
|
||||
dependencies = [
|
||||
"der",
|
||||
"pkcs8",
|
||||
"spki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs8"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
|
||||
dependencies = [
|
||||
"der",
|
||||
"spki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.32"
|
||||
@@ -3406,6 +3668,15 @@ dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
@@ -3558,6 +3829,26 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rsa"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"digest",
|
||||
"num-bigint-dig",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"pkcs1",
|
||||
"pkcs8",
|
||||
"rand_core 0.6.4",
|
||||
"signature",
|
||||
"spki",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.1"
|
||||
@@ -3969,6 +4260,17 @@ dependencies = [
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.9"
|
||||
@@ -4007,6 +4309,16 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.8"
|
||||
@@ -4036,6 +4348,9 @@ name = "smallvec"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
@@ -4062,7 +4377,7 @@ dependencies = [
|
||||
"objc2-foundation",
|
||||
"objc2-quartz-core",
|
||||
"raw-window-handle",
|
||||
"redox_syscall",
|
||||
"redox_syscall 0.5.18",
|
||||
"tracing",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
@@ -4095,6 +4410,213 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spki"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"der",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc"
|
||||
dependencies = [
|
||||
"sqlx-core",
|
||||
"sqlx-macros",
|
||||
"sqlx-mysql",
|
||||
"sqlx-postgres",
|
||||
"sqlx-sqlite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-core"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"crc",
|
||||
"crossbeam-queue",
|
||||
"either",
|
||||
"event-listener",
|
||||
"futures-core",
|
||||
"futures-intrusive",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"hashbrown 0.15.5",
|
||||
"hashlink",
|
||||
"indexmap 2.13.0",
|
||||
"log",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-macros"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"sqlx-core",
|
||||
"sqlx-macros-core",
|
||||
"syn 2.0.114",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-macros-core"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b"
|
||||
dependencies = [
|
||||
"dotenvy",
|
||||
"either",
|
||||
"heck 0.5.0",
|
||||
"hex",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"sqlx-core",
|
||||
"sqlx-mysql",
|
||||
"sqlx-postgres",
|
||||
"sqlx-sqlite",
|
||||
"syn 2.0.114",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-mysql"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526"
|
||||
dependencies = [
|
||||
"atoi",
|
||||
"base64 0.22.1",
|
||||
"bitflags 2.10.0",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"crc",
|
||||
"digest",
|
||||
"dotenvy",
|
||||
"either",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"generic-array",
|
||||
"hex",
|
||||
"hkdf",
|
||||
"hmac",
|
||||
"itoa",
|
||||
"log",
|
||||
"md-5",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"rand 0.8.5",
|
||||
"rsa",
|
||||
"serde",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"sqlx-core",
|
||||
"stringprep",
|
||||
"thiserror 2.0.18",
|
||||
"tracing",
|
||||
"whoami",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-postgres"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46"
|
||||
dependencies = [
|
||||
"atoi",
|
||||
"base64 0.22.1",
|
||||
"bitflags 2.10.0",
|
||||
"byteorder",
|
||||
"crc",
|
||||
"dotenvy",
|
||||
"etcetera",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"hkdf",
|
||||
"hmac",
|
||||
"home",
|
||||
"itoa",
|
||||
"log",
|
||||
"md-5",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"sqlx-core",
|
||||
"stringprep",
|
||||
"thiserror 2.0.18",
|
||||
"tracing",
|
||||
"whoami",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx-sqlite"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea"
|
||||
dependencies = [
|
||||
"atoi",
|
||||
"flume",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-intrusive",
|
||||
"futures-util",
|
||||
"libsqlite3-sys",
|
||||
"log",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"serde_urlencoded",
|
||||
"sqlx-core",
|
||||
"thiserror 2.0.18",
|
||||
"tracing",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.1"
|
||||
@@ -4126,6 +4648,17 @@ dependencies = [
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stringprep"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
|
||||
dependencies = [
|
||||
"unicode-bidi",
|
||||
"unicode-normalization",
|
||||
"unicode-properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
@@ -4966,6 +5499,7 @@ version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
@@ -5089,12 +5623,33 @@ version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-properties"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.12.0"
|
||||
@@ -5173,6 +5728,12 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.1"
|
||||
@@ -5245,6 +5806,12 @@ dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasite"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.108"
|
||||
@@ -5439,6 +6006,16 @@ dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "whoami"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d"
|
||||
dependencies = [
|
||||
"libredox",
|
||||
"wasite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
@@ -5644,6 +6221,15 @@ dependencies = [
|
||||
"windows-targets 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
@@ -5695,6 +6281,21 @@ dependencies = [
|
||||
"windows_x86_64_msvc 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
@@ -5752,6 +6353,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
@@ -5770,6 +6377,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
@@ -5788,6 +6401,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
@@ -5818,6 +6437,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
@@ -5836,6 +6461,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
@@ -5854,6 +6485,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
@@ -5872,6 +6509,12 @@ version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
[workspace]
|
||||
members = ["frontend/src-tauri", "crates/shared", "crates/daemon"]
|
||||
members = ["frontend/src-tauri", "crates/shared", "crates/daemon", "crates/feshared"]
|
||||
resolver = "2"
|
||||
|
||||
@@ -4,8 +4,11 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.101"
|
||||
directories = "6.0.0"
|
||||
genai = "0.5.3"
|
||||
shared = { path = "../shared" }
|
||||
sqlx = { version = "0.8.6", features = ["runtime-tokio", "sqlite", "macros"] }
|
||||
tokio = { version = "1.49.0", features = ["full"] }
|
||||
tonic = "0.14.2"
|
||||
tonic-reflection = "0.14.2"
|
||||
|
||||
12
crates/daemon/migrations/20260222_1_init.sql
Normal file
12
crates/daemon/migrations/20260222_1_init.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
chat_id INTEGER NOT NULL,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
text TEXT NOT NULL,
|
||||
is_user BOOL NOT NULL,
|
||||
|
||||
UNIQUE(id, chat_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_message_timestamp ON messages(timestamp);
|
||||
CREATE INDEX idx_message_chat_id ON messages(chat_id);
|
||||
133
crates/daemon/src/chatpersistence.rs
Normal file
133
crates/daemon/src/chatpersistence.rs
Normal file
@@ -0,0 +1,133 @@
|
||||
use anyhow::Result;
|
||||
use directories::ProjectDirs;
|
||||
use sqlx::sqlite::SqliteConnectOptions;
|
||||
use sqlx::{Row, SqlitePool};
|
||||
use tokio::fs;
|
||||
use tonic::async_trait;
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct ChatMessageData {
|
||||
pub id: i64,
|
||||
pub chat_id: i64,
|
||||
pub text: String,
|
||||
pub is_user: bool,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait ChatRepository {
|
||||
async fn save_message(
|
||||
&self,
|
||||
text: &str,
|
||||
is_user: &bool,
|
||||
chat_id: &i64,
|
||||
) -> Result<ChatMessageData>;
|
||||
async fn get_latest_messages(&self, chat_id: &i64, count: &i64)
|
||||
-> Result<Vec<ChatMessageData>>;
|
||||
async fn get_chat_ids(&self) -> Result<Box<[i64]>>;
|
||||
}
|
||||
|
||||
pub struct SqliteChatRepository {
|
||||
pool: SqlitePool,
|
||||
}
|
||||
|
||||
impl SqliteChatRepository {
|
||||
pub async fn new() -> Result<Self> {
|
||||
let project_dirs = ProjectDirs::from("com", "jarno", "wsagent")
|
||||
.ok_or_else(|| anyhow::anyhow!("Could not find home directory!"))?;
|
||||
let config_dir = project_dirs.config_dir();
|
||||
fs::create_dir_all(config_dir).await?;
|
||||
let db_path = config_dir.join("agent.db");
|
||||
let connection_str = format!("sqlite:{}", db_path.display());
|
||||
println!("Connection string: {}", connection_str);
|
||||
|
||||
let pool = SqlitePool::connect_with(
|
||||
SqliteConnectOptions::new()
|
||||
.filename(&db_path)
|
||||
.create_if_missing(true),
|
||||
)
|
||||
.await?;
|
||||
|
||||
sqlx::migrate!("./migrations")
|
||||
.run(&pool)
|
||||
.await
|
||||
.inspect_err(|e| eprintln!("Migration failed! {}", e))?;
|
||||
|
||||
Ok(Self { pool })
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ChatRepository for SqliteChatRepository {
|
||||
async fn save_message(
|
||||
&self,
|
||||
text: &str,
|
||||
is_user: &bool,
|
||||
chat_id: &i64,
|
||||
) -> Result<ChatMessageData> {
|
||||
let result = sqlx::query_as::<_, ChatMessageData>(
|
||||
r#"
|
||||
INSERT INTO messages (text, is_user, chat_id)
|
||||
VALUES (?, ?, ?)
|
||||
RETURNING id, chat_id, text, is_user
|
||||
"#,
|
||||
)
|
||||
.bind(text)
|
||||
.bind(is_user)
|
||||
.bind(chat_id)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.inspect_err(|e| println!("sql error: {}", e))?;
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
async fn get_latest_messages(
|
||||
&self,
|
||||
chat_id: &i64,
|
||||
count: &i64,
|
||||
) -> Result<Vec<ChatMessageData>> {
|
||||
// From all chat ids get the latest id.
|
||||
let rows = sqlx::query(
|
||||
format!(
|
||||
r#"
|
||||
SELECT * FROM (
|
||||
SELECT id, chat_id, text, is_user
|
||||
FROM messages
|
||||
WHERE chat_id = {chat_id}
|
||||
ORDER BY id DESC
|
||||
LIMIT {count}
|
||||
) AS subquery ORDER BY id ASC;"#
|
||||
)
|
||||
.as_str(),
|
||||
)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.inspect_err(|e| println!("sql error: {}", e))?;
|
||||
|
||||
let messages = rows
|
||||
.into_iter()
|
||||
.map(|row| ChatMessageData {
|
||||
id: row.get(0),
|
||||
chat_id: row.get(1),
|
||||
text: row.get(2),
|
||||
is_user: row.get(3),
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(messages)
|
||||
}
|
||||
|
||||
async fn get_chat_ids(&self) -> Result<Box<[i64]>> {
|
||||
let rows = sqlx::query("SELECT DISTINCT(chat_id) FROM messages ORDER BY chat_id DESC")
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.inspect_err(|e| println!("sql error: {}", e))?;
|
||||
let ids: Vec<i64> = rows
|
||||
.into_iter()
|
||||
.map(|row| {
|
||||
let i: i64 = row.get(0);
|
||||
i
|
||||
})
|
||||
.collect();
|
||||
Ok(ids.into_boxed_slice())
|
||||
}
|
||||
}
|
||||
148
crates/daemon/src/daemongrpc.rs
Normal file
148
crates/daemon/src/daemongrpc.rs
Normal file
@@ -0,0 +1,148 @@
|
||||
use crate::chatpersistence::{ChatMessageData, ChatRepository};
|
||||
use anyhow::Result;
|
||||
use genai::chat::{ChatMessage, ChatRequest};
|
||||
use genai::Client;
|
||||
use shared::ai::ai_service_server::AiService;
|
||||
use shared::ai::{
|
||||
ChatHistoryRequest, ChatHistoryResponse, ChatMessage as CMessage, ChatRequest as CRequest,
|
||||
ChatResponse as CResponse, DaemonStatusRequest, DaemonStatusResponse,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tonic::{Code, Request, Response, Status};
|
||||
|
||||
pub struct DaemonServer {
|
||||
repo: Arc<dyn ChatRepository + Send + Sync>,
|
||||
client: Client,
|
||||
}
|
||||
|
||||
impl DaemonServer {
|
||||
pub fn new(repo: Arc<dyn ChatRepository + Send + Sync>, client: Client) -> Self {
|
||||
Self {
|
||||
repo: repo,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl AiService for DaemonServer {
|
||||
async fn chat(&self, request: Request<CRequest>) -> Result<Response<CResponse>, Status> {
|
||||
let r = request.into_inner();
|
||||
let chat_id = id_or_new(self.repo.clone(), r.chat_id)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
let mut messages = gather_history(self.repo.clone(), &chat_id)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
messages.push(ChatMessage::user(r.text()));
|
||||
let model = "llama3.2:latest";
|
||||
let response = self
|
||||
.client
|
||||
.exec_chat(model, ChatRequest::new(messages), None)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
|
||||
let user_message = message_to_dto(
|
||||
&self
|
||||
.repo
|
||||
.save_message(r.text(), &true, &chat_id)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?,
|
||||
);
|
||||
let response_text = match response.first_text() {
|
||||
Some(t) => t,
|
||||
None => "[No response from AI]",
|
||||
};
|
||||
|
||||
println!("User: {}", r.text());
|
||||
println!("AI: {}", response_text);
|
||||
|
||||
let ai_message = message_to_dto(
|
||||
&self
|
||||
.repo
|
||||
.save_message(response_text, &false, &chat_id)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?,
|
||||
);
|
||||
let response = CResponse {
|
||||
chat_id: ai_message.chat_id,
|
||||
messages: vec![user_message, ai_message],
|
||||
};
|
||||
return Ok(Response::new(response));
|
||||
}
|
||||
|
||||
async fn chat_history(
|
||||
&self,
|
||||
request: Request<ChatHistoryRequest>,
|
||||
) -> Result<Response<ChatHistoryResponse>, Status> {
|
||||
let chat_id = get_latest_chat_id(self.repo.clone(), request.into_inner().chat_id)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
let messages = self
|
||||
.repo
|
||||
.get_latest_messages(&chat_id, &20)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
|
||||
let response = ChatHistoryResponse {
|
||||
chat_id: chat_id,
|
||||
history: messages.iter().map(|m| message_to_dto(m)).collect(),
|
||||
};
|
||||
Ok(Response::new(response))
|
||||
}
|
||||
|
||||
async fn daemon_status(
|
||||
&self,
|
||||
_: Request<DaemonStatusRequest>,
|
||||
) -> Result<Response<DaemonStatusResponse>, Status> {
|
||||
let status = DaemonStatusResponse {
|
||||
is_ok: true,
|
||||
message: None,
|
||||
error: None,
|
||||
};
|
||||
Ok(Response::new(status))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn message_to_dto(msg: &ChatMessageData) -> CMessage {
|
||||
CMessage {
|
||||
id: msg.id,
|
||||
chat_id: msg.chat_id,
|
||||
text: msg.text.clone(),
|
||||
is_user: msg.is_user,
|
||||
}
|
||||
}
|
||||
|
||||
async fn gather_history(
|
||||
repo: Arc<dyn ChatRepository + Send + Sync>,
|
||||
chat_id: &i64,
|
||||
) -> Result<Vec<ChatMessage>> {
|
||||
let messages = repo.get_latest_messages(chat_id, &10).await?;
|
||||
Ok(messages
|
||||
.iter()
|
||||
.map(|m| match m.is_user {
|
||||
true => ChatMessage::assistant(m.text.clone()),
|
||||
false => ChatMessage::user(m.text.clone()),
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
async fn get_latest_chat_id(
|
||||
repo: Arc<dyn ChatRepository + Send + Sync>,
|
||||
chat_id: Option<i64>,
|
||||
) -> Result<i64> {
|
||||
Ok(match chat_id {
|
||||
Some(i) => i,
|
||||
None => repo.get_chat_ids().await?.get(0).copied().unwrap_or(0),
|
||||
})
|
||||
}
|
||||
|
||||
async fn id_or_new(
|
||||
repo: Arc<dyn ChatRepository + Send + Sync>,
|
||||
chat_id: Option<i64>,
|
||||
) -> Result<i64> {
|
||||
Ok(match chat_id {
|
||||
Some(i) => i,
|
||||
None => repo.get_chat_ids().await?.get(0).copied().unwrap_or(0) + 1,
|
||||
})
|
||||
}
|
||||
@@ -1,56 +1,30 @@
|
||||
use genai::chat::{ChatMessage, ChatRequest};
|
||||
mod chatpersistence;
|
||||
mod daemongrpc;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use genai::Client;
|
||||
use shared::ai::ai_daemon_server::{AiDaemon, AiDaemonServer};
|
||||
use shared::ai::{PromptRequest, PromptResponse};
|
||||
use tonic::{transport::Server, Request, Response, Status};
|
||||
use shared::ai::ai_service_server::AiServiceServer;
|
||||
use tonic::transport::Server;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DaemonServer {}
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl AiDaemon for DaemonServer {
|
||||
async fn prompt(
|
||||
&self,
|
||||
request: Request<PromptRequest>,
|
||||
) -> Result<Response<PromptResponse>, Status> {
|
||||
let remote_a = request.remote_addr();
|
||||
let prompt_value = request.into_inner().prompt;
|
||||
println!("Request from {:?}: {:?}", remote_a, prompt_value);
|
||||
let client = Client::default();
|
||||
let response = prompt_ollama(&client, "llama3.2", prompt_value.as_str())
|
||||
.await
|
||||
.unwrap_or_else(|err| format!("Prompt error: {}", err));
|
||||
println!("Respone: {}", response);
|
||||
let reply = PromptResponse { response: response };
|
||||
Ok(Response::new(reply))
|
||||
}
|
||||
}
|
||||
|
||||
async fn prompt_ollama(
|
||||
client: &Client,
|
||||
model: &str,
|
||||
prompt: &str,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let chat_req = ChatRequest::new(vec![ChatMessage::user(prompt)]);
|
||||
let chat_res = client.exec_chat(model, chat_req, None).await?;
|
||||
let output = chat_res
|
||||
.first_text()
|
||||
.unwrap_or("No response content!")
|
||||
.to_string();
|
||||
Ok(output)
|
||||
}
|
||||
use chatpersistence::SqliteChatRepository;
|
||||
use daemongrpc::DaemonServer;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let chat_repo = SqliteChatRepository::new().await?;
|
||||
|
||||
let client = Client::default();
|
||||
|
||||
let addr_s = "[::1]:50051";
|
||||
let addr = addr_s.parse().unwrap();
|
||||
let daemon = DaemonServer::default();
|
||||
let daemon = DaemonServer::new(Arc::new(chat_repo), client);
|
||||
let reflection_service = tonic_reflection::server::Builder::configure()
|
||||
.register_encoded_file_descriptor_set(shared::ai::FILE_DESCRIPTOR_SET)
|
||||
.build_v1()?;
|
||||
println!("Started daemon at {}", addr_s);
|
||||
Server::builder()
|
||||
.add_service(AiDaemonServer::new(daemon))
|
||||
.add_service(AiServiceServer::new(daemon))
|
||||
.add_service(reflection_service)
|
||||
.serve(addr)
|
||||
.await?;
|
||||
|
||||
7
crates/feshared/Cargo.toml
Normal file
7
crates/feshared/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "feshared"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
49
crates/feshared/src/lib.rs
Normal file
49
crates/feshared/src/lib.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
pub mod chatmessage {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Message {
|
||||
pub id: i64,
|
||||
pub text: String,
|
||||
pub is_user: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct MessageHistory {
|
||||
pub chat_id: Option<i64>,
|
||||
pub history: Vec<Message>,
|
||||
}
|
||||
|
||||
pub enum TauriCommand {
|
||||
Chat,
|
||||
SetChatId,
|
||||
ChatHistory,
|
||||
DaemonState,
|
||||
ToggleDarkMode,
|
||||
TogglePopup,
|
||||
}
|
||||
|
||||
impl TauriCommand {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
TauriCommand::TogglePopup => "toggle_popup",
|
||||
TauriCommand::Chat => "chat",
|
||||
TauriCommand::SetChatId => "set_chat_id",
|
||||
TauriCommand::ChatHistory => "chat_history",
|
||||
TauriCommand::DaemonState => "daemon_state",
|
||||
TauriCommand::ToggleDarkMode => "toggle_dark_mode",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod daemon {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct DaemonState {
|
||||
pub is_ok: bool,
|
||||
pub message: Option<String>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,43 @@
|
||||
syntax = "proto3";
|
||||
package ai_daemon;
|
||||
|
||||
service AiDaemon {
|
||||
rpc Prompt (PromptRequest) returns (PromptResponse);
|
||||
service AiService {
|
||||
rpc Chat(ChatRequest) returns (ChatResponse);
|
||||
rpc ChatHistory(ChatHistoryRequest) returns (ChatHistoryResponse);
|
||||
rpc DaemonStatus(DaemonStatusRequest) returns (DaemonStatusResponse);
|
||||
}
|
||||
|
||||
message PromptRequest {
|
||||
string prompt = 1;
|
||||
message ChatMessage {
|
||||
int64 id = 1;
|
||||
int64 chat_id = 2;
|
||||
string text = 10;
|
||||
bool is_user = 20;
|
||||
}
|
||||
|
||||
message PromptResponse {
|
||||
string response = 1;
|
||||
message ChatResponse {
|
||||
int64 chat_id = 2;
|
||||
repeated ChatMessage messages = 10;
|
||||
}
|
||||
|
||||
message ChatRequest {
|
||||
optional int64 chat_id = 1;
|
||||
optional string text = 10;
|
||||
}
|
||||
|
||||
message ChatHistoryRequest {
|
||||
// If not set last chat is returned
|
||||
optional int64 chat_id = 1;
|
||||
}
|
||||
|
||||
message ChatHistoryResponse {
|
||||
int64 chat_id = 1;
|
||||
repeated ChatMessage history = 10;
|
||||
}
|
||||
|
||||
message DaemonStatusRequest {}
|
||||
|
||||
message DaemonStatusResponse {
|
||||
bool is_ok = 1;
|
||||
optional string message = 10;
|
||||
optional string error = 20;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod ai {
|
||||
tonic::include_proto!("ai_daemon");
|
||||
|
||||
pub const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("ai_service_descriptor");
|
||||
}
|
||||
pub const FILE_DESCRIPTOR_SET: &[u8] =
|
||||
tonic::include_file_descriptor_set!("ai_service_descriptor");
|
||||
}
|
||||
|
||||
9
frontend/Cargo.lock
generated
9
frontend/Cargo.lock
generated
@@ -21,6 +21,7 @@ dependencies = [
|
||||
name = "ai-desktop-app"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"feshared",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shared",
|
||||
@@ -37,6 +38,7 @@ name = "ai-desktop-app-ui"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"feshared",
|
||||
"js-sys",
|
||||
"leptos",
|
||||
"leptos_router",
|
||||
@@ -1159,6 +1161,13 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "feshared"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.6"
|
||||
|
||||
@@ -14,6 +14,7 @@ serde-wasm-bindgen = "0.6"
|
||||
console_error_panic_hook = "0.1.7"
|
||||
leptos_router = "0.8.11"
|
||||
serde_json = "1.0.149"
|
||||
feshared = {path = "../crates/feshared"}
|
||||
|
||||
[workspace]
|
||||
members = ["src-tauri"]
|
||||
|
||||
@@ -23,6 +23,7 @@ tauri-plugin-opener = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
shared = { path = "../../crates/shared" }
|
||||
feshared = { path = "../../crates/feshared" }
|
||||
tonic = "0.14.2"
|
||||
tokio = "1.49.0"
|
||||
|
||||
|
||||
@@ -3,8 +3,5 @@
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default"
|
||||
]
|
||||
"permissions": ["core:default", "opener:default"]
|
||||
}
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
{
|
||||
"identifier": "desktop-capability",
|
||||
"platforms": [
|
||||
"macOS",
|
||||
"windows",
|
||||
"linux"
|
||||
],
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"global-shortcut:default"
|
||||
]
|
||||
}
|
||||
"platforms": ["macOS", "windows", "linux"],
|
||||
"windows": ["main", "dashboard", "popup"],
|
||||
"permissions": ["global-shortcut:default", "core:event:allow-listen"]
|
||||
}
|
||||
|
||||
150
frontend/src-tauri/src/commands.rs
Normal file
150
frontend/src-tauri/src/commands.rs
Normal file
@@ -0,0 +1,150 @@
|
||||
use serde::Serialize;
|
||||
use tauri::{Emitter, Manager, State};
|
||||
|
||||
use feshared::{
|
||||
chatmessage::{Message, MessageHistory},
|
||||
daemon::DaemonState,
|
||||
};
|
||||
use shared::ai::{ChatHistoryRequest, ChatRequest, DaemonStatusRequest};
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn toggle_popup(app_handle: tauri::AppHandle) {
|
||||
match app_handle.get_webview_window("popup") {
|
||||
Some(window) => {
|
||||
let is_visible = window.is_visible().unwrap_or(false);
|
||||
if is_visible {
|
||||
window.hide().unwrap();
|
||||
} else {
|
||||
window.show().unwrap();
|
||||
window.set_focus().unwrap();
|
||||
let _ = window.emit("window-focused", ());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
println!("ERROR: Window with label 'popup' not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn chat(state: State<'_, AppState>, prompt: String) -> Result<Vec<Message>, String> {
|
||||
let mut client = state.grpc_client.lock().await;
|
||||
let cid = state.current_chat_id.lock().await.clone();
|
||||
let request = tonic::Request::new(ChatRequest {
|
||||
chat_id: cid,
|
||||
text: Some(prompt),
|
||||
});
|
||||
match client.chat(request).await {
|
||||
Ok(response) => {
|
||||
let r = response.into_inner();
|
||||
let mut cid = state.current_chat_id.lock().await;
|
||||
*cid = Some(r.chat_id);
|
||||
println!("CID={}", r.chat_id);
|
||||
r.messages.iter().for_each(|m| {
|
||||
if m.is_user {
|
||||
println!(">>> {}", m.text)
|
||||
} else {
|
||||
println!("<<< {}", m.text)
|
||||
}
|
||||
});
|
||||
Ok(r.messages
|
||||
.iter()
|
||||
.map(|msg| Message {
|
||||
id: msg.id,
|
||||
text: msg.text.clone(),
|
||||
is_user: msg.is_user,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
Err(e) => {
|
||||
println!("gRPC error: {}", e);
|
||||
Err(format!("gRPC error: {}", e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_chat_id(
|
||||
state: State<'_, AppState>,
|
||||
chat_id: Option<i64>,
|
||||
) -> Result<Option<i64>, String> {
|
||||
let mut cid = state.current_chat_id.lock().await;
|
||||
*cid = chat_id;
|
||||
Ok(chat_id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn chat_history(state: State<'_, AppState>) -> Result<MessageHistory, String> {
|
||||
let mut client = state.grpc_client.lock().await;
|
||||
let chat_id = state.current_chat_id.lock().await.clone();
|
||||
let result = client
|
||||
.chat_history(ChatHistoryRequest { chat_id: chat_id })
|
||||
.await;
|
||||
match result {
|
||||
Ok(response) => {
|
||||
let r = response.into_inner();
|
||||
let mut cid = state.current_chat_id.lock().await;
|
||||
*cid = Some(r.chat_id);
|
||||
println!("CID={}", r.chat_id);
|
||||
Ok(MessageHistory {
|
||||
chat_id: Some(r.chat_id),
|
||||
history: r
|
||||
.history
|
||||
.iter()
|
||||
.map(|m| Message {
|
||||
id: m.id,
|
||||
is_user: m.is_user,
|
||||
text: m.text.clone(),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Err(e) => Err(format!("gRPC error: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn daemon_state(state: State<'_, AppState>) -> Result<DaemonState, String> {
|
||||
let mut client = state.grpc_client.lock().await;
|
||||
let result = client.daemon_status(DaemonStatusRequest {}).await;
|
||||
match result {
|
||||
Ok(status) => {
|
||||
let status_inner = status.into_inner();
|
||||
Ok(DaemonState {
|
||||
is_ok: status_inner.is_ok,
|
||||
message: Some(status_inner.message.unwrap_or(String::from("Daemon OK"))),
|
||||
error: status_inner.error,
|
||||
})
|
||||
}
|
||||
Err(e) => Ok(DaemonState {
|
||||
is_ok: false,
|
||||
message: None,
|
||||
error: Some(e.message().to_string()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
struct DarkMode {
|
||||
is_dark_mode: bool,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn toggle_dark_mode(
|
||||
state: State<'_, AppState>,
|
||||
handle: tauri::AppHandle,
|
||||
) -> Result<bool, String> {
|
||||
let mut config = state.config.lock().await;
|
||||
config.dark_mode = !config.dark_mode;
|
||||
handle
|
||||
.emit(
|
||||
"dark-mode-changed",
|
||||
DarkMode {
|
||||
is_dark_mode: config.dark_mode,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
Ok(config.dark_mode)
|
||||
}
|
||||
@@ -1,62 +1,44 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
mod commands;
|
||||
|
||||
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use tauri::{Emitter, Manager, State, WindowEvent};
|
||||
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
|
||||
use commands::{chat, chat_history, daemon_state, set_chat_id, toggle_dark_mode, toggle_popup};
|
||||
use shared::ai::ai_service_client::AiServiceClient;
|
||||
|
||||
use shared::ai::{ai_daemon_client::AiDaemonClient, PromptRequest};
|
||||
|
||||
struct AppState {
|
||||
grpc_client: Mutex<AiDaemonClient<tonic::transport::Channel>>,
|
||||
pub struct AppConfig {
|
||||
dark_mode: bool,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn toggle_popup(app_handle: tauri::AppHandle) {
|
||||
match app_handle.get_webview_window("popup") {
|
||||
Some(window) => {
|
||||
let is_visible = window.is_visible().unwrap_or(false);
|
||||
if is_visible {
|
||||
window.hide().unwrap();
|
||||
} else {
|
||||
window.show().unwrap();
|
||||
window.set_focus().unwrap();
|
||||
let _ = window.emit("window-focused", ());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
println!("ERROR: Window with label 'popup' not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn prompt_llm(state: State<'_, AppState>, prompt: String) -> Result<String, String> {
|
||||
println!(">>>> {}", prompt);
|
||||
let mut client = state.grpc_client.lock().await;
|
||||
let request = tonic::Request::new(PromptRequest { prompt });
|
||||
match client.prompt(request).await {
|
||||
Ok(response) => Ok(response.into_inner().response),
|
||||
Err(e) => Err(format!("gRPC error: {}", e)),
|
||||
}
|
||||
pub struct AppState {
|
||||
grpc_client: Mutex<AiServiceClient<tonic::transport::Channel>>,
|
||||
config: Mutex<AppConfig>,
|
||||
current_chat_id: Mutex<Option<i64>>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let channel = tonic::transport::Channel::from_static("http://[::1]:50051")
|
||||
.connect()
|
||||
.await
|
||||
.expect("Could not connect to daemon!");
|
||||
|
||||
let client = AiDaemonClient::new(channel);
|
||||
let channel = tonic::transport::Channel::from_static("http://[::1]:50051").connect_lazy();
|
||||
let client = AiServiceClient::new(channel);
|
||||
|
||||
tauri::Builder::default()
|
||||
.manage(AppState {
|
||||
grpc_client: Mutex::new(client),
|
||||
config: Mutex::new(AppConfig { dark_mode: true }),
|
||||
current_chat_id: Mutex::new(None),
|
||||
})
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.invoke_handler(tauri::generate_handler![toggle_popup, prompt_llm])
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
toggle_popup,
|
||||
chat_history,
|
||||
set_chat_id,
|
||||
chat,
|
||||
daemon_state,
|
||||
toggle_dark_mode,
|
||||
])
|
||||
.setup(|app| {
|
||||
/* Auto-hide popup when focus is lost
|
||||
if let Some(window) = app.get_webview_window("popup") {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
"label": "popup",
|
||||
"title": "AI Quick Action",
|
||||
"url": "/popup",
|
||||
"width": 800,
|
||||
"height": 400,
|
||||
"width": 960,
|
||||
"height": 720,
|
||||
"decorations": false,
|
||||
"transparent": true,
|
||||
"alwaysOnTop": true,
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
use crate::bridge::invoke;
|
||||
use crate::popup::Popup;
|
||||
use std::time::Duration;
|
||||
|
||||
use feshared::{chatmessage::TauriCommand, daemon::DaemonState};
|
||||
use leptos::{prelude::*, reactive::spawn_local};
|
||||
use leptos_router::{
|
||||
components::{Route, Router, Routes},
|
||||
path,
|
||||
};
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
use crate::popup::PopupView;
|
||||
use crate::{bridge::invoke_js, components::DarkModeToggle};
|
||||
use crate::{
|
||||
bridge::invoke_typed,
|
||||
components::{DaemonProvider, ThemeProvider},
|
||||
};
|
||||
|
||||
pub const BTN_PRIMARY: &str = "bg-slate-300 hover:bg-slate-400 dark:bg-slate-800 hover:dark-bg-slate-700 px-4 py-2 rounded-md";
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
@@ -12,7 +23,7 @@ pub fn App() -> impl IntoView {
|
||||
<Router>
|
||||
<Routes fallback=|| view! { "Page not found."}>
|
||||
<Route path=path!("/") view=Dashboard />
|
||||
<Route path=path!("/popup") view=Popup />
|
||||
<Route path=path!("/popup") view=PopupView />
|
||||
</Routes>
|
||||
</Router>
|
||||
}
|
||||
@@ -23,22 +34,62 @@ fn Dashboard() -> impl IntoView {
|
||||
let on_click = move |_ev: leptos::ev::MouseEvent| {
|
||||
spawn_local(async move {
|
||||
let empty_args = serde_wasm_bindgen::to_value(&serde_json::json!({})).unwrap();
|
||||
invoke("toggle_popup", empty_args).await;
|
||||
});
|
||||
};
|
||||
let prompt = |_ev: leptos::ev::MouseEvent| {
|
||||
spawn_local(async {
|
||||
let prompt =
|
||||
serde_wasm_bindgen::to_value(&serde_json::json!({"prompt": "jee juu juu"}))
|
||||
.unwrap();
|
||||
invoke("prompt_llm", prompt).await;
|
||||
invoke_js(TauriCommand::TogglePopup, empty_args).await;
|
||||
});
|
||||
};
|
||||
view! {
|
||||
<main class="window-shell opaque-bg">
|
||||
<h1>"AI Dashboard"</h1>
|
||||
<button on:click=on_click>Test popup</button>
|
||||
<button on:click=prompt>Prompt!</button>
|
||||
</main>
|
||||
<ThemeProvider>
|
||||
<DaemonProvider>
|
||||
<div class="min-h-screen w-screen bg-white dark:bg-zinc-900 text-gray-950 dark:text-white">
|
||||
<button class=BTN_PRIMARY on:click=on_click>Open chat</button>
|
||||
</div>
|
||||
</DaemonProvider>
|
||||
<div class="fixed bottom-0 right-0 p-2">
|
||||
<DarkModeToggle />
|
||||
</div>
|
||||
</ThemeProvider>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn DaemonStatusIndicator() -> impl IntoView {
|
||||
let (poll_count, set_pool_count) = signal(0);
|
||||
set_interval(
|
||||
move || set_pool_count.update(|v| *v += 1),
|
||||
Duration::from_secs(1),
|
||||
);
|
||||
let status = LocalResource::new(move || async move {
|
||||
poll_count.get();
|
||||
let s: DaemonState = invoke_typed(TauriCommand::DaemonState, JsValue::NULL).await;
|
||||
s
|
||||
});
|
||||
|
||||
let f = |state: Option<DaemonState>| {
|
||||
let color = match state.clone() {
|
||||
Some(s) => match s.is_ok {
|
||||
true => "bg-green-600",
|
||||
false => "bg-red-600",
|
||||
},
|
||||
None => "bg-yellow-600",
|
||||
};
|
||||
let text = match state {
|
||||
Some(s) => match s.error {
|
||||
Some(err) => err,
|
||||
None => s.message.unwrap_or(String::from("")),
|
||||
},
|
||||
None => String::from("Loading..."),
|
||||
};
|
||||
view! {
|
||||
<div class="flex">
|
||||
<div class={format!("mt-1 h-4 w-4 rounded-full flex-none {color}")}></div>
|
||||
<span class="ml-2 flex-none text-gray-400 dark:text-gray-600">{ text }</span>
|
||||
</div>
|
||||
}
|
||||
};
|
||||
|
||||
view! {
|
||||
<div>
|
||||
{move || f(status.get())}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,41 @@
|
||||
use feshared::chatmessage::TauriCommand;
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use wasm_bindgen::prelude::*;
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
|
||||
pub async fn invoke(cmd: &str, args: JsValue) -> JsValue;
|
||||
async fn invoke(cmd: &str, args: JsValue) -> JsValue;
|
||||
|
||||
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "event"])]
|
||||
pub async fn listen(event: &str, handler: &Closure<dyn FnMut(JsValue)>) -> JsValue;
|
||||
}
|
||||
|
||||
pub async fn invoke_js(cmd: TauriCommand, args: JsValue) -> JsValue {
|
||||
invoke(cmd.as_str(), args).await
|
||||
}
|
||||
|
||||
pub async fn invoke_typed<T>(cmd: TauriCommand, args: JsValue) -> T
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
{
|
||||
let response = invoke(cmd.as_str(), args).await;
|
||||
let result: T = serde_wasm_bindgen::from_value(response).unwrap();
|
||||
result
|
||||
}
|
||||
|
||||
pub fn event_handler<T, F>(callback: F) -> Closure<dyn FnMut(JsValue)>
|
||||
where
|
||||
T: DeserializeOwned + 'static,
|
||||
F: Fn(T) + 'static,
|
||||
{
|
||||
Closure::new(move |val: JsValue| {
|
||||
#[derive(Deserialize)]
|
||||
struct TauriEvent<T> {
|
||||
payload: T,
|
||||
}
|
||||
|
||||
if let Ok(wrapper) = serde_wasm_bindgen::from_value::<TauriEvent<T>>(val) {
|
||||
callback(wrapper.payload)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
125
frontend/src/components.rs
Normal file
125
frontend/src/components.rs
Normal file
@@ -0,0 +1,125 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use feshared::{chatmessage::TauriCommand, daemon::DaemonState};
|
||||
use leptos::{component, prelude::*, reactive::spawn_local, view, IntoView};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
use crate::bridge::{event_handler, invoke_js, invoke_typed, listen};
|
||||
|
||||
#[component]
|
||||
pub fn DaemonProvider(children: ChildrenFn) -> impl IntoView {
|
||||
let (poll_count, set_pool_count) = signal(0);
|
||||
set_interval(
|
||||
move || set_pool_count.update(|v| *v += 1),
|
||||
Duration::from_secs(1),
|
||||
);
|
||||
let status_res = LocalResource::new(move || async move {
|
||||
poll_count.get();
|
||||
let s: DaemonState = invoke_typed(TauriCommand::DaemonState, JsValue::NULL).await;
|
||||
s
|
||||
});
|
||||
|
||||
let is_daemon_ok = Memo::new(move |_| status_res.get().map(|s| (s.is_ok, s.error)));
|
||||
|
||||
provide_context(status_res);
|
||||
|
||||
move || match is_daemon_ok.get() {
|
||||
Some((true, _)) => children().into_any(),
|
||||
Some((false, err)) => view! { <DaemonErrorStatus error=err/> }.into_any(),
|
||||
None => view! { <p>Connecting...</p> }.into_any(),
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn DaemonErrorStatus(error: Option<String>) -> impl IntoView {
|
||||
view! {
|
||||
<div class="w-screen h-screen
|
||||
text-gray-950 dark:text-white
|
||||
bg-white dark:bg-zinc-900
|
||||
flex justify-center items-center">
|
||||
<div class="text-zinc-100 dark:text-zinc-800 fixed w-full">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</div>
|
||||
<span class="fixed">{ error.unwrap_or("Daemon error!".to_string()) } </span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
pub struct DarkMode {
|
||||
is_dark_mode: bool,
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ThemeProvider(children: Children) -> impl IntoView {
|
||||
let (is_dark, set_dark) = signal(true);
|
||||
|
||||
Effect::new(move |_| {
|
||||
spawn_local(async move {
|
||||
let hndlr = event_handler(move |mode: DarkMode| {
|
||||
set_dark.set(mode.is_dark_mode);
|
||||
});
|
||||
// TODO use on_cleanup to call the unlisten JS function.
|
||||
let unlisten = listen("dark-mode-changed", &hndlr).await;
|
||||
hndlr.forget()
|
||||
});
|
||||
});
|
||||
|
||||
Effect::new(move |_| {
|
||||
let el = document()
|
||||
.document_element()
|
||||
.expect("HTML element not found!");
|
||||
if is_dark.get() {
|
||||
let _ = el.set_attribute("class", "dark");
|
||||
} else {
|
||||
let _ = el.set_attribute("class", "");
|
||||
}
|
||||
});
|
||||
|
||||
view! {
|
||||
{children()}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn DarkModeToggle() -> impl IntoView {
|
||||
let toggle_dark_mode = |_ev: leptos::ev::MouseEvent| {
|
||||
spawn_local(async {
|
||||
let _ = invoke_js(TauriCommand::ToggleDarkMode, JsValue::UNDEFINED).await;
|
||||
});
|
||||
};
|
||||
view! {
|
||||
<div on:click=toggle_dark_mode class="text-gray-600 dark:text-gray-600">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z" />
|
||||
</svg>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ConfirmDialog(
|
||||
is_open: ReadSignal<bool>,
|
||||
on_confirm: Callback<()>,
|
||||
on_cancel: Callback<()>,
|
||||
title: String,
|
||||
message: String,
|
||||
) -> impl IntoView {
|
||||
view! {
|
||||
<Show when=move || is_open.get()>
|
||||
<div class="fixed inset-0 z-50 flex items-center justify-center backdrop-blur text-zinc-950 dark:text-white">
|
||||
<div class="flex flex-col items-center justify-center p-4 rounded-lg bg-white/30 dark:bg-black/30">
|
||||
<h3 class="text-lg font-bold mb-2">{ title.clone() }</h3>
|
||||
<p>{ message.clone() }</p>
|
||||
<div>
|
||||
<button class="primary-button m-3" on:click=move |_| on_confirm.run(())>Confirm</button>
|
||||
<button class="primary-button m-3" on:click=move |_| on_cancel.run(())>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Show>
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
mod app;
|
||||
mod bridge;
|
||||
mod components;
|
||||
mod popup;
|
||||
|
||||
use app::*;
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
use crate::bridge::invoke;
|
||||
use crate::{
|
||||
bridge::{invoke_js, invoke_typed},
|
||||
components::{ConfirmDialog, DaemonProvider, DarkModeToggle, ThemeProvider},
|
||||
};
|
||||
use feshared::{
|
||||
chatmessage::{Message, MessageHistory, TauriCommand},
|
||||
daemon::DaemonState,
|
||||
};
|
||||
use leptos::{ev::keydown, html::Input, prelude::*};
|
||||
use wasm_bindgen::{prelude::Closure, JsCast, JsValue};
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Message {
|
||||
id: usize,
|
||||
text: String,
|
||||
is_user: bool,
|
||||
#[component]
|
||||
pub fn PopupView() -> impl IntoView {
|
||||
view! {<ThemeProvider>
|
||||
<DaemonProvider>
|
||||
<Popup />
|
||||
</DaemonProvider>
|
||||
</ThemeProvider>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
@@ -16,29 +26,55 @@ pub fn Popup() -> impl IntoView {
|
||||
let prompt_input_ref = NodeRef::<Input>::new();
|
||||
let (prompt_text, set_prompt_text) = signal(String::new());
|
||||
let (messages, set_messages) = signal(Vec::<Message>::new());
|
||||
// Action that calls the promp daemon
|
||||
let status_res =
|
||||
use_context::<LocalResource<DaemonState>>().expect("No daemon connection context!");
|
||||
|
||||
let init_history = Action::new_local(|(): &()| async move {
|
||||
let history: MessageHistory =
|
||||
invoke_typed(TauriCommand::ChatHistory, JsValue::UNDEFINED).await;
|
||||
history
|
||||
});
|
||||
Effect::new(move |prev_status: Option<bool>| {
|
||||
let current_ok = status_res.get().map(|s| s.is_ok).unwrap_or(false);
|
||||
if current_ok && prev_status != Some(true) {
|
||||
init_history.dispatch(());
|
||||
}
|
||||
current_ok
|
||||
});
|
||||
Effect::new(move |_| {
|
||||
if let Some(mut dat) = init_history.value().get() {
|
||||
set_messages.update(|m| m.append(&mut dat.history));
|
||||
}
|
||||
});
|
||||
|
||||
let set_chat_id_action = Action::new_local(|chat_id: &Option<i64>| {
|
||||
let cid = chat_id.clone();
|
||||
async move {
|
||||
let result: Option<i64> = invoke_typed(
|
||||
TauriCommand::SetChatId,
|
||||
serde_wasm_bindgen::to_value(&serde_json::json!({"chat_id": cid})).unwrap(),
|
||||
)
|
||||
.await;
|
||||
result
|
||||
}
|
||||
});
|
||||
|
||||
// Action that calls the chat action on the daemon
|
||||
let prompt_action = Action::new_local(|prompt: &String| {
|
||||
let prompt = prompt.clone();
|
||||
async move {
|
||||
let response = invoke(
|
||||
"prompt_llm",
|
||||
let result: Vec<Message> = invoke_typed(
|
||||
TauriCommand::Chat,
|
||||
serde_wasm_bindgen::to_value(&serde_json::json!({"prompt": prompt})).unwrap(),
|
||||
)
|
||||
.await;
|
||||
let result: String = serde_wasm_bindgen::from_value(response).unwrap();
|
||||
result
|
||||
}
|
||||
});
|
||||
// Update the model response div with the prompt result
|
||||
Effect::new(move |_| {
|
||||
if let Some(result) = prompt_action.value().get() {
|
||||
set_messages.update(|previous| {
|
||||
previous.push(Message {
|
||||
id: previous.len(),
|
||||
text: result,
|
||||
is_user: false,
|
||||
});
|
||||
});
|
||||
if let Some(mut result) = prompt_action.value().get() {
|
||||
set_messages.update(|m| m.append(&mut result));
|
||||
}
|
||||
});
|
||||
// Clear the propt text-input when the window loses focus (and is hidden)
|
||||
@@ -61,43 +97,61 @@ pub fn Popup() -> impl IntoView {
|
||||
let _ = window_event_listener(keydown, move |ev| {
|
||||
if ev.key() == "Escape" {
|
||||
spawn_local(async move {
|
||||
let _ = invoke("toggle_popup", JsValue::UNDEFINED).await;
|
||||
let _ = invoke_js(TauriCommand::TogglePopup, JsValue::UNDEFINED).await;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let (show_new_chat_confirm, set_new_chat_confirm) = signal(false);
|
||||
|
||||
let new_chat = move |_: ()| {
|
||||
set_messages.set(Vec::<Message>::new());
|
||||
// TODO add callback to the action, and clear chat and close dialog in the callback!
|
||||
set_chat_id_action.dispatch(None);
|
||||
set_new_chat_confirm.set(false);
|
||||
};
|
||||
|
||||
view! {
|
||||
<main class="window-shell rounded-container">
|
||||
<h3>"AI quick action"</h3>
|
||||
<input
|
||||
type="text"
|
||||
node_ref=prompt_input_ref
|
||||
placeholder="Ask Gordon AI"
|
||||
autofocus
|
||||
on:input=move |ev| set_prompt_text.set(event_target_value(&ev))
|
||||
on:keydown=move |ev| {
|
||||
if ev.key() == "Enter" {
|
||||
set_messages.update(|previous| {
|
||||
previous.push(Message {
|
||||
id: previous.len(),
|
||||
text: prompt_text.get(),
|
||||
is_user: true,
|
||||
});
|
||||
});
|
||||
prompt_action.dispatch(prompt_text.get());
|
||||
set_prompt_text.update(|s| *s = "".to_string());
|
||||
<ConfirmDialog
|
||||
is_open=show_new_chat_confirm
|
||||
on_confirm=Callback::new(new_chat)
|
||||
on_cancel=Callback::new(move |_| set_new_chat_confirm.set(false))
|
||||
title="Open a new chat?".to_string()
|
||||
message="Current chat is stored".to_string() />
|
||||
<div class="flex flex-col rounded-lg bg-white dark:bg-zinc-900 text-zinc-950 dark:text-white h-screen w-full">
|
||||
<header class="relative p-3">
|
||||
<input
|
||||
class="w-full p-3 rounded-lg bg-zinc-200 dark:bg-zinc-950"
|
||||
type="text"
|
||||
node_ref=prompt_input_ref
|
||||
placeholder="Prompt..."
|
||||
autofocus
|
||||
on:input=move |ev| set_prompt_text.set(event_target_value(&ev))
|
||||
on:keydown=move |ev| {
|
||||
if ev.key() == "Enter" {
|
||||
prompt_action.dispatch(prompt_text.get());
|
||||
set_prompt_text.update(|s| *s = "".to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
prop:value=prompt_text
|
||||
/>
|
||||
<div class="response-area">
|
||||
<For each=move || messages.get()
|
||||
key=|msg| msg.id
|
||||
let(msg)
|
||||
>
|
||||
<div class=if msg.is_user {"msg msg-user"} else {"msg msg-model"}>{msg.text}</div>
|
||||
</For>
|
||||
</div>
|
||||
</main>
|
||||
prop:value=prompt_text
|
||||
/>
|
||||
<button class="absolute py-1 px-2 right-5 mt-2
|
||||
rounded-full
|
||||
dark:bg-slate-800
|
||||
dark:hover:bg-slate-600"
|
||||
on:click=move |_| set_new_chat_confirm.set(true)>+</button>
|
||||
</header>
|
||||
<main class="flex-grow overflow-y-auto p-4">
|
||||
<div class="flex flex-col">
|
||||
<For each=move || messages.get()
|
||||
key=|msg| msg.id
|
||||
let(msg)
|
||||
>
|
||||
<div class=if msg.is_user {"msg msg-user"} else {"msg msg-model"}>{msg.text}</div>
|
||||
</For>
|
||||
</div>
|
||||
</main>
|
||||
<div class="fixed bottom-0 right-0 p-2"><DarkModeToggle /></div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
37
frontend/styles-input.css
Normal file
37
frontend/styles-input.css
Normal file
@@ -0,0 +1,37 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@custom-variant dark (&:where(.dark, .dark *));
|
||||
|
||||
@layer components {
|
||||
.msg {
|
||||
@apply rounded-lg mb-5 px-3 py-2 dark:bg-gray-800 max-w-[75%];
|
||||
}
|
||||
|
||||
.msg-model {
|
||||
@apply self-start bg-blue-200 dark:bg-slate-800;
|
||||
}
|
||||
|
||||
.msg-user {
|
||||
@apply self-end bg-slate-200 dark:bg-zinc-800;
|
||||
}
|
||||
|
||||
.primary-button {
|
||||
@apply bg-blue-300 dark:bg-gray-800 rounded-lg p-3;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: transparent !important;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px) scale(0.95);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
}
|
||||
3417
frontend/styles.css
3417
frontend/styles.css
File diff suppressed because it is too large
Load Diff
10
frontend/tailwind.config.js
Normal file
10
frontend/tailwind.config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
darkMode: "selector",
|
||||
content: ["./src/**/*.rs", "./index.html"],
|
||||
theme: {
|
||||
fontFamily: {
|
||||
sans: ["Inter", "serif"],
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user