Expose last message timestamp on sessions (#9961)
Co-authored-by: Douwe M Osinga <douwe@sidewalklabs.com>
This commit is contained in:
@@ -8124,6 +8124,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_message_at": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"nullable": true
|
||||
},
|
||||
"last_message_snippet": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { Recipe } from '../recipe';
|
||||
interface GooseSessionInfoMeta {
|
||||
messageCount?: number;
|
||||
createdAt?: string;
|
||||
lastMessageAt?: string;
|
||||
archivedAt?: string;
|
||||
projectId?: string;
|
||||
providerId?: string;
|
||||
@@ -30,6 +31,7 @@ export interface SessionListItem {
|
||||
workingDir: string;
|
||||
updatedAt: string;
|
||||
messageCount: number;
|
||||
lastMessageAt?: string;
|
||||
createdAt: string;
|
||||
archivedAt?: string;
|
||||
projectId?: string;
|
||||
@@ -94,6 +96,7 @@ export function sessionInfoToSession(s: SessionInfo, loadMeta: LoadSessionMeta =
|
||||
working_dir: loadMeta.workingDir ?? s.cwd,
|
||||
created_at: createdAt,
|
||||
updated_at: updatedAt,
|
||||
last_message_at: meta.lastMessageAt,
|
||||
message_count: meta.messageCount ?? 0,
|
||||
extension_data: {},
|
||||
archived_at: meta.archivedAt,
|
||||
@@ -116,6 +119,7 @@ function sessionInfoToListItem(s: SessionInfo): SessionListItem {
|
||||
workingDir: s.cwd,
|
||||
updatedAt: s.updatedAt ?? '',
|
||||
messageCount: meta.messageCount ?? 0,
|
||||
lastMessageAt: meta.lastMessageAt,
|
||||
createdAt: meta.createdAt ?? s.updatedAt ?? '',
|
||||
archivedAt: meta.archivedAt,
|
||||
projectId: meta.projectId,
|
||||
|
||||
@@ -1414,6 +1414,7 @@ export type Session = {
|
||||
extension_data: ExtensionData;
|
||||
goose_mode?: GooseMode;
|
||||
id: string;
|
||||
last_message_at?: string | null;
|
||||
last_message_snippet?: string | null;
|
||||
message_count: number;
|
||||
model_config?: ModelConfig | null;
|
||||
|
||||
@@ -21,7 +21,7 @@ import { ScrollArea } from '../ui/scroll-area';
|
||||
import { formatMessageTimestamp } from '../../utils/timeUtils';
|
||||
import { SearchView } from '../conversation/SearchView';
|
||||
import { MainPanelLayout } from '../Layout/MainPanelLayout';
|
||||
import { groupSessionsByDate, type DateGroup } from '../../utils/dateUtils';
|
||||
import { groupSessionsByDate, sessionActivityAt, type DateGroup } from '../../utils/dateUtils';
|
||||
import { errorMessage } from '../../utils/conversionUtils';
|
||||
import { Skeleton } from '../ui/skeleton';
|
||||
import { toast } from 'react-toastify';
|
||||
@@ -734,7 +734,9 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
|
||||
<div className="flex-1 mt-2">
|
||||
<div className="flex items-center text-text-secondary text-xs">
|
||||
<Calendar className="w-3 h-3 mr-1 flex-shrink-0" />
|
||||
<span>{formatMessageTimestamp(Date.parse(session.updatedAt) / 1000)}</span>
|
||||
<span>
|
||||
{formatMessageTimestamp(Date.parse(sessionActivityAt(session)) / 1000)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center text-text-secondary text-xs">
|
||||
<Folder className="w-3 h-3 mr-1 flex-shrink-0" />
|
||||
|
||||
@@ -31,6 +31,7 @@ export function sessionToListItem(s: Session): SessionListItem {
|
||||
workingDir: s.working_dir,
|
||||
updatedAt: s.updated_at,
|
||||
messageCount: s.message_count,
|
||||
lastMessageAt: s.last_message_at ?? undefined,
|
||||
createdAt: s.created_at,
|
||||
archivedAt: s.archived_at ?? undefined,
|
||||
projectId: s.project_id ?? undefined,
|
||||
|
||||
@@ -6,6 +6,10 @@ export interface DateGroup {
|
||||
date: Date;
|
||||
}
|
||||
|
||||
export function sessionActivityAt(session: SessionListItem): string {
|
||||
return session.lastMessageAt ?? session.updatedAt;
|
||||
}
|
||||
|
||||
export function groupSessionsByDate(sessions: SessionListItem[]): DateGroup[] {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
@@ -16,7 +20,7 @@ export function groupSessionsByDate(sessions: SessionListItem[]): DateGroup[] {
|
||||
const groups: { [key: string]: DateGroup } = {};
|
||||
|
||||
sessions.forEach((session) => {
|
||||
const sessionDate = new Date(session.updatedAt);
|
||||
const sessionDate = new Date(sessionActivityAt(session));
|
||||
const sessionDateStart = new Date(sessionDate);
|
||||
sessionDateStart.setHours(0, 0, 0, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user