AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(frontend): Add trigger agent banner for webhook-based flows (#11480)
Abhimanyu Yadav321ab8a48ad6
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/Flow.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/Flow.tsxindex 86b1e23871..d4c97353b7 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/Flow.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/Flow.tsx@@ -16,6 +16,7 @@ import { useCopyPaste } from "./useCopyPaste";import { FloatingReviewsPanel } from "@/components/organisms/FloatingReviewsPanel/FloatingReviewsPanel";import { parseAsString, useQueryStates } from "nuqs";import { CustomControls } from "./components/CustomControl";+import { TriggerAgentBanner } from "./components/TriggerAgentBanner";export const Flow = () => {const [{ flowExecutionID }] = useQueryStates({@@ -27,6 +28,9 @@ export const Flow = () => {const onNodesChange = useNodeStore(useShallow((state) => state.onNodesChange),);+ const hasWebhookNodes = useNodeStore(+ useShallow((state) => state.hasWebhookNodes()),+ );const nodeTypes = useMemo(() => ({ custom: CustomNode }), []);const edgeTypes = useMemo(() => ({ custom: CustomEdge }), []);const { edges, onConnect, onEdgesChange } = useCustomEdge();@@ -76,7 +80,7 @@ export const Flow = () => {<Background /><CustomControls setIsLocked={setIsLocked} isLocked={isLocked} /><NewControlPanel />- <BuilderActions />+ {hasWebhookNodes ? <TriggerAgentBanner /> : <BuilderActions />}{<GraphLoadingBox flowContentLoading={isFlowContentLoading} />}{isGraphRunning && <RunningBackground />}</ReactFlow>diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/components/TriggerAgentBanner.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/components/TriggerAgentBanner.tsxnew file mode 100644index 0000000000..f49a8cdd76--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/components/TriggerAgentBanner.tsx@@ -0,0 +1,49 @@+import {+ Alert,+ AlertDescription,+ AlertTitle,+} from "@/components/molecules/Alert/Alert";+import Link from "next/link";+import { useGetV2GetLibraryAgentByGraphId } from "@/app/api/__generated__/endpoints/library/library";+import { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";+import { useQueryStates, parseAsString } from "nuqs";++export const TriggerAgentBanner = () => {+ const [{ flowID }] = useQueryStates({+ flowID: parseAsString,+ });++ const { data: libraryAgent } = useGetV2GetLibraryAgentByGraphId(+ flowID ?? "",+ {},+ {+ query: {+ select: (x) => {+ return x.data as LibraryAgent;+ },+ enabled: !!flowID,+ },+ },+ );++ return (+ <Alert className="absolute bottom-4 left-1/2 z-20 w-auto -translate-x-1/2 select-none rounded-xlarge">+ <AlertTitle>You are building a Trigger Agent</AlertTitle>+ <AlertDescription>+ Your agent will listen for its trigger and will run when the time is+ right.+ <br />+ You can view its activity in your{" "}+ <Link+ href={+ libraryAgent ? `/library/agents/${libraryAgent.id}` : "/library"+ }+ className="underline"+ >+ Agent Library+ </Link>+ .+ </AlertDescription>+ </Alert>+ );+};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/stores/nodeStore.ts b/autogpt_platform/frontend/src/app/(platform)/build/stores/nodeStore.tsindex 3cc5764338..892c0e1cac 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/stores/nodeStore.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/stores/nodeStore.ts@@ -44,6 +44,7 @@ type NodeStore = {) => void;getNodeExecutionResult: (nodeId: string) => NodeExecutionResult | undefined;getNodeBlockUIType: (nodeId: string) => BlockUIType;+ hasWebhookNodes: () => boolean;};export const useNodeStore = create<NodeStore>((set, get) => ({@@ -204,4 +205,9 @@ export const useNodeStore = create<NodeStore>((set, get) => ({BlockUIType.STANDARD);},+ hasWebhookNodes: () => {+ return get().nodes.some((n) =>+ [BlockUIType.WEBHOOK, BlockUIType.WEBHOOK_MANUAL].includes(n.data.uiType),+ );+ },}));