diff --git a/autogpt_platform/frontend/src/components/runner-ui/RunnerOutputUI.tsx b/autogpt_platform/frontend/src/components/runner-ui/RunnerOutputUI.tsx index 4751e151ea86..3eed43cd6cac 100644 --- a/autogpt_platform/frontend/src/components/runner-ui/RunnerOutputUI.tsx +++ b/autogpt_platform/frontend/src/components/runner-ui/RunnerOutputUI.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect, useRef } from "react"; import { Sheet, SheetContent, @@ -10,6 +10,9 @@ import { ScrollArea } from "@/components/ui/scroll-area"; import { BlockIORootSchema } from "@/lib/autogpt-server-api/types"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; +import { Button } from "@/components/ui/button"; +import { Clipboard } from "lucide-react"; +import { useToast } from "@/components/ui/use-toast"; export interface BlockOutput { id: string; @@ -29,11 +32,20 @@ interface OutputModalProps { const formatOutput = (output: any): string => { if (typeof output === "object") { try { + if ( + Array.isArray(output) && + output.every((item) => typeof item === "string") + ) { + return output.join("\n").replace(/\\n/g, "\n"); + } return JSON.stringify(output, null, 2); } catch (error) { return `Error formatting output: ${(error as Error).message}`; } } + if (typeof output === "string") { + return output.replace(/\\n/g, "\n"); + } return String(output); }; @@ -42,11 +54,28 @@ export function RunnerOutputUI({ onClose, blockOutputs, }: OutputModalProps) { + const { toast } = useToast(); + + const copyOutput = (name: string, output: any) => { + const formattedOutput = formatOutput(output); + navigator.clipboard.writeText(formattedOutput).then(() => { + toast({ + title: `"${name}" output copied to clipboard!`, + duration: 2000, + }); + }); + }; + + const adjustTextareaHeight = (textarea: HTMLTextAreaElement) => { + textarea.style.height = "auto"; + textarea.style.height = `${textarea.scrollHeight}px`; + }; + return ( Run Outputs @@ -70,11 +99,38 @@ export function RunnerOutputUI({ )} -
+
+