diff --git a/backend/danswer/server/query_and_chat/chat_backend.py b/backend/danswer/server/query_and_chat/chat_backend.py index 558a644627a..01d5bf072a6 100644 --- a/backend/danswer/server/query_and_chat/chat_backend.py +++ b/backend/danswer/server/query_and_chat/chat_backend.py @@ -129,7 +129,6 @@ def get_chat_session( db_session: Session = Depends(get_session), ) -> ChatSessionDetailResponse: user_id = user.id if user is not None else None - try: chat_session = get_chat_session_by_id( chat_session_id=session_id, diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 4aa530d34cb..ae0fb94bff3 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -15,8 +15,8 @@ import { ToolCallMetadata, } from "./interfaces"; +import Prism from "prismjs"; import Cookies from "js-cookie"; - import { HistorySidebar } from "./sessionSidebar/HistorySidebar"; import { Persona } from "../admin/assistants/interfaces"; import { HealthCheckBanner } from "@/components/health/healthcheck"; @@ -193,6 +193,12 @@ export function ChatPage({ existingChatSessionId !== null ); + const [isReady, setIsReady] = useState(false); + useEffect(() => { + Prism.highlightAll(); + setIsReady(true); + }, []); + // this is triggered every time the user switches which chat // session they are using useEffect(() => { @@ -1233,7 +1239,7 @@ export function ChatPage({ /> )} - {documentSidebarInitialWidth !== undefined ? ( + {documentSidebarInitialWidth !== undefined && isReady ? ( {({ getRootProps }) => (
@@ -1241,15 +1247,15 @@ export function ChatPage({
)} diff --git a/web/src/app/chat/files/images/InMessageImage.tsx b/web/src/app/chat/files/images/InMessageImage.tsx index 501a04447f7..0139dc75ee4 100644 --- a/web/src/app/chat/files/images/InMessageImage.tsx +++ b/web/src/app/chat/files/images/InMessageImage.tsx @@ -19,6 +19,7 @@ export function InMessageImage({ fileId }: { fileId: string }) { {!imageLoaded && (
)} + void; @@ -175,19 +169,10 @@ export const AIMessage = ({ const finalContent = processContent(content as string); - const [isReady, setIsReady] = useState(false); - useEffect(() => { - Prism.highlightAll(); - setIsReady(true); - }, []); - const { isHovering, trackedElementRef, hoverElementRef } = useMouseTracking(); const settings = useContext(SettingsContext); // this is needed to give Prism a chance to load - if (!isReady) { - return
; - } const selectedDocumentIds = selectedDocuments?.map((document) => document.document_id) || []; @@ -247,8 +232,10 @@ export const AIMessage = ({ return (
-
-
+
+
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > -
+
diff --git a/web/src/app/chat/modal/ShareChatSessionModal.tsx b/web/src/app/chat/modal/ShareChatSessionModal.tsx index b3546c7e0e9..605f81dd8bf 100644 --- a/web/src/app/chat/modal/ShareChatSessionModal.tsx +++ b/web/src/app/chat/modal/ShareChatSessionModal.tsx @@ -63,13 +63,6 @@ export function ShareChatSessionModal({

Share link to Chat

- -
- -
{linkGenerating && } diff --git a/web/src/app/chat/sessionSidebar/HistorySidebar.tsx b/web/src/app/chat/sessionSidebar/HistorySidebar.tsx index ffd768f20ef..cf2edef9400 100644 --- a/web/src/app/chat/sessionSidebar/HistorySidebar.tsx +++ b/web/src/app/chat/sessionSidebar/HistorySidebar.tsx @@ -1,14 +1,7 @@ "use client"; -import { FiArrowDown, FiEdit, FiFolderPlus } from "react-icons/fi"; -import { - Dispatch, - ForwardedRef, - forwardRef, - SetStateAction, - useContext, - useEffect, -} from "react"; +import { FiEdit, FiFolderPlus } from "react-icons/fi"; +import { ForwardedRef, forwardRef, useContext, useEffect } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { ChatSession } from "../interfaces"; @@ -26,10 +19,7 @@ import { ClosedBookIcon, } from "@/components/icons/icons"; import { PagesTab } from "./PagesTab"; -import { Tooltip } from "@/components/tooltip/Tooltip"; -import KeyboardSymbol from "@/lib/browserUtilities"; import { pageType } from "./types"; -import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled"; import LogoType from "@/components/header/LogoType"; interface HistorySidebarProps { diff --git a/web/src/app/chat/sessionSidebar/types.ts b/web/src/app/chat/sessionSidebar/types.ts index 1e88ffef433..6aeffb84c8e 100644 --- a/web/src/app/chat/sessionSidebar/types.ts +++ b/web/src/app/chat/sessionSidebar/types.ts @@ -1 +1 @@ -export type pageType = "search" | "chat" | "assistants" | "admin"; +export type pageType = "search" | "chat" | "assistants" | "admin" | "shared"; diff --git a/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx b/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx index f9aba70d2fa..0ab1503c12a 100644 --- a/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx +++ b/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx @@ -1,4 +1,5 @@ "use client"; +import Prism from "prismjs"; import { humanReadableFormat } from "@/lib/time"; import { BackendChatSession } from "../../interfaces"; @@ -11,20 +12,22 @@ import { AIMessage, HumanMessage } from "../../message/Messages"; import { Button, Callout, Divider } from "@tremor/react"; import { useRouter } from "next/navigation"; import { Persona } from "@/app/admin/assistants/interfaces"; -import { useContext } from "react"; +import { useContext, useEffect, useState } from "react"; import { SettingsContext } from "@/components/settings/SettingsProvider"; +import { DanswerInitializingLoader } from "@/components/DanswerInitializingLoader"; function BackToDanswerButton() { const router = useRouter(); const enterpriseSettings = useContext(SettingsContext)?.enterpriseSettings; return ( -
+
+ pr
); } @@ -36,6 +39,11 @@ export function SharedChatDisplay({ chatSession: BackendChatSession | null; availableAssistants: Persona[]; }) { + const [isReady, setIsReady] = useState(false); + useEffect(() => { + Prism.highlightAll(); + setIsReady(true); + }, []); if (!chatSession) { return (
@@ -44,12 +52,10 @@ export function SharedChatDisplay({ Did not find a shared chat with the specified ID.
-
); } - const currentPersona = availableAssistants.find( (persona) => persona.id === chatSession.persona_id ); @@ -59,10 +65,10 @@ export function SharedChatDisplay({ ); return ( -
+
-
+

{chatSession.description || @@ -74,32 +80,42 @@ export function SharedChatDisplay({

- -
- {messages.map((message) => { - if (message.type === "user") { - return ( - - ); - } else { - return ( - - ); - } - })} -
+ {isReady ? ( +
+ {messages.map((message) => { + if (message.type === "user") { + return ( + + ); + } else { + return ( + + ); + } + })} +
+ ) : ( +
+
+ +
+
+ )}
diff --git a/web/src/app/chat/shared/[chatId]/page.tsx b/web/src/app/chat/shared/[chatId]/page.tsx index a70ba5928e3..9e8ce58432e 100644 --- a/web/src/app/chat/shared/[chatId]/page.tsx +++ b/web/src/app/chat/shared/[chatId]/page.tsx @@ -57,7 +57,7 @@ export default async function Page({ params }: { params: { chatId: string } }) { return (
- null} user={user} /> +
diff --git a/web/src/components/chat_search/Header.tsx b/web/src/components/chat_search/Header.tsx index 3c5193de988..ae84b4f4594 100644 --- a/web/src/components/chat_search/Header.tsx +++ b/web/src/components/chat_search/Header.tsx @@ -18,7 +18,7 @@ export default function FunctionalHeader({ page, currentChatSession, setSharingModalVisible, - toggleSidebar, + toggleSidebar = () => null, reset = () => null, sidebarToggled, }: { @@ -28,7 +28,7 @@ export default function FunctionalHeader({ sidebarToggled?: boolean; currentChatSession?: ChatSession | null | undefined; setSharingModalVisible?: (value: SetStateAction) => void; - toggleSidebar: () => void; + toggleSidebar?: () => void; }) { const combinedSettings = useContext(SettingsContext); const enterpriseSettings = combinedSettings?.enterpriseSettings;