mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-29 01:10:58 +02:00
broadly fixed minus some issues
This commit is contained in:
@ -91,7 +91,10 @@ import { ChatPopup } from "./ChatPopup";
|
|||||||
|
|
||||||
import FunctionalHeader from "@/components/chat_search/Header";
|
import FunctionalHeader from "@/components/chat_search/Header";
|
||||||
import { useSidebarVisibility } from "@/components/chat_search/hooks";
|
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 FixedLogo from "./shared_chat_search/FixedLogo";
|
||||||
|
|
||||||
import { DeleteEntityModal } from "../../components/modals/DeleteEntityModal";
|
import { DeleteEntityModal } from "../../components/modals/DeleteEntityModal";
|
||||||
@ -149,6 +152,7 @@ export function ChatPage({
|
|||||||
folders,
|
folders,
|
||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
refreshChatSessions,
|
refreshChatSessions,
|
||||||
|
proSearchToggled,
|
||||||
} = useChatContext();
|
} = useChatContext();
|
||||||
|
|
||||||
const defaultAssistantIdRaw = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
|
const defaultAssistantIdRaw = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
|
||||||
@ -195,8 +199,15 @@ export function ChatPage({
|
|||||||
const enterpriseSettings = settings?.enterpriseSettings;
|
const enterpriseSettings = settings?.enterpriseSettings;
|
||||||
|
|
||||||
const [documentSidebarToggled, setDocumentSidebarToggled] = useState(false);
|
const [documentSidebarToggled, setDocumentSidebarToggled] = useState(false);
|
||||||
const [proSearchEnabled, setProSearchEnabled] = useState(false);
|
const [proSearchEnabled, setProSearchEnabled] = useState(proSearchToggled);
|
||||||
const [streamingAllowed, setStreamingAllowed] = useState(false);
|
const [streamingAllowed, setStreamingAllowed] = useState(false);
|
||||||
|
const toggleProSearch = () => {
|
||||||
|
Cookies.set(
|
||||||
|
PRO_SEARCH_TOGGLED_COOKIE_NAME,
|
||||||
|
String(!proSearchEnabled).toLocaleLowerCase()
|
||||||
|
);
|
||||||
|
setProSearchEnabled(!proSearchEnabled);
|
||||||
|
};
|
||||||
|
|
||||||
const [userSettingsToggled, setUserSettingsToggled] = useState(false);
|
const [userSettingsToggled, setUserSettingsToggled] = useState(false);
|
||||||
|
|
||||||
@ -3076,7 +3087,7 @@ export function ChatPage({
|
|||||||
|
|
||||||
<ChatInputBar
|
<ChatInputBar
|
||||||
proSearchEnabled={proSearchEnabled}
|
proSearchEnabled={proSearchEnabled}
|
||||||
setProSearchEnabled={setProSearchEnabled}
|
setProSearchEnabled={() => toggleProSearch()}
|
||||||
toggleDocumentSidebar={toggleDocumentSidebar}
|
toggleDocumentSidebar={toggleDocumentSidebar}
|
||||||
availableSources={sources}
|
availableSources={sources}
|
||||||
availableDocumentSets={documentSets}
|
availableDocumentSets={documentSets}
|
||||||
|
@ -36,6 +36,7 @@ export default async function Layout({
|
|||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
ccPairs,
|
ccPairs,
|
||||||
inputPrompts,
|
inputPrompts,
|
||||||
|
proSearchToggled,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -43,6 +44,7 @@ export default async function Layout({
|
|||||||
<InstantSSRAutoRefresh />
|
<InstantSSRAutoRefresh />
|
||||||
<ChatProvider
|
<ChatProvider
|
||||||
value={{
|
value={{
|
||||||
|
proSearchToggled,
|
||||||
inputPrompts,
|
inputPrompts,
|
||||||
chatSessions,
|
chatSessions,
|
||||||
toggledSidebar: toggleSidebar,
|
toggledSidebar: toggleSidebar,
|
||||||
|
@ -396,17 +396,17 @@ export const AgenticMessage = ({
|
|||||||
<SubQuestionsDisplay
|
<SubQuestionsDisplay
|
||||||
docSidebarToggled={docSidebarToggled || false}
|
docSidebarToggled={docSidebarToggled || false}
|
||||||
finishedGenerating={
|
finishedGenerating={
|
||||||
finalContent.length > 8 &&
|
finalContent.length > 10 &&
|
||||||
streamedContent.length == streamedContent.length
|
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}
|
showSecondLevel={!isViewingInitialAnswer}
|
||||||
currentlyOpenQuestion={currentlyOpenQuestion}
|
currentlyOpenQuestion={currentlyOpenQuestion}
|
||||||
allowStreaming={() => setAllowStreaming(true)}
|
allowStreaming={() => setAllowStreaming(true)}
|
||||||
|
@ -480,10 +480,10 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
||||||
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
||||||
useStreamingMessages(secondLevelQuestions || [], () => {});
|
useStreamingMessages(secondLevelQuestions || [], () => {});
|
||||||
// const memoizedSubQuestions = useMemo(() => {
|
const memoizedSubQuestions = useMemo(() => {
|
||||||
// return overallAnswerGenerating ? dynamicSubQuestions : subQuestions;
|
return finishedGenerating ? subQuestions : dynamicSubQuestions;
|
||||||
// }, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]);
|
}, [finishedGenerating, dynamicSubQuestions, subQuestions]);
|
||||||
const memoizedSubQuestions = dynamicSubQuestions;
|
// const memoizedSubQuestions = dynamicSubQuestions;
|
||||||
const memoizedSecondLevelQuestions = useMemo(() => {
|
const memoizedSecondLevelQuestions = useMemo(() => {
|
||||||
return overallAnswerGenerating
|
return overallAnswerGenerating
|
||||||
? dynamicSecondLevelQuestions
|
? dynamicSecondLevelQuestions
|
||||||
@ -733,7 +733,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
isFirst={false}
|
isFirst={false}
|
||||||
setPresentingDocument={setPresentingDocument}
|
setPresentingDocument={setPresentingDocument}
|
||||||
unToggle={!canShowSummarizing || finishedGenerating!}
|
unToggle={!canShowSummarizing || finishedGenerating!}
|
||||||
completed={!overallAnswerGenerating}
|
completed={shownDocuments && shownDocuments.length > 0}
|
||||||
temporaryDisplay={{
|
temporaryDisplay={{
|
||||||
question: streamedText,
|
question: streamedText,
|
||||||
tinyQuestion: "Combining results",
|
tinyQuestion: "Combining results",
|
||||||
|
@ -34,6 +34,7 @@ interface ChatContextProps {
|
|||||||
refreshFolders: () => Promise<void>;
|
refreshFolders: () => Promise<void>;
|
||||||
refreshInputPrompts: () => Promise<void>;
|
refreshInputPrompts: () => Promise<void>;
|
||||||
inputPrompts: InputPrompt[];
|
inputPrompts: InputPrompt[];
|
||||||
|
proSearchToggled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChatContext = createContext<ChatContextProps | undefined>(undefined);
|
const ChatContext = createContext<ChatContextProps | undefined>(undefined);
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export const DOCUMENT_SIDEBAR_WIDTH_COOKIE_NAME = "documentSidebarWidth";
|
export const DOCUMENT_SIDEBAR_WIDTH_COOKIE_NAME = "documentSidebarWidth";
|
||||||
export const SIDEBAR_TOGGLED_COOKIE_NAME = "sidebarIsToggled";
|
export const SIDEBAR_TOGGLED_COOKIE_NAME = "sidebarIsToggled";
|
||||||
|
export const PRO_SEARCH_TOGGLED_COOKIE_NAME = "proSearchIsToggled";
|
||||||
|
@ -22,6 +22,7 @@ import { cookies, headers } from "next/headers";
|
|||||||
import {
|
import {
|
||||||
SIDEBAR_TOGGLED_COOKIE_NAME,
|
SIDEBAR_TOGGLED_COOKIE_NAME,
|
||||||
DOCUMENT_SIDEBAR_WIDTH_COOKIE_NAME,
|
DOCUMENT_SIDEBAR_WIDTH_COOKIE_NAME,
|
||||||
|
PRO_SEARCH_TOGGLED_COOKIE_NAME,
|
||||||
} from "@/components/resizable/constants";
|
} from "@/components/resizable/constants";
|
||||||
import { hasCompletedWelcomeFlowSS } from "@/components/initialSetup/welcome/WelcomeModalWrapper";
|
import { hasCompletedWelcomeFlowSS } from "@/components/initialSetup/welcome/WelcomeModalWrapper";
|
||||||
import {
|
import {
|
||||||
@ -45,6 +46,7 @@ interface FetchChatDataResult {
|
|||||||
finalDocumentSidebarInitialWidth?: number;
|
finalDocumentSidebarInitialWidth?: number;
|
||||||
shouldShowWelcomeModal: boolean;
|
shouldShowWelcomeModal: boolean;
|
||||||
inputPrompts: InputPrompt[];
|
inputPrompts: InputPrompt[];
|
||||||
|
proSearchToggled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchChatData(searchParams: {
|
export async function fetchChatData(searchParams: {
|
||||||
@ -175,6 +177,10 @@ export async function fetchChatData(searchParams: {
|
|||||||
);
|
);
|
||||||
const sidebarToggled = requestCookies.get(SIDEBAR_TOGGLED_COOKIE_NAME);
|
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)
|
// IF user is an anoymous user, we don't want to show the sidebar (they have no access to chat history)
|
||||||
const toggleSidebar =
|
const toggleSidebar =
|
||||||
!user?.is_anonymous_user &&
|
!user?.is_anonymous_user &&
|
||||||
@ -227,5 +233,6 @@ export async function fetchChatData(searchParams: {
|
|||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
inputPrompts,
|
inputPrompts,
|
||||||
|
proSearchToggled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user