diff --git a/surfsense_web/app/dashboard/page.tsx b/surfsense_web/app/dashboard/page.tsx index 2bd8f4462..525060bed 100644 --- a/surfsense_web/app/dashboard/page.tsx +++ b/surfsense_web/app/dashboard/page.tsx @@ -3,7 +3,7 @@ import { useAtomValue } from "jotai"; import { AlertCircle, Plus, Search } from "lucide-react"; import { motion } from "motion/react"; -import { useRouter } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; import { useTranslations } from "next-intl"; import { useEffect, useState } from "react"; import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms"; @@ -89,6 +89,7 @@ function EmptyState({ onCreateClick }: { onCreateClick: () => void }) { export default function DashboardPage() { const router = useRouter(); + const searchParams = useSearchParams(); const [showCreateDialog, setShowCreateDialog] = useState(false); const t = useTranslations("dashboard"); @@ -98,9 +99,11 @@ export default function DashboardPage() { if (isLoading) return; if (searchSpaces.length > 0) { - router.replace(`/dashboard/${searchSpaces[0].id}/new-chat`); + const params = searchParams.toString(); + const query = params ? `?${params}` : ""; + router.replace(`/dashboard/${searchSpaces[0].id}/new-chat${query}`); } - }, [isLoading, searchSpaces, router]); + }, [isLoading, searchSpaces, router, searchParams]); // Show loading while fetching or while we have spaces and are about to redirect const shouldShowLoading = isLoading || searchSpaces.length > 0; diff --git a/surfsense_web/app/quick-ask/page.tsx b/surfsense_web/app/quick-ask/page.tsx index e8191c913..0a304b3db 100644 --- a/surfsense_web/app/quick-ask/page.tsx +++ b/surfsense_web/app/quick-ask/page.tsx @@ -1,6 +1,5 @@ "use client"; -import { useAtomValue } from "jotai"; import { BookOpen, Check, @@ -13,7 +12,6 @@ import { Search, } from "lucide-react"; import { useEffect, useState } from "react"; -import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms"; import { DEFAULT_ACTIONS } from "./actions"; const ICONS: Record = { @@ -28,7 +26,6 @@ const ICONS: Record = { }; export default function QuickAskPage() { - const { data: searchSpaces = [], isLoading } = useAtomValue(searchSpacesAtom); const [clipboardText, setClipboardText] = useState(""); useEffect(() => { @@ -38,10 +35,8 @@ export default function QuickAskPage() { }, []); const navigateToChat = (prompt: string, mode: string) => { - if (!searchSpaces.length || !clipboardText) return; - const spaceId = searchSpaces[0].id; const encoded = encodeURIComponent(prompt); - window.location.href = `/dashboard/${spaceId}/new-chat?quickAskPrompt=${encoded}&quickAskMode=${mode}`; + window.location.href = `/dashboard?quickAskPrompt=${encoded}&quickAskMode=${mode}`; }; const handleAction = (actionId: string) => { @@ -55,15 +50,13 @@ export default function QuickAskPage() { const exploreActions = DEFAULT_ACTIONS.filter((a) => a.group === "explore"); const knowledgeActions = DEFAULT_ACTIONS.filter((a) => a.group === "knowledge"); - const ready = !isLoading && clipboardText; - return (
- {!ready && ( + {!clipboardText && (
Loading...
)} - {ready && ( + {clipboardText && (
Transform
{transformActions.map((action) => (