diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index e9bc93ac8a..d601538e58 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -91,7 +91,10 @@ import { ChatPopup } from "./ChatPopup"; import FunctionalHeader from "@/components/chat_search/Header"; import { useSidebarVisibility } from "@/components/chat_search/hooks"; -import { SIDEBAR_TOGGLED_COOKIE_NAME } from "@/components/resizable/constants"; +import { + PRO_SEARCH_TOGGLED_COOKIE_NAME, + SIDEBAR_TOGGLED_COOKIE_NAME, +} from "@/components/resizable/constants"; import FixedLogo from "./shared_chat_search/FixedLogo"; import { DeleteEntityModal } from "../../components/modals/DeleteEntityModal"; @@ -149,6 +152,7 @@ export function ChatPage({ folders, shouldShowWelcomeModal, refreshChatSessions, + proSearchToggled, } = useChatContext(); const defaultAssistantIdRaw = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID); @@ -195,8 +199,15 @@ export function ChatPage({ const enterpriseSettings = settings?.enterpriseSettings; const [documentSidebarToggled, setDocumentSidebarToggled] = useState(false); - const [proSearchEnabled, setProSearchEnabled] = useState(false); + const [proSearchEnabled, setProSearchEnabled] = useState(proSearchToggled); const [streamingAllowed, setStreamingAllowed] = useState(false); + const toggleProSearch = () => { + Cookies.set( + PRO_SEARCH_TOGGLED_COOKIE_NAME, + String(!proSearchEnabled).toLocaleLowerCase() + ); + setProSearchEnabled(!proSearchEnabled); + }; const [userSettingsToggled, setUserSettingsToggled] = useState(false); @@ -3076,7 +3087,7 @@ export function ChatPage({ toggleProSearch()} toggleDocumentSidebar={toggleDocumentSidebar} availableSources={sources} availableDocumentSets={documentSets} diff --git a/web/src/app/chat/layout.tsx b/web/src/app/chat/layout.tsx index f0cd4cfacb..c26112baaf 100644 --- a/web/src/app/chat/layout.tsx +++ b/web/src/app/chat/layout.tsx @@ -36,6 +36,7 @@ export default async function Layout({ shouldShowWelcomeModal, ccPairs, inputPrompts, + proSearchToggled, } = data; return ( @@ -43,6 +44,7 @@ export default async function Layout({ 8 && - streamedContent.length == streamedContent.length + finalContent.length > 10 && + streamedContent.length == finalContent.length + } + // overallAnswerGenerating={false} + overallAnswerGenerating={ + !!( + secondLevelSubquestions && + secondLevelSubquestions.length > 0 && + finalContent.length < 8 + ) } - overallAnswerGenerating={false} - // overallAnswerGenerating={ - // !!( - // secondLevelSubquestions && - // secondLevelSubquestions.length > 0 && - // finalContent.length < 8 - // ) - // } showSecondLevel={!isViewingInitialAnswer} currentlyOpenQuestion={currentlyOpenQuestion} allowStreaming={() => setAllowStreaming(true)} diff --git a/web/src/app/chat/message/SubQuestionsDisplay.tsx b/web/src/app/chat/message/SubQuestionsDisplay.tsx index 894c2ddb7e..9724801d34 100644 --- a/web/src/app/chat/message/SubQuestionsDisplay.tsx +++ b/web/src/app/chat/message/SubQuestionsDisplay.tsx @@ -480,10 +480,10 @@ const SubQuestionsDisplay: React.FC = ({ const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {}); const { dynamicSubQuestions: dynamicSecondLevelQuestions } = useStreamingMessages(secondLevelQuestions || [], () => {}); - // const memoizedSubQuestions = useMemo(() => { - // return overallAnswerGenerating ? dynamicSubQuestions : subQuestions; - // }, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]); - const memoizedSubQuestions = dynamicSubQuestions; + const memoizedSubQuestions = useMemo(() => { + return finishedGenerating ? subQuestions : dynamicSubQuestions; + }, [finishedGenerating, dynamicSubQuestions, subQuestions]); + // const memoizedSubQuestions = dynamicSubQuestions; const memoizedSecondLevelQuestions = useMemo(() => { return overallAnswerGenerating ? dynamicSecondLevelQuestions @@ -733,7 +733,7 @@ const SubQuestionsDisplay: React.FC = ({ isFirst={false} setPresentingDocument={setPresentingDocument} unToggle={!canShowSummarizing || finishedGenerating!} - completed={!overallAnswerGenerating} + completed={shownDocuments && shownDocuments.length > 0} temporaryDisplay={{ question: streamedText, tinyQuestion: "Combining results", diff --git a/web/src/components/context/ChatContext.tsx b/web/src/components/context/ChatContext.tsx index 621d797839..b2a6672abc 100644 --- a/web/src/components/context/ChatContext.tsx +++ b/web/src/components/context/ChatContext.tsx @@ -34,6 +34,7 @@ interface ChatContextProps { refreshFolders: () => Promise; refreshInputPrompts: () => Promise; inputPrompts: InputPrompt[]; + proSearchToggled: boolean; } const ChatContext = createContext(undefined); diff --git a/web/src/components/resizable/constants.ts b/web/src/components/resizable/constants.ts index 9439b371d8..d41a62ab6d 100644 --- a/web/src/components/resizable/constants.ts +++ b/web/src/components/resizable/constants.ts @@ -1,2 +1,3 @@ export const DOCUMENT_SIDEBAR_WIDTH_COOKIE_NAME = "documentSidebarWidth"; export const SIDEBAR_TOGGLED_COOKIE_NAME = "sidebarIsToggled"; +export const PRO_SEARCH_TOGGLED_COOKIE_NAME = "proSearchIsToggled"; diff --git a/web/src/lib/chat/fetchChatData.ts b/web/src/lib/chat/fetchChatData.ts index 9ce5661754..fefd90aeda 100644 --- a/web/src/lib/chat/fetchChatData.ts +++ b/web/src/lib/chat/fetchChatData.ts @@ -22,6 +22,7 @@ import { cookies, headers } from "next/headers"; import { SIDEBAR_TOGGLED_COOKIE_NAME, DOCUMENT_SIDEBAR_WIDTH_COOKIE_NAME, + PRO_SEARCH_TOGGLED_COOKIE_NAME, } from "@/components/resizable/constants"; import { hasCompletedWelcomeFlowSS } from "@/components/initialSetup/welcome/WelcomeModalWrapper"; import { @@ -45,6 +46,7 @@ interface FetchChatDataResult { finalDocumentSidebarInitialWidth?: number; shouldShowWelcomeModal: boolean; inputPrompts: InputPrompt[]; + proSearchToggled: boolean; } export async function fetchChatData(searchParams: { @@ -175,6 +177,10 @@ export async function fetchChatData(searchParams: { ); const sidebarToggled = requestCookies.get(SIDEBAR_TOGGLED_COOKIE_NAME); + const proSearchToggled = + requestCookies.get(PRO_SEARCH_TOGGLED_COOKIE_NAME)?.value.toLowerCase() === + "true"; + // IF user is an anoymous user, we don't want to show the sidebar (they have no access to chat history) const toggleSidebar = !user?.is_anonymous_user && @@ -227,5 +233,6 @@ export async function fetchChatData(searchParams: { toggleSidebar, shouldShowWelcomeModal, inputPrompts, + proSearchToggled, }; }