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.
feat(frontend/library): Make agent input fields expandable (#9650)
Reinier van der Leera187e877413a
diff --git a/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx b/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsxindex dfe215f2b2..b3bf55fd74 100644--- a/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx+++ b/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx@@ -6,9 +6,17 @@ import { GraphExecutionID, GraphMeta } from "@/lib/autogpt-server-api";import type { ButtonAction } from "@/components/agptui/types";import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";-import { Button, ButtonProps } from "@/components/agptui/Button";+import { LocalValuedInput } from "@/components/ui/input";+import { Pencil2Icon } from "@radix-ui/react-icons";+import { Textarea } from "@/components/ui/textarea";import { IconPlay } from "@/components/ui/icons";-import { Input } from "@/components/ui/input";+import { Button } from "@/components/agptui/Button";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+} from "@/components/ui/dialog";export default function AgentRunDraftView({graph,@@ -23,6 +31,27 @@ export default function AgentRunDraftView({const agentInputs = graph.input_schema.properties;const [inputValues, setInputValues] = useState<Record<string, any>>({});+ const [expandedInputKey, setExpandedInputKey] = useState<string | null>(null);+ const [tempInputValue, setTempInputValue] = useState("");++ const openInputPopout = useCallback(+ (key: string) => {+ setTempInputValue(inputValues[key] || "");+ setExpandedInputKey(key);+ },+ [inputValues],+ );++ const closeInputPopout = useCallback(() => {+ setExpandedInputKey(null);+ }, []);++ const saveAndCloseInputPopout = useCallback(() => {+ if (!expandedInputKey) return;++ setInputValues((obj) => ({ ...obj, [expandedInputKey]: tempInputValue }));+ closeInputPopout();+ }, [expandedInputKey, tempInputValue, closeInputPopout]);const doRun = useCallback(() =>@@ -61,22 +90,64 @@ export default function AgentRunDraftView({<label className="text-sm font-medium">{inputSubSchema.title || key}</label>- <Input- // TODO: render specific inputs based on input types- defaultValue={- "default" in inputSubSchema ? inputSubSchema.default : ""- }- className="rounded-full"- onChange={(e) =>- setInputValues((obj) => ({ ...obj, [key]: e.target.value }))- }- />++ <div className="nodrag relative">+ <LocalValuedInput+ // TODO: render specific inputs based on input types+ defaultValue={+ "default" in inputSubSchema ? inputSubSchema.default : ""+ }+ value={inputValues[key] ?? undefined}+ className="rounded-full"+ onChange={(e) =>+ setInputValues((obj) => ({+ ...obj,+ [key]: e.target.value,+ }))+ }+ />++ <Button+ variant="ghost"+ size="icon"+ className="absolute inset-1 left-auto h-7 w-8 rounded-full"+ onClick={() => openInputPopout(key)}+ title="Open a larger textbox input"+ >+ <Pencil2Icon className="m-0 p-0" />+ </Button>+ </div></div>))}</CardContent></Card></div>+ {/* Pop-out Long Input Modal */}+ <Dialog+ open={expandedInputKey !== null}+ onOpenChange={(open) => !open && closeInputPopout()}+ >+ <DialogContent className="sm:max-w-[720px]">+ <DialogHeader>+ <DialogTitle>+ Edit {expandedInputKey && agentInputs[expandedInputKey].title}+ </DialogTitle>+ </DialogHeader>+ <Textarea+ value={tempInputValue}+ onChange={(e) => setTempInputValue(e.target.value)}+ className="min-h-[320px]"+ />+ <div className="flex justify-end gap-2">+ <Button onClick={closeInputPopout}>Cancel</Button>+ <Button variant="primary" onClick={saveAndCloseInputPopout}>+ Save+ </Button>+ </div>+ </DialogContent>+ </Dialog>+{/* Actions */}<aside className="w-48 xl:w-56"><div className="flex flex-col gap-8">diff --git a/autogpt_platform/frontend/src/components/agptui/Button.tsx b/autogpt_platform/frontend/src/components/agptui/Button.tsxindex 1e4d9b0307..21818e7e20 100644--- a/autogpt_platform/frontend/src/components/agptui/Button.tsx+++ b/autogpt_platform/frontend/src/components/agptui/Button.tsx@@ -29,7 +29,7 @@ const buttonVariants = cva(lg: "h-12 px-5 py-2.5 rounded-full text-lg",primary:"h-10 w-28 rounded-full sm:h-12 sm:w-32 md:h-[4.375rem] md:w-[11rem] lg:h-[3.125rem] lg:w-[7rem]",- icon: "h-10 w-10",+ icon: "h-10 w-10 justify-center",card: "h-12 p-5 agpt-rounded-card justify-center text-lg",},},