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.

feat(builder): Aligning error and loading for NextJS best practices (#7894)

Andy Hookere17ea22a0a19
diff --git a/rnd/autogpt_builder/src/app/error.tsx b/rnd/autogpt_builder/src/app/error.tsx
new file mode 100644
index 0000000000..5dfb817b35
--- /dev/null
+++ b/rnd/autogpt_builder/src/app/error.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import { useEffect } from "react";
+import { IconCircleAlert } from "@/components/ui/icons";
+import { Button } from "@/components/ui/button";
+import Link from "next/link";
+
+export default function Error({
+ error,
+ reset,
+}: {
+ error: Error & { digest?: string };
+ reset: () => void;
+}) {
+ useEffect(() => {
+ console.error(error);
+ }, [error]);
+
+ return (
+ <div className="fixed inset-0 flex items-center justify-center bg-background">
+ <div className="w-full max-w-md px-4 text-center sm:px-6">
+ <div className="mx-auto flex size-12 items-center justify-center rounded-full bg-muted">
+ <IconCircleAlert className="size-10" />
+ </div>
+ <h1 className="mt-8 text-2xl font-bold tracking-tight text-foreground">
+ Oops, something went wrong!
+ </h1>
+ <p className="mt-4 text-muted-foreground">
+ We're sorry, but an unexpected error has occurred. Please try again
+ later or contact support if the issue persists.
+ </p>
+ <div className="mt-6 flex flex-row justify-center gap-4">
+ <Button onClick={reset} variant="outline">
+ Retry
+ </Button>
+ <Button>
+ <Link href="/">Go to Homepage</Link>
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/rnd/autogpt_builder/src/app/error/page.tsx b/rnd/autogpt_builder/src/app/error/page.tsx
deleted file mode 100644
index f984f84312..0000000000
--- a/rnd/autogpt_builder/src/app/error/page.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function ErrorPage() {
- return <p>Sorry, something went wrong</p>;
-}
diff --git a/rnd/autogpt_builder/src/app/loading.tsx b/rnd/autogpt_builder/src/app/loading.tsx
new file mode 100644
index 0000000000..b0be672e03
--- /dev/null
+++ b/rnd/autogpt_builder/src/app/loading.tsx
@@ -0,0 +1,21 @@
+import AgentFlowListSkeleton from "@/components/monitor/skeletons/AgentFlowListSkeleton";
+import React from "react";
+import FlowRunsListSkeleton from "@/components/monitor/skeletons/FlowRunsListSkeleton";
+import FlowRunsStatusSkeleton from "@/components/monitor/skeletons/FlowRunsStatusSkeleton";
+
+export default function MonitorLoadingSkeleton() {
+ return (
+ <div className="space-y-4 p-4">
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-3">
+ {/* Agents Section */}
+ <AgentFlowListSkeleton />
+
+ {/* Runs Section */}
+ <FlowRunsListSkeleton />
+
+ {/* Stats Section */}
+ <FlowRunsStatusSkeleton />
+ </div>
+ </div>
+ );
+}
diff --git a/rnd/autogpt_builder/src/components/monitor/skeletons/AgentFlowListSkeleton.tsx b/rnd/autogpt_builder/src/components/monitor/skeletons/AgentFlowListSkeleton.tsx
new file mode 100644
index 0000000000..58d8c6ca6f
--- /dev/null
+++ b/rnd/autogpt_builder/src/components/monitor/skeletons/AgentFlowListSkeleton.tsx
@@ -0,0 +1,24 @@
+export default function AgentsFlowListSkeleton() {
+ return (
+ <div className="mx-auto max-w-4xl p-4">
+ <div className="mb-4 flex items-center justify-between">
+ <h1 className="text-2xl font-bold">Agents</h1>
+ <div className="h-10 w-24 animate-pulse rounded bg-gray-200"></div>
+ </div>
+ <div className="rounded-lg bg-white p-4 shadow">
+ <div className="mb-4 grid grid-cols-3 gap-4 font-medium text-gray-500">
+ <div>Name</div>
+ <div># of runs</div>
+ <div>Last run</div>
+ </div>
+ {[...Array(3)].map((_, index) => (
+ <div key={index} className="mb-4 grid grid-cols-3 gap-4">
+ <div className="h-6 animate-pulse rounded bg-gray-200"></div>
+ <div className="h-6 animate-pulse rounded bg-gray-200"></div>
+ <div className="h-6 animate-pulse rounded bg-gray-200"></div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/rnd/autogpt_builder/src/components/monitor/skeletons/FlowRunsListSkeleton.tsx b/rnd/autogpt_builder/src/components/monitor/skeletons/FlowRunsListSkeleton.tsx
new file mode 100644
index 0000000000..6f884151d3
--- /dev/null
+++ b/rnd/autogpt_builder/src/components/monitor/skeletons/FlowRunsListSkeleton.tsx
@@ -0,0 +1,23 @@
+export default function FlowRunsListSkeleton() {
+ return (
+ <div className="mx-auto max-w-4xl p-4">
+ <div className="rounded-lg bg-white p-4 shadow">
+ <h2 className="mb-4 text-xl font-semibold">Runs</h2>
+ <div className="mb-4 grid grid-cols-4 gap-4 text-sm font-medium text-gray-500">
+ <div>Agent</div>
+ <div>Started</div>
+ <div>Status</div>
+ <div>Duration</div>
+ </div>
+ {[...Array(4)].map((_, index) => (
+ <div key={index} className="mb-4 grid grid-cols-4 gap-4">
+ <div className="h-5 animate-pulse rounded bg-gray-200"></div>
+ <div className="h-5 animate-pulse rounded bg-gray-200"></div>
+ <div className="h-5 animate-pulse rounded bg-gray-200"></div>
+ <div className="h-5 animate-pulse rounded bg-gray-200"></div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/rnd/autogpt_builder/src/components/monitor/skeletons/FlowRunsStatusSkeleton.tsx b/rnd/autogpt_builder/src/components/monitor/skeletons/FlowRunsStatusSkeleton.tsx
new file mode 100644
index 0000000000..40677c70cc
--- /dev/null
+++ b/rnd/autogpt_builder/src/components/monitor/skeletons/FlowRunsStatusSkeleton.tsx
@@ -0,0 +1,28 @@
+export default function FlowRunsStatusSkeleton() {
+ return (
+ <div className="mx-auto max-w-4xl p-4">
+ <div className="rounded-lg bg-white p-4 shadow">
+ <div className="mb-6 flex items-center justify-between">
+ <h2 className="text-xl font-semibold">Stats</h2>
+ <div className="flex space-x-2">
+ {["2h", "8h", "24h", "7d", "Custom", "All"].map((btn) => (
+ <div
+ key={btn}
+ className="h-8 w-16 animate-pulse rounded bg-gray-200"
+ ></div>
+ ))}
+ </div>
+ </div>
+
+ {/* Placeholder for the line chart */}
+ <div className="mb-6 h-64 w-full animate-pulse rounded bg-gray-200"></div>
+
+ {/* Placeholders for total runs and total run time */}
+ <div className="space-y-2">
+ <div className="h-6 w-1/3 animate-pulse rounded bg-gray-200"></div>
+ <div className="h-6 w-1/2 animate-pulse rounded bg-gray-200"></div>
+ </div>
+ </div>
+ </div>
+ );
+}