From f4e9fbaebca2050236bf149b75c3365a784c8de3 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Mon, 20 Jan 2025 19:52:12 +0100 Subject: [PATCH 1/7] p-diff-sync: add debug log when stop pulling because we're ahead and want them to pull --- .../hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs index 5897c3435..80bbda49e 100644 --- a/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs +++ b/bootstrap-languages/p-diff-sync/hc-dna/zomes/perspective_diff_sync/src/link_adapter/pull.rs @@ -98,6 +98,7 @@ pub fn pull( // First check if we are actually ahead of them -> we don't have to do anything // they will have to merge with / or fast-forward to our current if workspace.all_ancestors(¤t.hash)?.contains(&theirs) { + debug!("===PerspectiveDiffSync.pull(): We are ahead of them. They will have to pull/fast-forward. Exiting without change..."); return Ok(PullResult { diff: PerspectiveDiff::default(), current_revision: Some(current.hash), From 438d5f2d4cc974eceb6e0eb2eafcb5c0155bfd43 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Mon, 20 Jan 2025 19:56:51 +0100 Subject: [PATCH 2/7] p-diff-sync build updated --- cli/mainnet_seed.json | 2 +- rust-executor/src/mainnet_seed.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/mainnet_seed.json b/cli/mainnet_seed.json index 77e7b4913..5f22a3ab0 100644 --- a/cli/mainnet_seed.json +++ b/cli/mainnet_seed.json @@ -4,7 +4,7 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwdZYYgYGWSiRZqMGs5YrJu8gQzCQCxJFkK9Ar28vaki9UN" + "QmzSYwdbWZ8Y7w8ZtAb47xN8AEaTUveoUnxgnT6pxvrWdtBDMVy" ], "directMessageLanguage": "QmzSYwdmrcq32PAsQFD95D6oTGUK7odPDCmXvoYgDcV6SPRcA3u", "agentLanguage": "QmzSYwdZDdgxiyE8crozqbxoBP52h6ocMdDq2S2mg4ScjzVLWKQ", diff --git a/rust-executor/src/mainnet_seed.json b/rust-executor/src/mainnet_seed.json index 77e7b4913..5f22a3ab0 100644 --- a/rust-executor/src/mainnet_seed.json +++ b/rust-executor/src/mainnet_seed.json @@ -4,7 +4,7 @@ "did:key:z6MkvPpWxwXAnLtMcoc9sX7GEoJ96oNnQ3VcQJRLspNJfpE7" ], "knownLinkLanguages": [ - "QmzSYwdZYYgYGWSiRZqMGs5YrJu8gQzCQCxJFkK9Ar28vaki9UN" + "QmzSYwdbWZ8Y7w8ZtAb47xN8AEaTUveoUnxgnT6pxvrWdtBDMVy" ], "directMessageLanguage": "QmzSYwdmrcq32PAsQFD95D6oTGUK7odPDCmXvoYgDcV6SPRcA3u", "agentLanguage": "QmzSYwdZDdgxiyE8crozqbxoBP52h6ocMdDq2S2mg4ScjzVLWKQ", From ab430690e36a678b4b4a7c412c005dfe2f6da3d7 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 21 Jan 2025 16:03:44 +0100 Subject: [PATCH 3/7] Remove notify-rust patch which is not used after upgrading tauri to v2 --- Cargo.lock | 5 ----- Cargo.toml | 4 ---- 2 files changed, 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3668ad695..e6c6efe42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20873,8 +20873,3 @@ dependencies = [ "quote", "syn 2.0.87", ] - -[[patch.unused]] -name = "notify-rust" -version = "4.6.0" -source = "git+https://github.com/coasys/notify-rust.git#b08ab0233810d365d1e914998ff81002090753a6" diff --git a/Cargo.toml b/Cargo.toml index 72a2ae131..4cfc6b4fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,3 @@ members = [ "rust-executor", "ui/src-tauri" ] - - -[patch.crates-io] -notify-rust = { version = "4.6.0", git = "https://github.com/coasys/notify-rust.git" } \ No newline at end of file From 1c601efbb0520b945354764b0969eb2a9e9bf051 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 21 Jan 2025 16:12:10 +0100 Subject: [PATCH 4/7] Rename AgentList to AgentConfigDir which is less misleading --- ui/src-tauri/src/app_state.rs | 12 ++++++------ ui/src-tauri/src/commands/app.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/src-tauri/src/app_state.rs b/ui/src-tauri/src/app_state.rs index 6069fcaa6..336571fce 100644 --- a/ui/src-tauri/src/app_state.rs +++ b/ui/src-tauri/src/app_state.rs @@ -5,7 +5,7 @@ use std::io::prelude::*; use std::path::PathBuf; #[derive(Serialize, Deserialize, Clone, Debug)] -pub struct AgentList { +pub struct AgentConfigDir { pub name: String, pub path: PathBuf, pub bootstrap: Option, @@ -13,8 +13,8 @@ pub struct AgentList { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct LauncherState { - pub agent_list: Vec, - pub selected_agent: Option, + pub agent_list: Vec, + pub selected_agent: Option, } impl LauncherState { @@ -44,7 +44,7 @@ impl LauncherState { let state = match serde_json::from_str(&data) { Ok(state) => state, Err(_) => { - let agent = AgentList { + let agent = AgentConfigDir { name: "Main Net".to_string(), path: home_dir().expect("Could not get home dir").join(".ad4m"), bootstrap: None, @@ -60,13 +60,13 @@ impl LauncherState { Ok(state) } - pub fn add_agent(&mut self, agent: AgentList) { + pub fn add_agent(&mut self, agent: AgentConfigDir) { if !self.is_agent_taken(&agent.name, &agent.path) { self.agent_list.push(agent); } } - pub fn remove_agent(&mut self, agent: AgentList) { + pub fn remove_agent(&mut self, agent: AgentConfigDir) { self.agent_list .retain(|a| a.name != agent.name && a.path != agent.path); } diff --git a/ui/src-tauri/src/commands/app.rs b/ui/src-tauri/src/commands/app.rs index 79312c00c..4d3750eea 100644 --- a/ui/src-tauri/src/commands/app.rs +++ b/ui/src-tauri/src/commands/app.rs @@ -1,5 +1,5 @@ extern crate remove_dir_all; -use crate::app_state::{AgentList, LauncherState}; +use crate::app_state::{AgentConfigDir, LauncherState}; use crate::util::create_tray_message_windows; use crate::{config::data_path, get_main_window}; @@ -49,7 +49,7 @@ pub fn open_tray(app_handle: tauri::AppHandle) { } #[tauri::command] -pub fn add_app_agent_state(agent: AgentList) { +pub fn add_app_agent_state(agent: AgentConfigDir) { let mut state = LauncherState::load().unwrap(); let mut new_agent = agent.clone(); @@ -62,7 +62,7 @@ pub fn add_app_agent_state(agent: AgentList) { } #[tauri::command] -pub fn remove_app_agent_state(agent: AgentList) { +pub fn remove_app_agent_state(agent: AgentConfigDir) { let mut state = LauncherState::load().unwrap(); state.remove_agent(agent.clone()); @@ -71,7 +71,7 @@ pub fn remove_app_agent_state(agent: AgentList) { } #[tauri::command] -pub fn set_selected_agent(agent: AgentList) { +pub fn set_selected_agent(agent: AgentConfigDir) { let mut state = LauncherState::load().unwrap(); state.selected_agent = Some(agent); From bf25fb0b4f805cf8c4854cc2cb48c5f794426776 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 21 Jan 2025 16:29:32 +0100 Subject: [PATCH 5/7] Improve handling of launcher state. Move state file to .ad4m directory --- ui/src-tauri/src/app_state.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ui/src-tauri/src/app_state.rs b/ui/src-tauri/src/app_state.rs index 336571fce..da5d68d8d 100644 --- a/ui/src-tauri/src/app_state.rs +++ b/ui/src-tauri/src/app_state.rs @@ -1,9 +1,11 @@ use dirs::home_dir; use serde::{Deserialize, Serialize}; -use std::fs::{File, OpenOptions}; +use std::fs::{File, OpenOptions, create_dir_all}; use std::io::prelude::*; use std::path::PathBuf; +pub static FILE_NAME: &str = "launcher-state.json"; + #[derive(Serialize, Deserialize, Clone, Debug)] pub struct AgentConfigDir { pub name: String, @@ -17,27 +19,32 @@ pub struct LauncherState { pub selected_agent: Option, } +fn file_path() -> PathBuf { + let path = home_dir() + .expect("Could not get home dir") + .join(".ad4m"); + + // Create directories if they don't exist + create_dir_all(&path).expect("Failed to create directory"); + + path.join(FILE_NAME) +} + impl LauncherState { pub fn save(&mut self) -> std::io::Result<()> { - let path = home_dir() - .expect("Could not get home dir") - .join("ad4m-state.json"); - let mut file = File::create(path)?; + let mut file = File::create(file_path())?; let data = serde_json::to_string(&self).unwrap(); file.write_all(data.as_bytes())?; Ok(()) } pub fn load() -> std::io::Result { - let path = home_dir() - .expect("Could not get home dir") - .join("ad4m-state.json"); let mut file = OpenOptions::new() .read(true) .write(true) .create(true) .truncate(false) - .open(path)?; + .open(file_path())?; let mut data = String::new(); file.read_to_string(&mut data)?; From 167f60f24c6374500c74dc6075b36491a732efe8 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 21 Jan 2025 16:32:26 +0100 Subject: [PATCH 6/7] fmt --- ui/src-tauri/src/app_state.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/src-tauri/src/app_state.rs b/ui/src-tauri/src/app_state.rs index da5d68d8d..b9ea11a0d 100644 --- a/ui/src-tauri/src/app_state.rs +++ b/ui/src-tauri/src/app_state.rs @@ -1,6 +1,6 @@ use dirs::home_dir; use serde::{Deserialize, Serialize}; -use std::fs::{File, OpenOptions, create_dir_all}; +use std::fs::{create_dir_all, File, OpenOptions}; use std::io::prelude::*; use std::path::PathBuf; @@ -20,13 +20,9 @@ pub struct LauncherState { } fn file_path() -> PathBuf { - let path = home_dir() - .expect("Could not get home dir") - .join(".ad4m"); - + let path = home_dir().expect("Could not get home dir").join(".ad4m"); // Create directories if they don't exist create_dir_all(&path).expect("Failed to create directory"); - path.join(FILE_NAME) } From b6d652af247a826538fb2c8f19b745f86523aa9f Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Tue, 21 Jan 2025 16:37:23 +0100 Subject: [PATCH 7/7] changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 9e72e221f..bfb2e6464 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ This project _loosely_ adheres to [Semantic Versioning](https://semver.org/spec/ - Fix for missing links: race-condition fixed in useSubjects [PR#540](https://github.com/coasys/ad4m/pull/540) and [PR#554](https://github.com/coasys/ad4m/pull/554) - Fix for missing links: detect and rerun failed commits in p-diff-sync [PR#551](https://github.com/coasys/ad4m/pull/551) - Fix for syncing broken after some time: Prevent p-diff-sync diff entries from exceeding HC entry size limit of 4MB (which would happen at some point through snapshot creation) [PR#553](https://github.com/coasys/ad4m/pull/553) +- Fix for crash when removing .ad4m directory after using multiple agent feature [PR#556](https://github.com/coasys/ad4m/pull/556) ### Added