diff --git a/surfsense_web/app/dashboard/[search_space_id]/onboard/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/onboard/page.tsx index 1d3ff3cfd..5e3f1cf7b 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/onboard/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/onboard/page.tsx @@ -16,6 +16,7 @@ import { Logo } from "@/components/Logo"; import { LLMConfigForm, type LLMConfigFormData } from "@/components/shared/llm-config-form"; import { Button } from "@/components/ui/button"; import { Spinner } from "@/components/ui/spinner"; +import { useGlobalLoadingEffect } from "@/hooks/use-global-loading"; import { getBearerToken, redirectToLogin } from "@/lib/auth-utils"; export default function OnboardPage() { @@ -138,17 +139,11 @@ export default function OnboardPage() { const isSubmitting = isCreating || isUpdatingPreferences; - if (globalConfigsLoading || preferencesLoading || isAutoConfiguring) { - return ( -
-
- -

- {isAutoConfiguring ? "Setting up your AI..." : "Loading..."} -

-
-
- ); + const isLoading = globalConfigsLoading || preferencesLoading || isAutoConfiguring; + useGlobalLoadingEffect(isLoading); + + if (isLoading) { + return null; } if (globalConfigs.length > 0 && !isAutoConfiguring) { @@ -171,15 +166,13 @@ export default function OnboardPage() { {/* Form card */}
- - Add New Configuration + Add LLM Model
diff --git a/surfsense_web/components/shared/llm-config-form.tsx b/surfsense_web/components/shared/llm-config-form.tsx index 38c67cfa6..9fb8b9208 100644 --- a/surfsense_web/components/shared/llm-config-form.tsx +++ b/surfsense_web/components/shared/llm-config-form.tsx @@ -3,9 +3,8 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { useAtomValue } from "jotai"; import { Check, ChevronDown, ChevronsUpDown } from "lucide-react"; -import { AnimatePresence, motion } from "motion/react"; import { useEffect, useMemo, useState } from "react"; -import { useForm } from "react-hook-form"; +import { useForm, type Resolver } from "react-hook-form"; import { z } from "zod"; import { defaultSystemInstructionsAtom, @@ -41,7 +40,6 @@ import { SelectValue, } from "@/components/ui/select"; import { Separator } from "@/components/ui/separator"; -import { Spinner } from "@/components/ui/spinner"; import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { LLM_PROVIDERS } from "@/contracts/enums/llm-providers"; @@ -73,28 +71,18 @@ interface LLMConfigFormProps { initialData?: Partial; searchSpaceId: number; onSubmit: (data: LLMConfigFormData) => Promise; - onCancel?: () => void; - isSubmitting?: boolean; mode?: "create" | "edit"; - submitLabel?: string; showAdvanced?: boolean; - compact?: boolean; formId?: string; - hideActions?: boolean; } export function LLMConfigForm({ initialData, searchSpaceId, onSubmit, - onCancel, - isSubmitting = false, mode = "create", - submitLabel, showAdvanced = true, - compact = false, formId, - hideActions = false, }: LLMConfigFormProps) { const { data: defaultInstructions, isSuccess: defaultInstructionsLoaded } = useAtomValue( defaultSystemInstructionsAtom @@ -105,8 +93,7 @@ export function LLMConfigForm({ const [systemInstructionsOpen, setSystemInstructionsOpen] = useState(false); const form = useForm({ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - resolver: zodResolver(formSchema) as any, + resolver: zodResolver(formSchema) as Resolver, defaultValues: { name: initialData?.name ?? "", description: initialData?.description ?? "", @@ -232,34 +219,26 @@ export function LLMConfigForm({ )} /> - {/* Custom Provider (conditional) */} - - {watchProvider === "CUSTOM" && ( - - ( - - Custom Provider Name - - - - - - )} - /> - + {/* Custom Provider (conditional) */} + {watchProvider === "CUSTOM" && ( + ( + + Custom Provider Name + + + + + )} - + /> + )} {/* Model Name with Combobox */} - {/* Ollama Quick Actions */} - - {watchProvider === "OLLAMA" && ( - - - - - )} - + {/* Ollama Quick Actions */} + {watchProvider === "OLLAMA" && ( +
+ + +
+ )} {/* Advanced Parameters */} @@ -554,44 +526,6 @@ export function LLMConfigForm({ /> - - {!hideActions && ( -
- {onCancel && ( - - )} - -
- )} ); diff --git a/surfsense_web/components/shared/model-config-dialog.tsx b/surfsense_web/components/shared/model-config-dialog.tsx index f4ea9ba2f..4dff5f173 100644 --- a/surfsense_web/components/shared/model-config-dialog.tsx +++ b/surfsense_web/components/shared/model-config-dialog.tsx @@ -213,14 +213,12 @@ export function ModelConfigDialog({ )} {mode === "create" ? ( - + ) : isAutoMode && config ? (
@@ -362,11 +360,9 @@ export function ModelConfigDialog({ citations_enabled: config.citations_enabled, search_space_id: searchSpaceId, }} - onSubmit={handleSubmit} - isSubmitting={isSubmitting} - mode="edit" - formId="model-config-form" - hideActions + onSubmit={handleSubmit} + mode="edit" + formId="model-config-form" /> ) : null}