Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions desktop/src-tauri/src/managed_agents/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,16 +482,16 @@ fn profile_target_dirs(root: &Path) -> [PathBuf; 2] {
}

fn command_search_dirs() -> Vec<PathBuf> {
let mut dirs = profile_target_dirs(&workspace_root_dir()).to_vec();
// 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();
dirs.extend(profile_target_dirs(&workspace_root_dir()));
if let Ok(current_dir) = std::env::current_dir() {
dirs.extend(profile_target_dirs(&current_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);
Expand Down
7 changes: 4 additions & 3 deletions desktop/src/features/dkg-memory/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -96,7 +97,7 @@ export function useReputationSummary(
queryFn: () =>
fetchReputationSummary(channelId as string, pubkey as string),
enabled: Boolean(channelId && pubkey),
staleTime: 30 * 1_000,
...dkgReadQueryPolicy,
});
}

Expand Down
18 changes: 18 additions & 0 deletions desktop/src/features/dkg-memory/queryLoadPolicy.test.mjs
Original file line number Diff line number Diff line change
@@ -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,
});
});
14 changes: 14 additions & 0 deletions desktop/src/features/dkg-memory/queryLoadPolicy.ts
Original file line number Diff line number Diff line change
@@ -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;
27 changes: 26 additions & 1 deletion desktop/src/features/dkg-memory/ui/WebOfTrustPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
History,
Link2,
Loader2,
RefreshCw,
ShieldCheck,
ShieldX,
UserRoundCheck,
Expand Down Expand Up @@ -212,6 +213,17 @@ export function WebOfTrustPanel({
? network.error.message
: "The community DKG did not return a trust network."}
</p>
<Button
type="button"
size="xs"
variant="outline"
className="mt-3"
disabled={network.isFetching}
onClick={() => void network.refetch()}
>
<RefreshCw className={network.isFetching ? "animate-spin" : ""} />
Try again
</Button>
</Card>
);
}
Expand Down Expand Up @@ -242,7 +254,20 @@ export function WebOfTrustPanel({
signed vouches
</p>
</div>
<Badge variant="success">DKG evidence</Badge>
<div className="flex items-center gap-1.5">
<Badge variant="success">DKG evidence</Badge>
<Button
type="button"
variant="ghost"
size="icon-xs"
disabled={network.isFetching}
onClick={() => void network.refetch()}
title="Refresh trust evidence"
aria-label="Refresh trust evidence"
>
<RefreshCw className={network.isFetching ? "animate-spin" : ""} />
</Button>
</div>
</div>

{people.length === 0 ? (
Expand Down
Loading