update switching logic

This commit is contained in:
pablodanswer
2025-01-26 12:12:25 -08:00
committed by Evan Lohn
parent a0af8ee91c
commit a2247363af
4 changed files with 38 additions and 6 deletions

View File

@@ -2614,6 +2614,13 @@ export function ChatPage({
{message.sub_questions && {message.sub_questions &&
message.sub_questions.length > 0 ? ( message.sub_questions.length > 0 ? (
<AgenticMessage <AgenticMessage
docSidebarToggled={
documentSidebarToggled &&
(selectedMessageForDocDisplay ==
message.messageId ||
selectedMessageForDocDisplay ==
secondLevelMessage?.messageId)
}
isImprovement={message.isImprovement} isImprovement={message.isImprovement}
secondLevelGenerating={ secondLevelGenerating={
(message.second_level_generating && (message.second_level_generating &&
@@ -2707,18 +2714,33 @@ export function ChatPage({
messageHistory.length - 1 == i messageHistory.length - 1 == i
} }
selectedDocuments={selectedDocuments} selectedDocuments={selectedDocuments}
toggleDocumentSelection={() => { toggleDocumentSelection={(
second: boolean
) => {
if ( if (
!documentSidebarToggled || (!second &&
!documentSidebarToggled) ||
(documentSidebarToggled && (documentSidebarToggled &&
selectedMessageForDocDisplay === selectedMessageForDocDisplay ===
message.messageId) message.messageId)
) { ) {
toggleDocumentSidebar(); toggleDocumentSidebar();
} }
if (
(second &&
!documentSidebarToggled) ||
(documentSidebarToggled &&
selectedMessageForDocDisplay ===
secondLevelMessage?.messageId)
) {
toggleDocumentSidebar();
}
setSelectedMessageForDocDisplay( setSelectedMessageForDocDisplay(
message.messageId second
? secondLevelMessage?.messageId ||
null
: message.messageId
); );
}} }}
currentPersona={liveAssistant} currentPersona={liveAssistant}

View File

@@ -50,6 +50,7 @@ import SubQuestionsDisplay from "./SubQuestionsDisplay";
import { StatusRefinement } from "../Refinement"; import { StatusRefinement } from "../Refinement";
export const AgenticMessage = ({ export const AgenticMessage = ({
docSidebarToggled,
isImprovement, isImprovement,
secondLevelAssistantMessage, secondLevelAssistantMessage,
secondLevelGenerating, secondLevelGenerating,
@@ -79,6 +80,7 @@ export const AgenticMessage = ({
secondLevelSubquestions, secondLevelSubquestions,
toggleDocDisplay, toggleDocDisplay,
}: { }: {
docSidebarToggled?: boolean;
isImprovement?: boolean | null; isImprovement?: boolean | null;
secondLevelSubquestions?: SubQuestionDetail[] | null; secondLevelSubquestions?: SubQuestionDetail[] | null;
agenticDocs?: OnyxDocument[] | null; agenticDocs?: OnyxDocument[] | null;
@@ -91,7 +93,7 @@ export const AgenticMessage = ({
otherMessagesCanSwitchTo?: number[]; otherMessagesCanSwitchTo?: number[];
onMessageSelection?: (messageId: number) => void; onMessageSelection?: (messageId: number) => void;
selectedDocuments?: OnyxDocument[] | null; selectedDocuments?: OnyxDocument[] | null;
toggleDocumentSelection?: () => void; toggleDocumentSelection?: (second: boolean) => void;
docs?: OnyxDocument[] | null; docs?: OnyxDocument[] | null;
alternativeAssistant?: Persona | null; alternativeAssistant?: Persona | null;
currentPersona: Persona; currentPersona: Persona;
@@ -395,6 +397,7 @@ export const AgenticMessage = ({
<div className="w-full desktop:ml-4"> <div className="w-full desktop:ml-4">
{subQuestions && subQuestions.length > 0 && ( {subQuestions && subQuestions.length > 0 && (
<SubQuestionsDisplay <SubQuestionsDisplay
docSidebarToggled={docSidebarToggled || false}
finishedGenerating={finalContent.length > 8} finishedGenerating={finalContent.length > 8}
overallAnswerGenerating={finalContent.length < 8} overallAnswerGenerating={finalContent.length < 8}
showSecondLevel={!isViewingInitialAnswer} showSecondLevel={!isViewingInitialAnswer}
@@ -403,7 +406,9 @@ export const AgenticMessage = ({
subQuestions={subQuestions} subQuestions={subQuestions}
secondLevelQuestions={secondLevelSubquestions || []} secondLevelQuestions={secondLevelSubquestions || []}
documents={isViewingInitialAnswer ? docs! : agenticDocs!} documents={isViewingInitialAnswer ? docs! : agenticDocs!}
toggleDocumentSelection={toggleDocumentSelection!} toggleDocumentSelection={() => {
toggleDocumentSelection!(!isViewingInitialAnswer);
}}
setPresentingDocument={setPresentingDocument!} setPresentingDocument={setPresentingDocument!}
unToggle={false} unToggle={false}
/> />

View File

@@ -14,6 +14,7 @@ interface SourcesDisplayProps {
animateEntrance?: boolean; animateEntrance?: boolean;
threeCols?: boolean; threeCols?: boolean;
hideDocumentDisplay?: boolean; hideDocumentDisplay?: boolean;
docSidebarToggled?: boolean;
} }
const SourceCard: React.FC<{ const SourceCard: React.FC<{
@@ -54,6 +55,7 @@ export const SourcesDisplay: React.FC<SourcesDisplayProps> = ({
animateEntrance = false, animateEntrance = false,
threeCols = false, threeCols = false,
hideDocumentDisplay = false, hideDocumentDisplay = false,
docSidebarToggled = false,
}) => { }) => {
const displayedDocuments = documents.slice(0, 5); const displayedDocuments = documents.slice(0, 5);
const hasMoreDocuments = documents.length > 3; const hasMoreDocuments = documents.length > 3;
@@ -108,7 +110,7 @@ export const SourcesDisplay: React.FC<SourcesDisplayProps> = ({
{hasMoreDocuments && ( {hasMoreDocuments && (
<SeeMoreBlock <SeeMoreBlock
toggled={false} toggled={docSidebarToggled}
toggleDocumentSelection={toggleDocumentSelection} toggleDocumentSelection={toggleDocumentSelection}
uniqueSources={ uniqueSources={
Array.from( Array.from(

View File

@@ -65,6 +65,7 @@ export interface TemporaryDisplay {
tinyQuestion: string; tinyQuestion: string;
} }
interface SubQuestionsDisplayProps { interface SubQuestionsDisplayProps {
docSidebarToggled: boolean;
finishedGenerating: boolean; finishedGenerating: boolean;
currentlyOpenQuestion?: BaseQuestionIdentifier | null; currentlyOpenQuestion?: BaseQuestionIdentifier | null;
subQuestions: SubQuestionDetail[]; subQuestions: SubQuestionDetail[];
@@ -472,6 +473,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
toggleDocumentSelection, toggleDocumentSelection,
setPresentingDocument, setPresentingDocument,
secondLevelQuestions, secondLevelQuestions,
docSidebarToggled,
showSecondLevel, showSecondLevel,
overallAnswerGenerating, overallAnswerGenerating,
}) => { }) => {
@@ -745,6 +747,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
{shownDocuments && shownDocuments.length > 0 && ( {shownDocuments && shownDocuments.length > 0 && (
<SourcesDisplay <SourcesDisplay
docSidebarToggled={docSidebarToggled}
hideDocumentDisplay hideDocumentDisplay
animateEntrance={true} animateEntrance={true}
toggleDocumentSelection={toggleDocumentSelection} toggleDocumentSelection={toggleDocumentSelection}