From 829d8852496c82f577e3e25de4a9361f612459af Mon Sep 17 00:00:00 2001
From: branarakic
Date: Thu, 13 Aug 2026 00:26:57 +0200
Subject: [PATCH 1/3] perf: make DKG memory refresh demand driven
Signed-off-by: branarakic
---
desktop/src/features/dkg-memory/hooks.ts | 7 ++---
.../dkg-memory/queryLoadPolicy.test.mjs | 18 +++++++++++++
.../features/dkg-memory/queryLoadPolicy.ts | 14 ++++++++++
.../dkg-memory/ui/WebOfTrustPanel.tsx | 27 ++++++++++++++++++-
4 files changed, 62 insertions(+), 4 deletions(-)
create mode 100644 desktop/src/features/dkg-memory/queryLoadPolicy.test.mjs
create mode 100644 desktop/src/features/dkg-memory/queryLoadPolicy.ts
diff --git a/desktop/src/features/dkg-memory/hooks.ts b/desktop/src/features/dkg-memory/hooks.ts
index 6384062483f..eb06d734af9 100644
--- a/desktop/src/features/dkg-memory/hooks.ts
+++ b/desktop/src/features/dkg-memory/hooks.ts
@@ -8,6 +8,7 @@ import {
fetchTrustNetwork,
} from "./api";
import { fetchDkgMemoryCapabilities } from "./capabilities";
+import { dkgReadQueryPolicy } from "./queryLoadPolicy";
const CAPABILITY_RETRY_DELAYS_MS = [250, 1_000, 5_000] as const;
@@ -61,7 +62,7 @@ export function useChannelMemory(
queryKey: ["dkg-memory", "memory", channelId, cg],
queryFn: () => fetchChannelMemory(channelId as string, cg ?? null),
enabled: Boolean(channelId) && bindingResolved,
- refetchInterval: 30 * 1000,
+ ...dkgReadQueryPolicy,
});
}
@@ -83,7 +84,7 @@ export function useTrustNetwork(channelId: string | null) {
queryKey: ["dkg-memory", "trust-network", channelId],
queryFn: () => fetchTrustNetwork(channelId as string),
enabled: Boolean(channelId),
- refetchInterval: 30 * 1000,
+ ...dkgReadQueryPolicy,
});
}
@@ -96,7 +97,7 @@ export function useReputationSummary(
queryFn: () =>
fetchReputationSummary(channelId as string, pubkey as string),
enabled: Boolean(channelId && pubkey),
- staleTime: 30 * 1_000,
+ ...dkgReadQueryPolicy,
});
}
diff --git a/desktop/src/features/dkg-memory/queryLoadPolicy.test.mjs b/desktop/src/features/dkg-memory/queryLoadPolicy.test.mjs
new file mode 100644
index 00000000000..9e4f1c03df0
--- /dev/null
+++ b/desktop/src/features/dkg-memory/queryLoadPolicy.test.mjs
@@ -0,0 +1,18 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ DKG_READ_STALE_TIME_MS,
+ dkgReadQueryPolicy,
+} from "./queryLoadPolicy.ts";
+
+test("heavy DKG reads are cached briefly without polling or retry amplification", () => {
+ assert.equal(DKG_READ_STALE_TIME_MS, 30_000);
+ assert.deepEqual(dkgReadQueryPolicy, {
+ retry: false,
+ refetchInterval: false,
+ refetchOnReconnect: false,
+ refetchOnWindowFocus: false,
+ staleTime: 30_000,
+ });
+});
diff --git a/desktop/src/features/dkg-memory/queryLoadPolicy.ts b/desktop/src/features/dkg-memory/queryLoadPolicy.ts
new file mode 100644
index 00000000000..d702e18602c
--- /dev/null
+++ b/desktop/src/features/dkg-memory/queryLoadPolicy.ts
@@ -0,0 +1,14 @@
+/**
+ * DKG reads can fan out into several triple-store operations. Keep them
+ * user-driven and cache the successful result briefly instead of polling or
+ * multiplying an overloaded upstream with automatic retries.
+ */
+export const DKG_READ_STALE_TIME_MS = 30_000;
+
+export const dkgReadQueryPolicy = {
+ retry: false,
+ refetchInterval: false,
+ refetchOnReconnect: false,
+ refetchOnWindowFocus: false,
+ staleTime: DKG_READ_STALE_TIME_MS,
+} as const;
diff --git a/desktop/src/features/dkg-memory/ui/WebOfTrustPanel.tsx b/desktop/src/features/dkg-memory/ui/WebOfTrustPanel.tsx
index 1cb9fd396a9..f2a0026a8b6 100644
--- a/desktop/src/features/dkg-memory/ui/WebOfTrustPanel.tsx
+++ b/desktop/src/features/dkg-memory/ui/WebOfTrustPanel.tsx
@@ -4,6 +4,7 @@ import {
History,
Link2,
Loader2,
+ RefreshCw,
ShieldCheck,
ShieldX,
UserRoundCheck,
@@ -212,6 +213,17 @@ export function WebOfTrustPanel({
? network.error.message
: "The community DKG did not return a trust network."}
+
);
}
@@ -242,7 +254,20 @@ export function WebOfTrustPanel({
signed vouches
- DKG evidence
+
+ DKG evidence
+
+
{people.length === 0 ? (
From 021b3cefa02aa7161e7fb41c3af7679b510c36dc Mon Sep 17 00:00:00 2001
From: branarakic
Date: Thu, 13 Aug 2026 02:56:27 +0200
Subject: [PATCH 2/3] fix: prefer packaged agent sidecars
Signed-off-by: branarakic
---
.../src-tauri/src/managed_agents/discovery.rs | 18 +++++++++++-------
.../src/managed_agents/discovery/tests.rs | 15 +++++++++++++++
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/desktop/src-tauri/src/managed_agents/discovery.rs b/desktop/src-tauri/src/managed_agents/discovery.rs
index bc0e3a6cdae..4d6bb3f18f0 100644
--- a/desktop/src-tauri/src/managed_agents/discovery.rs
+++ b/desktop/src-tauri/src/managed_agents/discovery.rs
@@ -482,16 +482,20 @@ fn profile_target_dirs(root: &Path) -> [PathBuf; 2] {
}
fn command_search_dirs() -> Vec {
- let mut dirs = profile_target_dirs(&workspace_root_dir()).to_vec();
+ // A packaged app must resolve the sidecars shipped alongside the running
+ // executable before any build output left in the source workspace. The
+ // compile-time CARGO_MANIFEST_DIR remains present in locally built release
+ // bundles, so checking it first can silently run a newer or older debug
+ // binary instead of the artifact the user actually installed.
+ let mut dirs = std::env::current_exe()
+ .ok()
+ .and_then(|path| path.parent().map(Path::to_path_buf))
+ .into_iter()
+ .collect::>();
+ dirs.extend(profile_target_dirs(&workspace_root_dir()));
if let Ok(current_dir) = std::env::current_dir() {
dirs.extend(profile_target_dirs(¤t_dir));
}
-
- dirs.extend(
- std::env::current_exe()
- .ok()
- .and_then(|path| path.parent().map(Path::to_path_buf)),
- );
dirs.into_iter().fold(Vec::new(), |mut unique, dir| {
if !unique.contains(&dir) {
unique.push(dir);
diff --git a/desktop/src-tauri/src/managed_agents/discovery/tests.rs b/desktop/src-tauri/src/managed_agents/discovery/tests.rs
index 6fe6a77521b..77dd0cb035e 100644
--- a/desktop/src-tauri/src/managed_agents/discovery/tests.rs
+++ b/desktop/src-tauri/src/managed_agents/discovery/tests.rs
@@ -12,6 +12,21 @@ use super::{
};
use crate::managed_agents::AcpAvailabilityStatus;
+#[test]
+fn command_search_prefers_the_running_apps_sidecar_directory() {
+ let executable_dir = std::env::current_exe()
+ .expect("current executable")
+ .parent()
+ .expect("executable directory")
+ .to_path_buf();
+
+ assert_eq!(
+ super::command_search_dirs().first(),
+ Some(&executable_dir),
+ "the installed app bundle must win over compile-time workspace output"
+ );
+}
+
#[test]
fn resolves_known_avatar_for_bare_command() {
let avatar_url = managed_agent_avatar_url("goose").expect("goose avatar should resolve");
From 5a5238d1e841b9faf9e49f54d65fc1e85b7238e1 Mon Sep 17 00:00:00 2001
From: branarakic
Date: Thu, 13 Aug 2026 03:01:47 +0200
Subject: [PATCH 3/3] refactor: keep sidecar preference within size ratchet
Signed-off-by: branarakic
---
desktop/src-tauri/src/managed_agents/discovery.rs | 10 +++-------
.../src/managed_agents/discovery/tests.rs | 15 ---------------
2 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/desktop/src-tauri/src/managed_agents/discovery.rs b/desktop/src-tauri/src/managed_agents/discovery.rs
index 4d6bb3f18f0..0f007a489a0 100644
--- a/desktop/src-tauri/src/managed_agents/discovery.rs
+++ b/desktop/src-tauri/src/managed_agents/discovery.rs
@@ -482,16 +482,12 @@ fn profile_target_dirs(root: &Path) -> [PathBuf; 2] {
}
fn command_search_dirs() -> Vec {
- // A packaged app must resolve the sidecars shipped alongside the running
- // executable before any build output left in the source workspace. The
- // compile-time CARGO_MANIFEST_DIR remains present in locally built release
- // bundles, so checking it first can silently run a newer or older debug
- // binary instead of the artifact the user actually installed.
- let mut dirs = std::env::current_exe()
+ // Packaged sidecars must win over compile-time workspace build output.
+ let mut dirs: Vec<_> = std::env::current_exe()
.ok()
.and_then(|path| path.parent().map(Path::to_path_buf))
.into_iter()
- .collect::>();
+ .collect();
dirs.extend(profile_target_dirs(&workspace_root_dir()));
if let Ok(current_dir) = std::env::current_dir() {
dirs.extend(profile_target_dirs(¤t_dir));
diff --git a/desktop/src-tauri/src/managed_agents/discovery/tests.rs b/desktop/src-tauri/src/managed_agents/discovery/tests.rs
index 77dd0cb035e..6fe6a77521b 100644
--- a/desktop/src-tauri/src/managed_agents/discovery/tests.rs
+++ b/desktop/src-tauri/src/managed_agents/discovery/tests.rs
@@ -12,21 +12,6 @@ use super::{
};
use crate::managed_agents::AcpAvailabilityStatus;
-#[test]
-fn command_search_prefers_the_running_apps_sidecar_directory() {
- let executable_dir = std::env::current_exe()
- .expect("current executable")
- .parent()
- .expect("executable directory")
- .to_path_buf();
-
- assert_eq!(
- super::command_search_dirs().first(),
- Some(&executable_dir),
- "the installed app bundle must win over compile-time workspace output"
- );
-}
-
#[test]
fn resolves_known_avatar_for_bare_command() {
let avatar_url = managed_agent_avatar_url("goose").expect("goose avatar should resolve");