Skip to content

Commit

Permalink
Fix chat list double scrollbar (#3385)
Browse files Browse the repository at this point in the history
Close #3252
- Dont render scrollbar in /chat page anymore.
- Fix an overflow bug in the chat list

I have manually verified all the UI
  • Loading branch information
notmd committed Jun 11, 2023
1 parent 8ec4ebc commit 1c50662
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion website/src/components/Chat/ChatConversation.tsx
Expand Up @@ -8,7 +8,7 @@ import SimpleBar from "simplebar-react";
import { useMessageVote } from "src/hooks/chat/useMessageVote";
import { useBrowserConfig } from "src/hooks/env/BrowserEnv";
import { get, post } from "src/lib/api";
import { handleChatEventStream, QueueInfo, PluginIntermediateResponse } from "src/lib/chat_stream";
import { handleChatEventStream, PluginIntermediateResponse, QueueInfo } from "src/lib/chat_stream";
import { OasstError } from "src/lib/oasst_api_client";
import { API_ROUTES } from "src/lib/routes";
import {
Expand Down
43 changes: 29 additions & 14 deletions website/src/components/Chat/ChatListBase.tsx
Expand Up @@ -14,9 +14,9 @@ import { ChatListViewSelection, useListChatPagination } from "./useListChatPagin

export const ChatListBase = memo(function ChatListBase({
allowViews,
minHeight,
noScrollbar,
...props
}: CardProps & { allowViews?: boolean; minHeight?: string }) {
}: CardProps & { allowViews?: boolean; noScrollbar?: boolean }) {
const [view, setView] = useState<ChatListViewSelection>("visible");
const { loadMoreRef, responses, mutateChatResponses } = useListChatPagination(view);
const chats = responses?.flatMap((response) => response.chats) || [];
Expand Down Expand Up @@ -67,6 +67,21 @@ export const ChatListBase = memo(function ChatListBase({
mutateChatResponses();
}, [mutateChatResponses]);

const content = (
<>
{chats.map((chat) => (
<ChatListItem
key={chat.id}
chat={chat}
onUpdateTitle={handleUpdateTitle}
onHide={removeItemFromList}
onDelete={removeItemFromList}
/>
))}
<div ref={loadMoreRef} />
</>
);

return (
<Box
gap="1"
Expand Down Expand Up @@ -96,18 +111,18 @@ export const ChatListBase = memo(function ChatListBase({
<ChatViewSelection w={["full", "auto"]} onChange={(e) => setView(e.target.value as ChatListViewSelection)} />
)}
</Flex>
<SimpleBar style={{ padding: "8px", height: "100%", minHeight: chats.length && minHeight ? minHeight : "0" }}>
{chats.map((chat) => (
<ChatListItem
key={chat.id}
chat={chat}
onUpdateTitle={handleUpdateTitle}
onHide={removeItemFromList}
onDelete={removeItemFromList}
/>
))}
<div ref={loadMoreRef} />
</SimpleBar>
{noScrollbar ? (
content
) : (
<SimpleBar
style={{ padding: "8px", height: "100%", minHeight: "150px" }}
classNames={{
contentEl: "flex flex-col items-center overflow-y-hidden min-h-full",
}}
>
{content}
</SimpleBar>
)}
<InferencePoweredBy />
</Box>
);
Expand Down
3 changes: 2 additions & 1 deletion website/src/components/Chat/ChatListItem.tsx
Expand Up @@ -306,7 +306,8 @@ const ChatListItemIconButton = ({ label, onClick, icon }: ChatListItemIconButton
return (
<Tooltip label={label}>
<Box
as="button"
as="div"
role="button"
aria-label={label}
onClick={(e: MouseEvent) => {
stopEvent(e);
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/chat/index.tsx
Expand Up @@ -6,7 +6,7 @@ import { DashboardLayout } from "src/components/Layout";
export { getStaticProps } from "src/lib/defaultServerSideProps";

const ChatList = () => {
const { t } = useTranslation(["chat"]);
const { t } = useTranslation();

return (
<>
Expand All @@ -27,7 +27,7 @@ const ChatList = () => {
bg: "gray.700",
}}
shadow="md"
minHeight="300px"
noScrollbar
/>
</>
);
Expand Down

0 comments on commit 1c50662

Please sign in to comment.