mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
## Summary - preserve OSS relay-agent mentions under shared channel and agent policy - restrict owner-only release builds to relay agents with cryptographically verified ownership matching the current user - remove the remote policy replay loop that repeatedly rebuilt the relay directory, while retaining focused polling and send-time revalidation - query relay profiles and managed policies by exact author coordinates to prevent noisy events from crowding out valid agents ## Diagnosis The packaged Block release compiles `BUZZ_DESKTOP_BUILD_AGENT_ACCESS_OWNER_ONLY`, while ordinary OSS/dev builds do not. Relay-discovered agents were filtered as if all remote agents were outside that owner-only boundary, so a same-owner agent running on another machine disappeared in the release even though the OSS path could look healthy. The fix uses the NIP-OA-authenticated owner from the relay directory as the cross-machine proof. Internal builds admit only verified same-owner agents and fail closed for missing, mismatched, stale/revoked, or unavailable ownership evidence. OSS builds retain shared channel/policy behavior. ## Validation - desktop focused unit coverage: 39 tests passed - desktop typecheck and focused static checks passed - focused Tauri Rust policy/directory tests passed - production-style E2E build succeeded - targeted Playwright mention scenarios passed: - owner-only release hides other-owned relay agent - owner-only release shows verified same-owner relay agent - OSS build shows shared `anyone` agent - repository pre-push hook passed on `4d40b6e5bb032f2c0755127172c50dee213f65a3`: - branch skew - desktop check and typecheck - desktop tests - Rust tests - Tauri checks - mobile tests --------- Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { listen } from "@tauri-apps/api/event";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
import { useEffect } from "react";
|
|
|
|
import {
|
|
managedAgentsQueryKey,
|
|
personasQueryKey,
|
|
teamsQueryKey,
|
|
} from "@/features/agents/hooks";
|
|
import { managedAgentRuntimesQueryKey } from "@/features/agents/managedAgentRuntimeHooks";
|
|
|
|
export const LOCAL_AGENT_DATA_QUERY_KEYS = [
|
|
personasQueryKey,
|
|
teamsQueryKey,
|
|
managedAgentsQueryKey,
|
|
] as const;
|
|
|
|
// Trailing-coalesce local agent-store bursts into one cache refresh. The relay
|
|
// directory is deliberately excluded: local persona/team/agent reconciliation
|
|
// cannot change remote directory records, and rebuilding that directory is a
|
|
// relay-wide operation. Remote data keeps its focused poll and is revalidated
|
|
// directly before an agent mention is sent.
|
|
const COALESCE_MS = 200;
|
|
|
|
export function useAgentsDataRefresh(): void {
|
|
const queryClient = useQueryClient();
|
|
|
|
useEffect(() => {
|
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
|
|
const unlistenRuntime = listen("managed-agent-runtime-status", () => {
|
|
void queryClient.invalidateQueries({
|
|
queryKey: managedAgentRuntimesQueryKey,
|
|
});
|
|
void queryClient.invalidateQueries({ queryKey: managedAgentsQueryKey });
|
|
});
|
|
|
|
const unlisten = listen("agents-data-changed", () => {
|
|
if (timer !== undefined) clearTimeout(timer);
|
|
timer = setTimeout(() => {
|
|
for (const queryKey of LOCAL_AGENT_DATA_QUERY_KEYS) {
|
|
void queryClient.invalidateQueries({ queryKey });
|
|
}
|
|
}, COALESCE_MS);
|
|
});
|
|
|
|
return () => {
|
|
if (timer !== undefined) clearTimeout(timer);
|
|
void unlisten.then((fn) => fn());
|
|
void unlistenRuntime.then((fn) => fn());
|
|
};
|
|
}, [queryClient]);
|
|
}
|