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.

refactor(frontend): remove unused legacy components (#14938)

Ubbe7d3cd08a8947
diff --git a/autogpt_platform/frontend/package.json b/autogpt_platform/frontend/package.json
index 7b7220f487..f4cb467532 100644
--- a/autogpt_platform/frontend/package.json
+++ b/autogpt_platform/frontend/package.json
@@ -52,7 +52,6 @@
"@radix-ui/react-icons": "1.3.2",
"@radix-ui/react-label": "2.1.7",
"@radix-ui/react-popover": "1.1.15",
- "@radix-ui/react-radio-group": "1.3.8",
"@radix-ui/react-scroll-area": "1.2.10",
"@radix-ui/react-select": "2.2.6",
"@radix-ui/react-separator": "1.1.7",
@@ -69,7 +68,6 @@
"@streamdown/math": "1.0.1",
"@streamdown/mermaid": "1.0.1",
"@tanstack/react-query": "5.90.6",
- "@tanstack/react-table": "8.21.3",
"@types/jaro-winkler": "0.2.4",
"@vercel/analytics": "2.0.1",
"@vercel/speed-insights": "1.2.0",
diff --git a/autogpt_platform/frontend/pnpm-lock.yaml b/autogpt_platform/frontend/pnpm-lock.yaml
index 76afccf9ac..a2628bb72e 100644
--- a/autogpt_platform/frontend/pnpm-lock.yaml
+++ b/autogpt_platform/frontend/pnpm-lock.yaml
@@ -67,9 +67,6 @@ importers:
'@radix-ui/react-popover':
specifier: 1.1.15
- '@radix-ui/react-radio-group':
- specifier: 1.3.8
'@radix-ui/react-scroll-area':
specifier: 1.2.10
@@ -118,9 +115,6 @@ importers:
'@tanstack/react-query':
specifier: 5.90.6
version: 5.90.6([email protected])
- '@tanstack/react-table':
- specifier: 8.21.3
'@types/jaro-winkler':
specifier: 0.2.4
version: 0.2.4
@@ -3162,19 +3156,6 @@ packages:
'@types/react-dom':
optional: true
- '@radix-ui/[email protected]':
- resolution: {integrity: sha512-VBKYIYImA5zsxACdisNQ3BjCBfmbGH3kQlnFVqlWU4tXwjy7cGX8ta80BcrO+WJXIn5iBylEH3K6ZTlee//lgQ==}
- peerDependencies:
- '@types/react': '*'
- '@types/react-dom': '*'
- react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
- react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
- peerDependenciesMeta:
- '@types/react':
- optional: true
- '@types/react-dom':
- optional: true
-
'@radix-ui/[email protected]':
resolution: {integrity: sha512-7A6S9jSgm/S+7MdtNDSb+IU859vQqJ/QAtcYQcfFC6W8RS4IxIZDldLR0xqCFZ6DCyrQLjLPsxtTNch5jVA4lA==}
peerDependencies:
@@ -4102,23 +4083,12 @@ packages:
peerDependencies:
react: ^18 || ^19
- '@tanstack/[email protected]':
- resolution: {integrity: sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==}
- engines: {node: '>=12'}
- peerDependencies:
- react: '>=16.8'
- react-dom: '>=16.8'
-
'@tanstack/[email protected]':
resolution: {integrity: sha512-dZkhyfahpvlaV0rIKnvQiVoWPyURppl6w4m9IwMDpuIjcJ1sD9YGWrt0wISvgU7ewACXx2Ct46WPgI6qAD4v6A==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
- '@tanstack/[email protected]':
- resolution: {integrity: sha512-ldZXEhOBb8Is7xLs01fR3YEc3DERiz5silj8tnGkFZytt1abEvl/GhUmCE0PMLaMPTa3Jk4HbKmRlHmu+gCftg==}
- engines: {node: '>=12'}
-
'@tanstack/[email protected]':
resolution: {integrity: sha512-Mx86Hqu1k39icq2Zusq+Ey2J6dDWTjDvEv43PJtRCoEYTLyfaPnxIQ6iy7YAOK0NV/qOEmZQ/uCufrppZxTgcg==}
@@ -12483,24 +12453,6 @@ snapshots:
'@types/react': 18.3.17
'@types/react-dom': 18.3.5(@types/[email protected])
- dependencies:
- '@radix-ui/primitive': 1.1.3
- '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
- '@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])
- '@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])
- '@radix-ui/react-roving-focus': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
- '@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])
- '@radix-ui/react-use-previous': 1.1.1(@types/[email protected])([email protected])
- '@radix-ui/react-use-size': 1.1.1(@types/[email protected])([email protected])
- react: 18.3.1
- react-dom: 18.3.1([email protected])
- optionalDependencies:
- '@types/react': 18.3.17
- '@types/react-dom': 18.3.5(@types/[email protected])
-
dependencies:
'@radix-ui/primitive': 1.1.3
@@ -13581,20 +13533,12 @@ snapshots:
'@tanstack/query-core': 5.90.6
react: 18.3.1
- dependencies:
- '@tanstack/table-core': 8.21.3
- react: 18.3.1
- react-dom: 18.3.1([email protected])
-
dependencies:
'@tanstack/virtual-core': 3.13.18
react: 18.3.1
react-dom: 18.3.1([email protected])
- '@tanstack/[email protected]': {}
-
'@tanstack/[email protected]': {}
'@testing-library/[email protected]':
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/components/OutputActions.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/components/OutputActions.tsx
deleted file mode 100644
index 2bc50f5306..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/components/OutputActions.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-"use client";
-
-import React, { useState } from "react";
-import { Button } from "@/components/atoms/Button/Button";
-import { OutputRenderer, OutputMetadata } from "../types";
-import { downloadOutputs } from "../utils/download";
-import { cn } from "@/lib/utils";
-import {
- Copy01Icon,
- Download04Icon,
- Tick02Icon,
-} from "@hugeicons/core-free-icons";
-import { Icon } from "@/components/atoms/Icon/Icon";
-
-interface OutputActionsProps {
- items: Array<{
- value: unknown;
- metadata?: OutputMetadata;
- renderer: OutputRenderer;
- }>;
- isPrimary?: boolean;
- className?: string;
-}
-
-export function OutputActions({
- items,
- isPrimary = false,
-}: OutputActionsProps) {
- const [copied, setCopied] = useState(false);
-
- const handleCopyAll = async () => {
- const textContents: string[] = [];
-
- for (const item of items) {
- const copyContent = item.renderer.getCopyContent(
- item.value,
- item.metadata,
- );
- if (
- copyContent &&
- item.renderer.isConcatenable(item.value, item.metadata)
- ) {
- // For concatenable items, extract the text
- let text: string;
- if (typeof copyContent.data === "string") {
- text = copyContent.data;
- } else if (copyContent.fallbackText) {
- text = copyContent.fallbackText;
- } else {
- continue;
- }
- textContents.push(text);
- }
- }
-
- if (textContents.length > 0) {
- const combinedText = textContents.join("\n\n");
- try {
- await navigator.clipboard.writeText(combinedText);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- } catch (error) {
- console.error("Failed to copy:", error);
- }
- }
- };
-
- const handleDownloadAll = () => {
- downloadOutputs(items);
- };
-
- return (
- <div className="flex items-center gap-3">
- <Button
- variant={isPrimary ? "primary" : "ghost"}
- size={isPrimary ? "small" : "icon"}
- onClick={handleCopyAll}
- aria-label="Copy all text outputs"
- className={cn(isPrimary ? "min-w-0" : "")}
- >
- {copied ? (
- <Icon icon={Tick02Icon} className="size-4 text-green-600" />
- ) : (
- <Icon
- icon={Copy01Icon}
- className={cn(
- "size-4",
- isPrimary ? "text-white" : "text-neutral-500",
- )}
- />
- )}
- {isPrimary && <span>Copy All</span>}
- </Button>
-
- <Button
- variant={isPrimary ? "primary" : "ghost"}
- size={isPrimary ? "small" : "icon"}
- onClick={handleDownloadAll}
- aria-label="Download outputs"
- className={cn(isPrimary ? "min-w-0" : "")}
- >
- <Icon
- icon={Download04Icon}
- className={cn(
- "size-4",
- isPrimary ? "text-white" : "text-neutral-500",
- )}
- />
- {isPrimary && <span>Download All</span>}
- </Button>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/components/OutputItem.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/components/OutputItem.tsx
deleted file mode 100644
index c5c91d5d48..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/components/OutputItem.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-"use client";
-
-import { Text } from "@/components/atoms/Text/Text";
-import { OutputMetadata, OutputRenderer } from "../types";
-
-interface OutputItemProps {
- value: any;
- metadata?: OutputMetadata;
- renderer: OutputRenderer;
- label?: string;
-}
-
-export function OutputItem({
- value,
- metadata,
- renderer,
- label,
-}: OutputItemProps) {
- return (
- <div className="relative">
- {label && (
- <Text variant="large-medium" className="capitalize">
- {label}
- </Text>
- )}
-
- <div className="relative">{renderer.render(value, metadata)}</div>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/index.ts b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/index.ts
deleted file mode 100644
index ba26054eb2..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/index.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { globalRegistry } from "./types";
-import { textRenderer } from "./renderers/TextRenderer";
-import { codeRenderer } from "./renderers/CodeRenderer";
-import { imageRenderer } from "./renderers/ImageRenderer";
-import { videoRenderer } from "./renderers/VideoRenderer";
-import { jsonRenderer } from "./renderers/JSONRenderer";
-import { markdownRenderer } from "./renderers/MarkdownRenderer";
-
-// Register all renderers in priority order
-globalRegistry.register(videoRenderer);
-globalRegistry.register(imageRenderer);
-globalRegistry.register(codeRenderer);
-globalRegistry.register(markdownRenderer);
-globalRegistry.register(jsonRenderer);
-globalRegistry.register(textRenderer);
-
-export { globalRegistry };
-export type { OutputRenderer, OutputMetadata, DownloadContent } from "./types";
-export { OutputItem } from "./components/OutputItem";
-export { OutputActions } from "./components/OutputActions";
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/CodeRenderer.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/CodeRenderer.tsx
deleted file mode 100644
index a204890a3a..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/CodeRenderer.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import React from "react";
-import {
- OutputRenderer,
- OutputMetadata,
- DownloadContent,
- CopyContent,
-} from "../types";
-
-function getFileExtension(language: string): string {
- const extensionMap: Record<string, string> = {
- javascript: "js",
- typescript: "ts",
- python: "py",
- java: "java",
- csharp: "cs",
- cpp: "cpp",
- c: "c",
- html: "html",
- css: "css",
- json: "json",
- xml: "xml",
- yaml: "yaml",
- markdown: "md",
- sql: "sql",
- bash: "sh",
- shell: "sh",
- plaintext: "txt",
- };
-
- return extensionMap[language.toLowerCase()] || "txt";
-}
-
-function canRenderCode(value: unknown, metadata?: OutputMetadata): boolean {
- if (metadata?.type === "code" || metadata?.language) {
- return typeof value === "string";
- }
-
- if (typeof value !== "string") return false;
-
- const markdownIndicators = [
- /^#{1,6}\s+/m,
- /\*\*[^*]+\*\*/,
- /\[([^\]]+)\]\(([^)]+)\)/,
- /^>\s+/m,
- /^\s*[-*+]\s+\w+/m,
- /!\[([^\]]*)\]\(([^)]+)\)/,
- ];
-
- let markdownMatches = 0;
- for (const pattern of markdownIndicators) {
- if (pattern.test(value)) {
- markdownMatches++;
- if (markdownMatches >= 2) {
- return false;
- }
- }
- }
-
- const codeIndicators = [
- /^(function|const|let|var|class|import|export|if|for|while)\s/m,
- /^def\s+\w+\s*\(/m,
- /^import\s+/m,
- /^from\s+\w+\s+import/m,
- /^\s*<[^>]+>/,
- /[{}[\]();]/,
- ];
-
- return codeIndicators.some((pattern) => pattern.test(value));
-}
-
-function renderCode(
- value: unknown,
- metadata?: OutputMetadata,
-): React.ReactNode {
- const codeValue = String(value);
- const language = metadata?.language || "plaintext";
-
- return (
- <div className="group relative">
- {metadata?.language && (
- <div className="absolute right-2 top-2 rounded bg-background/80 px-2 py-1 text-xs text-muted-foreground">
- {language}
- </div>
- )}
- <pre className="overflow-x-auto rounded-md bg-muted p-3">
- <code className="whitespace-pre-wrap break-words font-mono text-sm">
- {codeValue}
- </code>
- </pre>
- </div>
- );
-}
-
-function getCopyContentCode(
- value: unknown,
- _metadata?: OutputMetadata,
-): CopyContent | null {
- const codeValue = String(value);
- return {
- mimeType: "text/plain",
- data: codeValue,
- fallbackText: codeValue,
- };
-}
-
-function getDownloadContentCode(
- value: unknown,
- metadata?: OutputMetadata,
-): DownloadContent | null {
- const codeValue = String(value);
- const language = metadata?.language || "txt";
- const extension = getFileExtension(language);
- const blob = new Blob([codeValue], { type: "text/plain" });
-
- return {
- data: blob,
- filename: metadata?.filename || `code.${extension}`,
- mimeType: "text/plain",
- };
-}
-
-function isConcatenableCode(
- _value: unknown,
- _metadata?: OutputMetadata,
-): boolean {
- return true;
-}
-
-export const codeRenderer: OutputRenderer = {
- name: "CodeRenderer",
- priority: 30,
- canRender: canRenderCode,
- render: renderCode,
- getCopyContent: getCopyContentCode,
- getDownloadContent: getDownloadContentCode,
- isConcatenable: isConcatenableCode,
-};
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/ImageRenderer.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/ImageRenderer.tsx
deleted file mode 100644
index f2a7636c6e..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/ImageRenderer.tsx
+++ /dev/null
@@ -1,209 +0,0 @@
-import React from "react";
-import {
- OutputRenderer,
- OutputMetadata,
- DownloadContent,
- CopyContent,
-} from "../types";
-
-const imageExtensions = [
- ".jpg",
- ".jpeg",
- ".png",
- ".gif",
- ".bmp",
- ".svg",
- ".webp",
- ".ico",
-];
-
-const imageMimeTypes = [
- "image/jpeg",
- "image/png",
- "image/gif",
- "image/bmp",
- "image/svg+xml",
- "image/webp",
- "image/x-icon",
-];
-
-function guessMimeType(url: string): string | null {
- const extension = url.split(".").pop()?.toLowerCase();
- const mimeMap: Record<string, string> = {
- jpg: "image/jpeg",
- jpeg: "image/jpeg",
- png: "image/png",
- gif: "image/gif",
- bmp: "image/bmp",
- svg: "image/svg+xml",
- webp: "image/webp",
- ico: "image/x-icon",
- };
- return extension ? mimeMap[extension] || null : null;
-}
-
-function canRenderImage(value: unknown, metadata?: OutputMetadata): boolean {
- if (
- metadata?.type === "image" ||
- (metadata?.mimeType && imageMimeTypes.includes(metadata.mimeType))
- ) {
- return true;
- }
-
- if (typeof value === "object" && value !== null) {
- const obj = value as any;
- if (obj.url || obj.data || obj.path) {
- const urlOrData = obj.url || obj.data || obj.path;
-
- if (typeof urlOrData === "string") {
- if (urlOrData.startsWith("data:image/")) {
- return true;
- }
-
- if (
- urlOrData.startsWith("http://") ||
- urlOrData.startsWith("https://")
- ) {
- const hasImageExt = imageExtensions.some((ext) =>
- urlOrData.toLowerCase().includes(ext),
- );
- return hasImageExt;
- }
- }
- }
-
- if (obj.filename) {
- const hasImageExt = imageExtensions.some((ext) =>
- obj.filename.toLowerCase().endsWith(ext),
- );
- return hasImageExt;
- }
- }
-
- if (typeof value === "string") {
- if (value.startsWith("data:image/")) {
- return true;
- }
-
- if (value.startsWith("http://") || value.startsWith("https://")) {
- const hasImageExt = imageExtensions.some((ext) =>
- value.toLowerCase().includes(ext),
- );
- return hasImageExt;
- }
-
- if (metadata?.filename) {
- const hasImageExt = imageExtensions.some((ext) =>
- metadata.filename!.toLowerCase().endsWith(ext),
- );
- return hasImageExt;
- }
- }
-
- return false;
-}
-
-function renderImage(
- value: unknown,
- metadata?: OutputMetadata,
-): React.ReactNode {
- const imageUrl = String(value);
- const altText = metadata?.filename || "Output image";
-
- return (
- <div className="group relative">
- {/* eslint-disable-next-line @next/next/no-img-element */}
- <img
- src={imageUrl}
- alt={altText}
- className="h-auto max-w-full rounded-md border border-gray-200"
- loading="lazy"
- />
- </div>
- );
-}
-
-function getCopyContentImage(
- value: unknown,
- metadata?: OutputMetadata,
-): CopyContent | null {
- const imageUrl = String(value);
-
- if (imageUrl.startsWith("data:")) {
- const mimeMatch = imageUrl.match(/data:([^;]+)/);
- const mimeType = mimeMatch?.[1] || "image/png";
-
- return {
- mimeType: mimeType,
- data: async () => {
- const response = await fetch(imageUrl);
- return await response.blob();
- },
- alternativeMimeTypes: ["image/png", "text/plain"],
- fallbackText: imageUrl,
- };
- }
-
- const mimeType = metadata?.mimeType || guessMimeType(imageUrl) || "image/png";
-
- return {
- mimeType: mimeType,
- data: async () => {
- const response = await fetch(imageUrl);
- return await response.blob();
- },
- alternativeMimeTypes: ["image/png", "text/plain"],
- fallbackText: imageUrl,
- };
-}
-
-function getDownloadContentImage(
- value: unknown,
- metadata?: OutputMetadata,
-): DownloadContent | null {
- const imageUrl = String(value);
-
- if (imageUrl.startsWith("data:")) {
- const [mimeInfo, base64Data] = imageUrl.split(",");
- const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || "image/png";
- const byteCharacters = atob(base64Data);
- const byteNumbers = new Array(byteCharacters.length);
-
- for (let i = 0; i < byteCharacters.length; i++) {
- byteNumbers[i] = byteCharacters.charCodeAt(i);
- }
-
- const byteArray = new Uint8Array(byteNumbers);
- const blob = new Blob([byteArray], { type: mimeType });
-
- const extension = mimeType.split("/")[1] || "png";
- return {
- data: blob,
- filename: metadata?.filename || `image.${extension}`,
- mimeType,
- };
- }
-
- return {
- data: imageUrl,
- filename: metadata?.filename || "image.png",
- mimeType: metadata?.mimeType || "image/png",
- };
-}
-
-function isConcatenableImage(
- _value: unknown,
- _metadata?: OutputMetadata,
-): boolean {
- return false;
-}
-
-export const imageRenderer: OutputRenderer = {
- name: "ImageRenderer",
- priority: 40,
- canRender: canRenderImage,
- render: renderImage,
- getCopyContent: getCopyContentImage,
- getDownloadContent: getDownloadContentImage,
- isConcatenable: isConcatenableImage,
-};
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/JSONRenderer.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/JSONRenderer.tsx
deleted file mode 100644
index d325726c7e..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/JSONRenderer.tsx
+++ /dev/null
@@ -1,205 +0,0 @@
-"use client";
-
-import React, { useState } from "react";
-import {
- OutputRenderer,
- OutputMetadata,
- DownloadContent,
- CopyContent,
-} from "../types";
-import { ArrowDown01Icon, ArrowRight01Icon } from "@hugeicons/core-free-icons";
-import { Icon } from "@/components/atoms/Icon/Icon";
-
-function canRenderJSON(value: unknown, _metadata?: OutputMetadata): boolean {
- if (_metadata?.type === "json") {
- return true;
- }
-
- if (typeof value === "object" && value !== null) {
- return true;
- }
-
- if (typeof value === "string") {
- try {
- JSON.parse(value);
- return true;
- } catch {
- return false;
- }
- }
-
- return false;
-}
-
-function renderJSON(
- value: unknown,
- _metadata?: OutputMetadata,
-): React.ReactNode {
- let jsonData = value;
-
- if (typeof value === "string") {
- try {
- jsonData = JSON.parse(value);
- } catch {
- return null;
- }
- }
-
- return <JSONViewer data={jsonData} />;
-}
-
-function getCopyContentJSON(
- value: unknown,
- _metadata?: OutputMetadata,
-): CopyContent | null {
- const jsonString =
- typeof value === "string" ? value : JSON.stringify(value, null, 2);
-
- return {
- mimeType: "application/json",
- data: jsonString,
- alternativeMimeTypes: ["text/plain"],
- fallbackText: jsonString,
- };
-}
-
-function getDownloadContentJSON(
- value: unknown,
- _metadata?: OutputMetadata,
-): DownloadContent | null {
- const jsonString =
- typeof value === "string" ? value : JSON.stringify(value, null, 2);
- const blob = new Blob([jsonString], { type: "application/json" });
-
- return {
- data: blob,
- filename: _metadata?.filename || "output.json",
- mimeType: "application/json",
- };
-}
-
-function isConcatenableJSON(
- _value: unknown,
- _metadata?: OutputMetadata,
-): boolean {
- return true;
-}
-
-export const jsonRenderer: OutputRenderer = {
- name: "JSONRenderer",
- priority: 20,
- canRender: canRenderJSON,
- render: renderJSON,
- getCopyContent: getCopyContentJSON,
- getDownloadContent: getDownloadContentJSON,
- isConcatenable: isConcatenableJSON,
-};
-
-function JSONViewer({ data }: { data: any }) {
- const [collapsed, setCollapsed] = useState<Record<string, boolean>>({});
-
- const toggleCollapse = (key: string) => {
- setCollapsed((prev) => ({ ...prev, [key]: !prev[key] }));
- };
-
- const renderValue = (value: any, key: string = ""): React.ReactNode => {
- if (value === null)
- return <span className="text-muted-foreground">null</span>;
- if (value === undefined)
- return <span className="text-muted-foreground">undefined</span>;
-
- if (typeof value === "boolean") {
- return <span className="text-blue-600">{value.toString()}</span>;
- }
-
- if (typeof value === "number") {
- return <span className="text-green-600">{value}</span>;
- }
-
- if (typeof value === "string") {
- return <span className="text-orange-600">&quot;{value}&quot;</span>;
- }
-
- if (Array.isArray(value)) {
- const isCollapsed = collapsed[key];
- const itemCount = value.length;
-
- if (itemCount === 0) {
- return <span className="text-muted-foreground">[]</span>;
- }
-
- return (
- <div className="inline-block">
- <button
- onClick={() => toggleCollapse(key)}
- className="inline-flex items-center rounded px-1 hover:bg-muted"
- >
- {isCollapsed ? (
- <Icon icon={ArrowRight01Icon} className="size-3" />
- ) : (
- <Icon icon={ArrowDown01Icon} className="size-3" />
- )}
- <span className="ml-1 text-muted-foreground">
- Array({itemCount})
- </span>
- </button>
- {!isCollapsed && (
- <div className="ml-4 mt-1">
- {value.map((item, index) => (
- <div key={index} className="flex">
- <span className="mr-2 text-muted-foreground">{index}:</span>
- {renderValue(item, `${key}[${index}]`)}
- </div>
- ))}
- </div>
- )}
- </div>
- );
- }
-
- if (typeof value === "object") {
- const isCollapsed = collapsed[key];
- const keys = Object.keys(value);
-
- if (keys.length === 0) {
- return <span className="text-muted-foreground">{"{}"}</span>;
- }
-
- return (
- <div className="inline-block">
- <button
- onClick={() => toggleCollapse(key)}
- className="inline-flex items-center rounded px-1 hover:bg-muted"
- >
- {isCollapsed ? (
- <Icon icon={ArrowRight01Icon} className="size-3" />
- ) : (
- <Icon icon={ArrowDown01Icon} className="size-3" />
- )}
- <span className="ml-1 text-muted-foreground">Object</span>
- </button>
- {!isCollapsed && (
- <div className="ml-4 mt-1">
- {keys.map((objKey) => (
- <div key={objKey} className="flex">
- <span className="mr-2 text-purple-600">
- &quot;{objKey}&quot;:
- </span>
- {renderValue(value[objKey], `${key}.${objKey}`)}
- </div>
- ))}
- </div>
- )}
- </div>
- );
- }
-
- return <span className="text-muted-foreground">{String(value)}</span>;
- };
-
- return (
- <div className="overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm">
- {renderValue(data, "root")}
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/MarkdownRenderer.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/MarkdownRenderer.tsx
deleted file mode 100644
index 3865f7b242..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/MarkdownRenderer.tsx
+++ /dev/null
@@ -1,457 +0,0 @@
-"use client";
-
-import React from "react";
-import ReactMarkdown from "react-markdown";
-import remarkGfm from "remark-gfm";
-import remarkMath from "remark-math";
-import rehypeKatex from "rehype-katex";
-import rehypeHighlight from "rehype-highlight";
-import rehypeSlug from "rehype-slug";
-import rehypeAutolinkHeadings from "rehype-autolink-headings";
-import {
- OutputRenderer,
- OutputMetadata,
- DownloadContent,
- CopyContent,
-} from "../types";
-import "highlight.js/styles/github-dark.css";
-import "katex/dist/katex.min.css";
-import { escapeCurrencyAmounts } from "@/lib/markdown-math";
-
-const markdownPatterns = [
- /```[\s\S]*?```/u, // Fenced code blocks (check first)
- /^#{1,6}\s+\S+/gmu, // ATX headers (require content)
- /\*\*[^*\n]+?\*\*/u, // **bold**
- /__(?!_)[^_\n]+?__(?!_)/u, // __bold__ (avoid ___/snake_case_)
- /(?<!\*)\*(?!\*)(?:[^*\n]|(?<=\\)\*)+?(?<!\\)\*(?!\*)/u, // *italic* (try to avoid **)
- /(?<!_)_(?!_)(?:[^_\n]|(?<=\\)_)+?(?<!\\)_(?!_)/u, // _italic_ with guards
- /\[([^\]\n]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/u, // Links with optional title (simple)
- /!\[([^\]\n]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/u, // Images with optional title (simple)
- /`[^`\n]+`/u, // Inline code
- /^(?:\s*[-*+]\s+\S.*)(?:\n\s*[-*+]\s+\S.*)+$/gmu, // UL list (≥2 items)
- /^(?:\s*\d+\.\s+\S.*)(?:\n\s*\d+\.\s+\S.*)+$/gmu, // OL list (≥2 items)
- /^>\s+\S.*/gm, // Blockquotes
- /^\|[^|\n]+(\|[^|\n]+)+\|\s*$/gm, // Table row (at least two cells)
- /^\s*\|(?:\s*:?[-=]{3,}\s*\|)+\s*$/gm, // Table separator row
- /\$\$[\s\S]+?\$\$/u, // Display math
- /(?<!\\)(?<!\w)\$[^$\n]+?\$(?!\w)/u, // Inline math: avoid prices/ids
-];
-
-const videoExtensions = [".mp4", ".webm", ".ogg", ".mov", ".avi"];
-
-function isVideoUrl(url: string): boolean {
- if (url.includes("youtube.com/watch") || url.includes("youtu.be/")) {
- return true;
- }
- try {
- const parsed = new URL(url);
- if (
- parsed.hostname === "vimeo.com" ||
- parsed.hostname === "www.vimeo.com"
- ) {
- return true;
- }
- } catch {
- // If URL parsing fails, treat as not a Vimeo URL.
- }
- return videoExtensions.some((ext) => url.toLowerCase().includes(ext));
-}
-
-function getVideoEmbedUrl(url: string): string | null {
- const youtubeMatch = url.match(
- /(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\s]+)/,
- );
- if (youtubeMatch) {
- return `https://www.youtube.com/embed/${youtubeMatch[1]}`;
- }
-
- const vimeoMatch = url.match(/vimeo\.com\/(\d+)/);
- if (vimeoMatch) {
- return `https://player.vimeo.com/video/${vimeoMatch[1]}`;
- }
-
- if (videoExtensions.some((ext) => url.toLowerCase().includes(ext))) {
- return url;
- }
-
- return null;
-}
-
-function renderVideoEmbed(url: string): React.ReactNode {
- const embedUrl = getVideoEmbedUrl(url);
-
- if (!embedUrl) {
- return (
- <a
- href={url}
- target="_blank"
- rel="noopener noreferrer"
- className="text-blue-600 underline"
- >
- {url}
- </a>
- );
- }
-
- if (videoExtensions.some((ext) => embedUrl.toLowerCase().includes(ext))) {
- return (
- <div className="my-4">
- <video
- controls
- className="w-full max-w-2xl rounded-lg shadow-md"
- preload="metadata"
- >
- <source src={embedUrl} />
- Your browser does not support the video tag.
- </video>
- </div>
- );
- }
-
- return (
- <div className="my-4">
- <div className="relative aspect-video">
- <iframe
- src={embedUrl}
- title="Embedded video player"
- className="absolute left-0 top-0 h-full w-full rounded-lg shadow-md"
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- />
- </div>
- </div>
- );
-}
-
-function canRenderMarkdown(value: unknown, metadata?: OutputMetadata): boolean {
- if (
- metadata?.type === "markdown" ||
- metadata?.mimeType === "text/markdown" ||
- metadata?.mimeType === "text/x-markdown"
- ) {
- return true;
- }
-
- if (typeof value !== "string") {
- return false;
- }
-
- if (metadata?.filename?.toLowerCase().endsWith(".md")) {
- return true;
- }
-
- let matchCount = 0;
- const requiredMatches = 2;
-
- for (const pattern of markdownPatterns) {
- if (pattern.test(value)) {
- matchCount++;
- if (matchCount >= requiredMatches) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-function renderMarkdown(
- value: unknown,
- _metadata?: OutputMetadata,
-): React.ReactNode {
- const markdownContent = escapeCurrencyAmounts(String(value));
-
- return (
- <div className="markdown-output">
- <ReactMarkdown
- className="prose prose-sm dark:prose-invert max-w-none"
- remarkPlugins={[
- remarkGfm, // GitHub Flavored Markdown (tables, task lists, strikethrough)
- [remarkMath, { singleDollarTextMath: true }], // Math support for LaTeX
- ]}
- rehypePlugins={[
- [rehypeKatex, { strict: false }], // Render math with KaTeX
- rehypeHighlight, // Syntax highlighting for code blocks
- rehypeSlug, // Add IDs to headings
- [rehypeAutolinkHeadings, { behavior: "wrap" }], // Make headings clickable
- ]}
- components={{
- // Custom components for better rendering
- pre: ({ children, ...props }) => (
- <pre
- className="my-4 overflow-x-auto rounded-md bg-gray-900 p-4 dark:bg-gray-950"
- {...props}
- >
- {children}
- </pre>
- ),
- code: ({ children, ...props }: any) => {
- // Check if it's inline code by looking at the parent
- const isInline = !props.className?.includes("language-");
- if (isInline) {
- return (
- <code
- className="rounded bg-gray-100 px-1.5 py-0.5 font-mono text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200"
- {...props}
- >
- {children}
- </code>
- );
- }
- // Block code is handled by rehype-highlight
- return (
- <code className="font-mono text-sm text-gray-100" {...props}>
- {children}
- </code>
- );
- },
- a: ({ children, href, ...props }) => (
- <a
- href={href}
- target="_blank"
- rel="noopener noreferrer"
- className="text-black underline decoration-1 underline-offset-2 transition-colors"
- {...props}
- >
- {children}
- </a>
- ),
- blockquote: ({ children, ...props }) => (
- <blockquote
- className="my-4 border-l-4 border-blue-500 pl-4 italic text-gray-700 dark:border-blue-400 dark:text-gray-300"
- {...props}
- >
- {children}
- </blockquote>
- ),
- table: ({ children, ...props }) => (
- <div className="my-4 overflow-x-auto">
- <table
- className="min-w-full divide-y divide-gray-200 rounded-lg border border-gray-200 dark:divide-gray-700 dark:border-gray-700"
- {...props}
- >
- {children}
- </table>
- </div>
- ),
- th: ({ children, ...props }) => (
- <th
- className="bg-gray-50 px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-700 dark:bg-gray-800 dark:text-gray-300"
- {...props}
- >
- {children}
- </th>
- ),
- td: ({ children, ...props }) => (
- <td
- className="border-t border-gray-200 px-4 py-3 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"
- {...props}
- >
- {children}
- </td>
- ),
- // GitHub Flavored Markdown task lists
- input: ({ ...props }: any) => {
- if (props.type === "checkbox") {
- return (
- <input
- type="checkbox"
- className="mr-2 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-70"
- disabled
- {...props}
- />
- );
- }
- return <input {...props} />;
- },
- // Better list styling
- ul: ({ children, ...props }: any) => (
- <ul
- className={`my-4 list-disc space-y-2 pl-6 ${
- props.className?.includes("contains-task-list")
- ? "list-none pl-0"
- : ""
- }`}
- {...props}
- >
- {children}
- </ul>
- ),
- ol: ({ children, ...props }) => (
- <ol className="my-4 list-decimal space-y-2 pl-6" {...props}>
- {children}
- </ol>
- ),
- li: ({ children, ...props }: any) => (
- <li
- className={`text-gray-700 dark:text-gray-300 ${
- props.className?.includes("task-list-item")
- ? "flex items-start"
- : ""
- }`}
- {...props}
- >
- {children}
- </li>
- ),
- // Better heading styles
- h1: ({ children, ...props }) => (
- <h1
- className="my-6 text-3xl font-bold text-gray-900 dark:text-gray-100"
- {...props}
- >
- {children}
- </h1>
- ),
- h2: ({ children, ...props }) => (
- <h2
- className="my-5 text-2xl font-semibold text-gray-800 dark:text-gray-200"
- {...props}
- >
- {children}
- </h2>
- ),
- h3: ({ children, ...props }) => (
- <h3
- className="my-4 text-xl font-semibold text-gray-800 dark:text-gray-200"
- {...props}
- >
- {children}
- </h3>
- ),
- h4: ({ children, ...props }) => (
- <h4
- className="my-3 text-lg font-medium text-gray-700 dark:text-gray-300"
- {...props}
- >
- {children}
- </h4>
- ),
- h5: ({ children, ...props }) => (
- <h5
- className="my-2 text-base font-medium text-gray-700 dark:text-gray-300"
- {...props}
- >
- {children}
- </h5>
- ),
- h6: ({ children, ...props }) => (
- <h6
- className="my-2 text-sm font-medium text-gray-600 dark:text-gray-400"
- {...props}
- >
- {children}
- </h6>
- ),
- // Horizontal rule
- hr: ({ ...props }) => (
- <hr
- className="my-6 border-gray-300 dark:border-gray-700"
- {...props}
- />
- ),
- // Strikethrough (GFM)
- del: ({ children, ...props }) => (
- <del
- className="text-gray-500 line-through dark:text-gray-500"
- {...props}
- >
- {children}
- </del>
- ),
- // Image handling
- img: ({ src, alt, ...props }) => {
- // Check if it's a video URL pattern
- if (src && isVideoUrl(src)) {
- return renderVideoEmbed(src);
- }
-
- return (
- // eslint-disable-next-line @next/next/no-img-element
- <img
- src={src}
- alt={alt}
- className="my-4 h-auto max-w-full rounded-lg shadow-md"
- loading="lazy"
- {...props}
- />
- );
- },
- // Custom paragraph to handle standalone video URLs
- p: ({ children, ...props }) => {
- // Check if paragraph contains just a video URL
- if (typeof children === "string" && isVideoUrl(children.trim())) {
- return renderVideoEmbed(children.trim());
- }
-
- // Check for video URLs in link children
- if (React.Children.count(children) === 1) {
- const child = React.Children.toArray(children)[0];
- if (React.isValidElement(child) && child.type === "a") {
- const href = child.props.href;
- if (href && isVideoUrl(href)) {
- return renderVideoEmbed(href);
- }
- }
- }
-
- return (
- <p
- className="my-3 leading-relaxed text-gray-700 dark:text-gray-300"
- {...props}
- >
- {children}
- </p>
- );
- },
- }}
- >
- {markdownContent}
- </ReactMarkdown>
- </div>
- );
-}
-
-function getCopyContentMarkdown(
- value: unknown,
- _metadata?: OutputMetadata,
-): CopyContent | null {
- const markdownText = String(value);
- return {
- mimeType: "text/markdown",
- data: markdownText,
- fallbackText: markdownText,
- alternativeMimeTypes: ["text/plain"],
- };
-}
-
-function getDownloadContentMarkdown(
- value: unknown,
- metadata?: OutputMetadata,
-): DownloadContent | null {
- const markdownText = String(value);
- const blob = new Blob([markdownText], { type: "text/markdown" });
-
- return {
- data: blob,
- filename: metadata?.filename || "output.md",
- mimeType: "text/markdown",
- };
-}
-
-function isConcatenableMarkdown(
- _value: unknown,
- _metadata?: OutputMetadata,
-): boolean {
- return true;
-}
-
-export const markdownRenderer: OutputRenderer = {
- name: "MarkdownRenderer",
- priority: 35,
- canRender: canRenderMarkdown,
- render: renderMarkdown,
- getCopyContent: getCopyContentMarkdown,
- getDownloadContent: getDownloadContentMarkdown,
- isConcatenable: isConcatenableMarkdown,
-};
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/TextRenderer.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/TextRenderer.tsx
deleted file mode 100644
index 725743fb7e..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/TextRenderer.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import React from "react";
-import {
- OutputRenderer,
- OutputMetadata,
- DownloadContent,
- CopyContent,
-} from "../types";
-
-function canRenderText(value: unknown, _metadata?: OutputMetadata): boolean {
- return (
- typeof value === "string" ||
- typeof value === "number" ||
- typeof value === "boolean"
- );
-}
-
-function renderText(
- value: unknown,
- _metadata?: OutputMetadata,
-): React.ReactNode {
- const textValue = String(value);
-
- return (
- <p className="resize-none overflow-x-auto whitespace-pre-wrap break-words border-none text-sm text-neutral-700">
- {textValue}
- </p>
- );
-}
-
-function getCopyContentText(
- value: unknown,
- _metadata?: OutputMetadata,
-): CopyContent | null {
- const textValue = String(value);
- return {
- mimeType: "text/plain",
- data: textValue,
- fallbackText: textValue,
- };
-}
-
-function getDownloadContentText(
- value: unknown,
- _metadata?: OutputMetadata,
-): DownloadContent | null {
- const textValue = String(value);
- const blob = new Blob([textValue], { type: "text/plain" });
-
- return {
- data: blob,
- filename: _metadata?.filename || "output.txt",
- mimeType: "text/plain",
- };
-}
-
-function isConcatenableText(
- _value: unknown,
- _metadata?: OutputMetadata,
-): boolean {
- return true;
-}
-
-export const textRenderer: OutputRenderer = {
- name: "TextRenderer",
- priority: 0,
- canRender: canRenderText,
- render: renderText,
- getCopyContent: getCopyContentText,
- getDownloadContent: getDownloadContentText,
- isConcatenable: isConcatenableText,
-};
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/VideoRenderer.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/VideoRenderer.tsx
deleted file mode 100644
index bd74eacbd6..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/renderers/VideoRenderer.tsx
+++ /dev/null
@@ -1,169 +0,0 @@
-import React from "react";
-import {
- OutputRenderer,
- OutputMetadata,
- DownloadContent,
- CopyContent,
-} from "../types";
-
-const videoExtensions = [
- ".mp4",
- ".webm",
- ".ogg",
- ".mov",
- ".avi",
- ".mkv",
- ".m4v",
-];
-
-const videoMimeTypes = [
- "video/mp4",
- "video/webm",
- "video/ogg",
- "video/quicktime",
- "video/x-msvideo",
- "video/x-matroska",
-];
-
-function guessMimeType(url: string): string | null {
- const extension = url.split(".").pop()?.toLowerCase();
- const mimeMap: Record<string, string> = {
- mp4: "video/mp4",
- webm: "video/webm",
- ogg: "video/ogg",
- mov: "video/quicktime",
- avi: "video/x-msvideo",
- mkv: "video/x-matroska",
- m4v: "video/mp4",
- };
- return extension ? mimeMap[extension] || null : null;
-}
-
-function canRenderVideo(value: unknown, metadata?: OutputMetadata): boolean {
- if (
- metadata?.type === "video" ||
- (metadata?.mimeType && videoMimeTypes.includes(metadata.mimeType))
- ) {
- return true;
- }
-
- if (typeof value === "string") {
- if (value.startsWith("data:video/")) {
- return true;
- }
-
- if (value.startsWith("http://") || value.startsWith("https://")) {
- return videoExtensions.some((ext) => value.toLowerCase().includes(ext));
- }
-
- if (metadata?.filename) {
- return videoExtensions.some((ext) =>
- metadata.filename!.toLowerCase().endsWith(ext),
- );
- }
- }
-
- return false;
-}
-
-function renderVideo(
- value: unknown,
- metadata?: OutputMetadata,
-): React.ReactNode {
- const videoUrl = String(value);
-
- return (
- <div className="group relative">
- <video
- controls
- className="h-auto max-w-full rounded-md border border-gray-200"
- preload="metadata"
- >
- <source src={videoUrl} type={metadata?.mimeType || "video/mp4"} />
- Your browser does not support the video tag.
- </video>
- </div>
- );
-}
-
-function getCopyContentVideo(
- value: unknown,
- metadata?: OutputMetadata,
-): CopyContent | null {
- const videoUrl = String(value);
-
- if (videoUrl.startsWith("data:")) {
- const mimeMatch = videoUrl.match(/data:([^;]+)/);
- const mimeType = mimeMatch?.[1] || "video/mp4";
-
- return {
- mimeType: mimeType,
- data: videoUrl,
- alternativeMimeTypes: ["text/plain"],
- fallbackText: videoUrl,
- };
- }
-
- const mimeType = metadata?.mimeType || guessMimeType(videoUrl) || "video/mp4";
-
- return {
- mimeType: mimeType,
- data: async () => {
- const response = await fetch(videoUrl);
- return await response.blob();
- },
- alternativeMimeTypes: ["text/plain"],
- fallbackText: videoUrl,
- };
-}
-
-function getDownloadContentVideo(
- value: unknown,
- metadata?: OutputMetadata,
-): DownloadContent | null {
- const videoUrl = String(value);
-
- if (videoUrl.startsWith("data:")) {
- const [mimeInfo, base64Data] = videoUrl.split(",");
- const mimeType = mimeInfo.match(/data:([^;]+)/)?.[1] || "video/mp4";
- const byteCharacters = atob(base64Data);
- const byteNumbers = new Array(byteCharacters.length);
-
- for (let i = 0; i < byteCharacters.length; i++) {
- byteNumbers[i] = byteCharacters.charCodeAt(i);
- }
-
- const byteArray = new Uint8Array(byteNumbers);
- const blob = new Blob([byteArray], { type: mimeType });
-
- const extension = mimeType.split("/")[1] || "mp4";
- return {
- data: blob,
- filename: metadata?.filename || `video.${extension}`,
- mimeType,
- };
- }
-
- return {
- data: videoUrl,
- filename: metadata?.filename || "video.mp4",
- mimeType: metadata?.mimeType || "video/mp4",
- };
-}
-
-function isConcatenableVideo(
- _value: unknown,
- _metadata?: OutputMetadata,
-): boolean {
- return false;
-}
-
-export const videoRenderer: OutputRenderer = {
- name: "VideoRenderer",
- priority: 45,
- canRender: canRenderVideo,
- render: renderVideo,
- getCopyContent: getCopyContentVideo,
- getDownloadContent: getDownloadContentVideo,
- isConcatenable: isConcatenableVideo,
-};
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/types.ts b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/types.ts
deleted file mode 100644
index 0b2c8ed6bf..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/types.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import { ReactNode } from "react";
-
-export interface OutputMetadata {
- type?: string;
- language?: string;
- mimeType?: string;
- filename?: string;
- [key: string]: any;
-}
-
-export interface DownloadContent {
- data: Blob | string;
- filename: string;
- mimeType: string;
-}
-
-export interface CopyContent {
- mimeType: string; // Primary MIME type to try
- data: Blob | string | (() => Promise<Blob | string>); // Data or async function to get data
- fallbackText?: string; // Optional fallback text if rich copy fails
- alternativeMimeTypes?: string[]; // Alternative MIME types to try if primary isn't supported
-}
-
-export interface OutputRenderer {
- name: string;
- priority: number;
- canRender(value: any, metadata?: OutputMetadata): boolean;
- render(value: any, metadata?: OutputMetadata): ReactNode;
- getCopyContent(value: any, metadata?: OutputMetadata): CopyContent | null;
- getDownloadContent(
- value: any,
- metadata?: OutputMetadata,
- ): DownloadContent | null;
- isConcatenable(value: any, metadata?: OutputMetadata): boolean;
-}
-
-export class OutputRendererRegistry {
- private renderers: OutputRenderer[] = [];
-
- register(renderer: OutputRenderer): void {
- const index = this.renderers.findIndex(
- (r) => r.priority < renderer.priority,
- );
- if (index === -1) {
- this.renderers.push(renderer);
- } else {
- this.renderers.splice(index, 0, renderer);
- }
- }
-
- getRenderer(value: any, metadata?: OutputMetadata): OutputRenderer | null {
- return this.renderers.find((r) => r.canRender(value, metadata)) || null;
- }
-
- getAllRenderers(): OutputRenderer[] {
- return [...this.renderers];
- }
-}
-
-export const globalRegistry = new OutputRendererRegistry();
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/utils/copy.ts b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/utils/copy.ts
deleted file mode 100644
index 5b18f44669..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/utils/copy.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import { CopyContent } from "../types";
-
-export function isClipboardTypeSupported(mimeType: string): boolean {
- // ClipboardItem.supports() is the proper way to check
- if ("ClipboardItem" in window && "supports" in ClipboardItem) {
- return ClipboardItem.supports(mimeType);
- }
-
- // Fallback for browsers that don't support the supports() method
- // These are generally supported
- const fallbackSupported = ["text/plain", "text/html", "image/png"];
-
- return fallbackSupported.includes(mimeType);
-}
-
-export function getSupportedClipboardType(
- preferredTypes: string[],
-): string | null {
- for (const type of preferredTypes) {
- if (isClipboardTypeSupported(type)) {
- return type;
- }
- }
- return null;
-}
-
-export async function copyToClipboard(copyContent: CopyContent): Promise<void> {
- try {
- // Determine the best supported MIME type
- const supportedTypes = [
- copyContent.mimeType,
- ...(copyContent.alternativeMimeTypes || []),
- ];
- const bestType = getSupportedClipboardType(supportedTypes);
-
- if (!bestType) {
- // No supported type found, use fallback text if available
- if (copyContent.fallbackText) {
- await navigator.clipboard.writeText(copyContent.fallbackText);
- return;
- }
- throw new Error(
- `None of the MIME types are supported: ${supportedTypes.join(", ")}`,
- );
- }
-
- // Get the data (resolve if it's a function)
- let data = copyContent.data;
- if (typeof data === "function") {
- data = await data();
- }
-
- // If data is already a Blob, use it directly
- if (data instanceof Blob) {
- // If we need a different MIME type than the blob has, recreate it
- if (bestType !== data.type && bestType !== copyContent.mimeType) {
- data = new Blob([data], { type: bestType });
- }
-
- await navigator.clipboard.write([
- new ClipboardItem({
- [bestType]: data,
- }),
- ]);
- return;
- }
-
- // If data is a string
- if (typeof data === "string") {
- // For plain text, use the simpler writeText API
- if (bestType === "text/plain") {
- await navigator.clipboard.writeText(data);
- return;
- }
-
- // For other text formats (HTML, JSON, etc.), create a blob
- const blob = new Blob([data], { type: bestType });
- await navigator.clipboard.write([
- new ClipboardItem({
- [bestType]: blob,
- }),
- ]);
- }
- } catch (_error) {
- // If rich copy fails and we have fallback text, try that
- if (copyContent.fallbackText) {
- try {
- await navigator.clipboard.writeText(copyContent.fallbackText);
- return;
- } catch {
- // Even fallback failed
- }
- }
- throw _error;
- }
-}
-
-export async function fetchAndCopyImage(imageUrl: string): Promise<void> {
- try {
- const response = await fetch(imageUrl);
- if (!response.ok) throw new Error("Failed to fetch image");
-
- const blob = await response.blob();
- const mimeType = blob.type || "image/png";
-
- await navigator.clipboard.write([
- new ClipboardItem({
- [mimeType]: blob,
- }),
- ]);
- } catch (_error) {
- // If fetching fails (e.g., CORS), fall back to copying the URL
- await navigator.clipboard.writeText(imageUrl);
- }
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/utils/download.ts b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/utils/download.ts
deleted file mode 100644
index 5111d4aeb2..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/OutputRenderers/utils/download.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { downloadOutputs } from "@/lib/utils/download-outputs";
-export type { DownloadItem } from "@/lib/utils/download-outputs";
diff --git a/autogpt_platform/frontend/src/components/__legacy__/AgentImageItem.tsx b/autogpt_platform/frontend/src/components/__legacy__/AgentImageItem.tsx
deleted file mode 100644
index 7a894d654c..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/AgentImageItem.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-import * as React from "react";
-import Image from "next/image";
-import { PlayIcon } from "@radix-ui/react-icons";
-import { Button } from "./Button";
-
-const isValidVideoFile = (url: string): boolean => {
- const videoExtensions = /\.(mp4|webm|ogg)$/i;
- return videoExtensions.test(url);
-};
-
-const isValidVideoUrl = (url: string): boolean => {
- const videoExtensions = /\.(mp4|webm|ogg)$/i;
- const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
- return videoExtensions.test(url) || youtubeRegex.test(url);
-};
-
-const getYouTubeVideoId = (url: string) => {
- const regExp =
- /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
- const match = url.match(regExp);
- return match && match[7].length === 11 ? match[7] : null;
-};
-
-interface AgentImageItemProps {
- image: string;
- index: number;
- playingVideoIndex: number | null;
- handlePlay: (index: number) => void;
- handlePause: (index: number) => void;
-}
-
-export const AgentImageItem: React.FC<AgentImageItemProps> = React.memo(
- ({ image, index, playingVideoIndex, handlePlay, handlePause }) => {
- const videoRef = React.useRef<HTMLVideoElement>(null);
-
- React.useEffect(() => {
- if (
- playingVideoIndex !== index &&
- videoRef.current &&
- !videoRef.current.paused
- ) {
- videoRef.current.pause();
- }
- }, [playingVideoIndex, index]);
-
- const isVideoFile = isValidVideoFile(image);
-
- return (
- <div className="relative">
- <div className="h-[15rem] overflow-hidden rounded-[26px] bg-[#a8a8a8] dark:bg-neutral-700 sm:h-[20rem] sm:w-full md:h-[25rem] lg:h-[30rem]">
- {isValidVideoUrl(image) ? (
- getYouTubeVideoId(image) ? (
- <iframe
- width="100%"
- height="100%"
- src={`https://www.youtube.com/embed/${getYouTubeVideoId(image)}`}
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- title="YouTube video player"
- ></iframe>
- ) : (
- <div className="relative h-full w-full overflow-hidden">
- <video
- ref={videoRef}
- className="absolute inset-0 h-full w-full object-cover"
- controls
- preload="metadata"
- poster={`${image}#t=0.1`}
- style={{ objectPosition: "center 25%" }}
- onPlay={() => handlePlay(index)}
- onPause={() => handlePause(index)}
- autoPlay={false}
- title="Video"
- >
- <source src={image} type="video/mp4" />
- Your browser does not support the video tag.
- </video>
- </div>
- )
- ) : (
- <div className="relative h-full w-full">
- <Image
- src={image}
- alt="Image"
- fill
- sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
- className="rounded-xl object-cover"
- />
- </div>
- )}
- </div>
- {isVideoFile && playingVideoIndex !== index && (
- <div className="absolute bottom-2 left-2 sm:bottom-3 sm:left-3 md:bottom-4 md:left-4 lg:bottom-[1.25rem] lg:left-[1.25rem]">
- <Button
- size="default"
- onClick={() => {
- if (videoRef.current) {
- videoRef.current.play();
- }
- }}
- >
- <span className="pr-1 text-sm font-medium leading-6 tracking-tight text-[#272727] dark:text-neutral-200 sm:pr-2 sm:text-base sm:leading-7 md:text-lg md:leading-8 lg:text-xl lg:leading-9">
- Play demo
- </span>
- <PlayIcon className="h-5 w-5 text-black dark:text-neutral-200 sm:h-6 sm:w-6 md:h-7 md:w-7" />
- </Button>
- </div>
- )}
- </div>
- );
- },
-);
-
-AgentImageItem.displayName = "AgentImageItem";
diff --git a/autogpt_platform/frontend/src/components/__legacy__/AgentImages.tsx b/autogpt_platform/frontend/src/components/__legacy__/AgentImages.tsx
deleted file mode 100644
index 3f8d37d780..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/AgentImages.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { AgentImageItem } from "./AgentImageItem";
-
-interface AgentImagesProps {
- images: string[];
-}
-
-export const AgentImages: React.FC<AgentImagesProps> = ({ images }) => {
- const [playingVideoIndex, setPlayingVideoIndex] = React.useState<
- number | null
- >(null);
-
- const handlePlay = React.useCallback((index: number) => {
- setPlayingVideoIndex(index);
- }, []);
-
- const handlePause = React.useCallback(
- (index: number) => {
- if (playingVideoIndex === index) {
- setPlayingVideoIndex(null);
- }
- },
- [playingVideoIndex],
- );
-
- return (
- <div className="w-full overflow-y-auto bg-white px-2 dark:bg-transparent lg:w-[56.25rem]">
- <div className="space-y-4 sm:space-y-6 md:space-y-[1.875rem]">
- {images.map((image, index) => (
- <AgentImageItem
- key={index}
- image={image}
- index={index}
- playingVideoIndex={playingVideoIndex}
- handlePlay={handlePlay}
- handlePause={handlePause}
- />
- ))}
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/BecomeACreator.tsx b/autogpt_platform/frontend/src/components/__legacy__/BecomeACreator.tsx
deleted file mode 100644
index 954ac1dd33..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/BecomeACreator.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { PublishAgentModal } from "../contextual/PublishAgentModal/PublishAgentModal";
-
-interface BecomeACreatorProps {
- title?: string;
- description?: string;
- buttonText?: string;
-}
-
-export function BecomeACreator({
- title = "Become a creator",
- description = "Join a community where your AI creations can inspire, engage, and be downloaded by users around the world.",
- buttonText = "Upload your agent",
-}: BecomeACreatorProps) {
- return (
- <div className="relative mx-auto h-auto min-h-[300px] w-full max-w-[1360px] md:min-h-[400px] lg:h-[459px]">
- {/* Title */}
- <h2 className="mb-[77px] font-poppins text-[18px] font-semibold leading-[28px] text-neutral-800 dark:text-neutral-200">
- {title}
- </h2>
-
- {/* Content Container */}
- <div className="mx-auto w-full max-w-[900px] px-4 text-center md:px-6 lg:px-0">
- <h2 className="mb-6 text-center font-poppins text-[48px] font-semibold leading-[54px] tracking-[-0.012em] text-neutral-950 dark:text-neutral-50 md:mb-8 lg:mb-12">
- Build AI agents and share
- <br />
- <span className="text-violet-600 dark:text-violet-400">
- your
- </span>{" "}
- vision
- </h2>
-
- <p className="mx-auto mb-8 max-w-[90%] text-lg font-normal leading-relaxed text-neutral-700 dark:text-neutral-300 md:mb-10 md:text-xl md:leading-loose lg:mb-14 lg:text-2xl">
- {description}
- </p>
-
- <PublishAgentModal
- trigger={
- <button className="inline-flex h-[48px] cursor-pointer items-center justify-center rounded-[38px] bg-neutral-800 px-8 py-3 transition-colors hover:bg-neutral-700 dark:bg-neutral-700 dark:hover:bg-neutral-600 md:h-[56px] md:px-10 md:py-4 lg:h-[68px] lg:px-12 lg:py-5">
- <span className="whitespace-nowrap font-poppins text-base font-medium leading-normal text-neutral-50 md:text-lg md:leading-relaxed lg:text-xl lg:leading-7">
- {buttonText}
- </span>
- </button>
- }
- />
- </div>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/__legacy__/CreatorCard.tsx b/autogpt_platform/frontend/src/components/__legacy__/CreatorCard.tsx
deleted file mode 100644
index 918d09f506..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/CreatorCard.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import * as React from "react";
-import Image from "next/image";
-
-const BACKGROUND_COLORS = [
- "bg-amber-100 dark:bg-amber-800", // #fef3c7 / #92400e
- "bg-violet-100 dark:bg-violet-800", // #ede9fe / #5b21b6
- "bg-green-100 dark:bg-green-800", // #dcfce7 / #065f46
- "bg-blue-100 dark:bg-blue-800", // #dbeafe / #1e3a8a
-];
-
-interface CreatorCardProps {
- creatorName: string;
- creatorImage: string;
- bio: string;
- agentsUploaded: number;
- onClick: () => void;
- index: number;
-}
-
-export const CreatorCard: React.FC<CreatorCardProps> = ({
- creatorName,
- creatorImage,
- bio,
- agentsUploaded,
- onClick,
- index,
-}) => {
- const backgroundColor = BACKGROUND_COLORS[index % BACKGROUND_COLORS.length];
-
- return (
- <div
- className={`h-[264px] w-full px-[18px] pb-5 pt-6 ${backgroundColor} inline-flex cursor-pointer flex-col items-start justify-start gap-3.5 rounded-[26px] transition-all duration-200 hover:brightness-95`}
- onClick={onClick}
- data-testid="creator-card"
- >
- <div className="relative h-[64px] w-[64px]">
- <div className="absolute inset-0 overflow-hidden rounded-full">
- {creatorImage ? (
- <Image
- src={creatorImage}
- alt={creatorName}
- width={64}
- height={64}
- className="h-full w-full object-cover"
- priority
- />
- ) : (
- <div className="h-full w-full bg-neutral-300 dark:bg-neutral-600" />
- )}
- </div>
- </div>
-
- <div className="flex flex-col gap-2">
- <h3 className="font-poppins text-2xl font-semibold leading-tight text-neutral-900 dark:text-neutral-100">
- {creatorName}
- </h3>
- <p className="text-sm font-normal leading-normal text-neutral-600 dark:text-neutral-400">
- {bio}
- </p>
- <div className="text-lg font-semibold leading-7 text-neutral-800 dark:text-neutral-200">
- {agentsUploaded} agents
- </div>
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/CreatorInfoCard.tsx b/autogpt_platform/frontend/src/components/__legacy__/CreatorInfoCard.tsx
deleted file mode 100644
index 394b0cf5a6..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/CreatorInfoCard.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-import * as React from "react";
-import { StarRatingIcons } from "@/components/__legacy__/ui/icons";
-import Avatar, { AvatarFallback, AvatarImage } from "../atoms/Avatar/Avatar";
-
-interface CreatorInfoCardProps {
- username: string;
- handle: string;
- avatarSrc: string;
- categories: string[];
- averageRating: number;
- totalRuns: number;
-}
-
-export const CreatorInfoCard: React.FC<CreatorInfoCardProps> = ({
- username,
- handle,
- avatarSrc,
- categories,
- averageRating,
- totalRuns,
-}) => {
- return (
- <div
- className="inline-flex h-auto min-h-[500px] w-full max-w-[440px] flex-col items-start justify-between rounded-[26px] bg-violet-100 p-4 dark:bg-violet-900 sm:h-[632px] sm:w-[440px] sm:p-6"
- role="article"
- aria-label={`Creator profile for ${username}`}
- >
- <div className="flex w-full flex-col items-start justify-start gap-3.5 sm:h-[218px]">
- <Avatar className="h-[100px] w-[100px] sm:h-[130px] sm:w-[130px]">
- <AvatarImage
- width={130}
- height={130}
- src={avatarSrc}
- alt={`${username}'s avatar`}
- />
- <AvatarFallback
- size={130}
- className="h-[100px] w-[100px] sm:h-[130px] sm:w-[130px]"
- >
- {username.charAt(0)}
- </AvatarFallback>
- </Avatar>
- <div className="flex w-full flex-col items-start justify-start gap-1.5">
- <div
- data-testid="creator-title"
- className="w-full font-poppins text-[35px] font-medium leading-10 text-neutral-900 dark:text-neutral-100 sm:text-[35px] sm:leading-10"
- >
- {username}
- </div>
- <div className="w-full text-lg font-normal leading-6 text-neutral-800 dark:text-neutral-200 sm:text-xl sm:leading-7">
- @{handle}
- </div>
- </div>
- </div>
-
- <div className="my-4 flex w-full flex-col items-start justify-start gap-6 sm:gap-[50px]">
- <div className="flex w-full flex-col items-start justify-start gap-3">
- <div className="h-px w-full bg-neutral-700 dark:bg-neutral-300" />
- <div className="flex flex-col items-start justify-start gap-2.5">
- <div className="w-full text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- Top categories
- </div>
- <div
- className="flex flex-wrap items-center gap-2.5"
- role="list"
- aria-label="Categories"
- >
- {categories.map((category, index) => (
- <div
- key={index}
- className="flex items-center justify-center gap-2.5 rounded-[34px] border border-neutral-600 px-4 py-3 dark:border-neutral-400"
- role="listitem"
- >
- <div className="text-base font-normal leading-normal text-neutral-800 dark:text-neutral-200">
- {category}
- </div>
- </div>
- ))}
- </div>
- </div>
- </div>
-
- <div className="flex w-full flex-col items-start justify-start gap-3">
- <div className="h-px w-full bg-neutral-700 dark:bg-neutral-300" />
- <div className="flex w-full flex-col items-start justify-between gap-4 sm:flex-row sm:gap-0">
- <div className="flex w-full flex-col items-start justify-start gap-2.5 sm:w-[164px]">
- <div className="w-full text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- Average rating
- </div>
- <div className="inline-flex items-center gap-2">
- <div className="text-[18px] font-semibold leading-[28px] text-neutral-800 dark:text-neutral-200">
- {averageRating.toFixed(1)}
- </div>
- <div
- className="flex items-center gap-px"
- role="img"
- aria-label={`Rating: ${averageRating} out of 5 stars`}
- >
- {StarRatingIcons(averageRating)}
- </div>
- </div>
- </div>
- <div className="flex w-full flex-col items-start justify-start gap-2.5 sm:w-[164px]">
- <div className="w-full text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- Number of runs
- </div>
- <div className="text-[18px] font-semibold leading-[28px] text-neutral-800 dark:text-neutral-200">
- {new Intl.NumberFormat().format(totalRuns)} runs
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/CreatorLinks.tsx b/autogpt_platform/frontend/src/components/__legacy__/CreatorLinks.tsx
deleted file mode 100644
index f05811db36..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/CreatorLinks.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import * as React from "react";
-import { getIconForSocial } from "@/components/__legacy__/ui/icons";
-
-interface CreatorLinksProps {
- links: string[];
-}
-
-export const CreatorLinks: React.FC<CreatorLinksProps> = ({ links }) => {
- if (!links || links.length === 0) {
- return null;
- }
-
- const renderLinkButton = (url: string) => (
- <a
- href={url}
- target="_blank"
- rel="noopener noreferrer"
- className="flex min-w-[200px] flex-1 items-center justify-between rounded-[34px] border border-neutral-600 px-5 py-3 dark:border-neutral-400"
- >
- <div className="text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- {new URL(url).hostname.replace("www.", "")}
- </div>
- <div className="relative h-6 w-6">
- {getIconForSocial(url, {
- className: "h-6 w-6 text-neutral-800 dark:text-neutral-200",
- })}
- </div>
- </a>
- );
-
- return (
- <div className="flex flex-col items-start justify-start gap-4">
- <div className="text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- Other links
- </div>
- <div className="flex w-full flex-wrap gap-3">
- {links.map((link, index) => (
- <React.Fragment key={index}>{renderLinkButton(link)}</React.Fragment>
- ))}
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/FeaturedAgentCard.tsx b/autogpt_platform/frontend/src/components/__legacy__/FeaturedAgentCard.tsx
deleted file mode 100644
index ee498bc8ea..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/FeaturedAgentCard.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import Image from "next/image";
-import { StarRatingIcons } from "@/components/__legacy__/ui/icons";
-import {
- Card,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
-} from "@/components/__legacy__/ui/card";
-import { useState } from "react";
-import type { StoreAgent } from "@/app/api/__generated__/models/storeAgent";
-
-interface FeaturedStoreCardProps {
- agent: StoreAgent;
- backgroundColor: string;
-}
-
-export const FeaturedAgentCard: React.FC<FeaturedStoreCardProps> = ({
- agent,
- backgroundColor,
-}) => {
- const [isHovered, setIsHovered] = useState(false);
-
- return (
- <Card
- data-testid="featured-store-card"
- onMouseEnter={() => setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- className={`flex h-full flex-col ${backgroundColor} rounded-[1.5rem] border-none`}
- >
- <CardHeader>
- <CardTitle className="line-clamp-2 text-base sm:text-xl">
- {agent.agent_name}
- </CardTitle>
- <CardDescription className="text-sm">
- By {agent.creator}
- </CardDescription>
- </CardHeader>
- <CardContent className="flex-1 p-4">
- <div className="relative aspect-[4/3] w-full overflow-hidden rounded-xl">
- <Image
- src={agent.agent_image || "/autogpt-logo-dark-bg.png"}
- alt={`${agent.agent_name} preview`}
- fill
- sizes="100%"
- className={`object-cover transition-opacity duration-200 ${
- isHovered ? "opacity-0" : "opacity-100"
- }`}
- />
- <div
- className={`absolute inset-0 overflow-y-auto p-4 transition-opacity duration-200 ${
- isHovered ? "opacity-100" : "opacity-0"
- }`}
- >
- <CardDescription className="line-clamp-[6] text-xs sm:line-clamp-[8] sm:text-sm">
- {agent.description}
- </CardDescription>
- </div>
- </div>
- </CardContent>
- <CardFooter className="flex items-center justify-between">
- <div className="font-semibold">
- {agent.runs?.toLocaleString() ?? "0"} runs
- </div>
- <div className="flex items-center gap-1.5">
- <p>{agent.rating.toFixed(1) ?? "0.0"}</p>
- {StarRatingIcons(agent.rating)}
- </div>
- </CardFooter>
- </Card>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/FilterChips.tsx b/autogpt_platform/frontend/src/components/__legacy__/FilterChips.tsx
deleted file mode 100644
index b78dc70e86..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/FilterChips.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { Badge } from "@/components/__legacy__/ui/badge";
-
-interface FilterChipsProps {
- badges: string[];
- onFilterChange?: (selectedFilters: string[]) => void;
- multiSelect?: boolean;
-}
-/** FilterChips is a component that allows the user to select filters from a list of badges. It is used on the Marketplace home page */
-export const FilterChips: React.FC<FilterChipsProps> = ({
- badges,
- onFilterChange,
- multiSelect = true,
-}) => {
- const [selectedFilters, setSelectedFilters] = React.useState<string[]>([]);
-
- const handleBadgeClick = (badge: string) => {
- setSelectedFilters((prevFilters) => {
- let newFilters;
- if (multiSelect) {
- newFilters = prevFilters.includes(badge)
- ? prevFilters.filter((filter) => filter !== badge)
- : [...prevFilters, badge];
- } else {
- newFilters = prevFilters.includes(badge) ? [] : [badge];
- }
-
- if (onFilterChange) {
- onFilterChange(newFilters);
- }
-
- return newFilters;
- });
- };
-
- return (
- <div className="flex h-auto min-h-8 flex-wrap items-center justify-center gap-3 lg:min-h-14 lg:justify-start lg:gap-5">
- {badges.map((badge) => (
- <Badge
- key={badge}
- variant={selectedFilters.includes(badge) ? "secondary" : "outline"}
- className="mb-2 flex cursor-pointer items-center justify-center gap-2 rounded-full border border-black/50 px-3 py-1 dark:border-white/50 lg:mb-3 lg:gap-2.5 lg:px-6 lg:py-2"
- onClick={() => handleBadgeClick(badge)}
- >
- <div className="text-sm font-light tracking-tight text-[#474747] dark:text-[#e0e0e0] lg:text-xl lg:font-medium lg:leading-9">
- {badge}
- </div>
- </Badge>
- ))}
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/RatingCard.tsx b/autogpt_platform/frontend/src/components/__legacy__/RatingCard.tsx
deleted file mode 100644
index 82fa1870cb..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/RatingCard.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { Cross1Icon } from "@radix-ui/react-icons";
-import { IconStar, IconStarFilled } from "@/components/__legacy__/ui/icons";
-import { postV2CreateAgentReview } from "@/app/api/__generated__/endpoints/store/store";
-
-interface RatingCardProps {
- agentName: string;
- storeListingVersionId: string;
-}
-
-export const RatingCard: React.FC<RatingCardProps> = ({
- agentName,
- storeListingVersionId,
-}) => {
- const [rating, setRating] = React.useState<number>(0);
- const [hoveredRating, setHoveredRating] = React.useState<number>(0);
- const [isVisible, setIsVisible] = React.useState(true);
-
- const handleClose = () => {
- setIsVisible(false);
- };
-
- if (!isVisible) return null;
-
- const handleSubmit = async (rating: number) => {
- if (rating > 0) {
- console.log(`Rating submitted for ${agentName}:`, rating);
- await postV2CreateAgentReview("--", agentName, {
- store_listing_version_id: storeListingVersionId,
- score: rating,
- });
- handleClose();
- }
- };
-
- const getRatingText = (rating: number) => {
- switch (rating) {
- case 1:
- return "Needs improvement";
- case 2:
- return "Meh";
- case 3:
- return "Average";
- case 4:
- return "Good";
- case 5:
- return "Awesome!";
- default:
- return "Rate it!";
- }
- };
-
- return (
- <div className="relative flex w-[400px] flex-col rounded-[32px] bg-white p-8 shadow-lg">
- <button
- onClick={handleClose}
- className="absolute right-6 top-6 h-6 w-6 text-gray-400 transition-colors hover:text-gray-600"
- >
- <Cross1Icon className="h-5 w-5" />
- </button>
-
- <div className="mb-2 text-center text-xl font-semibold">Rate agent</div>
-
- <div className="mb-6 text-center text-sm text-gray-600">
- Could you rate {agentName} agent for us?
- </div>
-
- <div className="mb-6 flex flex-col items-center">
- <div className="mb-2 flex gap-2">
- {[1, 2, 3, 4, 5].map((star) => (
- <button
- key={star}
- className="flex h-8 w-8 items-center justify-center"
- onMouseEnter={() => setHoveredRating(star)}
- onMouseLeave={() => setHoveredRating(0)}
- onClick={() => setRating(star)}
- >
- {star <= (hoveredRating || rating) ? (
- <IconStarFilled className="h-8 w-8 text-yellow-400" />
- ) : (
- <IconStar className="h-8 w-8 text-gray-200" />
- )}
- </button>
- ))}
- </div>
-
- <div className="text-center text-sm text-gray-600">
- {getRatingText(hoveredRating || rating)}
- </div>
- </div>
-
- <div className="self-end">
- <button
- onClick={() => rating > 0 && handleSubmit(rating)}
- className={`rounded-full px-6 py-2 text-sm font-medium transition-colors ${
- rating > 0
- ? "cursor-pointer bg-slate-900 text-white hover:bg-slate-800"
- : "cursor-not-allowed bg-gray-200 text-gray-400"
- }`}
- >
- Submit
- </button>
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/SearchBar.tsx b/autogpt_platform/frontend/src/components/__legacy__/SearchBar.tsx
deleted file mode 100644
index 713ac0b075..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/SearchBar.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { useRouter } from "next/navigation";
-
-import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
-
-interface SearchBarProps {
- placeholder?: string;
- backgroundColor?: string;
- iconColor?: string;
- textColor?: string;
- placeholderColor?: string;
- width?: string;
- height?: string;
-}
-
-/** SearchBar component for user input and search functionality. */
-export const SearchBar: React.FC<SearchBarProps> = ({
- placeholder = 'Search for tasks like "optimise SEO"',
- backgroundColor = "bg-neutral-100 dark:bg-neutral-800",
- iconColor = "text-[#646464] dark:text-neutral-400",
- textColor = "text-[#707070] dark:text-neutral-200",
- placeholderColor = "text-[#707070] dark:text-neutral-400",
- width = "w-9/10 lg:w-[56.25rem]",
- height = "h-[60px]",
-}) => {
- const router = useRouter();
-
- const [searchQuery, setSearchQuery] = React.useState("");
-
- const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
- event.preventDefault();
- console.log(searchQuery);
-
- if (searchQuery.trim()) {
- // Encode the search term and navigate to the desired path
- const encodedTerm = encodeURIComponent(searchQuery);
- router.push(`/marketplace/search?searchTerm=${encodedTerm}`);
- }
- };
-
- return (
- <form
- onSubmit={handleSubmit}
- data-testid="store-search-bar"
- className={`${width} ${height} px-4 pt-2 md:px-6 md:pt-1 ${backgroundColor} flex items-center justify-center gap-2 rounded-full md:gap-5`}
- >
- <MagnifyingGlassIcon className={`h-5 w-5 md:h-7 md:w-7 ${iconColor}`} />
- <input
- type="text"
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- placeholder={placeholder}
- className={`flex-grow border-none bg-transparent ${textColor} font-sans text-lg font-normal leading-[2.25rem] tracking-tight md:text-xl placeholder:${placeholderColor} focus:outline-none`}
- data-testid="store-search-input"
- />
- </form>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/SmartImage.tsx b/autogpt_platform/frontend/src/components/__legacy__/SmartImage.tsx
deleted file mode 100644
index 525096f059..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/SmartImage.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-"use client";
-import { cn } from "@/lib/utils";
-import Image from "next/image";
-import { useState } from "react";
-
-interface SmartImageProps {
- src?: string | null;
- alt: string;
- imageContain?: boolean;
- className?: string;
-}
-
-export default function SmartImage({
- src,
- alt,
- imageContain,
- className,
-}: SmartImageProps) {
- const [isLoading, setIsLoading] = useState(true);
- const shouldShowSkeleton = isLoading || !src;
-
- return (
- <div className={cn("relative overflow-hidden", className)}>
- {src && (
- <Image
- src={src}
- alt={alt}
- fill
- onLoad={() => setIsLoading(false)}
- className={cn(
- "rounded-inherit object-center transition-opacity duration-300",
- isLoading ? "opacity-0" : "opacity-100",
- imageContain ? "object-contain" : "object-cover",
- )}
- sizes="100%"
- />
- )}
- {shouldShowSkeleton && (
- <div className="rounded-inherit absolute inset-0 animate-pulse bg-gray-300 dark:bg-gray-700" />
- )}
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/__legacy__/ThemeToggle.tsx b/autogpt_platform/frontend/src/components/__legacy__/ThemeToggle.tsx
deleted file mode 100644
index 18daaa7bd4..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/ThemeToggle.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { useTheme } from "next-themes";
-import { IconMoon, IconSun } from "@/components/__legacy__/ui/icons";
-
-export function ThemeToggle() {
- const { theme, setTheme } = useTheme();
- const [mounted, setMounted] = React.useState(false);
-
- React.useEffect(() => {
- setMounted(true);
- }, []);
-
- if (!mounted) {
- return (
- <div className="relative h-6 w-12 rounded-full bg-gray-200 transition-colors dark:bg-gray-600">
- <div className="absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-white" />
- </div>
- );
- }
-
- return (
- <div
- className="relative h-6 w-12 cursor-pointer rounded-full bg-gray-200 transition-colors dark:bg-gray-600"
- onClick={() => setTheme(theme === "light" ? "dark" : "light")}
- role="button"
- tabIndex={0}
- >
- <div
- className={`absolute left-0.5 top-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-white transition-transform duration-200 ${
- theme === "dark" ? "translate-x-6" : ""
- }`}
- >
- {theme === "light" ? (
- <IconSun className="h-4 w-4 text-yellow-500" />
- ) : (
- <IconMoon className="h-4 w-4 text-gray-700" />
- )}
- </div>
- <span className="sr-only">Toggle theme</span>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/__legacy__/action-button-group.tsx b/autogpt_platform/frontend/src/components/__legacy__/action-button-group.tsx
deleted file mode 100644
index 85b514809b..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/action-button-group.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import React from "react";
-import { cn } from "@/lib/utils";
-
-import type { ButtonAction } from "@/components/__legacy__/types";
-import { Button, buttonVariants } from "@/components/__legacy__/Button";
-import Link from "next/link";
-
-export default function ActionButtonGroup({
- title,
- actions,
- className,
-}: {
- title: React.ReactNode;
- actions: ButtonAction[];
- className?: string;
-}): React.ReactElement {
- return (
- <div className={cn("flex flex-col gap-3", className)}>
- <h3 className="text-sm font-medium">{title}</h3>
- {actions.map((action, i) =>
- "callback" in action ? (
- <Button
- key={i}
- variant={action.variant ?? "outline"}
- disabled={action.disabled}
- onClick={action.callback}
- {...action.extraProps}
- >
- {action.label}
- </Button>
- ) : (
- <Link
- key={i}
- className={cn(
- buttonVariants({ variant: action.variant }),
- action.disabled &&
- "pointer-events-none border-zinc-400 text-zinc-400",
- )}
- href={action.href}
- {...action.extraProps}
- >
- {action.label}
- </Link>
- ),
- )}
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/__legacy__/composite/FeaturedCreators.tsx b/autogpt_platform/frontend/src/components/__legacy__/composite/FeaturedCreators.tsx
deleted file mode 100644
index 589542bf32..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/composite/FeaturedCreators.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { CreatorCard } from "@/components/__legacy__/CreatorCard";
-import { useRouter } from "next/navigation";
-
-export interface FeaturedCreator {
- name: string;
- username: string;
- description: string;
- avatar_url: string;
- num_agents: number;
-}
-
-interface FeaturedCreatorsProps {
- title?: string;
- featuredCreators: FeaturedCreator[];
-}
-
-export const FeaturedCreators: React.FC<FeaturedCreatorsProps> = ({
- featuredCreators,
- title = "Featured Creators",
-}) => {
- const router = useRouter();
-
- const handleCardClick = (creator: string) => {
- router.push(`/marketplace/creator/${encodeURIComponent(creator)}`);
- };
-
- // Only show first 4 creators
- const displayedCreators = featuredCreators.slice(0, 4);
-
- return (
- <div className="flex w-full flex-col items-center justify-center">
- <div className="w-full max-w-[1360px]">
- <h2 className="mb-9 font-poppins text-lg font-semibold text-neutral-800 dark:text-neutral-200">
- {title}
- </h2>
-
- <div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4">
- {displayedCreators.map((creator, index) => (
- <CreatorCard
- key={index}
- creatorName={creator.name || creator.username}
- creatorImage={creator.avatar_url}
- bio={creator.description}
- agentsUploaded={creator.num_agents}
- onClick={() => handleCardClick(creator.username)}
- index={index}
- />
- ))}
- </div>
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/composite/FeaturedSection.tsx b/autogpt_platform/frontend/src/components/__legacy__/composite/FeaturedSection.tsx
deleted file mode 100644
index a6f21d39e4..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/composite/FeaturedSection.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { FeaturedAgentCard } from "@/components/__legacy__/FeaturedAgentCard";
-import {
- Carousel,
- CarouselContent,
- CarouselItem,
- CarouselPrevious,
- CarouselNext,
- CarouselIndicator,
-} from "@/components/__legacy__/ui/carousel";
-import { useCallback, useState } from "react";
-import type { StoreAgent } from "@/app/api/__generated__/models/storeAgent";
-import Link from "next/link";
-
-const BACKGROUND_COLORS = [
- "bg-violet-200 dark:bg-violet-800", // #ddd6fe / #5b21b6
- "bg-blue-200 dark:bg-blue-800", // #bfdbfe / #1e3a8a
- "bg-green-200 dark:bg-green-800", // #bbf7d0 / #065f46
-];
-
-interface FeaturedSectionProps {
- featuredAgents: StoreAgent[];
-}
-
-export const FeaturedSection: React.FC<FeaturedSectionProps> = ({
- featuredAgents,
-}) => {
- const [_, setCurrentSlide] = useState(0);
-
- const handlePrevSlide = useCallback(() => {
- setCurrentSlide((prev) =>
- prev === 0 ? featuredAgents.length - 1 : prev - 1,
- );
- }, [featuredAgents.length]);
-
- const handleNextSlide = useCallback(() => {
- setCurrentSlide((prev) =>
- prev === featuredAgents.length - 1 ? 0 : prev + 1,
- );
- }, [featuredAgents.length]);
-
- const getBackgroundColor = (index: number) => {
- return BACKGROUND_COLORS[index % BACKGROUND_COLORS.length];
- };
-
- return (
- <section className="w-full">
- <h2 className="mb-8 font-poppins text-2xl font-semibold leading-7 text-neutral-800 dark:text-neutral-200">
- Featured agents
- </h2>
-
- <Carousel
- opts={{
- align: "center",
- containScroll: "trimSnaps",
- }}
- >
- <CarouselContent>
- {featuredAgents.map((agent, index) => (
- <CarouselItem
- key={index}
- className="h-[480px] md:basis-1/2 lg:basis-1/3"
- >
- <Link
- href={`/marketplace/agent/${encodeURIComponent(agent.creator)}/${encodeURIComponent(agent.slug)}`}
- className="block h-full"
- >
- <FeaturedAgentCard
- agent={agent}
- backgroundColor={getBackgroundColor(index)}
- />
- </Link>
- </CarouselItem>
- ))}
- </CarouselContent>
- <div className="relative mt-4">
- <CarouselIndicator />
- <CarouselPrevious afterClick={handlePrevSlide} />
- <CarouselNext afterClick={handleNextSlide} />
- </div>
- </Carousel>
- </section>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/composite/HeroSection.tsx b/autogpt_platform/frontend/src/components/__legacy__/composite/HeroSection.tsx
deleted file mode 100644
index a6d12d1892..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/composite/HeroSection.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { SearchBar } from "@/components/__legacy__/SearchBar";
-import { FilterChips } from "@/components/__legacy__/FilterChips";
-import { useRouter } from "next/navigation";
-
-export const HeroSection: React.FC = () => {
- const router = useRouter();
-
- function onFilterChange(selectedFilters: string[]) {
- const encodedTerm = encodeURIComponent(selectedFilters.join(", "));
- router.push(`/marketplace/search?searchTerm=${encodedTerm}`);
- }
-
- return (
- <div className="mb-2 mt-8 flex flex-col items-center justify-center px-4 sm:mb-4 sm:mt-12 sm:px-6 md:mb-6 md:mt-16 lg:my-24 lg:px-8 xl:my-16">
- <div className="w-full max-w-3xl lg:max-w-4xl xl:max-w-5xl">
- <div className="mb-4 text-center md:mb-8">
- <h1 className="text-center">
- <span className="font-poppins text-[48px] font-semibold leading-[54px] text-neutral-950 dark:text-neutral-50">
- Explore AI agents built for{" "}
- </span>
- <span className="font-poppins text-[48px] font-semibold leading-[54px] text-violet-600">
- you
- </span>
- <br />
- <span className="font-poppins text-[48px] font-semibold leading-[54px] text-neutral-950 dark:text-neutral-50">
- by the{" "}
- </span>
- <span className="font-poppins text-[48px] font-semibold leading-[54px] text-blue-500">
- community
- </span>
- </h1>
- </div>
- <h3 className="mb:text-2xl mb-6 text-center font-sans text-xl font-normal leading-loose text-neutral-700 dark:text-neutral-300 md:mb-12">
- Bringing you AI agents designed by thinkers from around the world
- </h3>
- <div className="mb-4 flex justify-center sm:mb-5">
- <SearchBar height="h-[74px]" />
- </div>
- <div>
- <div className="flex justify-center">
- <FilterChips
- badges={[
- "Marketing",
- "SEO",
- "Content Creation",
- "Automation",
- "Fun",
- ]}
- onFilterChange={onFilterChange}
- multiSelect={false}
- />
- </div>
- </div>
- </div>
- </div>
- );
-};
diff --git a/autogpt_platform/frontend/src/components/__legacy__/delete-confirm-dialog.tsx b/autogpt_platform/frontend/src/components/__legacy__/delete-confirm-dialog.tsx
deleted file mode 100644
index 1ad726eb2c..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/delete-confirm-dialog.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { Button } from "@/components/__legacy__/Button";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from "@/components/__legacy__/ui/dialog";
-
-export default function DeleteConfirmDialog({
- entityType,
- entityName,
- open,
- onOpenChange,
- onDoDelete,
- isIrreversible = true,
- className,
-}: {
- entityType: string;
- entityName?: string;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onDoDelete: () => void;
- isIrreversible?: boolean;
- className?: string;
-}): React.ReactNode {
- const displayType = entityType
- .split(" ")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className={className}>
- <DialogHeader>
- <DialogTitle>
- Delete {displayType} {entityName && `"${entityName}"`}
- </DialogTitle>
- <DialogDescription>
- Are you sure you want to delete this {entityType}?
- {isIrreversible && (
- <b>
- <br /> This action cannot be undone.
- </b>
- )}
- </DialogDescription>
- </DialogHeader>
- <DialogFooter>
- <Button onClick={() => onOpenChange(false)}>Cancel</Button>
- <Button variant="destructive" onClick={onDoDelete}>
- Delete
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/__legacy__/types.ts b/autogpt_platform/frontend/src/components/__legacy__/types.ts
deleted file mode 100644
index 30593968b1..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/types.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { ButtonProps } from "@/components/__legacy__/Button";
-import type { LinkProps } from "next/link";
-import React from "react";
-
-export type ButtonAction = {
- label: React.ReactNode;
- variant?: ButtonProps["variant"];
- disabled?: boolean;
- extraProps?: Record<`data-${string}`, string>;
-} & (
- | {
- callback: () => void;
- extraProps?: Partial<ButtonProps>;
- }
- | {
- href: string;
- extraProps?: Partial<LinkProps>;
- }
-);
diff --git a/autogpt_platform/frontend/src/components/__legacy__/ui/data-table.tsx b/autogpt_platform/frontend/src/components/__legacy__/ui/data-table.tsx
deleted file mode 100644
index 43a4cf1978..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/ui/data-table.tsx
+++ /dev/null
@@ -1,209 +0,0 @@
-"use client";
-
-import {
- ColumnDef,
- ColumnFiltersState,
- SortingState,
- VisibilityState,
- flexRender,
- getCoreRowModel,
- useReactTable,
- getPaginationRowModel,
- getSortedRowModel,
- getFilteredRowModel,
-} from "@tanstack/react-table";
-import {
- TableHeader,
- TableRow,
- TableHead,
- TableBody,
- TableCell,
- Table,
-} from "@/components/__legacy__/ui/table";
-import { Button } from "@/components/__legacy__/ui/button";
-import {
- DropdownMenu,
- DropdownMenuCheckboxItem,
- DropdownMenuContent,
- DropdownMenuTrigger,
-} from "@/components/__legacy__/ui/dropdown-menu";
-import { Input } from "@/components/__legacy__/ui/input";
-import { cloneElement, Fragment, useState } from "react";
-
-export interface GlobalActions<TData> {
- component: React.ReactElement;
- action: (rows: TData[]) => Promise<void>;
-}
-
-interface DataTableProps<TData, TValue> {
- columns: ColumnDef<TData, TValue>[];
- data: TData[];
- filterPlaceholder: string;
- filterColumn?: string;
- globalActions?: GlobalActions<TData>[];
-}
-
-export function DataTable<TData, TValue>({
- columns,
- data,
- filterPlaceholder = "Filter...",
- filterColumn,
- globalActions = [],
-}: DataTableProps<TData, TValue>) {
- const [sorting, setSorting] = useState<SortingState>([]);
- const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
- const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
- const [rowSelection, setRowSelection] = useState({});
-
- const table = useReactTable({
- data,
- columns,
- getCoreRowModel: getCoreRowModel(),
- getPaginationRowModel: getPaginationRowModel(),
- getSortedRowModel: getSortedRowModel(),
- getFilteredRowModel: getFilteredRowModel(),
- onSortingChange: setSorting,
- onColumnFiltersChange: setColumnFilters,
- onColumnVisibilityChange: setColumnVisibility,
- onRowSelectionChange: setRowSelection,
- state: {
- sorting,
- columnFilters,
- columnVisibility,
- rowSelection,
- },
- });
-
- return (
- <div>
- <div className="flex items-center gap-2 py-4">
- {filterColumn && (
- <Input
- placeholder={filterPlaceholder}
- value={
- (table.getColumn(filterColumn)?.getFilterValue() as string) ?? ""
- }
- onChange={(event) =>
- table.getColumn(filterColumn)?.setFilterValue(event.target.value)
- }
- className="max-w-sm"
- />
- )}
-
- {globalActions &&
- globalActions.map((action, index) => {
- return (
- <Fragment key={index}>
- <div className="flex items-center">
- {cloneElement(action.component, {
- onClick: () => {
- const filteredSelectedRows = table
- .getFilteredSelectedRowModel()
- .rows.map((row) => row.original);
- action.action(filteredSelectedRows);
- },
- })}
- </div>
- </Fragment>
- );
- })}
-
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" className="ml-auto">
- Columns
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {table
- .getAllColumns()
- .filter((column) => column.getCanHide())
- .map((column) => {
- return (
- <DropdownMenuCheckboxItem
- key={column.id}
- className="capitalize"
- checked={column.getIsVisible()}
- onCheckedChange={(value) =>
- column.toggleVisibility(!!value)
- }
- >
- {column.id}
- </DropdownMenuCheckboxItem>
- );
- })}
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
-
- <div className="rounded-md border">
- <Table>
- <TableHeader>
- {table.getHeaderGroups().map((headerGroup) => (
- <TableRow key={headerGroup.id}>
- {headerGroup.headers.map((header) => {
- return (
- <TableHead key={header.id}>
- {header.isPlaceholder
- ? null
- : flexRender(
- header.column.columnDef.header,
- header.getContext(),
- )}
- </TableHead>
- );
- })}
- </TableRow>
- ))}
- </TableHeader>
- <TableBody>
- {table.getRowModel().rows?.length ? (
- table.getRowModel().rows.map((row) => (
- <TableRow
- key={row.id}
- data-state={row.getIsSelected() && "selected"}
- >
- {row.getVisibleCells().map((cell) => (
- <TableCell key={cell.id}>
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
- </TableCell>
- ))}
- </TableRow>
- ))
- ) : (
- <TableRow>
- <TableCell
- colSpan={columns.length}
- className="h-24 text-center"
- >
- No results.
- </TableCell>
- </TableRow>
- )}
- </TableBody>
- </Table>
- </div>
- <div className="flex items-center justify-end space-x-2 py-4">
- <Button
- variant="outline"
- size="sm"
- onClick={() => table.previousPage()}
- disabled={!table.getCanPreviousPage()}
- >
- Previous
- </Button>
- <Button
- variant="outline"
- size="sm"
- onClick={() => table.nextPage()}
- disabled={!table.getCanNextPage()}
- >
- Next
- </Button>
- </div>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/__legacy__/ui/radio-group.tsx b/autogpt_platform/frontend/src/components/__legacy__/ui/radio-group.tsx
deleted file mode 100644
index c5dc573404..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/ui/radio-group.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-"use client";
-
-import * as React from "react";
-import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
-import { cn } from "@/lib/utils";
-import { DotFilledIcon } from "@radix-ui/react-icons";
-
-const RadioGroup = React.forwardRef<
- React.ElementRef<typeof RadioGroupPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
->(({ className, ...props }, ref) => {
- return (
- <RadioGroupPrimitive.Root
- className={cn("grid gap-2", className)}
- {...props}
- ref={ref}
- />
- );
-});
-RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
-
-const RadioGroupItem = React.forwardRef<
- React.ElementRef<typeof RadioGroupPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
->(({ className, ...props }, ref) => {
- return (
- <RadioGroupPrimitive.Item
- ref={ref}
- className={cn(
- "aspect-square h-4 w-4 rounded-full border border-neutral-200 border-neutral-900 text-neutral-900 shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-neutral-950 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-50 dark:border-neutral-800 dark:text-neutral-50 dark:focus-visible:ring-neutral-300",
- className,
- )}
- {...props}
- >
- <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
- <DotFilledIcon className="h-3.5 w-3.5 fill-primary" />
- </RadioGroupPrimitive.Indicator>
- </RadioGroupPrimitive.Item>
- );
-});
-RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
-
-export { RadioGroup, RadioGroupItem };
diff --git a/autogpt_platform/frontend/src/components/__legacy__/ui/render.tsx b/autogpt_platform/frontend/src/components/__legacy__/ui/render.tsx
deleted file mode 100644
index b290c51809..0000000000
--- a/autogpt_platform/frontend/src/components/__legacy__/ui/render.tsx
+++ /dev/null
@@ -1,153 +0,0 @@
-"use client";
-
-import * as React from "react";
-
-const getYouTubeVideoId = (url: string) => {
- const regExp =
- /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
- const match = url.match(regExp);
- return match && match[7].length === 11 ? match[7] : null;
-};
-
-const isValidMediaUri = (url: string): boolean => {
- if (url.startsWith("data:")) {
- return true;
- }
- const validUrl = /^(https?:\/\/)(www\.)?/i;
- const cleanedUrl = url.split("?")[0];
- return validUrl.test(cleanedUrl);
-};
-
-const isValidVideoUrl = (url: string): boolean => {
- if (url.startsWith("data:video")) {
- return true;
- }
- const videoExtensions = /\.(mp4|webm|ogg|mov|avi|mkv|m4v)$/i;
- const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
- const cleanedUrl = url.split("?")[0];
- return (
- (isValidMediaUri(url) && videoExtensions.test(cleanedUrl)) ||
- youtubeRegex.test(cleanedUrl)
- );
-};
-
-const isValidImageUrl = (url: string): boolean => {
- if (url.startsWith("data:image/")) {
- return true;
- }
- const imageExtensions = /\.(jpeg|jpg|gif|png|svg|webp)$/i;
- const cleanedUrl = url.split("?")[0];
- return isValidMediaUri(url) && imageExtensions.test(cleanedUrl);
-};
-
-const isValidAudioUrl = (url: string): boolean => {
- if (url.startsWith("data:audio")) {
- return true;
- }
- const audioExtensions = /\.(mp3|wav|ogg|m4a|aac|flac)$/i;
- const cleanedUrl = url.split("?")[0];
- return isValidMediaUri(url) && audioExtensions.test(cleanedUrl);
-};
-
-const getVideoMimeType = (url: string): string => {
- if (url.startsWith("data:video/")) {
- const match = url.match(/^data:(video\/[^;]+)/);
- return match?.[1] || "video/mp4";
- }
- const extension = url.split("?")[0].split(".").pop()?.toLowerCase();
- const mimeMap: Record<string, string> = {
- mp4: "video/mp4",
- webm: "video/webm",
- ogg: "video/ogg",
- mov: "video/quicktime",
- avi: "video/x-msvideo",
- mkv: "video/x-matroska",
- m4v: "video/mp4",
- };
- return mimeMap[extension || ""] || "video/mp4";
-};
-
-const VideoRenderer: React.FC<{ videoUrl: string }> = ({ videoUrl }) => {
- const videoId = getYouTubeVideoId(videoUrl);
- return (
- <div className="w-full p-2">
- {videoId ? (
- <iframe
- width="100%"
- height="315"
- src={`https://www.youtube.com/embed/${videoId}`}
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- ></iframe>
- ) : (
- <video controls width="100%" height="315">
- <source src={videoUrl} type={getVideoMimeType(videoUrl)} />
- Your browser does not support the video tag.
- </video>
- )}
- </div>
- );
-};
-
-const ImageRenderer: React.FC<{ imageUrl: string }> = ({ imageUrl }) => {
- return (
- <div className="w-full p-2">
- <picture>
- <img
- src={imageUrl}
- alt="Image"
- className="h-auto max-w-full"
- width="100%"
- height="auto"
- />
- </picture>
- </div>
- );
-};
-
-const AudioRenderer: React.FC<{ audioUrl: string }> = ({ audioUrl }) => (
- <div className="w-full p-2">
- <audio controls className="w-full">
- <source
- src={audioUrl}
- type={`audio/${audioUrl.split(".").pop()?.toLowerCase()}`}
- />
- Your browser does not support the audio element.
- </audio>
- </div>
-);
-
-export const TextRenderer: React.FC<{
- value: any;
- truncateLengthLimit?: number;
-}> = ({ value, truncateLengthLimit }) => {
- const text =
- typeof value === "object" ? JSON.stringify(value, null, 2) : String(value);
- return truncateLengthLimit && text.length > truncateLengthLimit
- ? text.slice(0, truncateLengthLimit) + "..."
- : text;
-};
-
-export const ContentRenderer: React.FC<{
- value: any;
- truncateLongData?: boolean;
-}> = ({ value, truncateLongData }) => {
- if (typeof value === "string") {
- if (value.startsWith("data:image/")) {
- return <ImageRenderer imageUrl={value} />;
- }
- if (isValidVideoUrl(value)) {
- return <VideoRenderer videoUrl={value} />;
- } else if (isValidImageUrl(value)) {
- return <ImageRenderer imageUrl={value} />;
- } else if (isValidAudioUrl(value)) {
- return <AudioRenderer audioUrl={value} />;
- }
- }
- return (
- <TextRenderer
- value={value}
- truncateLengthLimit={truncateLongData ? 100 : undefined}
- />
- );
-};
diff --git a/autogpt_platform/frontend/src/tests/integrations/vitest.setup.tsx b/autogpt_platform/frontend/src/tests/integrations/vitest.setup.tsx
index 64d4f49a37..291bf7f14e 100644
--- a/autogpt_platform/frontend/src/tests/integrations/vitest.setup.tsx
+++ b/autogpt_platform/frontend/src/tests/integrations/vitest.setup.tsx
@@ -18,29 +18,6 @@ vi.mock("react", async (importActual) => {
};
});
-// NumberFlow renders into a shadow-DOM custom element and schedules animation
-// work outside React. happy-dom can mount it, but the resulting rAF + custom
-// element lifecycle collides with React 18's concurrent renderer during
-// cleanup ("Should not already be working"). Render a plain span with the
-// formatted value — tests query the wrapping aria-label, not NumberFlow's
-// internals.
-vi.mock("@number-flow/react", () => ({
- default: ({
- value,
- format,
- locales,
- }: {
- value: number;
- format?: Intl.NumberFormatOptions;
- locales?: Intl.LocalesArgument;
- }) => {
- const text = format
- ? new Intl.NumberFormat(locales ?? "en-US", format).format(value)
- : String(value);
- return <span>{text}</span>;
- },
-}));
-
beforeAll(() => {
mockNextjsModules();
mockAuthRequest(); // If you need user's data - please mock auth actions in your specific test - it sends null user [It's only to avoid cookies() call]