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 unused helpers from the builder tutorial module (#15777)
Reinier van der Leer396865992e33
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/blocks.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/blocks.tsindex 0de0a168b6..a06dad3004 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/blocks.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/blocks.ts@@ -21,15 +21,11 @@ export const prefetchTutorialBlocks = async (): Promise<void> => {}};-export const getPrefetchedBlock = (blockId: string): BlockInfo | undefined => {- return prefetchedBlocks.get(blockId);-};-export const clearPrefetchedBlocks = (): void => {prefetchedBlocks.clear();};-export const addPrefetchedBlock = (+const addPrefetchedBlock = (blockId: string,position?: { x: number; y: number },): void => {@@ -41,7 +37,7 @@ export const addPrefetchedBlock = (}};-export const getNodeByBlockId = (blockId: string) => {+const getNodeByBlockId = (blockId: string) => {const nodes = useNodeStore.getState().nodes;return nodes.find((n) => n.data?.block_id === blockId);};@@ -62,7 +58,7 @@ export const addSecondCalculatorBlock = (): void => {}};-export const getCalculatorNodes = () => {+const getCalculatorNodes = () => {const nodes = useNodeStore.getState().nodes;return nodes.filter((n) => n.data?.block_id === BLOCK_IDS.CALCULATOR);};@@ -71,19 +67,3 @@ export const getSecondCalculatorNode = () => {const calculatorNodes = getCalculatorNodes();return calculatorNodes.length >= 2 ? calculatorNodes[1] : null;};--export const getFormContainerSelector = (blockId: string): string | null => {- const node = getNodeByBlockId(blockId);- if (node) {- return `[data-id="form-creator-container-${node.id}-node"]`;- }- return null;-};--export const getFormContainerElement = (blockId: string): Element | null => {- const selector = getFormContainerSelector(blockId);- if (selector) {- return document.querySelector(selector);- }- return null;-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/canvas.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/canvas.tsindex dd3d8576d9..c2c08dc40f 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/canvas.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/canvas.ts@@ -50,29 +50,11 @@ export const waitForNodesCount = (});};-export const getNodesCount = (): number => {- return useNodeStore.getState().nodes.length;-};-export const getFirstNode = () => {const nodes = useNodeStore.getState().nodes;return nodes.length > 0 ? nodes[0] : null;};-export const getNodeById = (nodeId: string) => {- const nodes = useNodeStore.getState().nodes;- return nodes.find((n) => n.id === nodeId);-};--export const nodeHasValues = (nodeId: string): boolean => {- const node = getNodeById(nodeId);- if (!node) return false;- const hardcodedValues = node.data?.hardcodedValues || {};- return Object.values(hardcodedValues).some(- (value) => value !== undefined && value !== null && value !== "",- );-};-export const fitViewToScreen = () => {const fitViewButton = document.querySelector(TUTORIAL_SELECTORS.FIT_VIEW_BUTTON,diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/connections.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/connections.tsdeleted file mode 100644index 4ec8c4df74..0000000000--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/connections.ts+++ /dev/null@@ -1,19 +0,0 @@-import { useNodeStore } from "../../../../stores/nodeStore";-import { useEdgeStore } from "../../../../stores/edgeStore";--export const isConnectionMade = (- sourceBlockId: string,- targetBlockId: string,-): boolean => {- const edges = useEdgeStore.getState().edges;- const nodes = useNodeStore.getState().nodes;-- const sourceNode = nodes.find((n) => n.data?.block_id === sourceBlockId);- const targetNode = nodes.find((n) => n.data?.block_id === targetBlockId);-- if (!sourceNode || !targetNode) return false;-- return edges.some((edge) => {- return edge.source === sourceNode.id && edge.target === targetNode.id;- });-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/dom.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/dom.tsindex 3ae9359cd9..4ffba0881e 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/dom.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/dom.ts@@ -1,4 +1,4 @@-import { TUTORIAL_CONFIG, TUTORIAL_SELECTORS } from "../constants";+import { TUTORIAL_CONFIG } from "../constants";export const waitForElement = (selector: string,@@ -21,160 +21,9 @@ export const waitForElement = (});};-export const waitForInputValue = (- selector: string,- targetValue: string,- timeout = 30000,-): Promise<void> => {- return new Promise((resolve) => {- const startTime = Date.now();-- const checkInput = () => {- const input = document.querySelector(selector) as HTMLInputElement;- if (input) {- const currentValue = input.value.toLowerCase().trim();- const target = targetValue.toLowerCase().trim();-- if (currentValue.includes(target) || target.includes(currentValue)) {- if (currentValue.length >= 4 || currentValue === target) {- resolve();- return;- }- }- }-- if (Date.now() - startTime > timeout) {- resolve();- } else {- setTimeout(checkInput, TUTORIAL_CONFIG.INPUT_CHECK_INTERVAL);- }- };- checkInput();- });-};--export const waitForSearchResult = (- selector: string,- timeout = 15000,-): Promise<Element | null> => {- return new Promise((resolve) => {- const startTime = Date.now();-- const checkResult = () => {- const element = document.querySelector(selector);- if (element) {- resolve(element);- } else if (Date.now() - startTime > timeout) {- resolve(null);- } else {- setTimeout(checkResult, TUTORIAL_CONFIG.ELEMENT_CHECK_INTERVAL);- }- };- checkResult();- });-};--export const waitForAnyBlockCard = (- timeout = 10000,-): Promise<Element | null> => {- return new Promise((resolve) => {- const startTime = Date.now();-- const checkBlock = () => {- const block = document.querySelector(- TUTORIAL_SELECTORS.BLOCK_CARD_PREFIX,- );- if (block) {- resolve(block);- } else if (Date.now() - startTime > timeout) {- resolve(null);- } else {- setTimeout(checkBlock, TUTORIAL_CONFIG.ELEMENT_CHECK_INTERVAL);- }- };- checkBlock();- });-};-export const focusElement = (selector: string): void => {const element = document.querySelector(selector) as HTMLElement;if (element) {element.focus();}};--export const scrollIntoView = (selector: string): void => {- const element = document.querySelector(selector);- if (element) {- element.scrollIntoView({- behavior: "smooth",- block: "center",- });- }-};--export const typeIntoInput = (selector: string, text: string) => {- const input = document.querySelector(selector) as HTMLInputElement;- if (input) {- input.focus();- input.value = text;- input.dispatchEvent(new Event("input", { bubbles: true }));- input.dispatchEvent(new Event("change", { bubbles: true }));- }-};--export const observeElement = (- selector: string,- callback: (element: Element) => void,-): MutationObserver => {- const observer = new MutationObserver((mutations, obs) => {- const element = document.querySelector(selector);- if (element) {- callback(element);- obs.disconnect();- }- });-- observer.observe(document.body, {- childList: true,- subtree: true,- });-- const element = document.querySelector(selector);- if (element) {- callback(element);- observer.disconnect();- }-- return observer;-};--export const watchSearchInput = (- targetValue: string,- onMatch: () => void,-): (() => void) => {- const input = document.querySelector(- TUTORIAL_SELECTORS.BLOCKS_SEARCH_INPUT,- ) as HTMLInputElement;- if (!input) return () => {};-- let hasMatched = false;-- const handler = () => {- if (hasMatched) return;-- const currentValue = input.value.toLowerCase().trim();- const target = targetValue.toLowerCase().trim();-- if (currentValue.length >= 4 && target.startsWith(currentValue)) {- hasMatched = true;- onMatch();- }- };-- input.addEventListener("input", handler);-- return () => {- input.removeEventListener("input", handler);- };-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/index.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/index.tsindex bd60ef06bb..027519a7bb 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/index.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/index.ts@@ -1,14 +1,4 @@-export {- waitForElement,- waitForInputValue,- waitForSearchResult,- waitForAnyBlockCard,- focusElement,- scrollIntoView,- typeIntoInput,- observeElement,- watchSearchInput,-} from "./dom";+export { waitForElement, focusElement } from "./dom";export {disableOtherBlocks,@@ -21,43 +11,21 @@ export {export {prefetchTutorialBlocks,- getPrefetchedBlock,clearPrefetchedBlocks,- addPrefetchedBlock,- getNodeByBlockId,addSecondCalculatorBlock,- getCalculatorNodes,getSecondCalculatorNode,- getFormContainerSelector,- getFormContainerElement,} from "./blocks";export {waitForNodeOnCanvas,waitForNodesCount,- getNodesCount,getFirstNode,- getNodeById,- nodeHasValues,fitViewToScreen,} from "./canvas";-export { isConnectionMade } from "./connections";--export {- forceBlockMenuOpen,- openBlockMenu,- closeBlockMenu,- clearBlockMenuSearch,-} from "./menu";+export { forceBlockMenuOpen, closeBlockMenu } from "./menu";-export {- openSaveControl,- closeSaveControl,- forceSaveOpen,- clickSaveButton,- isAgentSaved,-} from "./save";+export { forceSaveOpen } from "./save";export {handleTutorialCancel,diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/menu.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/menu.tsindex 905e34dfb9..1c8eb7f544 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/menu.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/menu.ts@@ -1,25 +1,10 @@-import { TUTORIAL_SELECTORS } from "../constants";import { useControlPanelStore } from "../../../../stores/controlPanelStore";export const forceBlockMenuOpen = (force: boolean) => {useControlPanelStore.getState().setForceOpenBlockMenu(force);};-export const openBlockMenu = () => {- useControlPanelStore.getState().setBlockMenuOpen(true);-};-export const closeBlockMenu = () => {useControlPanelStore.getState().setBlockMenuOpen(false);useControlPanelStore.getState().setForceOpenBlockMenu(false);};--export const clearBlockMenuSearch = () => {- const input = document.querySelector(- TUTORIAL_SELECTORS.BLOCKS_SEARCH_INPUT,- ) as HTMLInputElement;- if (input) {- input.value = "";- input.dispatchEvent(new Event("input", { bubbles: true }));- }-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/save.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/save.tsindex e932ee1b84..7125cbe869 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/save.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/helpers/save.ts@@ -1,10 +1,5 @@-import { TUTORIAL_SELECTORS } from "../constants";import { useControlPanelStore } from "../../../../stores/controlPanelStore";-export const openSaveControl = () => {- useControlPanelStore.getState().setSaveControlOpen(true);-};-export const closeSaveControl = () => {useControlPanelStore.getState().setSaveControlOpen(false);useControlPanelStore.getState().setForceOpenSave(false);@@ -13,19 +8,3 @@ export const closeSaveControl = () => {export const forceSaveOpen = (force: boolean) => {useControlPanelStore.getState().setForceOpenSave(force);};--export const clickSaveButton = () => {- const saveButton = document.querySelector(- TUTORIAL_SELECTORS.SAVE_AGENT_BUTTON,- ) as HTMLButtonElement;- if (saveButton && !saveButton.disabled) {- saveButton.click();- }-};--export const isAgentSaved = (): boolean => {- const versionInput = document.querySelector(- '[data-tutorial-id="save-control-version-output"]',- ) as HTMLInputElement;- return !!(versionInput && versionInput.value && versionInput.value !== "-");-};diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/icons.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/icons.tsindex 2c7a22b423..41c3dc8179 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/icons.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/icons.ts@@ -23,10 +23,3 @@ export const ICONS = {Keyboard: createIcon(iconPaths.Keyboard),Drag: createIcon(iconPaths.Drag),};--export function getIcon(- name: keyof typeof iconPaths,- options?: IconOptions,-): string {- return createIcon(iconPaths[name], options);-}diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/index.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/index.tsindex 49f505054b..5a6a2bd38e 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/index.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/index.ts@@ -13,7 +13,6 @@ import { useNodeStore } from "../../../stores/nodeStore";import { useEdgeStore } from "../../../stores/edgeStore";import { useTutorialStore } from "../../../stores/tutorialStore";-let isTutorialLoading = false;let tutorialLoadingCallback: ((loading: boolean) => void) | null = null;export const setTutorialLoadingCallback = (@@ -22,10 +21,7 @@ export const setTutorialLoadingCallback = (tutorialLoadingCallback = callback;};-export const getTutorialLoadingState = () => isTutorialLoading;-export const startTutorial = async () => {- isTutorialLoading = true;tutorialLoadingCallback?.(true);useNodeStore.getState().setNodes([]);@@ -35,7 +31,6 @@ export const startTutorial = async () => {try {await prefetchTutorialBlocks();} finally {- isTutorialLoading = false;tutorialLoadingCallback?.(false);}diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/styles.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/styles.tsindex 52a1b29c2e..6c7a6b348c 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/styles.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/tutorial/styles.ts@@ -66,37 +66,3 @@ export const banner = (</div>`;};--// Requirement box components-export const requirementBox = (- title: string,- items: string,- variant: "warning" | "success" = "warning",-) => {- const isSuccess = variant === "success";- return `- <div id="requirements-box" class="mt-3 p-3 ${isSuccess ? "bg-green-50 ring-1 ring-green-200" : "bg-amber-50 ring-1 ring-amber-200"} rounded-2xl">- <p class="text-sm font-medium ${isSuccess ? "text-green-600" : "text-amber-600"} m-0 mb-2">${title}</p>- ${items}- </div>-`;-};--export const requirementItem = (id: string, content: string) => `- <li id="${id}" class="flex items-center gap-2 text-amber-600">- <span class="req-icon">○</span> ${content}- </li>-`;--// Connection status box-export const connectionStatusBox = (- id: string,- variant: "waiting" | "connected" = "waiting",-) => {- const isConnected = variant === "connected";- return `- <div id="${id}" class="mt-3 p-2 ${isConnected ? "bg-green-50 ring-1 ring-green-200" : "bg-amber-50 ring-1 ring-amber-200"} rounded-2xl text-center text-sm ${isConnected ? "text-green-600" : "text-amber-600"}">- ${isConnected ? "✅ Connection already exists!" : "Waiting for connection..."}- </div>-`;-};