diff --git a/backend/onyx/server/query_and_chat/chat_backend.py b/backend/onyx/server/query_and_chat/chat_backend.py index b9e3dc06686..a378446a7f0 100644 --- a/backend/onyx/server/query_and_chat/chat_backend.py +++ b/backend/onyx/server/query_and_chat/chat_backend.py @@ -184,10 +184,7 @@ def get_chat_session( persona_name=chat_session.persona.name if chat_session.persona else None, current_alternate_model=chat_session.current_alternate_model, messages=[ - translate_db_message_to_chat_message_detail( - msg, remove_doc_content=is_shared # if shared, don't leak doc content - ) - for msg in session_messages + translate_db_message_to_chat_message_detail(msg) for msg in session_messages ], time_created=chat_session.time_created, shared_status=chat_session.shared_status, diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 89ba2960f0d..ecc7a63934e 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -2105,6 +2105,7 @@ export function ChatPage({ } /> )} + {sharingModalVisible && chatSessionIdRef.current !== null && ( +
void; selectedMessage: Message | null; selectedDocuments: OnyxDocument[] | null; @@ -79,6 +79,7 @@ export const ChatFilters = forwardRef( const dedupedDocuments = removeDuplicateDocs(currentDocuments || []); const tokenLimitReached = selectedDocumentTokens > maxTokens - 75; + console.log("SELECTED MESSAGE is", selectedMessage); const hasSelectedDocuments = selectedDocumentIds.length > 0; @@ -122,10 +123,10 @@ export const ChatFilters = forwardRef(
{showFilters ? ( ccPair.source)} availableTags={tags} diff --git a/web/src/app/chat/message/Messages.tsx b/web/src/app/chat/message/Messages.tsx index 9d480d2f742..4e829910ed5 100644 --- a/web/src/app/chat/message/Messages.tsx +++ b/web/src/app/chat/message/Messages.tsx @@ -393,21 +393,16 @@ export const AIMessage = ({
{!toolCall || toolCall.tool_name === SEARCH_TOOL_NAME ? ( <> - {query !== undefined && - handleShowRetrieved && - !retrievalDisabled && ( -
- -
- )} + {query !== undefined && !retrievalDisabled && ( +
+ +
+ )} {handleForceSearch && content && query === undefined && diff --git a/web/src/app/chat/message/SearchSummary.tsx b/web/src/app/chat/message/SearchSummary.tsx index 7349ec6ca35..9c22f81d3fa 100644 --- a/web/src/app/chat/message/SearchSummary.tsx +++ b/web/src/app/chat/message/SearchSummary.tsx @@ -43,18 +43,12 @@ export function ShowHideDocsButton({ export function SearchSummary({ index, query, - hasDocs, finished, - messageId, - handleShowRetrieved, handleSearchQueryEdit, }: { index: number; finished: boolean; query: string; - hasDocs: boolean; - messageId: number | null; - handleShowRetrieved: (messageId: number | null) => void; handleSearchQueryEdit?: (query: string) => void; }) { const [isEditing, setIsEditing] = useState(false); diff --git a/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx b/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx index 1a7a2adda0d..67ff23f3749 100644 --- a/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx +++ b/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx @@ -6,6 +6,7 @@ import { BackendChatSession } from "../../interfaces"; import { buildLatestMessageChain, getCitedDocumentsFromMessage, + getHumanAndAIMessageFromMessageNumber, processRawChatHistory, } from "../../lib"; import { AIMessage, HumanMessage } from "../../message/Messages"; @@ -19,6 +20,12 @@ import { Persona } from "@/app/admin/assistants/interfaces"; import { Button } from "@/components/ui/button"; import { OnyxDocument } from "@/lib/search/interfaces"; import TextView from "@/components/chat_search/TextView"; +import { ChatFilters } from "../../documentSidebar/ChatFilters"; +import { Modal } from "@/components/Modal"; +import FunctionalHeader from "@/components/chat_search/Header"; +import { MinimalMarkdown } from "@/components/chat_search/MinimalMarkdown"; +import FixedLogo from "../../shared_chat_search/FixedLogo"; +import { useDocumentSelection } from "../../useDocumentSelection"; function BackToOnyxButton() { const router = useRouter(); @@ -42,10 +49,18 @@ export function SharedChatDisplay({ chatSession: BackendChatSession | null; persona: Persona; }) { + const settings = useContext(SettingsContext); + const [documentSidebarToggled, setDocumentSidebarToggled] = useState(false); + const [selectedMessageForDocDisplay, setSelectedMessageForDocDisplay] = + useState(null); const [isReady, setIsReady] = useState(false); const [presentingDocument, setPresentingDocument] = useState(null); + const toggleDocumentSidebar = () => { + setDocumentSidebarToggled(!documentSidebarToggled); + }; + useEffect(() => { Prism.highlightAll(); setIsReady(true); @@ -62,11 +77,31 @@ export function SharedChatDisplay({
); } + const [ + selectedDocuments, + toggleDocumentSelection, + clearSelectedDocuments, + selectedDocumentTokens, + ] = useDocumentSelection(); const messages = buildLatestMessageChain( processRawChatHistory(chatSession.messages) ); + const messagesWithDocuments = messages.map((message) => ({ + ...message, + documents: message.documents || [], + })); + + useEffect(() => { + messagesWithDocuments.forEach((message) => { + console.log( + `Message ID ${message.messageId} documents:`, + message.documents + ); + }); + }, []); + console.log("selectedDocuments", selectedDocuments); return ( <> {presentingDocument && ( @@ -75,8 +110,96 @@ export function SharedChatDisplay({ onClose={() => setPresentingDocument(null)} /> )} -
-
+ {documentSidebarToggled && settings?.isMobile && ( +
+ + { + setDocumentSidebarToggled(true); + }} + clearSelectedDocuments={() => {}} + selectedDocumentTokens={0} + maxTokens={0} + initialWidth={400} + isOpen={true} + setPresentingDocument={setPresentingDocument} + modal={true} + ccPairs={[]} + tags={[]} + documentSets={[]} + showFilters={false} + closeSidebar={() => { + setDocumentSidebarToggled(false); + }} + selectedDocuments={[]} + /> + +
+ )} +
+
+
+ {}} + page="chat" + reset={() => {}} + /> +
+ {!settings?.isMobile && ( +
+ + message.messageId === selectedMessageForDocDisplay + ) || null + : null + } + toggleDocumentSelection={() => { + setDocumentSidebarToggled(true); + }} + clearSelectedDocuments={() => {}} + selectedDocumentTokens={0} + maxTokens={0} + initialWidth={400} + isOpen={true} + setPresentingDocument={setPresentingDocument} + modal={true} + ccPairs={[]} + tags={[]} + documentSets={[]} + showFilters={false} + closeSidebar={() => { + setDocumentSidebarToggled(false); + }} + selectedDocuments={selectedDocuments} + /> +
+ )}
@@ -87,7 +210,6 @@ export function SharedChatDisplay({

{humanReadableFormat(chatSession.time_created)}

-
{isReady ? ( @@ -120,6 +242,20 @@ export function SharedChatDisplay({ content={message.message} files={message.files || []} citedDocuments={getCitedDocumentsFromMessage(message)} + // toggleDocumentSelection={() => { + // setDocumentSidebarToggled(true); + // }} + toggleDocumentSelection={() => { + if ( + !documentSidebarToggled || + (documentSidebarToggled && + selectedMessageForDocDisplay === + message.messageId) + ) { + toggleDocumentSidebar(); + } + setSelectedMessageForDocDisplay(message.messageId); + }} isComplete /> ); @@ -133,10 +269,36 @@ export function SharedChatDisplay({
)} + + {settings?.enterpriseSettings + ?.custom_lower_disclaimer_content && ( +
+
+ +
+
+ )} + + {settings?.enterpriseSettings?.use_custom_logotype && ( +
+ logotype +
+ )}
+
diff --git a/web/src/app/chat/shared/[chatId]/page.tsx b/web/src/app/chat/shared/[chatId]/page.tsx index 597525b0672..955929ff2df 100644 --- a/web/src/app/chat/shared/[chatId]/page.tsx +++ b/web/src/app/chat/shared/[chatId]/page.tsx @@ -73,15 +73,5 @@ export default async function Page(props: { console.log(`Message ${index} context_docs:`, message.context_docs); }); } - return ( -
-
- -
- -
- -
-
- ); + return ; }