diff --git a/surfsense_web/app/dashboard/page.tsx b/surfsense_web/app/dashboard/page.tsx
index fbf567cba..951e17a8c 100644
--- a/surfsense_web/app/dashboard/page.tsx
+++ b/surfsense_web/app/dashboard/page.tsx
@@ -7,11 +7,8 @@ import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
-import { useEffect, useRef, useState } from "react";
-import {
- createSearchSpaceMutationAtom,
- deleteSearchSpaceMutationAtom,
-} from "@/atoms/search-spaces/search-space-mutation.atoms";
+import { useEffect } from "react";
+import { deleteSearchSpaceMutationAtom } from "@/atoms/search-spaces/search-space-mutation.atoms";
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
import { currentUserAtom } from "@/atoms/user/user-query.atoms";
import { Logo } from "@/components/Logo";
@@ -135,10 +132,6 @@ const DashboardPage = () => {
const tCommon = useTranslations("common");
const router = useRouter();
- // State for auto-creating search space
- const [isAutoCreating, setIsAutoCreating] = useState(false);
- const hasAttemptedAutoCreate = useRef(false);
-
// Animation variants
const containerVariants: Variants = {
hidden: { opacity: 0 },
@@ -170,44 +163,17 @@ const DashboardPage = () => {
refetch: refreshSearchSpaces,
} = useAtomValue(searchSpacesAtom);
const { mutateAsync: deleteSearchSpace } = useAtomValue(deleteSearchSpaceMutationAtom);
- const { mutateAsync: createSearchSpace } = useAtomValue(createSearchSpaceMutationAtom);
const { data: user, isPending: isLoadingUser, error: userError } = useAtomValue(currentUserAtom);
- // Auto-redirect to chat for users with exactly 1 search space, or auto-create if none
+ // Auto-redirect to chat for users with exactly 1 search space
useEffect(() => {
- const handleAutoRedirect = async () => {
-
- if (loading || hasAttemptedAutoCreate.current) return;
+ if (loading) return;
-
- if (searchSpaces.length === 1) {
- router.replace(`/dashboard/${searchSpaces[0].id}/new-chat`);
- return;
- }
-
- if (searchSpaces.length > 1) {
- return;
- }
-
-
- hasAttemptedAutoCreate.current = true;
- setIsAutoCreating(true);
-
- try {
- const newSearchSpace = await createSearchSpace({
- name: "My Search Space",
- description: "Your personal search space",
- });
- router.replace(`/dashboard/${newSearchSpace.id}/new-chat`);
- } catch (err) {
- console.error("Failed to auto-create search space:", err);
- setIsAutoCreating(false);
- }
- };
-
- handleAutoRedirect();
- }, [loading, searchSpaces, router, createSearchSpace]);
+ if (searchSpaces.length === 1) {
+ router.replace(`/dashboard/${searchSpaces[0].id}/new-chat`);
+ }
+ }, [loading, searchSpaces, router]);
// Create user object for UserDropdown
const customUser = {
@@ -218,8 +184,8 @@ const DashboardPage = () => {
avatar: "/icon-128.png", // Default avatar
};
- // Show loading while loading, auto-redirecting (single search space), or auto-creating
- if (loading || isAutoCreating || (searchSpaces.length === 1 && !error)) return ;
+ // Show loading while loading or auto-redirecting (single search space)
+ if (loading || (searchSpaces.length === 1 && !error)) return ;
if (error) return ;
const handleDeleteSearchSpace = async (id: number) => {