A local-first private AI assistant for everyday use. Runs on-device models with encrypted P2P sync, and supports sharing chats publicly on ATProto.
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Fixed daemon creation loop

- tiles daemon will directly opens a server instead of calling itself

- test: tests for daemon module

madclaws 2d836329 0691b9c6

+87 -7
+42
Cargo.lock
··· 3781 3781 checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" 3782 3782 3783 3783 [[package]] 3784 + name = "scc" 3785 + version = "2.4.0" 3786 + source = "registry+https://github.com/rust-lang/crates.io-index" 3787 + checksum = "46e6f046b7fef48e2660c57ed794263155d713de679057f2d0c169bfc6e756cc" 3788 + dependencies = [ 3789 + "sdd", 3790 + ] 3791 + 3792 + [[package]] 3784 3793 name = "schannel" 3785 3794 version = "0.1.28" 3786 3795 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3819 3828 version = "1.2.0" 3820 3829 source = "registry+https://github.com/rust-lang/crates.io-index" 3821 3830 checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 3831 + 3832 + [[package]] 3833 + name = "sdd" 3834 + version = "3.0.10" 3835 + source = "registry+https://github.com/rust-lang/crates.io-index" 3836 + checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca" 3822 3837 3823 3838 [[package]] 3824 3839 name = "sec1" ··· 3999 4014 "itoa", 4000 4015 "ryu", 4001 4016 "serde", 4017 + ] 4018 + 4019 + [[package]] 4020 + name = "serial_test" 4021 + version = "3.4.0" 4022 + source = "registry+https://github.com/rust-lang/crates.io-index" 4023 + checksum = "911bd979bf1070a3f3aa7b691a3b3e9968f339ceeec89e08c280a8a22207a32f" 4024 + dependencies = [ 4025 + "futures-executor", 4026 + "futures-util", 4027 + "log", 4028 + "once_cell", 4029 + "parking_lot", 4030 + "scc", 4031 + "serial_test_derive", 4032 + ] 4033 + 4034 + [[package]] 4035 + name = "serial_test_derive" 4036 + version = "3.4.0" 4037 + source = "registry+https://github.com/rust-lang/crates.io-index" 4038 + checksum = "0a7d91949b85b0d2fb687445e448b40d322b6b3e4af6b44a29b21d9a5f33e6d9" 4039 + dependencies = [ 4040 + "proc-macro2", 4041 + "quote", 4042 + "syn 2.0.117", 4002 4043 ] 4003 4044 4004 4045 [[package]] ··· 4341 4382 "semver", 4342 4383 "serde", 4343 4384 "serde_json", 4385 + "serial_test", 4344 4386 "tempfile", 4345 4387 "tilekit", 4346 4388 "tokio",
+1
tiles/Cargo.toml
··· 27 27 keyring = { version = "3", features = ["apple-native"] } 28 28 wiremock = "0.6.5" 29 29 async-std = { version = "1.12", features = ["attributes"] } 30 + serial_test = "3.4.0"
+38 -2
tiles/src/daemon.rs
··· 38 38 // running in background and have commands to stop if needed 39 39 #[allow(clippy::zombie_processes)] 40 40 async fn start_daemon() -> Result<()> { 41 - tokio::time::sleep(Duration::from_secs(5)).await; 42 41 if (ping().await).is_ok() { 43 42 return Ok(()); 44 43 } ··· 51 50 .create(true) 52 51 .append(true) 53 52 .open(data_dir.join("logs/daemon.err.log"))?; 53 + // let _process = Command::new("target/debug/tiles") 54 54 let _process = Command::new("tiles") 55 55 .arg("daemon") 56 56 .stdin(Stdio::null()) ··· 129 129 Err(err) => { 130 130 retry_count -= 1; 131 131 error = err; 132 - tokio::time::sleep(Duration::from_secs(5)).await; 132 + tokio::time::sleep(Duration::from_secs(2)).await; 133 133 } 134 134 } 135 135 } 136 136 } 137 + 138 + #[cfg(test)] 139 + mod tests { 140 + use anyhow::Result; 141 + use serial_test::serial; 142 + 143 + use crate::daemon::{ping, start_server, stop_server, wait_until_server_is_up}; 144 + 145 + #[tokio::test] 146 + #[serial] 147 + async fn test_sever_process_started_not_server() -> Result<()> { 148 + tokio::spawn(async move { 149 + let _ = start_server().await; 150 + }); 151 + assert!(ping().await.is_err()); 152 + stop_server().await 153 + } 154 + 155 + #[tokio::test] 156 + #[serial] 157 + async fn test_sever_process_and_server_started() -> Result<()> { 158 + tokio::spawn(async move { 159 + let _ = start_server().await; 160 + }); 161 + wait_until_server_is_up().await?; 162 + assert!(ping().await.is_ok()); 163 + 164 + stop_server().await 165 + } 166 + 167 + #[tokio::test] 168 + #[serial] 169 + async fn stop_server_but_server_not_up() { 170 + assert!(stop_server().await.is_err()) 171 + } 172 + }
+6 -5
tiles/src/main.rs
··· 2 2 3 3 use clap::{Args, Parser, Subcommand}; 4 4 use tiles::{ 5 - daemon::{start_cmd, stop_cmd}, 5 + daemon::{start_cmd, start_server, stop_cmd}, 6 6 runtime::{RunArgs, build_runtime}, 7 7 utils::installer, 8 8 }; ··· 155 155 .inspect_err(|e| eprintln!("Failed to setup Tiles due to {:?}", e))?; 156 156 let _ = commands::try_app_update().await; 157 157 158 - // trying to run the tiles daemon in background 159 - //TODO: Run this as an async process tokio::spawn 158 + // trying to run the tiles daemon in background concurrently 160 159 if !cfg!(debug_assertions) { 161 - let _ = start_cmd().await; 160 + tokio::spawn(async move { 161 + let _ = start_cmd().await; 162 + }); 162 163 } 163 164 164 165 commands::run(&runtime, run_args) ··· 216 217 .await 217 218 .inspect_err(|e| eprintln!("{:?}", e)) 218 219 .inspect(|_| println!("Daemon stopped successfully"))?, 219 - _ => start_cmd().await?, 220 + _ => start_server().await?, 220 221 }, 221 222 } 222 223 Ok(())