From ae5c85adb961fd7796ae79aa053e0857c66381f6 Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 2 Mar 2026 16:55:37 -0600 Subject: [PATCH] feat(agents): sort recent issues by most recent activity including comments Update addComment to touch issue updatedAt so comment activity is reflected in recency sorting. Sort assigned issues on agent detail page by updatedAt desc so the most recently active issues appear first. Co-Authored-By: Claude Opus 4.6 --- server/src/services/issues.ts | 13 ++++++++++--- ui/src/pages/AgentDetail.tsx | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/src/services/issues.ts b/server/src/services/issues.ts index ae9f10b..5cc24ff 100644 --- a/server/src/services/issues.ts +++ b/server/src/services/issues.ts @@ -788,7 +788,7 @@ export function issueService(db: Db) { if (!issue) throw notFound("Issue not found"); - return db + const [comment] = await db .insert(issueComments) .values({ companyId: issue.companyId, @@ -797,8 +797,15 @@ export function issueService(db: Db) { authorUserId: actor.userId ?? null, body, }) - .returning() - .then((rows) => rows[0]); + .returning(); + + // Update issue's updatedAt so comment activity is reflected in recency sorting + await db + .update(issues) + .set({ updatedAt: new Date() }) + .where(eq(issues.id, issueId)); + + return comment; }, createAttachment: async (input: { diff --git a/ui/src/pages/AgentDetail.tsx b/ui/src/pages/AgentDetail.tsx index 327cd1a..b57063b 100644 --- a/ui/src/pages/AgentDetail.tsx +++ b/ui/src/pages/AgentDetail.tsx @@ -289,7 +289,9 @@ export function AgentDetail() { enabled: !!resolvedCompanyId, }); - const assignedIssues = (allIssues ?? []).filter((i) => i.assigneeAgentId === agent?.id); + const assignedIssues = (allIssues ?? []) + .filter((i) => i.assigneeAgentId === agent?.id) + .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()); const reportsToAgent = (allAgents ?? []).find((a) => a.id === agent?.reportsTo); const directReports = (allAgents ?? []).filter((a) => a.reportsTo === agent?.id && a.status !== "terminated"); const mobileLiveRun = useMemo(