mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
- Deleted `chats-client.tsx` and `page.tsx` as part of the chat management overhaul. - Introduced `AllChatsSidebar` and `NavChats` components for improved chat navigation and management. - Updated sidebar to integrate new chat components and removed the deprecated `NavProjects`. - Enhanced chat deletion handling and added loading states for better user experience. - Added new translation keys for chat-related UI strings.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import type { ResearchMode } from "@/components/chat";
|
|
import type { Document } from "@/contracts/types/document.types";
|
|
import { getBearerToken } from "@/lib/auth-utils";
|
|
|
|
interface UseChatStateProps {
|
|
search_space_id: string;
|
|
chat_id?: string;
|
|
}
|
|
|
|
export function useChatState({ chat_id }: UseChatStateProps) {
|
|
const [token, setToken] = useState<string | null>(null);
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const [currentChatId, setCurrentChatId] = useState<string | null>(chat_id || null);
|
|
|
|
// Chat configuration state
|
|
const [researchMode, setResearchMode] = useState<ResearchMode>("QNA");
|
|
const [selectedConnectors, setSelectedConnectors] = useState<string[]>([]);
|
|
const [selectedDocuments, setSelectedDocuments] = useState<Document[]>([]);
|
|
const [topK, setTopK] = useState<number>(5);
|
|
|
|
useEffect(() => {
|
|
const bearerToken = getBearerToken();
|
|
setToken(bearerToken);
|
|
}, []);
|
|
|
|
return {
|
|
token,
|
|
setToken,
|
|
isLoading,
|
|
setIsLoading,
|
|
currentChatId,
|
|
setCurrentChatId,
|
|
researchMode,
|
|
setResearchMode,
|
|
selectedConnectors,
|
|
setSelectedConnectors,
|
|
selectedDocuments,
|
|
setSelectedDocuments,
|
|
topK,
|
|
setTopK,
|
|
};
|
|
}
|