From a0193451a9762cc33c20147c8c5561c85919e16f Mon Sep 17 00:00:00 2001 From: suyao Date: Tue, 23 Sep 2025 17:54:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=8C=89=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E9=97=B4=E9=99=8D=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/services/agents/services/SessionService.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/services/agents/services/SessionService.ts b/src/main/services/agents/services/SessionService.ts index fc833aa2bd..fae7c136fc 100644 --- a/src/main/services/agents/services/SessionService.ts +++ b/src/main/services/agents/services/SessionService.ts @@ -8,7 +8,7 @@ import { type UpdateSessionRequest, UpdateSessionResponse } from '@types' -import { and, count, eq, type SQL } from 'drizzle-orm' +import { and, count, desc, eq, type SQL } from 'drizzle-orm' import { BaseService } from '../BaseService' import { agentsTable, type InsertSessionRow, type SessionRow, sessionsTable } from '../database/schema' @@ -137,8 +137,12 @@ export class SessionService extends BaseService { const total = totalResult[0].count - // Build list query with pagination - const baseQuery = this.database.select().from(sessionsTable).where(whereClause).orderBy(sessionsTable.created_at) + // Build list query with pagination - sort by updated_at descending (latest first) + const baseQuery = this.database + .select() + .from(sessionsTable) + .where(whereClause) + .orderBy(desc(sessionsTable.updated_at)) const result = options.limit !== undefined