From 7f452458cdd399abe9fa57dedbba4a46d22a6ca3 Mon Sep 17 00:00:00 2001 From: mason-zy <1442059430@qq.com> Date: Thu, 15 Oct 2026 16:24:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(workspace):=20=E5=9B=BA=E5=AE=9A=E4=BE=A7?= =?UTF-8?q?=E6=A0=8F=E6=99=BA=E8=83=BD=E4=BD=93=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workspace/frontend/lib/sidebar-agents.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/workspace/frontend/lib/sidebar-agents.ts b/workspace/frontend/lib/sidebar-agents.ts index 0941f3d1d..2728c2c14 100644 --- a/workspace/frontend/lib/sidebar-agents.ts +++ b/workspace/frontend/lib/sidebar-agents.ts @@ -3,5 +3,20 @@ import type { WorkspaceAgent } from './types'; /** The personal roster never includes other people's or unclaimed agents. */ export function ownedSidebarAgents(agents: WorkspaceAgent[], email: string) { const owner = email.trim().toLowerCase(); - return owner ? agents.filter((agent) => agent.ownerEmail?.trim().toLowerCase() === owner && agent.status !== 'removed') : []; + return owner + ? agents + .filter((agent) => agent.ownerEmail?.trim().toLowerCase() === owner && agent.status !== 'removed') + .sort((a, b) => { + const aJoinedAt = a.joinedAt ? Date.parse(a.joinedAt) : Number.NaN; + const bJoinedAt = b.joinedAt ? Date.parse(b.joinedAt) : Number.NaN; + const aHasJoinedAt = Number.isFinite(aJoinedAt); + const bHasJoinedAt = Number.isFinite(bJoinedAt); + + if (aHasJoinedAt && bHasJoinedAt && aJoinedAt !== bJoinedAt) { + return aJoinedAt - bJoinedAt; + } + if (aHasJoinedAt !== bHasJoinedAt) return aHasJoinedAt ? -1 : 1; + return a.agentName.localeCompare(b.agentName); + }) + : []; }