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.

fix(frontend): small library/mobile improvements (#11626)

Ubbecd3e35df9ef7
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/CredentialsInputs/components/CredentialRow/CredentialRow.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/CredentialsInputs/components/CredentialRow/CredentialRow.tsx
index 34c066e90d..7d6598d7be 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/CredentialsInputs/components/CredentialRow/CredentialRow.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/CredentialsInputs/components/CredentialRow/CredentialRow.tsx
@@ -70,7 +70,7 @@ export function CredentialRow({
</Text>
<Text
variant="large"
- className="relative top-1 flex-[0_0_40%] overflow-hidden font-mono tracking-tight"
+ className="relative top-1 hidden flex-[0_0_40%] overflow-hidden truncate font-mono tracking-tight md:block"
>
{"*".repeat(MASKED_KEY_LENGTH)}
</Text>
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentInputs/RunAgentInputs.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentInputs/RunAgentInputs.tsx
index ea372193c5..d3e6fd9669 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentInputs/RunAgentInputs.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentInputs/RunAgentInputs.tsx
@@ -103,7 +103,7 @@ export function RunAgentInputs({
value={value}
onChange={onChange}
className="w-full"
- showRemoveButton={false}
+ showRemoveButton={!readOnly}
/>
);
break;
diff --git a/autogpt_platform/frontend/src/components/atoms/OverflowText/OverflowText.stories.tsx b/autogpt_platform/frontend/src/components/atoms/OverflowText/OverflowText.stories.tsx
new file mode 100644
index 0000000000..049948cd1b
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/atoms/OverflowText/OverflowText.stories.tsx
@@ -0,0 +1,157 @@
+import type { Meta, StoryObj } from "@storybook/nextjs";
+import { OverflowText } from "./OverflowText";
+
+const meta: Meta<typeof OverflowText> = {
+ title: "Atoms/OverflowText",
+ component: OverflowText,
+ tags: ["autodocs"],
+ parameters: {
+ layout: "centered",
+ docs: {
+ description: {
+ component:
+ "Text component that automatically truncates overflowing content with ellipsis and shows a tooltip on hover when truncated. Supports both string and ReactNode values.",
+ },
+ },
+ },
+ argTypes: {
+ value: {
+ control: "text",
+ description: "The text content to display (string or ReactNode)",
+ },
+ className: {
+ control: "text",
+ description: "Additional CSS classes to customize styling",
+ },
+ },
+ args: {
+ value: "This is a sample text that may overflow",
+ className: "",
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const Default: Story = {
+ render: function DefaultOverflowText(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} />
+ </div>
+ );
+ },
+};
+
+export const ShortText: Story = {
+ args: {
+ value: "Short text",
+ },
+ render: function ShortTextStory(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} />
+ </div>
+ );
+ },
+};
+
+export const LongText: Story = {
+ args: {
+ value:
+ "This is a very long text that will definitely overflow and show a tooltip when you hover over it",
+ },
+ render: function LongTextStory(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} />
+ </div>
+ );
+ },
+};
+
+export const CustomStyling: Story = {
+ args: {
+ value: "Text with custom styling",
+ className: "text-lg font-semibold text-indigo-600",
+ },
+ render: function CustomStylingStory(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} />
+ </div>
+ );
+ },
+};
+
+export const WithReactNode: Story = {
+ args: {
+ value: (
+ <span>
+ Text with <strong>bold</strong> and <em>italic</em> content
+ </span>
+ ),
+ },
+ render: function WithReactNodeStory(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} />
+ </div>
+ );
+ },
+};
+
+export const DifferentWidths: Story = {
+ render: function DifferentWidthsStory() {
+ const longText =
+ "This text will truncate differently depending on the container width";
+ return (
+ <div className="flex flex-col gap-8">
+ <div className="flex flex-col gap-2">
+ <span className="text-xs text-zinc-500">Width: 200px</span>
+ <div className="w-[200px]">
+ <OverflowText value={longText} variant="body" />
+ </div>
+ </div>
+ <div className="flex flex-col gap-2">
+ <span className="text-xs text-zinc-500">Width: 300px</span>
+ <div className="w-[300px]">
+ <OverflowText value={longText} variant="body" />
+ </div>
+ </div>
+ <div className="flex flex-col gap-2">
+ <span className="text-xs text-zinc-500">Width: 400px</span>
+ <div className="w-[400px]">
+ <OverflowText value={longText} variant="body" />
+ </div>
+ </div>
+ </div>
+ );
+ },
+};
+
+export const FilePathExample: Story = {
+ args: {
+ value: "/very/long/path/to/a/file/that/might/overflow/in/the/ui.tsx",
+ },
+ render: function FilePathExampleStory(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} className="font-mono text-sm" />
+ </div>
+ );
+ },
+};
+
+export const URLExample: Story = {
+ args: {
+ value: "https://example.com/very/long/url/path/that/might/overflow",
+ },
+ render: function URLExampleStory(args) {
+ return (
+ <div className="w-64">
+ <OverflowText {...args} className="text-blue-600" />
+ </div>
+ );
+ },
+};
diff --git a/autogpt_platform/frontend/src/components/atoms/OverflowText/OverflowText.tsx b/autogpt_platform/frontend/src/components/atoms/OverflowText/OverflowText.tsx
new file mode 100644
index 0000000000..efc345f79c
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/atoms/OverflowText/OverflowText.tsx
@@ -0,0 +1,100 @@
+import { Text, type TextProps } from "@/components/atoms/Text/Text";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/atoms/Tooltip/BaseTooltip";
+import { cn } from "@/lib/utils";
+import type { ReactNode } from "react";
+import { useEffect, useRef, useState } from "react";
+
+interface Props extends Omit<TextProps, "children"> {
+ value: string | ReactNode;
+}
+
+export function OverflowText(props: Props) {
+ const elementRef = useRef<HTMLSpanElement | null>(null);
+ const [isTruncated, setIsTruncated] = useState(false);
+
+ function updateTruncation() {
+ const element = elementRef.current;
+
+ if (!element) {
+ return;
+ }
+
+ const hasOverflow = element.scrollWidth > element.clientWidth;
+
+ setIsTruncated(hasOverflow);
+ }
+
+ function setupResizeListener() {
+ function handleResize() {
+ updateTruncation();
+ }
+
+ window.addEventListener("resize", handleResize);
+
+ return function cleanupResizeListener() {
+ window.removeEventListener("resize", handleResize);
+ };
+ }
+
+ function setupObserver() {
+ const element = elementRef.current;
+
+ if (!element || typeof ResizeObserver === "undefined") {
+ return undefined;
+ }
+
+ function handleResizeObserver() {
+ updateTruncation();
+ }
+
+ const observer = new ResizeObserver(handleResizeObserver);
+
+ observer.observe(element);
+
+ return function disconnectObserver() {
+ observer.disconnect();
+ };
+ }
+
+ useEffect(() => {
+ if (typeof props.value === "string") updateTruncation();
+ }, [props.value]);
+
+ useEffect(setupResizeListener, []);
+ useEffect(setupObserver, []);
+
+ const { value, className, variant = "body", ...restProps } = props;
+
+ const content = (
+ <span
+ ref={elementRef}
+ className={cn(
+ "block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",
+ )}
+ >
+ <Text variant={variant} className={className} {...restProps}>
+ {value}
+ </Text>
+ </span>
+ );
+
+ if (isTruncated) {
+ return (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>{content}</TooltipTrigger>
+ <TooltipContent>
+ {typeof value === "string" ? <p>{value}</p> : value}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ );
+ }
+
+ return content;
+}
diff --git a/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/GoogleDrivePickerInput.tsx b/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/GoogleDrivePickerInput.tsx
index 1db9809de2..2a1ada5012 100644
--- a/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/GoogleDrivePickerInput.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/GoogleDrivePicker/GoogleDrivePickerInput.tsx
@@ -5,7 +5,7 @@ import { Cross2Icon } from "@radix-ui/react-icons";
import React, { useCallback } from "react";
import { GoogleDrivePicker } from "./GoogleDrivePicker";
-export interface GoogleDrivePickerInputProps {
+export interface Props {
config: GoogleDrivePickerConfig;
value: any;
onChange: (value: any) => void;
@@ -21,7 +21,7 @@ export function GoogleDrivePickerInput({
error,
className,
showRemoveButton = true,
-}: GoogleDrivePickerInputProps) {
+}: Props) {
const [pickerError, setPickerError] = React.useState<string | null>(null);
const isMultiSelect = config.multiselect || false;
const hasAutoCredentials = !!config.auto_credentials;
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/MobileNavbar/components/MobileNavbarMenuItem.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/MobileNavbar/components/MobileNavbarMenuItem.tsx
index fb061f3e0a..fa190b63b7 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/MobileNavbar/components/MobileNavbarMenuItem.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/MobileNavbar/components/MobileNavbarMenuItem.tsx
@@ -19,7 +19,7 @@ export function MobileNavbarMenuItem({
onClick,
}: Props) {
const content = (
- <div className="inline-flex w-full items-center justify-start gap-4 hover:rounded hover:bg-[#e0e0e0]">
+ <div className="inline-flex w-full items-center justify-start gap-4 py-2 hover:rounded hover:bg-[#e0e0e0]">
{getAccountMenuOptionIcon(icon)}
<div className="relative">
<div