diff --git a/ui/src/components/sidebars/ChatItem.stories.tsx b/ui/src/components/sidebars/ChatItem.stories.tsx index 406405a2f..5339874f1 100644 --- a/ui/src/components/sidebars/ChatItem.stories.tsx +++ b/ui/src/components/sidebars/ChatItem.stories.tsx @@ -62,7 +62,7 @@ export const ShortTitle: Story = { agentNamespace: "kagent", onDelete: async () => {}, sessionName: "Quick question", - createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }, }; @@ -73,7 +73,7 @@ export const LongTitle: Story = { agentNamespace: "kagent", onDelete: async () => {}, sessionName: "Review https://github.com/Smartest-Fly/app/pull/1234 and provide feedback on the authentication implementation", - createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }, }; @@ -84,7 +84,7 @@ export const LongTitleWithAgentName: Story = { agentNamespace: "kagent", onDelete: async () => {}, sessionName: "Review https://github.com/Smartest-Fly/app/pull/1234 and provide feedback on the authentication implementation", - createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }, }; @@ -107,7 +107,7 @@ export const MultipleLongTitles: Story = { agentNamespace="kagent" onDelete={async () => {}} sessionName={title} - createdAt={new Date(Date.now() - i * 3600000).toISOString()} + updatedAt={new Date(Date.now() - i * 3600000).toISOString()} /> ))} diff --git a/ui/src/components/sidebars/ChatItem.tsx b/ui/src/components/sidebars/ChatItem.tsx index 6b01371ed..18e70c726 100644 --- a/ui/src/components/sidebars/ChatItem.tsx +++ b/ui/src/components/sidebars/ChatItem.tsx @@ -22,10 +22,10 @@ interface ChatItemProps { agentNamespace?: string; sessionName?: string; onDownload?: (sessionId: string) => Promise; - createdAt?: string; + updatedAt?: string; } -const ChatItem = ({ sessionId, agentName, agentNamespace, onDelete, sessionName, onDownload, createdAt }: ChatItemProps) => { +const ChatItem = ({ sessionId, agentName, agentNamespace, onDelete, sessionName, onDownload, updatedAt }: ChatItemProps) => { const title = sessionName || "Untitled"; // Format timestamp based on how recent it is @@ -58,7 +58,7 @@ const ChatItem = ({ sessionId, agentName, agentNamespace, onDelete, sessionName, style={{ background: 'linear-gradient(to right, transparent, hsl(var(--sidebar-background)) 30%)', }} - >{formatTime(createdAt)} + >{formatTime(updatedAt)} diff --git a/ui/src/components/sidebars/GroupedChats.tsx b/ui/src/components/sidebars/GroupedChats.tsx index 6a11ca824..f423a457d 100644 --- a/ui/src/components/sidebars/GroupedChats.tsx +++ b/ui/src/components/sidebars/GroupedChats.tsx @@ -35,9 +35,9 @@ export default function GroupedChats({ agentName, agentNamespace, sessions }: Gr older: [], }; - // Process each session and group by date + // Process each session and group by last activity date (updated_at) localSessions.forEach(session => { - const date = new Date(session.created_at); + const date = new Date(session.updated_at || session.created_at); if (isToday(date)) { groups.today.push(session); } else if (isYesterday(date)) { @@ -50,7 +50,7 @@ export default function GroupedChats({ agentName, agentNamespace, sessions }: Gr const sortChats = (sessions: Session[]) => sessions.sort((a, b) => { const getLatestTimestamp = (session: Session) => { - return new Date(session.created_at).getTime(); + return new Date(session.updated_at || session.created_at).getTime(); }; return getLatestTimestamp(b) - getLatestTimestamp(a); diff --git a/ui/src/components/sidebars/SessionGroup.tsx b/ui/src/components/sidebars/SessionGroup.tsx index 6a952ab6d..073dd7916 100644 --- a/ui/src/components/sidebars/SessionGroup.tsx +++ b/ui/src/components/sidebars/SessionGroup.tsx @@ -29,7 +29,7 @@ const ChatGroup = ({ title, sessions, onDeleteSession, onDownloadSession, agentN {sessions.map((session) => ( - + ))}