From f566e4683a49dbcf1522b4d0f3f74770318c1c72 Mon Sep 17 00:00:00 2001 From: yiekheng Date: Sun, 10 May 2026 21:19:01 +0800 Subject: [PATCH] feat(web): sort accounts by created_at ascending (earliest first) Earlier accounts were ordered by label, so the list reshuffled every time an account was renamed. Switch to created_at ASC + id ASC as a deterministic tiebreaker. Earliest-added accounts now stay on top where the operator added them. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/src/lib/queries.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/lib/queries.ts b/apps/web/src/lib/queries.ts index 9ebe1b7..51d77df 100644 --- a/apps/web/src/lib/queries.ts +++ b/apps/web/src/lib/queries.ts @@ -63,9 +63,12 @@ export async function listAccounts(operatorId: string) { // exposes Pair / Re-pair / Delete actions accordingly. Hiding rows // by status produced phantom "I created an account but it's gone" // bug reports. + // Earliest-added on top, newest at the bottom. Stable across renames + // (a label edit shouldn't reorder the list and confuse muscle memory) + // and matches how other admin tools order accounts that grow over time. return db.query.whatsappAccounts.findMany({ where: (a, { eq }) => eq(a.operatorId, operatorId), - orderBy: (a, { asc }) => [asc(a.label)], + orderBy: (a, { asc }) => [asc(a.createdAt), asc(a.id)], }); }