Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix: sort execution log past runs by timestamp (newest first) (#4018)
Antoine GIRARD5480c69c9e7e
diff --git a/apps/mobile/app/(app)/[workspace]/issue/[id]/runs.tsx b/apps/mobile/app/(app)/[workspace]/issue/[id]/runs.tsxindex e6e6d4251a..5cbcd58aa5 100644--- a/apps/mobile/app/(app)/[workspace]/issue/[id]/runs.tsx+++ b/apps/mobile/app/(app)/[workspace]/issue/[id]/runs.tsx@@ -1,7 +1,7 @@/*** Agent Runs sheet — presented as a formSheet by the parent Stack. Two* sections: Active (queued/dispatched/running, created_at desc) and Past- * (failed → cancelled → completed, completed_at desc within each). Empty+ * (completed_at desc, status rank as tiebreaker). Empty* sections hide entirely.** Both entry points (the in-card AgentActivityRow and the Stack-header@@ -58,9 +58,9 @@ export default function IssueRunsRoute() {t.status === "cancelled",);return filtered.sort((a, b) => {- const ord = PAST_STATUS_ORDER[a.status] - PAST_STATUS_ORDER[b.status];- if (ord !== 0) return ord;- return (b.completed_at ?? "").localeCompare(a.completed_at ?? "");+ const timeDiff = (b.completed_at ?? "").localeCompare(a.completed_at ?? "");+ if (timeDiff !== 0) return timeDiff;+ return PAST_STATUS_ORDER[a.status] - PAST_STATUS_ORDER[b.status];});}, [allTasks]);diff --git a/packages/views/issues/components/execution-log-section.tsx b/packages/views/issues/components/execution-log-section.tsxindex 91f21e5541..513c1770bf 100644--- a/packages/views/issues/components/execution-log-section.tsx+++ b/packages/views/issues/components/execution-log-section.tsx@@ -48,9 +48,9 @@ interface ExecutionLogSectionProps {issueId: string;}-// Past-runs sort priority: failed first (needs attention), then-// cancelled (procedural noise), then completed (the boring 'done'-// case sinks to the bottom). Within each group, newest first.+// Past-runs sort priority: newest first by timestamp. When two runs+// share the same timestamp, failed ranks above cancelled, which ranks+// above completed.const PAST_STATUS_RANK: Record<string, number> = {failed: 0,cancelled: 1,@@ -96,17 +96,15 @@ export function ExecutionLogSection({ issueId }: ExecutionLogSectionProps) {t.status === "failed" ||t.status === "cancelled",);- // Stable sort: failed first, cancelled second, completed last.- // Within group: newest completed_at first (fall back to created_at- // for malformed rows missing completed_at).return past.toSorted((a, b) => {- const rankDiff =- (PAST_STATUS_RANK[a.status] ?? 99) -- (PAST_STATUS_RANK[b.status] ?? 99);- if (rankDiff !== 0) return rankDiff;const at = a.completed_at ?? a.created_at;const bt = b.completed_at ?? b.created_at;- return new Date(bt).getTime() - new Date(at).getTime();+ const timeDiff = new Date(bt).getTime() - new Date(at).getTime();+ if (timeDiff !== 0) return timeDiff;+ return (+ (PAST_STATUS_RANK[a.status] ?? 99) -+ (PAST_STATUS_RANK[b.status] ?? 99)+ );});}, [tasks]);