Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 2x 9x 9x 3x 9x 9x 9x | import NetworkCanvas from "@/components/dashboard/widgets/network/NetworkCanvas";
import { SectionCard, SkeletonLines } from "@/components/detail";
import type { KnowledgeNetworkSummary, NetworkGraph } from "@/objects/Network";
import { useApiHandler } from "@/services/useApiHandler";
import { useQuery } from "@tanstack/react-query";
import { Share2 } from "lucide-react";
import React from "react";
import { sourceKey } from "../figures";
/**
* Where a source is used, in this workspace: the repositories holding it and
* the agents those are granted to (svc-core `load_source_network`), drawn on
* the network views' canvas. It is reach — what may retrieve from it; what
* answers actually cited is the Usage tab.
*/
const WhereUsedCard: React.FC<{ knowledgeId: string }> = ({ knowledgeId }) => {
const { getApiHandler } = useApiHandler();
const { data, isLoading } = useQuery<NetworkGraph<KnowledgeNetworkSummary> | null>({
queryKey: [...sourceKey(knowledgeId), "network"],
queryFn: () =>
getApiHandler().network_router.getKnowledgeNetwork({
knowledgeIds: [knowledgeId],
includeMemory: false,
}),
staleTime: 60_000,
});
const graph: NetworkGraph<KnowledgeNetworkSummary> | null | undefined = data;
const held = (graph?.nodes ?? []).some((n) => n.kind === "repository");
return (
<SectionCard
icon={Share2}
title="Where it is used"
description="The repositories holding it here, and the agents they are granted to"
>
{isLoading ? (
<SkeletonLines count={3} />
) : !graph ? (
<p className="text-sm text-gray-400 dark:text-gray-500 italic">
Where it is used could not be read.
</p>
) : !held ? (
<p className="text-sm text-gray-500 dark:text-gray-400">
No repository here holds it, so no agent can retrieve from it. Add it
to a repository and grant that to an agent.
</p>
) : (
<div className="h-72">
<NetworkCanvas
graph={graph}
empty="No repository here holds it."
testId="where-used"
/>
</div>
)}
</SectionCard>
);
};
export default WhereUsedCard;
|