From e53ec1474e3531aa5881adfc0b233ed5806b8336 Mon Sep 17 00:00:00 2001
From: Sean Hatfield <seanhatfield5@gmail.com>
Date: Wed, 19 Feb 2025 12:50:22 +0800
Subject: [PATCH] Normalize chat sorting defaults in developer API (#3270)

* normalize sorting for workspace and workspace thread chats in dev api

* lint

---------

Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
---
 server/endpoints/api/workspace/index.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/endpoints/api/workspace/index.js b/server/endpoints/api/workspace/index.js
index 069d69591..f022dd577 100644
--- a/server/endpoints/api/workspace/index.js
+++ b/server/endpoints/api/workspace/index.js
@@ -411,7 +411,7 @@ function apiWorkspaceEndpoints(app) {
         const {
           apiSessionId = null,
           limit = 100,
-          orderBy = "desc",
+          orderBy = "asc",
         } = request.query;
         const workspace = await Workspace.get({ slug });
 
@@ -423,7 +423,7 @@ function apiWorkspaceEndpoints(app) {
         const validLimit = Math.max(1, parseInt(limit));
         const validOrderBy = ["asc", "desc"].includes(orderBy)
           ? orderBy
-          : "desc";
+          : "asc";
 
         const history = apiSessionId
           ? await WorkspaceChats.forWorkspaceByApiSessionId(
-- 
GitLab