broadly fixed minus some issues

This commit is contained in:
pablodanswer 2025-02-01 17:16:35 -08:00 committed by Evan Lohn
parent feaa3b653f
commit eaffdee0dc
7 changed files with 40 additions and 18 deletions

View File

@ -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({
<ChatInputBar
proSearchEnabled={proSearchEnabled}
setProSearchEnabled={setProSearchEnabled}
setProSearchEnabled={() => toggleProSearch()}
toggleDocumentSidebar={toggleDocumentSidebar}
availableSources={sources}
availableDocumentSets={documentSets}

View File

@ -36,6 +36,7 @@ export default async function Layout({
shouldShowWelcomeModal,
ccPairs,
inputPrompts,
proSearchToggled,
} = data;
return (
@ -43,6 +44,7 @@ export default async function Layout({
<InstantSSRAutoRefresh />
<ChatProvider
value={{
proSearchToggled,
inputPrompts,
chatSessions,
toggledSidebar: toggleSidebar,

View File

@ -396,17 +396,17 @@ export const AgenticMessage = ({
<SubQuestionsDisplay
docSidebarToggled={docSidebarToggled || false}
finishedGenerating={
finalContent.length > 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)}

View File

@ -480,10 +480,10 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
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<SubQuestionsDisplayProps> = ({
isFirst={false}
setPresentingDocument={setPresentingDocument}
unToggle={!canShowSummarizing || finishedGenerating!}
completed={!overallAnswerGenerating}
completed={shownDocuments && shownDocuments.length > 0}
temporaryDisplay={{
question: streamedText,
tinyQuestion: "Combining results",

View File

@ -34,6 +34,7 @@ interface ChatContextProps {
refreshFolders: () => Promise<void>;
refreshInputPrompts: () => Promise<void>;
inputPrompts: InputPrompt[];
proSearchToggled: boolean;
}
const ChatContext = createContext<ChatContextProps | undefined>(undefined);

View File

@ -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";

View File

@ -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,
};
}