automatically open the side bar when a new chat is created with the default agent.

This commit is contained in:
sabaimran
2025-01-21 11:56:06 -08:00
parent c43079cb21
commit e3e93e091d
2 changed files with 9 additions and 3 deletions

View File

@@ -49,7 +49,7 @@ interface ChatBodyDataProps {
setImages: (images: string[]) => void;
setTriggeredAbort: (triggeredAbort: boolean) => void;
isChatSideBarOpen: boolean;
onChatSideBarOpenChange: (open: boolean) => void;
setIsChatSideBarOpen: (open: boolean) => void;
}
function ChatBodyData(props: ChatBodyDataProps) {
@@ -156,6 +156,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
incomingMessages={props.streamedMessages}
setIncomingMessages={props.setStreamedMessages}
customClassName={chatHistoryCustomClassName}
setIsChatSideBarOpen={props.setIsChatSideBarOpen}
/>
</div>
<div
@@ -180,7 +181,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
<ChatSidebar
conversationId={conversationId}
isOpen={props.isChatSideBarOpen}
onOpenChange={props.onChatSideBarOpenChange}
onOpenChange={props.setIsChatSideBarOpen}
isMobileWidth={props.isMobileWidth} />
</div>
);
@@ -478,7 +479,7 @@ export default function Chat() {
setImages={setImages}
setTriggeredAbort={setTriggeredAbort}
isChatSideBarOpen={isChatSideBarOpen}
onChatSideBarOpenChange={setIsChatSideBarOpen}
setIsChatSideBarOpen={setIsChatSideBarOpen}
/>
</Suspense>
</div>

View File

@@ -40,6 +40,7 @@ interface ChatHistoryProps {
publicConversationSlug?: string;
setAgent: (agent: AgentData) => void;
customClassName?: string;
setIsChatSideBarOpen?: (isOpen: boolean) => void;
}
interface TrainOfThoughtComponentProps {
@@ -149,6 +150,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
latestUserMessageRef.current?.scrollIntoView({ behavior: "auto", block: "start" });
});
}
}, [data, currentPage]);
useEffect(() => {
@@ -251,6 +253,9 @@ export default function ChatHistory(props: ChatHistoryProps) {
};
props.setAgent(chatData.response.agent);
setData(chatMetadata);
if (props.setIsChatSideBarOpen) {
props.setIsChatSideBarOpen(true);
}
}
setHasMoreMessages(false);