Skip to content

Commit 1fbf00d

Browse files
feat(ui): sort session history by last activity instead of creation time
Signed-off-by: Raghavendiran-Github <raghavendiran46461@gmail.com>
1 parent e06146b commit 1fbf00d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

ui/src/components/sidebars/ChatItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ interface ChatItemProps {
2222
agentNamespace?: string;
2323
sessionName?: string;
2424
onDownload?: (sessionId: string) => Promise<void>;
25-
createdAt?: string;
25+
updatedAt?: string;
2626
}
2727

28-
const ChatItem = ({ sessionId, agentName, agentNamespace, onDelete, sessionName, onDownload, createdAt }: ChatItemProps) => {
28+
const ChatItem = ({ sessionId, agentName, agentNamespace, onDelete, sessionName, onDownload, updatedAt }: ChatItemProps) => {
2929
const title = sessionName || "Untitled";
3030

3131
// Format timestamp based on how recent it is
@@ -58,7 +58,7 @@ const ChatItem = ({ sessionId, agentName, agentNamespace, onDelete, sessionName,
5858
style={{
5959
background: 'linear-gradient(to right, transparent, hsl(var(--sidebar-background)) 30%)',
6060
}}
61-
>{formatTime(createdAt)}</span>
61+
>{formatTime(updatedAt)}</span>
6262
</Link>
6363
</SidebarMenuButton>
6464
<DropdownMenu modal={false}>

ui/src/components/sidebars/GroupedChats.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ export default function GroupedChats({ agentName, agentNamespace, sessions }: Gr
3535
older: [],
3636
};
3737

38-
// Process each session and group by date
38+
// Process each session and group by last activity date (updated_at)
3939
localSessions.forEach(session => {
40-
const date = new Date(session.created_at);
40+
const date = new Date(session.updated_at || session.created_at);
4141
if (isToday(date)) {
4242
groups.today.push(session);
4343
} else if (isYesterday(date)) {
@@ -50,7 +50,7 @@ export default function GroupedChats({ agentName, agentNamespace, sessions }: Gr
5050
const sortChats = (sessions: Session[]) =>
5151
sessions.sort((a, b) => {
5252
const getLatestTimestamp = (session: Session) => {
53-
return new Date(session.created_at).getTime();
53+
return new Date(session.updated_at || session.created_at).getTime();
5454
};
5555

5656
return getLatestTimestamp(b) - getLatestTimestamp(a);

ui/src/components/sidebars/SessionGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const ChatGroup = ({ title, sessions, onDeleteSession, onDownloadSession, agentN
2929
<CollapsibleContent>
3030
<SidebarMenuSub className="mx-0 px-0 ml-2 pl-2">
3131
{sessions.map((session) => (
32-
<ChatItem key={session.id} sessionId={session.id!} agentName={agentName} agentNamespace={agentNamespace} onDelete={onDeleteSession} sessionName={session.name} onDownload={onDownloadSession} createdAt={session.created_at} />
32+
<ChatItem key={session.id} sessionId={session.id!} agentName={agentName} agentNamespace={agentNamespace} onDelete={onDeleteSession} sessionName={session.name} onDownload={onDownloadSession} updatedAt={session.updated_at || session.created_at} />
3333
))}
3434
</SidebarMenuSub>
3535
</CollapsibleContent>

0 commit comments

Comments
 (0)