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): delete the shared components' unused files (#15829)

Reinier van der Leerbf09dc97d965
diff --git a/autogpt_platform/frontend/src/components/auth/PasswordInput.tsx b/autogpt_platform/frontend/src/components/auth/PasswordInput.tsx
deleted file mode 100644
index db920c34e3..0000000000
--- a/autogpt_platform/frontend/src/components/auth/PasswordInput.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { forwardRef, useState } from "react";
-import { EyeIcon, EyeOffIcon } from "lucide-react";
-import { Button } from "@/components/__legacy__/ui/button";
-import { Input, InputProps } from "@/components/__legacy__/ui/input";
-import { cn } from "@/lib/utils";
-
-const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
- ({ className, ...props }, ref) => {
- const [showPassword, setShowPassword] = useState(false);
- const disabled =
- props.value === "" || props.value === undefined || props.disabled;
-
- return (
- <div className="relative">
- <Input
- type={showPassword ? "text" : "password"}
- className={cn("hide-password-toggle pr-10", className)}
- ref={ref}
- title="password"
- {...props}
- />
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
- onMouseDown={() => setShowPassword(true)}
- onMouseUp={() => setShowPassword(false)}
- onMouseLeave={() => setShowPassword(false)}
- disabled={disabled}
- tabIndex={-1}
- >
- {showPassword && !disabled ? (
- <EyeIcon className="h-4 w-4" aria-hidden="true" />
- ) : (
- <EyeOffIcon className="h-4 w-4" aria-hidden="true" />
- )}
- <span className="sr-only">
- {showPassword ? "Hide password" : "Show password"}
- </span>
- </Button>
-
- {/* hides browsers password toggles */}
- <style>{`
- .hide-password-toggle::-ms-reveal,
- .hide-password-toggle::-ms-clear {
- visibility: hidden;
- pointer-events: none;
- display: none;
- }
- `}</style>
- </div>
- );
- },
-);
-PasswordInput.displayName = "PasswordInput";
-
-export { PasswordInput };
diff --git a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsAccordionView/CredentialsAccordionView.tsx b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsAccordionView/CredentialsAccordionView.tsx
deleted file mode 100644
index 9204a4d9b0..0000000000
--- a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsAccordionView/CredentialsAccordionView.tsx
+++ /dev/null
@@ -1,203 +0,0 @@
-import { Button } from "@/components/atoms/Button/Button";
-import { Text } from "@/components/atoms/Text/Text";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "@/components/molecules/Accordion/Accordion";
-import { InformationTooltip } from "@/components/molecules/InformationTooltip/InformationTooltip";
-import {
- BlockIOCredentialsSubSchema,
- CredentialsMetaInput,
-} from "@/lib/autogpt-server-api/types";
-import { SlidersHorizontalIcon } from "lucide-react";
-import { CredentialRow } from "../CredentialRow/CredentialRow";
-import { CredentialsSelect } from "../CredentialsSelect/CredentialsSelect";
-
-type Credential = {
- id: string;
- title?: string;
- username?: string;
- type: string;
- provider: string;
-};
-
-type Props = {
- schema: BlockIOCredentialsSubSchema;
- provider: string;
- displayName: string;
- userCredentials: Credential[];
- systemCredentials: Credential[];
- isSystemProvider: boolean;
- selectedCredential?: CredentialsMetaInput;
- onSelectCredential: (credentialId: string) => void;
- onClearCredential: () => void;
- onAddCredential: () => void;
- actionButtonText: string;
- isOptional: boolean;
- showTitle: boolean;
- variant: "default" | "node";
-};
-
-export function CredentialsAccordionView({
- schema,
- provider,
- displayName,
- userCredentials,
- systemCredentials,
- isSystemProvider,
- selectedCredential,
- onSelectCredential,
- onClearCredential,
- onAddCredential,
- actionButtonText,
- isOptional,
- showTitle,
- variant,
-}: Props) {
- const allCredentials = [...userCredentials, ...systemCredentials];
- const hasSystemCredentials = systemCredentials.length > 0;
- const hasUserCredentials = userCredentials.length > 0;
-
- const credentialsInAccordion = isSystemProvider
- ? allCredentials
- : systemCredentials;
-
- const shouldOpenAccordionByDefault =
- hasSystemCredentials && !isOptional && !selectedCredential;
-
- const showUserCredentialsOutsideAccordion =
- !isSystemProvider && hasUserCredentials;
-
- return (
- <>
- {showTitle && showUserCredentialsOutsideAccordion && (
- <div className="mb-2 flex items-center gap-2">
- <Text variant="large-medium">
- {displayName} credentials
- {isOptional && (
- <span className="ml-1 text-sm font-normal text-gray-500">
- (optional)
- </span>
- )}
- </Text>
- {schema.description && (
- <InformationTooltip description={schema.description} />
- )}
- </div>
- )}
-
- {showUserCredentialsOutsideAccordion && (
- <>
- {userCredentials.length > 1 || isOptional ? (
- <CredentialsSelect
- credentials={userCredentials}
- provider={provider}
- displayName={displayName}
- selectedCredentials={selectedCredential}
- onSelectCredential={onSelectCredential}
- onClearCredential={onClearCredential}
- allowNone={isOptional}
- variant={variant}
- />
- ) : (
- <div className="mb-4 space-y-2">
- {userCredentials.map((credential) => (
- <CredentialRow
- key={credential.id}
- credential={credential}
- provider={provider}
- displayName={displayName}
- onSelect={() => onSelectCredential(credential.id)}
- />
- ))}
- </div>
- )}
- <Button
- variant="secondary"
- size="small"
- onClick={onAddCredential}
- className="w-fit"
- type="button"
- >
- {actionButtonText}
- </Button>
- </>
- )}
-
- {hasSystemCredentials && (
- <Accordion
- type="single"
- collapsible
- defaultValue={
- shouldOpenAccordionByDefault ? "system-credentials" : undefined
- }
- className={showUserCredentialsOutsideAccordion ? "mt-4" : ""}
- >
- <AccordionItem value="system-credentials" className="border-none">
- <AccordionTrigger className="py-2 text-sm text-muted-foreground hover:no-underline">
- <div className="flex items-center gap-1">
- <SlidersHorizontalIcon className="size-4" /> System credentials
- </div>
- </AccordionTrigger>
- <AccordionContent>
- <div className="space-y-4 px-1 pt-2">
- {showTitle && (
- <div className="flex items-center gap-2">
- <Text variant="large-medium">
- {displayName} credentials
- {isOptional && (
- <span className="ml-1 text-sm font-normal text-gray-500">
- (optional)
- </span>
- )}
- </Text>
- {schema.description && (
- <InformationTooltip description={schema.description} />
- )}
- </div>
- )}
- {credentialsInAccordion.length > 0 && (
- <CredentialsSelect
- credentials={credentialsInAccordion}
- provider={provider}
- displayName={displayName}
- selectedCredentials={selectedCredential}
- onSelectCredential={onSelectCredential}
- onClearCredential={onClearCredential}
- allowNone={isOptional}
- variant={variant}
- />
- )}
- {isSystemProvider && (
- <Button
- variant="secondary"
- size="small"
- onClick={onAddCredential}
- className="w-fit"
- type="button"
- >
- {actionButtonText}
- </Button>
- )}
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- )}
-
- {!showUserCredentialsOutsideAccordion && !isSystemProvider && (
- <Button
- variant="secondary"
- size="small"
- onClick={onAddCredential}
- className="w-fit"
- type="button"
- >
- {actionButtonText}
- </Button>
- )}
- </>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/types.ts b/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/types.ts
deleted file mode 100644
index b317dc6879..0000000000
--- a/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/types.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export type EnvironmentDrivenGoogleConfig = {
- clientId?: string | undefined;
- developerKey?: string | undefined;
- appId?: string | undefined; // Cloud project number
-};
-
-export function readEnvGoogleConfig(): EnvironmentDrivenGoogleConfig {
- return {
- clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
- developerKey: process.env.NEXT_PUBLIC_GOOGLE_API_KEY,
- appId: process.env.NEXT_PUBLIC_GOOGLE_APP_ID,
- };
-}
diff --git a/autogpt_platform/frontend/src/components/contextual/OutputRenderers/utils/copy.ts b/autogpt_platform/frontend/src/components/contextual/OutputRenderers/utils/copy.ts
deleted file mode 100644
index 5b18f44669..0000000000
--- a/autogpt_platform/frontend/src/components/contextual/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/components/contextual/marketplaceHelpers.ts b/autogpt_platform/frontend/src/components/contextual/marketplaceHelpers.ts
deleted file mode 100644
index a080eca57f..0000000000
--- a/autogpt_platform/frontend/src/components/contextual/marketplaceHelpers.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Marketplace-specific helper functions that can be reused across different marketplace screens
- */
-
-/**
- * Calculate the latest marketplace version from agent graph versions
- */
-export function getLatestMarketplaceVersion(
- agentGraphVersions?: string[],
-): number | undefined {
- if (!agentGraphVersions?.length) return undefined;
-
- return Math.max(...agentGraphVersions.map((v: string) => parseInt(v, 10)));
-}
-
-/**
- * Check if the current user is the creator of the agent
- * Uses ID-based comparison for accurate matching
- */
-export function isUserCreator(
- creatorId: string | undefined,
- currentUserId: string | undefined,
-): boolean {
- if (!creatorId || !currentUserId) return false;
- return creatorId === currentUserId;
-}
-
-/**
- * Calculate update status for an agent
- */
-export function calculateUpdateStatus({
- latestMarketplaceVersion,
- currentVersion,
- isUserCreator,
- isAgentAddedToLibrary,
-}: {
- latestMarketplaceVersion?: number;
- currentVersion: number;
- isUserCreator: boolean;
- isAgentAddedToLibrary: boolean;
-}) {
- if (!latestMarketplaceVersion) {
- return { hasUpdate: false, hasUnpublishedChanges: false };
- }
-
- const hasUnpublishedChanges =
- isUserCreator &&
- isAgentAddedToLibrary &&
- currentVersion > latestMarketplaceVersion;
-
- const hasUpdate =
- isAgentAddedToLibrary &&
- !isUserCreator &&
- latestMarketplaceVersion > currentVersion;
-
- return { hasUpdate, hasUnpublishedChanges };
-}
diff --git a/autogpt_platform/frontend/src/components/molecules/ErrorCard/components/LoadingState.tsx b/autogpt_platform/frontend/src/components/molecules/ErrorCard/components/LoadingState.tsx
deleted file mode 100644
index 7a276847c1..0000000000
--- a/autogpt_platform/frontend/src/components/molecules/ErrorCard/components/LoadingState.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import React from "react";
-import { Text } from "@/components/atoms/Text/Text";
-import { Refresh01Icon } from "@hugeicons/core-free-icons";
-import { Icon } from "@/components/atoms/Icon/Icon";
-
-interface LoadingStateProps {
- loadingSlot?: React.ReactNode;
-}
-
-export function LoadingState({ loadingSlot }: LoadingStateProps) {
- return (
- <div className="relative flex items-center justify-center gap-3 p-6">
- {loadingSlot || (
- <>
- <Icon
- icon={Refresh01Icon}
- size={20}
- className="animate-spin text-purple-500"
- />
- <Text variant="body" className="text-zinc-600">
- Loading...
- </Text>
- </>
- )}
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatar.tsx b/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatar.tsx
deleted file mode 100644
index 3d55e5e3fb..0000000000
--- a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatar.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-"use client";
-
-import dynamic from "next/dynamic";
-import { useId } from "react";
-import { findNotionColor, type NotionAvatarConfig } from "./helpers";
-import type { AvatarStatus } from "./status";
-
-// The artwork is a few hundred kilobytes of paths. Loading it with the route
-// would put it on every page that shows an avatar, so it arrives as its own
-// chunk on mount. Until it lands, the disc stands in.
-const NotionAvatarSvg = dynamic(
- () => import("./NotionAvatarSvg").then((module) => module.NotionAvatarSvg),
- { ssr: false, loading: () => null },
-);
-
-interface Props {
- config: NotionAvatarConfig;
- status?: AvatarStatus;
- size?: number;
- showBadge?: boolean;
- transparent?: boolean;
- title?: string;
- className?: string;
-}
-
-/** A face drawn inline, for the picker, where cycling a feature has to redraw
- * without a round trip. Everywhere else wants NotionAvatarImage. */
-export function NotionAvatar({
- config,
- status = "idle",
- size = 96,
- showBadge = true,
- transparent = false,
- title,
- className,
-}: Props) {
- const idPrefix = useId().replace(/:/g, "");
-
- return (
- <span
- style={{
- width: size,
- height: size,
- backgroundColor: transparent
- ? undefined
- : findNotionColor(config.color).disc,
- }}
- className="inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full"
- >
- <NotionAvatarSvg
- config={config}
- status={status}
- idPrefix={idPrefix}
- size={size}
- showBadge={showBadge}
- transparent
- title={title}
- className={className}
- />
- </span>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatarImage.tsx b/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatarImage.tsx
deleted file mode 100644
index ebf59e0e14..0000000000
--- a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatarImage.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { cn } from "@/lib/utils";
-import Image from "next/image";
-import { notionAvatarImageUrlFor, type NotionAvatarConfig } from "./helpers";
-import type { AvatarStatus } from "./status";
-import { StatusDot } from "./StatusDot";
-
-interface Props {
- config: NotionAvatarConfig;
- status?: AvatarStatus;
- size?: number;
- title?: string;
- className?: string;
-}
-
-/** The avatar as a cacheable image. The face never moves, so this is how it is
- * drawn everywhere except the picker, which redraws as you cycle features. */
-export function NotionAvatarImage({
- config,
- status = "idle",
- size = 36,
- title,
- className,
-}: Props) {
- const src = notionAvatarImageUrlFor(config);
- const face = (
- <Image
- src={src}
- alt={title ?? "Avatar"}
- width={size}
- height={size}
- unoptimized
- data-testid="notion-avatar-image"
- data-avatar={src}
- className={cn("shrink-0 rounded-full", className)}
- />
- );
-
- if (status === "idle") return face;
-
- return (
- <span
- style={{ width: size, height: size }}
- className="relative inline-flex shrink-0"
- >
- {face}
- <StatusDot
- status={status}
- size={Math.round(size * 0.34)}
- className="absolute -bottom-0.5 -right-0.5"
- />
- </span>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatarSvg.tsx b/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatarSvg.tsx
deleted file mode 100644
index 4368a450cb..0000000000
--- a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/NotionAvatarSvg.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { cn } from "@/lib/utils";
-import { composeNotionAvatar } from "./compose";
-import {
- encodeNotionConfig,
- findNotionColor,
- type NotionAvatarConfig,
-} from "./helpers";
-import type { AvatarStatus } from "./status";
-
-interface Props {
- config: NotionAvatarConfig;
- status: AvatarStatus;
- idPrefix: string;
- size?: number;
- showBadge?: boolean;
- transparent?: boolean;
- title?: string;
- className?: string;
-}
-
-// The same markup the /avatars/notion route serves, inlined so a picker can
-// redraw without a round trip. One composer, so the two can never disagree.
-export function NotionAvatarSvg({
- config,
- status,
- idPrefix,
- size = 96,
- showBadge = true,
- transparent = false,
- title,
- className,
-}: Props) {
- const color = findNotionColor(config.color);
-
- return (
- <span
- role="img"
- aria-label={title ?? `${color.label} avatar`}
- data-testid="notion-avatar"
- data-avatar={encodeNotionConfig(config)}
- data-status={status}
- className={cn("inline-flex shrink-0", className)}
- dangerouslySetInnerHTML={{
- __html: composeNotionAvatar(config, {
- size,
- idPrefix,
- transparent,
- status: showBadge ? status : "idle",
- }),
- }}
- />
- );
-}
diff --git a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/helpers.ts b/autogpt_platform/frontend/src/components/molecules/NotionAvatar/helpers.ts
index 6e1bf3f107..af7b573b6b 100644
--- a/autogpt_platform/frontend/src/components/molecules/NotionAvatar/helpers.ts
+++ b/autogpt_platform/frontend/src/components/molecules/NotionAvatar/helpers.ts
@@ -1,12 +1,9 @@
import {
NOTION_CATEGORIES,
NOTION_PART_COUNTS,
- VIEWBOX,
type NotionCategory,
} from "./metadata.generated";
-export { VIEWBOX };
-
export type NotionParts = Record<NotionCategory, number>;
export interface NotionAvatarConfig {
@@ -73,36 +70,6 @@ export const PICKABLE_CATEGORIES: NotionCategory[] = [
"details",
];
-export const CATEGORY_LABELS: Record<NotionCategory, string> = {
- face: "Face",
- nose: "Nose",
- mouth: "Mouth",
- eyes: "Eyes",
- eyebrows: "Eyebrows",
- glasses: "Glasses",
- hair: "Hair",
- accessories: "Accessories",
- // Upstream calls these "details"; they are blush, freckles, moles and lines.
- details: "Marks",
- beard: "Beard",
-};
-
-export const DEFAULT_NOTION_CONFIG: NotionAvatarConfig = {
- parts: {
- face: 0,
- nose: 0,
- mouth: 0,
- eyes: 0,
- eyebrows: 0,
- glasses: 0,
- hair: 0,
- accessories: 0,
- details: 0,
- beard: 0,
- },
- color: "violet",
-};
-
export function findNotionColor(id: NotionColorId) {
return NOTION_COLORS.find((color) => color.id === id) ?? NOTION_COLORS[0];
}
diff --git a/autogpt_platform/frontend/src/components/molecules/RunStatusBadge/helpers.ts b/autogpt_platform/frontend/src/components/molecules/RunStatusBadge/helpers.ts
deleted file mode 100644
index 0e7749181d..0000000000
--- a/autogpt_platform/frontend/src/components/molecules/RunStatusBadge/helpers.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-const GUIDANCE: Record<string, string> = {
- COMPLETED: "Execution finished. Open the output to review the result.",
- FAILED:
- "Execution failed. Open run details to inspect the cause before retrying.",
- RUNNING: "Execution is in progress. Open run details to follow progress.",
- QUEUED: "Execution is waiting to start. Open run details to check progress.",
- REVIEW:
- "Execution is waiting for a decision. Review the request before approving or rejecting it.",
- TERMINATED: "Execution stopped. Open run details to inspect where it ended.",
- INCOMPLETE:
- "Execution has not completed. Open run details to inspect what remains.",
-};
-
-export function getRunStatusGuidance(status: string): string {
- return (
- GUIDANCE[status.toUpperCase()] ??
- "No status details available. Open run details for more information."
- );
-}