@@ -21,7 +21,6 @@ import {
2121 AlertDialogTitle ,
2222 AlertDialogTrigger ,
2323} from '@/components/ui/alert-dialog'
24- import { ChatSession } from '@/lib/chat-persistence'
2524import {
2625 MessageSquare ,
2726 Search ,
@@ -36,6 +35,7 @@ import {
3635 Clock
3736} from 'lucide-react'
3837import { formatDistanceToNow } from 'date-fns'
38+ import { ChatSession } from '@/lib/database.types'
3939
4040interface ChatHistoryProps {
4141 sessions : ChatSession [ ]
@@ -71,26 +71,26 @@ export function ChatHistory({
7171
7272 const groupedSessions = {
7373 today : filteredSessions . filter ( session => {
74- const sessionDate = new Date ( session . lastActivity )
74+ const sessionDate = new Date ( session . last_activity )
7575 const today = new Date ( )
7676 return sessionDate . toDateString ( ) === today . toDateString ( )
7777 } ) ,
7878 yesterday : filteredSessions . filter ( session => {
79- const sessionDate = new Date ( session . lastActivity )
79+ const sessionDate = new Date ( session . last_activity )
8080 const yesterday = new Date ( )
8181 yesterday . setDate ( yesterday . getDate ( ) - 1 )
8282 return sessionDate . toDateString ( ) === yesterday . toDateString ( )
8383 } ) ,
8484 lastWeek : filteredSessions . filter ( session => {
85- const sessionDate = new Date ( session . lastActivity )
85+ const sessionDate = new Date ( session . last_activity )
8686 const weekAgo = new Date ( )
8787 weekAgo . setDate ( weekAgo . getDate ( ) - 7 )
8888 const yesterday = new Date ( )
8989 yesterday . setDate ( yesterday . getDate ( ) - 1 )
9090 return sessionDate > weekAgo && sessionDate < yesterday
9191 } ) ,
9292 older : filteredSessions . filter ( session => {
93- const sessionDate = new Date ( session . lastActivity )
93+ const sessionDate = new Date ( session . last_activity )
9494 const weekAgo = new Date ( )
9595 weekAgo . setDate ( weekAgo . getDate ( ) - 7 )
9696 return sessionDate <= weekAgo
@@ -106,27 +106,27 @@ export function ChatHistory({
106106 }
107107
108108 const startEditing = ( session : ChatSession ) => {
109- setEditingSession ( session . sessionId )
109+ setEditingSession ( session . session_id )
110110 setEditTitle ( session . title || '' )
111111 }
112112
113113 const handleDeleteConfirm = ( ) => {
114114 if ( deletingSession ) {
115- onSessionDelete ( deletingSession . sessionId )
115+ onSessionDelete ( deletingSession . session_id )
116116 setDeletingSession ( null )
117117 }
118118 }
119119
120120 const SessionItem = ( { session } : { session : ChatSession } ) => {
121- const isActive = session . sessionId === currentSessionId
122- const isEditing = editingSession === session . sessionId
121+ const isActive = session . session_id === currentSessionId
122+ const isEditing = editingSession === session . session_id
123123
124124 return (
125125 < div
126126 className = { `group flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors hover:bg-accent ${
127127 isActive ? 'bg-accent border border-border' : ''
128128 } `}
129- onClick = { ( ) => ! isEditing && onSessionSelect ( session . sessionId ) }
129+ onClick = { ( ) => ! isEditing && onSessionSelect ( session . session_id ) }
130130 >
131131 < MessageSquare className = "h-4 w-4 text-muted-foreground shrink-0" />
132132
@@ -135,10 +135,10 @@ export function ChatHistory({
135135 < Input
136136 value = { editTitle }
137137 onChange = { ( e ) => setEditTitle ( e . target . value ) }
138- onBlur = { ( ) => handleSessionRename ( session . sessionId ) }
138+ onBlur = { ( ) => handleSessionRename ( session . session_id ) }
139139 onKeyDown = { ( e ) => {
140140 if ( e . key === 'Enter' ) {
141- handleSessionRename ( session . sessionId )
141+ handleSessionRename ( session . session_id )
142142 } else if ( e . key === 'Escape' ) {
143143 setEditingSession ( null )
144144 setEditTitle ( '' )
@@ -155,9 +155,9 @@ export function ChatHistory({
155155 </ div >
156156 < div className = "flex items-center gap-1 text-xs text-muted-foreground" >
157157 < Hash className = "h-3 w-3" />
158- < span > { session . messageCount } </ span >
158+ < span > { session . message_count } </ span >
159159 < Clock className = "h-3 w-3 ml-1" />
160- < span > { formatDistanceToNow ( new Date ( session . lastActivity ) , { addSuffix : true } ) } </ span >
160+ < span > { formatDistanceToNow ( new Date ( session . last_activity ) , { addSuffix : true } ) } </ span >
161161 </ div >
162162 { ( session . model || session . template ) && (
163163 < div className = "flex items-center gap-1 text-xs text-muted-foreground mt-1" >
@@ -210,7 +210,7 @@ export function ChatHistory({
210210 </ h3 >
211211 < div className = "space-y-1" >
212212 { sessions . map ( session => (
213- < SessionItem key = { session . sessionId } session = { session } />
213+ < SessionItem key = { session . session_id } session = { session } />
214214 ) ) }
215215 </ div >
216216 </ div >
0 commit comments