Skip to content

An AI-powered search engine with a generative UI

Refactor: Move SidebarGroup for history into ChatHistoryClient

Yoshiki Miura0f9b397f5d65
diff --git a/components/sidebar/chat-history-client.tsx b/components/sidebar/chat-history-client.tsx
index 389e77f6..7abc96b4 100644
--- a/components/sidebar/chat-history-client.tsx
+++ b/components/sidebar/chat-history-client.tsx
@@ -1,6 +1,10 @@
'use client'
-import { SidebarMenu } from '@/components/ui/sidebar'
+import {
+ SidebarGroup,
+ SidebarGroupLabel,
+ SidebarMenu
+} from '@/components/ui/sidebar'
import { Chat } from '@/lib/types'
import { useCallback, useEffect, useRef, useState, useTransition } from 'react'
import { toast } from 'sonner'
@@ -108,10 +112,13 @@ export function ChatHistoryClient() {
const isHistoryEmpty = !isLoading && !chats.length && nextOffset === null
return (
- <>
- <div className="px-2 pb-1 pt-0 mt-[-8px] mb-1">
- <ClearHistoryAction empty={isHistoryEmpty} />
- </div>
+ <div className="flex flex-col flex-1 h-full">
+ <SidebarGroup>
+ <div className="flex items-center justify-between w-full">
+ <SidebarGroupLabel className="p-0">History</SidebarGroupLabel>
+ <ClearHistoryAction empty={isHistoryEmpty} />
+ </div>
+ </SidebarGroup>
<div className="flex-1 overflow-y-auto mb-2 relative">
{isHistoryEmpty && !isPending ? (
<div className="px-2 text-foreground/30 text-sm text-center py-4">
@@ -131,6 +138,6 @@ export function ChatHistoryClient() {
</div>
)}
</div>
- </>
+ </div>
)
}
diff --git a/components/sidebar/chat-history-section.tsx b/components/sidebar/chat-history-section.tsx
index ac765b45..103c3e35 100644
--- a/components/sidebar/chat-history-section.tsx
+++ b/components/sidebar/chat-history-section.tsx
@@ -1,4 +1,3 @@
-import { SidebarGroup, SidebarGroupLabel } from '@/components/ui/sidebar'
import { ChatHistoryClient } from './chat-history-client'
export async function ChatHistorySection() {
@@ -7,14 +6,5 @@ export async function ChatHistorySection() {
return null
}
- return (
- <div className="flex flex-col flex-1 h-full">
- <SidebarGroup>
- <div className="flex items-center justify-between w-full">
- <SidebarGroupLabel className="p-0">History</SidebarGroupLabel>
- </div>
- </SidebarGroup>
- <ChatHistoryClient />
- </div>
- )
+ return <ChatHistoryClient />
}