Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

Fix new project

Marc Klingende79e80bed06
diff --git a/src/features/projects/components/NewProjectButton.tsx b/src/features/projects/components/NewProjectButton.tsx
index e67e4aaf0b..36550d2e1c 100644
--- a/src/features/projects/components/NewProjectButton.tsx
+++ b/src/features/projects/components/NewProjectButton.tsx
@@ -44,7 +44,10 @@ export function NewProjectButton({ size = "default" }: NewProjectButtonProps) {
const utils = api.useContext();
const router = useRouter();
const createProjectMutation = api.projects.create.useMutation({
- onSuccess: () => utils.projects.invalidate(),
+ onSuccess: (newProject) => {
+ void router.push(`/project/${newProject.id}/setup`);
+ utils.projects.invalidate();
+ },
onError: (error) => form.setError("name", { message: error.message }),
});
@@ -53,7 +56,7 @@ export function NewProjectButton({ size = "default" }: NewProjectButtonProps) {
.mutateAsync(values)
.then((project) => {
setOpen(false);
- void router.push(`/project/${project.id}/setup`);
+ form.reset();
})
.catch((error) => {
console.error(error);
diff --git a/src/features/projects/components/ProjectList.tsx b/src/features/projects/components/ProjectList.tsx
deleted file mode 100644
index c94f347cad..0000000000
--- a/src/features/projects/components/ProjectList.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { api } from "@/src/utils/api";
-import { NewProjectButton } from "@/src/features/projects/components/NewProjectButton";
-import { useRouter } from "next/router";
-import { useEffect, useState } from "react";
-
-export default function ProjectList() {
- const projects = api.projects.all.useQuery();
- const router = useRouter();
- const [loading, setLoading] = useState(true);
-
- useEffect(() => {
- if (projects.data) {
- if (projects.data.length > 0)
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- void router.push(`/project/${projects.data[0]!.id}`);
- else setLoading(false);
- }
- }, [projects.data, router]);
-
- if (loading || projects.status === "loading") {
- return <div>Loading...</div>;
- }
-
- return (
- <div className="text-center">
- <svg
- className="mx-auto h-12 w-12 text-gray-400"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- aria-hidden="true"
- >
- <path
- vectorEffect="non-scaling-stroke"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"
- />
- </svg>
- <h3 className="mt-2 text-sm font-semibold text-gray-900">No projects</h3>
- <p className="mt-1 text-sm text-gray-500">
- Get started by creating a new project.
- </p>
- <div className="mt-6">
- <NewProjectButton />
- </div>
- </div>
- );
-}
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 4e68ddd7b5..ac08b706ee 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -20,12 +20,12 @@ export default function GetStartedPage() {
useEffect(() => {
if (projects.data) {
- if (projects.data.length > 0)
+ if (projects.data.length > 0 && loading === true)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
void router.push(`/project/${projects.data[0]!.id}`);
else setLoading(false);
}
- }, [projects.data, router]);
+ }, [projects.data, router, loading]);
if (loading || projects.status === "loading") {
return <div>Loading...</div>;