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.
refactor(frontend/builder): delete the builder's unused files, helpers and tutorial constants (#15821)
Reinier van der Leerd0c0ac780a9c
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/ARCHITECTURE_FLOW_EDITOR.md b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/ARCHITECTURE_FLOW_EDITOR.mdindex cd8a89bcbe..6d3aeebae8 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/ARCHITECTURE_FLOW_EDITOR.md+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/ARCHITECTURE_FLOW_EDITOR.md@@ -448,11 +448,11 @@ convertNodesPlusBlockInfoIntoCustomNodes(node, blockInfo);// Merges backend Node + BlockInfo → CustomNode (for loading)```-### **Handle ID Generation** (`handlers/helpers.ts`)+### **Handle ID Generation** (`@/components/renderers/InputRenderer/helpers.ts`)```typescript-generateHandleId(fieldId);-// input-{fieldId} or output-{fieldId}+getHandleId({ id, schema, uiOptions });+// Derives a field's handle id from its form id and ui options// Used to uniquely identify connection points```diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/components/SVGBeads.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/components/SVGBeads.tsxdeleted file mode 100644index 4573386456..0000000000--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/components/SVGBeads.tsx+++ /dev/null@@ -1,85 +0,0 @@-// This component uses SVG animation [Will see in future if we can make it work]-// Problem - it doesn't work with real time updates--import { useEffect, useMemo, useRef, useState } from "react";-import { getLengthOfPathInPixels } from "../helpers";--const BEAD_SPACING = 12;-const BASE_STOP_DISTANCE = 15;-const ANIMATION_DURATION = 0.5;-const ANIMATION_DELAY_PER_BEAD = 0.05;--interface BeadsProps {- beadUp: number;- beadDown: number;- edgePath: string;- beadsKey: string;-}--export const SVGBeads = ({- beadUp,- beadDown,- edgePath,- beadsKey,-}: BeadsProps) => {- const [removedBeads, setRemovedBeads] = useState<Set<number>>(new Set());- const animateRef = useRef<SVGAElement | null>(null);-- const visibleBeads = useMemo(() => {- return Array.from({ length: Math.max(0, beadUp) }, (_, i) => i).filter(- (index) => !removedBeads.has(index),- );- }, [beadUp, removedBeads]);-- const totalLength = getLengthOfPathInPixels(edgePath);-- useEffect(() => {- setRemovedBeads(new Set());- }, [beadUp]);-- useEffect(() => {- const elem = animateRef.current;- if (elem) {- const handleEnd = () => {- if (beadDown > 0) {- const beadsToRemove = Array.from(- { length: beadDown },- (_, i) => beadUp - beadDown + i,- );-- beadsToRemove.forEach((beadIndex) => {- setRemovedBeads((prev) => new Set(prev).add(beadIndex));- });- }- };- elem.addEventListener("endEvent", handleEnd);- return () => elem.removeEventListener("endEvent", handleEnd);- }- }, [beadUp, beadDown]);-- return (- <>- {visibleBeads.map((index) => {- const stopDistance = BASE_STOP_DISTANCE + index * BEAD_SPACING;- const beadStopPoint =- Math.max(0, totalLength - stopDistance) / totalLength;-- return (- <circle key={`${beadsKey}-${index}`} r="5" fill="#8d8d95">- <animateMotion- ref={animateRef}- dur={`${ANIMATION_DURATION}s`}- repeatCount="1"- fill="freeze"- path={edgePath}- begin={`${index * ANIMATION_DELAY_PER_BEAD}s`}- keyPoints={`0;${beadStopPoint}`}- keyTimes="0;1"- calcMode="linear"- />- </circle>- );- })}- </>- );-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/helpers.tsindex e0e481533a..8bdd48b041 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/helpers.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/edges/helpers.ts@@ -1,17 +1,4 @@-import { Link } from "@/app/api/__generated__/models/link";-import { Connection } from "@xyflow/react";--export const convertConnectionsToBackendLinks = (- connections: Connection[],-): Link[] =>- connections.map((c) => ({- source_id: c.source || "",- sink_id: c.target || "",- source_name: c.sourceHandle || "",- sink_name: c.targetHandle || "",- }));--// ------------------- SVG Beads helpers -------------------+// ------------------- JS Beads helpers -------------------export const getLengthOfPathInPixels = (path: string) => {const pathElement = document.createElementNS(@@ -22,27 +9,6 @@ export const getLengthOfPathInPixels = (path: string) => {return pathElement.getTotalLength();};-// ------------------- JS Beads helpers ---------------------export const getPointAtT = (- t: number,- edgePath: string,- pathRef: React.MutableRefObject<SVGPathElement | null>,-) => {- if (!pathRef.current) {- const tempPath = document.createElementNS(- "http://www.w3.org/2000/svg",- "path",- );- tempPath.setAttribute("d", edgePath);- pathRef.current = tempPath;- }-- const totalLength = pathRef.current.getTotalLength();- const point = pathRef.current.getPointAtLength(t * totalLength);- return { x: point.x, y: point.y };-};-export const getTForDistance = (distanceFromEnd: number,totalLength: number,diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/handlers/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/handlers/helpers.tsdeleted file mode 100644index afaa85a38a..0000000000--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/handlers/helpers.ts+++ /dev/null@@ -1,63 +0,0 @@-// Here we are handling single level of nesting, if need more in future then i will update it--const sanitizeForHandleId = (str: string): string => {- if (!str) return "";-- return str- .trim()- .replace(/\s+/g, "_") // Replace spaces with underscores- .replace(/[^a-zA-Z0-9_-]/g, "") // Remove special characters except underscores and hyphens- .replace(/_+/g, "_") // Replace multiple consecutive underscores with single underscore- .replace(/^_|_$/g, ""); // Remove leading/trailing underscores-};--const cleanTitleId = (id: string): string => {- if (!id) return "";-- if (id.endsWith("_title")) {- id = id.slice(0, -6);- }- const parts = id.split("_");- const filtered = parts.filter(- (p) => p !== "root" && p !== "properties" && p.length > 0,- );- const filtered_id = filtered.join("_") || "";- return filtered_id;-};--export const generateHandleIdFromTitleId = (- fieldKey: string,- {- isObjectProperty,- isAdditionalProperty,- isArrayItem,- }: {- isArrayItem?: boolean;- isObjectProperty?: boolean;- isAdditionalProperty?: boolean;- } = {- isArrayItem: false,- isObjectProperty: false,- isAdditionalProperty: false,- },-): string => {- if (!fieldKey) return "";-- const filteredKey = cleanTitleId(fieldKey);- if (isAdditionalProperty || isArrayItem) {- return filteredKey;- }- const cleanedKey = sanitizeForHandleId(filteredKey);-- if (isObjectProperty) {- // "config_api_key" -> "config.api_key"- const parts = cleanedKey.split("_");- if (parts.length >= 2) {- const baseName = parts[0];- const propertyName = parts.slice(1).join("_");- return `${baseName}.${propertyName}`;- }- }-- return cleanedKey;-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/constants.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/constants.tsindex 1a7e4176c6..9279ef8b53 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/constants.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/constants.ts@@ -1,29 +1,16 @@// Block IDs for tutorial blocksexport const BLOCK_IDS = {CALCULATOR: "b1ab9b19-67a6-406d-abf5-2dba76d00c79",- AGENT_INPUT: "c0a8e994-ebf1-4a9c-a4d8-89d09c86741b",- AGENT_OUTPUT: "363ae599-353e-4804-937e-b2ee3cef3da4",} as const;export const TUTORIAL_SELECTORS = {- // Custom nodes - These are all before saving- INPUT_NODE: '[data-id="custom-node-2"]',- OUTPUT_NODE: '[data-id="custom-node-3 "]',- CALCULATOR_NODE: '[data-id="custom-node-1"]',-- // Paricular field selector- NAME_FIELD_OUTPUT_NODE: '[data-id="field-3-root_name"]',-// Output Handlers- SECOND_CALCULATOR_RESULT_OUTPUT_HANDLER:- '[data-tutorial-id="output-handler-2-result"]',FIRST_CALCULATOR_RESULT_OUTPUT_HANDLER:'[data-tutorial-id="output-handler-1-result"]',// Input HandlerSECOND_CALCULATOR_NUMBER_A_INPUT_HANDLER:'[data-tutorial-id="input-handler-2-a"]',- OUTPUT_VALUE_INPUT_HANDLEER: '[data-tutorial-id="label-3-root_value"]',// Block MenuBLOCKS_TRIGGER: '[data-id="blocks-control-popover-trigger"]',@@ -100,9 +87,6 @@ export const TUTORIAL_SELECTORS = {FIRST_CALCULATOR_NODE_OUTPUT: '[data-tutorial-id="node-output"]',// These are the Id's of the nodes before savingCALCULATOR_NODE_FORM_CONTAINER: '[data-id^="form-creator-container-1-node"]', // <-- Add this line- AGENT_INPUT_NODE_FORM_CONTAINER: '[data-id^="form-creator-container-2-node"]', // <-- Add this line- AGENT_OUTPUT_NODE_FORM_CONTAINER:- '[data-id^="form-creator-container-3-node"]', // <-- Add this line// Execution badgesBADGE_QUEUED: '[data-id^="badge-"][data-id$="-QUEUED"]',diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/AiBlock.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/AiBlock.tsxdeleted file mode 100644index 52322eb094..0000000000--- a/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/AiBlock.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { Button } from "@/components/__legacy__/ui/button";-import { cn } from "@/lib/utils";-import { Plus } from "lucide-react";-import { ButtonHTMLAttributes } from "react";--interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {- title?: string;- description?: string;- ai_name?: string;-}--export const AiBlock: React.FC<Props> = ({- title,- description,- className,- ai_name,- ...rest-}) => {- return (- <Button- className={cn(- "group flex h-[5.625rem] w-full min-w-[7.5rem] items-center justify-start space-x-3 whitespace-normal rounded-[0.75rem] bg-zinc-50 px-[0.875rem] py-[0.625rem] text-start shadow-none",- "hover:bg-zinc-100 focus:ring-0 active:bg-zinc-100 active:ring-1 active:ring-zinc-300 disabled:pointer-events-none",- className,- )}- {...rest}- >- <div className="flex flex-1 flex-col items-start gap-1.5">- <div className="space-y-0.5">- <span- className={cn(- "line-clamp-1 font-sans text-sm font-medium leading-[1.375rem] text-zinc-700 group-disabled:text-zinc-400",- )}- >- {title}- </span>- <span- className={cn(- "line-clamp-1 font-sans text-xs font-normal leading-5 text-zinc-500 group-disabled:text-zinc-400",- )}- >- {description}- </span>- </div>-- <span- className={cn(- "rounded-[0.75rem] bg-zinc-200 px-[0.5rem] font-sans text-xs leading-[1.25rem] text-zinc-500",- )}- >- Supports {ai_name}- </span>- </div>- <div- className={cn(- "flex h-7 w-7 items-center justify-center rounded-[0.5rem] bg-zinc-700 group-disabled:bg-zinc-400",- )}- >- <Plus className="h-5 w-5 text-zinc-50" strokeWidth={2} />- </div>- </Button>- );-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/BlockMenuFilters/types.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/BlockMenuFilters/types.tsindex 43aacee787..5610842879 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/BlockMenuFilters/types.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/NewControlPanel/NewBlockMenu/BlockMenuFilters/types.ts@@ -1,26 +1,5 @@import { SearchEntryFilterAnyOfItem } from "@/app/api/__generated__/models/searchEntryFilterAnyOfItem";-export type DefaultStateType =- | "suggestion"- | "all_blocks"- | "input_blocks"- | "action_blocks"- | "output_blocks"- | "integrations"- | "marketplace_agents"- | "my_agents";-export type CategoryKey = SearchEntryFilterAnyOfItem;-export interface Filters {- categories: {- blocks: boolean;- integrations: boolean;- marketplace_agents: boolean;- my_agents: boolean;- providers: boolean;- };- createdBy: string[];-}-export type CategoryCounts = Record<CategoryKey, number>;diff --git a/autogpt_platform/frontend/src/app/(platform)/build/hooks/useCopyPasteKeyboard.ts b/autogpt_platform/frontend/src/app/(platform)/build/hooks/useCopyPasteKeyboard.tsdeleted file mode 100644index b1b1b34774..0000000000--- a/autogpt_platform/frontend/src/app/(platform)/build/hooks/useCopyPasteKeyboard.ts+++ /dev/null@@ -1,39 +0,0 @@-import { useEffect } from "react";-import { useCopyPasteStore } from "../stores/copyPasteStore";--export function useCopyPasteKeyboard() {- const { copySelectedNodes, pasteNodes } = useCopyPasteStore();-- useEffect(() => {- const handleKeyDown = (event: KeyboardEvent) => {- const activeElement = document.activeElement;- const isInputField =- activeElement?.tagName === "INPUT" ||- activeElement?.tagName === "TEXTAREA" ||- activeElement?.getAttribute("contenteditable") === "true";-- if (isInputField) return;-- if (- (event.ctrlKey || event.metaKey) &&- (event.key === "c" || event.key === "C")- ) {- event.preventDefault();- copySelectedNodes();- }-- if (- (event.ctrlKey || event.metaKey) &&- (event.key === "v" || event.key === "V")- ) {- event.preventDefault();- pasteNodes();- }- };-- window.addEventListener("keydown", handleKeyDown);- return () => {- window.removeEventListener("keydown", handleKeyDown);- };- }, [copySelectedNodes, pasteNodes]);-}