Skip to content

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(builder): Added tooltips for blocks (#7793)

Swifty98c1cb8ff9ac
diff --git a/rnd/autogpt_builder/src/components/CustomNode.tsx b/rnd/autogpt_builder/src/components/CustomNode.tsx
index 7001e72a5e..511a9bd883 100644
--- a/rnd/autogpt_builder/src/components/CustomNode.tsx
+++ b/rnd/autogpt_builder/src/components/CustomNode.tsx
@@ -23,12 +23,14 @@ import { history } from "./history";
import NodeHandle from "./NodeHandle";
import { CustomEdgeData } from "./CustomEdge";
import { NodeGenericInputField } from "./node-input-components";
+import SchemaTooltip from "./SchemaTooltip";
type ParsedKey = { key: string; index?: number };
export type CustomNodeData = {
blockType: string;
title: string;
+ description: string;
inputSchema: BlockIORootSchema;
outputSchema: BlockIORootSchema;
hardcodedValues: { [key: string]: any };
@@ -282,8 +284,13 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {
onMouseLeave={handleMouseLeave}
>
<div className="mb-2 p-3 bg-gray-300/[.7] rounded-t-xl">
- <div className="p-3 text-lg font-semibold font-roboto">
- {beautifyString(data.blockType?.replace(/Block$/, "") || data.title)}
+ <div className="flex items-center justify-between">
+ <div className="p-3 text-lg font-semibold font-roboto">
+ {beautifyString(
+ data.blockType?.replace(/Block$/, "") || data.title,
+ )}
+ </div>
+ <SchemaTooltip description={data.description} />
</div>
<div className="flex gap-[5px] ">
{isHovered && (
diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsx
index d49ba92ae7..028ed2ac39 100644
--- a/rnd/autogpt_builder/src/components/Flow.tsx
+++ b/rnd/autogpt_builder/src/components/Flow.tsx
@@ -380,6 +380,7 @@ const FlowEditor: React.FC<{
data: {
blockType: nodeType,
title: `${nodeType} ${nodeId}`,
+ description: nodeSchema.description,
inputSchema: nodeSchema.inputSchema,
outputSchema: nodeSchema.outputSchema,
hardcodedValues: {},
@@ -459,6 +460,7 @@ const FlowEditor: React.FC<{
data: {
block_id: block.id,
blockType: block.name,
+ description: block.description,
title: `${block.name} ${node.id}`,
inputSchema: block.inputSchema,
outputSchema: block.outputSchema,
diff --git a/rnd/autogpt_builder/src/components/NodeHandle.tsx b/rnd/autogpt_builder/src/components/NodeHandle.tsx
index 7bfae99e26..f4495fa429 100644
--- a/rnd/autogpt_builder/src/components/NodeHandle.tsx
+++ b/rnd/autogpt_builder/src/components/NodeHandle.tsx
@@ -60,7 +60,7 @@ const NodeHandle: FC<HandleProps> = ({
{label}
</div>
</Handle>
- <SchemaTooltip schema={schema} />
+ <SchemaTooltip description={schema.description} />
</div>
);
} else {
diff --git a/rnd/autogpt_builder/src/components/SchemaTooltip.tsx b/rnd/autogpt_builder/src/components/SchemaTooltip.tsx
index e16db7508a..f35bcd11ea 100644
--- a/rnd/autogpt_builder/src/components/SchemaTooltip.tsx
+++ b/rnd/autogpt_builder/src/components/SchemaTooltip.tsx
@@ -4,12 +4,11 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
-import { BlockIOSubSchema } from "@/lib/autogpt-server-api/types";
import { Info } from "lucide-react";
import ReactMarkdown from "react-markdown";
-const SchemaTooltip: React.FC<{ schema: BlockIOSubSchema }> = ({ schema }) => {
- if (!schema.description) return null;
+const SchemaTooltip: React.FC<{ description?: string }> = ({ description }) => {
+ if (!description) return null;
return (
<TooltipProvider delayDuration={400}>
@@ -25,7 +24,7 @@ const SchemaTooltip: React.FC<{ schema: BlockIOSubSchema }> = ({ schema }) => {
),
}}
>
- {schema.description}
+ {description}
</ReactMarkdown>
</TooltipContent>
</Tooltip>
diff --git a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx
index 906d322cc9..736d32b36e 100644
--- a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx
+++ b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx
@@ -14,6 +14,7 @@ import {
import { Block } from "@/lib/autogpt-server-api";
import { PlusIcon } from "@radix-ui/react-icons";
import { IconToyBrick } from "@/components/ui/icons";
+import SchemaTooltip from "@/components/SchemaTooltip";
interface BlocksControlProps {
blocks: Block[];
@@ -80,6 +81,7 @@ export const BlocksControl: React.FC<BlocksControlProps> = ({
{beautifyString(block.name)}
</span>
</div>
+ <SchemaTooltip description={block.description} />
<div className="flex items-center gap-1 flex-shrink-0">
<Button
variant="ghost"